/* ============================================
   BASE
============================================ */
:root{
  --maroon:#800000;
  --muted:#777;
  --panel-bg:#fafafa;
  --border:#ccc;
  --accent:#440077;
  --success-bg:#f8fff8;
  --placeholder-bg:#f4f4f4;
  --mono-font: "Courier New", Courier, monospace;
}

*{box-sizing:border-box}
html,body{height:100%}
body{
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin:0;
  padding:1rem;
  color:#222;
  background:#fff;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
}

.container{
  max-width:1100px;
  margin:0 auto;
  width:100%;
}

/* Typography helpers */
.bold-maroon{ color:var(--maroon); font-weight:700; }
.line-maroon{ border-bottom:2px solid var(--maroon); margin:1rem 0; }
.link-comment{ color:var(--muted); font-size:0.9rem; }

/* ============================================
   INTRO
============================================ */
.intro{ margin-bottom:0rem; font-size:0.95rem; line-height:1.05; color:#333; }

/* ============================================
   TEXTAREA & FILE
============================================ */
textarea.paste-area{
  width:100%;
  max-width:360px;
  height:80px;
  font-family:var(--mono-font);
  font-size:14px;
  padding:0.5rem;
  border:1px solid var(--border);
  border-radius:4px;
  resize:vertical;
  background:#fff;
}

/* file row */
.file-row{ display:flex; align-items:center; gap:1rem; flex-wrap:wrap; }

/* ============================================
   PREVIEW
============================================ */
#data-preview{
  max-height:220px;
  overflow:auto;
  border:1px solid var(--border);
  padding:0.5rem;
  font-family:var(--mono-font);
  width:100%;
  background:var(--success-bg);
  border-radius:4px;
  white-space:pre;
  line-height:1.3;
}


/* table-like preview */
.preview-grid th, .preview-grid td{ padding:0.2rem 0.8rem; }

/* ============================================
   PARAMETRI
============================================ */
/* layout columns */
.param-columns{ display:flex; gap:1%; justify-content:space-between; flex-wrap:wrap; }
.param-col{ flex:1 1 32%; min-width:220px; }

/* rows */
.param-row, .color-row{
  display:flex; align-items:center; gap:12px; margin:0.6rem 0; flex-wrap:wrap;
}

/* labels */
.param-row label, .color-row label{
  width:160px; font-size:14px; line-height:22px; white-space:nowrap; color:#222;
}

/* numeric inputs */
input[type="number"], input[type="text"]{
  width:80px; height:28px; padding:4px 6px; font-size:14px; border:1px solid var(--border); border-radius:4px;
}

/* range slider */
.param-row input[type="range"]{
  width:100px; height:22px; margin:0; padding:0; background:#eee; border-radius:6px; -webkit-appearance:none; appearance:none;
}
.param-row input[type="range"]::-webkit-slider-runnable-track{ height:22px; background:#eee; border-radius:6px; }
.param-row input[type="range"]::-webkit-slider-thumb{
  -webkit-appearance:none; appearance:none; width:12px; height:22px; background:var(--accent); border-radius:2px; cursor:pointer; margin-top:0;
}
.param-row input[type="range"]::-moz-range-track{ height:22px; background:#eee; border-radius:6px; }
.param-row input[type="range"]::-moz-range-thumb{ width:12px; height:22px; background:var(--accent); border-radius:2px; cursor:pointer; }

/* color display */
.color-display{
  width:100px; height:28px; border:1px solid #444; box-sizing:border-box; cursor:pointer; border-radius:4px;
}
.real-color-input{ position:absolute; opacity:0; width:100px; height:28px; cursor:pointer; }

/* info icon */
.info-icon::after{ content:"ℹ️"; cursor:pointer; margin-left:6px; }

/* ============================================
   RUN
============================================ */
.run-row{ display:flex; align-items:center; gap:2rem; flex-wrap:wrap; }

.run-button{
  background:var(--maroon);
  color:#fff;
  padding:0.6rem 1.2rem;
  border:none;
  font-size:1rem;
  cursor:pointer;
  border-radius:6px;
  box-shadow:0 2px 0 rgba(0,0,0,0.08);
}

.run-button:disabled{
  background:#cccccc;
  cursor:default;
  box-shadow:none;
  opacity:0.9;
}

/* run status */
#run-status{
  font-size:0.95rem;
  color:var(--muted);
}

/* RUN: dati mancanti o errati */
.run-disabled{
    background:#808080 !important;
    color:#ffffff !important;
}

.run-ready{
    background:#d32f2f !important;
    color:#ffffff !important;
}

.run-completed{
    background:#2e7d32 !important;
    color:#ffffff !important;
}
/* ============================================
   CANVAS / OUTPUT
============================================ */
#output-area{
  border:1px dashed var(--border); min-height:120px; margin-top:1rem; text-align:center; padding:1rem; border-radius:6px;
  background:#fff;
}

/* placeholder canvas styling */
.canvas-placeholder{
  display:flex !important; align-items:center; justify-content:center; gap:0.5rem;
  width:100%; height:100px; background:var(--placeholder-bg); color:var(--muted); border:0px solid #e0e0e0;
  border-radius:6px; font-family:var(--mono-font); font-size:0.95rem;
  pointer-events:none;
}

/* actual canvas element */
#canvas-canvas{ display:block; max-width:100%; margin:0 auto;}

/* ============================================
   RESPONSIVE
============================================ */
@media (max-width:880px){
  .param-col{ flex-basis:100%; width:100%; }
  .param-row label{ width:140px; }
  input[type="number"]{ width:72px; }
  .run-row{ gap:1rem; }
}
#help-box {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 500px;
    max-height: 70vh;
    overflow-y: auto;
    background: #fffff5;
    border: 1px solid #999;
    padding: 12px;
    box-shadow: 0 0 10px rgba(0,0,0,.3);
    z-index: 9999;
}

.help-hidden {
    display: none;
}
/* ============================================
   ACCESSIBILITY
============================================ */
input:focus, button:focus, textarea:focus{ outline:3px solid rgba(68,0,119,0.12); outline-offset:2px; }

/* ============================================
   SMALL HELPERS
============================================ */
.hidden{ display:none !important; }
.small{ font-size:0.85rem; color:var(--muted); }
