/* ==========================================================================
   Conversor — folha de estilo
   Tema escuro por padrao, claro quando o sistema pedir.
   ========================================================================== */

:root {
  --bg:          #0d1117;
  --bg-raised:   #151b23;
  --bg-input:    #0b0f14;
  --border:      #26303d;
  --border-soft: #1c242e;

  --text:        #dfe6ee;
  --text-dim:    #98a5b4;
  --text-faint:  #6b7887;

  --accent:      #38bdf8;
  --accent-dim:  #0d5f80;
  --ok:          #4ade80;
  --warn:        #fbbf24;
  --danger:      #f87171;

  --radius:      10px;
  --radius-sm:   7px;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg:          #f4f6f9;
    --bg-raised:   #ffffff;
    --bg-input:    #ffffff;
    --border:      #d3dae3;
    --border-soft: #e6ebf1;

    --text:        #16202b;
    --text-dim:    #566472;
    --text-faint:  #8593a2;

    --accent:      #0369a1;
    --accent-dim:  #bae6fd;
    --ok:          #15803d;
    --warn:        #b45309;
    --danger:      #b91c1c;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--border-soft);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ------------------------------- topo ---------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 16px 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 14px; }

.logo { width: 38px; height: 38px; flex: none; }
.logo rect { fill: var(--accent-dim); }
.logo path { stroke: var(--accent); }

.brand h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.2px;
}

.brand p {
  margin: 1px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
}

.job-name { display: flex; align-items: center; gap: 9px; }

.job-name label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.job-name input {
  width: 210px;
  padding: 7px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

/* ------------------------------ resumo --------------------------------- */

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

/* `display` numa regra de classe vence o [hidden] do HTML, entao as fichas
   apareciam zeradas antes de qualquer arquivo entrar. */
.stats[hidden],
.stat[hidden],
.next-step[hidden] { display: none; }

.stat {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 13px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: 999px;
}

.stat-value { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.stat-label { font-size: 12px; color: var(--text-dim); }
.stat.warn  { border-color: var(--warn); }
.stat.warn .stat-value { color: var(--warn); }
.stat.muted .stat-value { color: var(--text-dim); font-size: 13px; }

/* ------------------------------- abas ---------------------------------- */

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 24px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 11px 17px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s, border-color .12s;
}

.tab:hover { color: var(--text); }

.tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Número do passo: a sequência das abas é o roteiro de uso. */
.tab b {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--border);
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 600;
  vertical-align: -3px;
}

.tab.active b { background: var(--accent); color: var(--bg); }

/* "Painel e bandejas" é recurso opcional, não um passo do caminho normal. */
.tab.extra { margin-left: auto; font-style: italic; }

/* ----------------------------- conteudo -------------------------------- */

main { padding: 20px 24px 90px; max-width: 1500px; }

.panel { display: none; }
.panel.active { display: block; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 16px;
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card h2 { margin: 0 0 6px; font-size: 17px; }
.card h3 { margin: 0 0 4px; font-size: 14.5px; font-weight: 620; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.card-head > div:first-child { flex: 1 1 320px; }

.hint {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--text-dim);
  max-width: 62ch;
}

/* -------------------------- area de upload ----------------------------- */

.drop-card {
  text-align: center;
  padding: 34px 22px;
  border: 1.5px dashed var(--border);
  transition: border-color .15s, background .15s;
}

.drop-card.dragging {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 7%, var(--bg-raised));
}

.drop-icon { width: 40px; height: 40px; stroke: var(--accent); margin-bottom: 6px; }
.drop-card p { margin: 6px auto 14px; color: var(--text-dim); max-width: 56ch; font-size: 13px; }

.drop-note {
  margin-top: 14px !important;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ok) !important;
}

/* ------------------------------ campos --------------------------------- */

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 4px; }

.field input,
input[type="search"] {
  width: 100%;
  padding: 8px 11px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.field input:focus,
input[type="search"]:focus,
.job-name input:focus {
  outline: none;
  border-color: var(--accent);
}

.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.radio-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0 4px; }

.radio {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}

.radio:has(input:checked) {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-input));
}

.radio em {
  font-style: normal;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-left: 3px;
}

.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }

.sub-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}

/* ------------------------------ botoes --------------------------------- */

.btn {
  padding: 8px 15px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #06131c;
  font-weight: 600;
}

@media (prefers-color-scheme: light) {
  .btn.primary { color: #fff; }
}

.btn.primary:hover:not(:disabled) { filter: brightness(1.12); }
.btn.ghost { background: none; }
.btn.small { padding: 5px 11px; font-size: 12.5px; }

.btn.danger-ghost { background: none; color: var(--danger); border-color: var(--border); }
.btn.danger-ghost:hover:not(:disabled) { border-color: var(--danger); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row input[type="search"] { width: 240px; }

/* ------------------------------ tabelas -------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.table-wrap.tall { max-height: 62vh; overflow-y: auto; }

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.grid th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 9px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

table.grid td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

table.grid tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
table.grid tr.is-skipped td { opacity: .42; }
table.grid tr.no-feeder td:first-child { box-shadow: inset 2px 0 0 var(--warn); }

.col-check { width: 34px; }
.col-wide  { min-width: 150px; }
.col-flags { min-width: 190px; }

/* celulas editaveis */
table.grid input[type="text"],
table.grid input[type="number"],
table.grid select {
  width: 100%;
  min-width: 52px;
  padding: 4px 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
}

table.grid input:hover, table.grid select:hover { border-color: var(--border); }

table.grid input:focus, table.grid select:focus {
  outline: none;
  background: var(--bg-input);
  border-color: var(--accent);
}

table.grid input.wide { min-width: 130px; }
table.grid select { min-width: 66px; cursor: pointer; }
table.grid option { background: var(--bg-raised); color: var(--text); }

.flags { display: flex; gap: 9px; }

.flags label {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  color: var(--text-dim);
  cursor: pointer;
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  margin: 0;
}

/* --------------------------- passo seguinte ---------------------------- */

/* Uma frase, sempre a mesma posição: quem não conhece a ferramenta lê daqui
   o que fazer, em vez de adivinhar por qual aba começar. */
.next-step {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
  padding: 11px 16px;
  border: 1px solid var(--accent-dim);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 7%, transparent);
  font-size: 13.5px;
  color: var(--text);
}

.next-step .next-icon { color: var(--accent); font-weight: 700; flex: none; }
.next-step #next-text { flex: 1; }

.next-step.done {
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  border-left-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 7%, transparent);
}
.next-step.done .next-icon { color: var(--ok); }

/* ------------------------------ introdução ----------------------------- */

.intro .steps {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 9px;
}

.intro .steps li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  font-size: 13px;
  color: var(--text-dim);
}

.intro .steps b {
  flex: none;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--text);
  display: grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 600;
}

.intro .steps strong { color: var(--text); font-weight: 600; }

/* Sugestão de setup embaixo do nome do componente, na tabela de feeders. */
.feeder-hint {
  display: block;
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--mono);
  white-space: nowrap;
}

/* Quando não deu para deduzir, o aviso não pode passar por sugestão. */
.feeder-hint.unknown { color: var(--warn); opacity: .85; font-style: italic; }

/* -------------------------------- mapa --------------------------------- */

.map-wrap {
  position: relative;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  overflow: hidden;
}

#map-svg {
  display: block;
  width: 100%;
  height: clamp(320px, 58vh, 620px);
  cursor: grab;
  touch-action: none;
}
#map-svg.dragging { cursor: grabbing; }

.map-axis {
  fill: var(--text-faint);
  font-family: var(--mono);
  pointer-events: none;
  user-select: none;
}

/* Grade de 10 mm: presente o bastante para dar escala, discreta o bastante
   para nao competir com os componentes. */
.map-grid line {
  stroke: var(--border-soft);
  stroke-width: 0.12;
  vector-effect: non-scaling-stroke;
}

.map-origin line {
  stroke: var(--accent);
  stroke-width: 1.5;
  vector-effect: non-scaling-stroke;
}

.map-path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1;
  stroke-opacity: 0.45;
  stroke-dasharray: 4 3;
  vector-effect: non-scaling-stroke;
}

.map-part rect { fill-opacity: 0.55; }
.map-part.skip rect { stroke-dasharray: 1.5 1.5; stroke-opacity: 0.5; }
.map-part.th  rect { fill-opacity: 0.18; }

.map-pin1 {
  stroke: var(--text);
  stroke-opacity: 0.75;
  vector-effect: non-scaling-stroke;
}
.map-part.skip .map-pin1 { stroke-opacity: 0.25; }

/* Halo atrás do texto: sem ele a referência some em cima do componente. */
.map-label {
  fill: var(--text);
  text-anchor: middle;
  font-family: var(--sans);
  pointer-events: none;
  user-select: none;
  paint-order: stroke;
  stroke: var(--bg-input);
  stroke-width: 2.5;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.map-label.skip { fill: var(--text-faint); }

.map-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  white-space: pre-line;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.35);
  max-width: 280px;
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-dim);
}

.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: none;
}
.legend-item.warn { color: var(--warn); font-weight: 500; }

.lib-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.lib-label {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 4px;
}

.rotate-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-dim);
}

.rotate-bar .hint { margin: 0; }

.advanced { margin-top: 16px; }

.advanced summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  padding: 7px 0;
}

.advanced summary:hover { color: var(--text); }

/* ---------------------------- validacao -------------------------------- */

.validation:empty { display: none; }

.verdict {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 12px;
}

.verdict.ok   { background: color-mix(in srgb, var(--ok) 12%, transparent);   border: 1px solid var(--ok); }
.verdict.bad  { background: color-mix(in srgb, var(--danger) 12%, transparent); border: 1px solid var(--danger); }

.issue {
  display: flex;
  gap: 11px;
  padding: 10px 13px;
  border-left: 3px solid var(--border);
  background: var(--bg);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin-bottom: 7px;
}

.issue.error { border-left-color: var(--danger); }
.issue.warn  { border-left-color: var(--warn); }

.issue-badge {
  flex: none;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  padding-top: 2px;
}

.issue.error .issue-badge { color: var(--danger); }
.issue.warn  .issue-badge { color: var(--warn); }

.issue-text { font-size: 13px; }
.issue-hint { font-size: 12.5px; color: var(--text-dim); margin-top: 2px; }

/* ---------------------------- downloads -------------------------------- */

.download-row { display: flex; flex-direction: column; gap: 10px; }

.download-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}

.download-item .hint { margin-top: 2px; }

/* ----------------------------- console --------------------------------- */

.console {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  z-index: 10;
}

.console-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 7px 24px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
}

.console-title {
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-size: 11.5px;
  flex: none;
}

.console-last {
  flex: 1;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chev { transition: transform .15s; }
.console.open .chev { transform: rotate(180deg); }

.console-body {
  display: none;
  max-height: 190px;
  overflow-y: auto;
  padding: 6px 24px 12px;
  font-family: var(--mono);
  font-size: 12px;
}

.console.open .console-body { display: block; }

.log-line { display: flex; gap: 10px; padding: 1.5px 0; }
.log-time { color: var(--text-faint); flex: none; }
.log-info  { color: var(--text); }
.log-ok    { color: var(--ok); }
.log-warn  { color: var(--warn); }
.log-error { color: var(--danger); }

/* ------------------------------ rodape --------------------------------- */

.foot {
  padding: 14px 24px 44px;
  font-size: 12px;
  color: var(--text-faint);
}

.foot .sep { margin: 0 7px; }

/* ------------------------------ telas pequenas ------------------------- */

@media (max-width: 720px) {
  .topbar, .stats, .tabs, main, .console-head, .console-body { padding-left: 14px; padding-right: 14px; }
  .job-name { width: 100%; }
  .job-name input { flex: 1; width: auto; }
  .download-item { flex-direction: column; align-items: stretch; }
}
