/* ==========================================================================
   TEMA AGROLOGISTICA — tokens claro/escuro (Quasar alterna body--light/--dark)
   ========================================================================== */

:root, body.body--light {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --surface-2: #fafafa;
  --surface-3: #f4f4f5;
  --surface-4: #e4e4e7;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;

  --fg: #18181b;
  --fg-2: #3f3f46;
  --fg-muted: #71717a;
  --fg-subtle: #a1a1aa;

  --inverse: #18181b;
  --on-inverse: #fafafa;
  --primary: #18181b;
  --primary-hover: #27272a;
  --on-primary: #ffffff;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-solid: #4f46e5;
  --accent-solid-hover: #4338ca;
  --accent-soft: #eef2ff;

  --green-soft: #ecfdf3;  --green-line: #bbf7d0;  --green-fg: #15803d;
  --orange-soft: #fff4ed; --orange-line: #fed7aa; --orange-fg: #c2410c;
  --red-soft: #fef2f2;    --red-line: #fecaca;    --red-fg: #b91c1c;
  --amber-soft: #fffbeb;  --amber-line: #fde68a;  --amber-fg: #b45309;
  --blue-soft: #eff6ff;   --blue-line: #bfdbfe;   --blue-fg: #1d4ed8;
  --violet-soft: #f5f3ff; --violet-line: #ddd6fe; --violet-fg: #6d28d9;

  --prio-baixa: #16a34a;
  --prio-moderada: #f59e0b;
  --prio-critica: #b91c1c;

  --shadow-1: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow-2: 0 1px 2px rgba(24, 24, 27, 0.04), 0 4px 12px rgba(24, 24, 27, 0.06);
  --shadow-3: 0 8px 24px rgba(24, 24, 27, 0.12), 0 2px 6px rgba(24, 24, 27, 0.06);
  --ring: 0 0 0 3px rgba(79, 70, 229, 0.25);
  color-scheme: light;
}

body.body--dark {
  /* Mesma família de cores do login: marinho profundo + verde da arte */
  --bg: #050a17;
  --surface: #0b1428;
  --surface-2: #0e1830;
  --surface-3: #111d3a;
  --surface-4: #1a2a52;
  --border: rgba(148, 163, 209, 0.14);
  --border-strong: rgba(148, 163, 209, 0.26);

  --fg: #eef2ff;
  --fg-2: #c7d0e8;
  --fg-muted: #8d9abd;
  --fg-subtle: #5d6a8e;

  --inverse: #eef2ff;
  --on-inverse: #0b1428;
  --primary: #2f9e44;
  --primary-hover: #37b24d;
  --on-primary: #ffffff;

  --accent: #7aa2ff;
  --accent-hover: #a3bfff;
  --accent-solid: #3d6be0;
  --accent-solid-hover: #4a78ec;
  --accent-soft: rgba(122, 162, 255, 0.12);

  --green-soft: rgba(34, 197, 94, 0.12);   --green-line: rgba(34, 197, 94, 0.28);   --green-fg: #4ade80;
  --orange-soft: rgba(249, 115, 22, 0.12); --orange-line: rgba(249, 115, 22, 0.3);  --orange-fg: #fb923c;
  --red-soft: rgba(239, 68, 68, 0.13);     --red-line: rgba(239, 68, 68, 0.32);     --red-fg: #f87171;
  --amber-soft: rgba(245, 158, 11, 0.12);  --amber-line: rgba(245, 158, 11, 0.3);   --amber-fg: #fbbf24;
  --blue-soft: rgba(59, 130, 246, 0.13);   --blue-line: rgba(59, 130, 246, 0.32);   --blue-fg: #60a5fa;
  --violet-soft: rgba(139, 92, 246, 0.14); --violet-line: rgba(139, 92, 246, 0.32); --violet-fg: #a78bfa;

  --prio-baixa: #22c55e;
  --prio-moderada: #f59e0b;
  --prio-critica: #ef4444;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-3: 0 30px 80px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.4);
  --ring: 0 0 0 3px rgba(122, 162, 255, 0.3);
  color-scheme: dark;
}
/* Brilhos azul e verde do login no fundo do tema escuro */
body.body--dark {
  background:
    radial-gradient(900px 520px at 12% 0%, rgba(37, 78, 170, 0.22), transparent 70%),
    radial-gradient(700px 480px at 95% 100%, rgba(47, 158, 68, 0.1), transparent 70%),
    var(--bg) !important;
  background-attachment: fixed !important;
}
body.body--dark .q-layout, body.body--dark .q-page-container, body.body--dark .q-page {
  background: transparent !important;
}

/* ===== Base ===== */
html, body, #q-app, .q-layout, .q-page-container, .q-page, .nicegui-content {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
}
body, .q-layout, .q-page-container, .q-page {
  background-color: var(--bg) !important;
  color: var(--fg) !important;
}
body {
  font-family: "Archivo", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0;
}
.q-btn, .q-field, .q-item, .q-menu, .q-table, .q-notification { font-family: inherit; }

::selection { background: var(--accent-soft); color: var(--fg); }
body.body--dark ::selection { background: rgba(122, 162, 255, 0.35); }
* { scrollbar-width: thin; scrollbar-color: var(--surface-4) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-4); border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* Tracking mais contido nos rótulos em caixa-alta */
.tracking-wider, .tracking-widest { letter-spacing: 0.04em !important; }
.tracking-wide { letter-spacing: 0.02em !important; }

/* ===== Botões Quasar ===== */
.q-btn { border-radius: 8px; text-transform: none; letter-spacing: 0; font-weight: 500; }
.q-btn:before { box-shadow: none !important; }
.q-btn .q-focus-helper { display: none; }
.q-btn:focus-visible { box-shadow: var(--ring) !important; }
.q-btn[disabled], .q-btn.disabled { opacity: 0.55 !important; }
.q-btn { transition: background-color .15s ease, border-color .15s ease, color .15s ease, filter .15s ease; }

/* ===== Campos ===== */
.q-field--outlined .q-field__control { border-radius: 8px; background: var(--surface) !important; }
.q-field--outlined .q-field__control:before { border-color: var(--border-strong) !important; }
.q-field--outlined:hover .q-field__control:before { border-color: var(--fg-subtle) !important; }
.q-field--outlined.q-field--focused .q-field__control:after { border-width: 1px !important; border-color: var(--accent) !important; box-shadow: var(--ring); }
.q-field__native, .q-field__input, .q-field__prefix, .q-field__suffix, .q-select__dropdown-icon { color: var(--fg) !important; }
.q-field__native::placeholder, .q-field__input::placeholder { color: var(--fg-subtle) !important; opacity: 1; }
.q-field__label { color: var(--fg-muted) !important; }
.q-field__marginal { color: var(--fg-muted) !important; }

/* ===== Menus, diálogos, tabelas, notificações ===== */
.q-menu {
  background: var(--surface) !important;
  color: var(--fg) !important;
  border: 1px solid var(--border);
  border-radius: 10px !important;
  box-shadow: var(--shadow-3) !important;
}
.q-item { color: var(--fg); border-radius: 6px; }
/* O focus-helper do Quasar é absoluto e fica por cima do texto: o fundo vai no próprio item */
.q-item > .q-focus-helper { display: none; }
.q-item.q-manual-focusable--focused, .q-item:hover { background: var(--surface-3); color: var(--fg); }
.q-dialog__backdrop { background: rgba(9, 9, 11, 0.45) !important; backdrop-filter: blur(2px); }
.q-dialog .q-card { background: var(--surface) !important; color: var(--fg); }
.q-card { box-shadow: var(--shadow-1); }
.q-table__container, .q-table { background: var(--surface) !important; color: var(--fg) !important; }
.q-table--bordered, .q-table th, .q-table td { border-color: var(--border) !important; }
.q-table th { color: var(--fg-muted) !important; font-weight: 500; }
.q-notification { border-radius: 10px !important; box-shadow: var(--shadow-3) !important; }
.q-checkbox__inner { color: var(--fg-muted); }
.q-drawer { background: var(--surface) !important; }
.q-header { background: var(--surface) !important; }
.q-tooltip { background: var(--inverse) !important; color: var(--on-inverse) !important; font-size: 12px; border-radius: 6px; }

/* ===== Peças do sistema ===== */
.app-header {
  background: color-mix(in srgb, var(--surface) 88%, transparent) !important;
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
  box-shadow: none !important;
}
.nav-tab { color: var(--fg-muted); border-radius: 6px; }
.nav-tab:hover { color: var(--fg); background: var(--surface-3); }
.nav-tab.ativo { color: var(--fg); background: var(--surface-3); box-shadow: inset 0 0 0 1px var(--border); }
.brand-mark { background: var(--inverse); color: var(--on-inverse); }

/* Archivo largo nos títulos e números grandes: a única nota "alta" do sistema */
.page-title { color: var(--fg); font-stretch: 118%; font-variation-settings: "wdth" 118; letter-spacing: -0.015em; }
.kpi-num { font-stretch: 125%; font-variation-settings: "wdth" 125; letter-spacing: -0.02em; font-variant-numeric: proportional-nums; }
.painel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-1); }

/* Faixa de KPIs: um painel único dividido por linhas */
.kpi-strip { gap: 0 !important; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-1); overflow: hidden; }
.kpi-strip > * { border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; }
.kpi-strip > * + * { border-left: 1px solid var(--border) !important; }
@media (max-width: 1023px) {
  .kpi-strip > * { border-top: 1px solid var(--border) !important; }
  .kpi-strip > *:nth-child(-n+2) { border-top: 0 !important; }
  .kpi-strip > *:nth-child(odd) { border-left: 0 !important; }
  .kpi-strip > *:last-child:nth-child(odd) { grid-column: span 2; }
}

.dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; flex-shrink: 0; }
.dot-baixa { background: var(--prio-baixa); }
.dot-moderada { background: var(--prio-moderada); }
.dot-critica { background: var(--prio-critica); box-shadow: 0 0 0 3px var(--red-soft); }

/* ===== Ciclo de vida: indicador de etapas ===== */
.etapas { --no: 26px; display: flex; width: 100%; padding-top: 2px; }
.etapas.compacto { --no: 20px; }
.passo { position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; }

/* linha de progresso entre um nó e o anterior */
.passo + .passo::before {
  content: "";
  position: absolute;
  top: calc(var(--no) / 2 - 1.5px);
  left: calc(-50% + var(--no) / 2 + 3px);
  right: calc(50% + var(--no) / 2 + 3px);
  height: 3px;
  border-radius: 3px;
  background: var(--surface-4);
}
.passo.feito::before { background: var(--green-fg); }
.passo.atual::before { background: linear-gradient(90deg, var(--green-fg), var(--amber-fg)); }

.passo .no {
  width: var(--no);
  height: var(--no);
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: calc(var(--no) * 0.58);
  transition: transform .2s ease;
}
.passo.feito .no {
  background: var(--green-fg);
  color: var(--surface);
  box-shadow: 0 0 0 3px var(--green-soft);
}
.passo.atual .no {
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--amber-fg) 70%, #fff), var(--amber-fg) 70%);
  color: #fff;
  animation: brilho-etapa 2.2s cubic-bezier(0.16, 1, 0.3, 1) infinite;
}
.passo.futuro .no {
  background: var(--surface);
  color: var(--fg-subtle);
  border: 1.5px dashed var(--border-strong);
}
.passo:hover .no { transform: scale(1.08); }
/* Imagem do WhatsApp: sem pulso (a captura pegaria o anel no meio da animação) */
#relatorio-abertos .passo.atual .no { animation: none; box-shadow: 0 0 0 3px var(--amber-soft); }

.passo-nome { font-size: 10px; font-weight: 500; color: var(--fg-muted); line-height: 1; white-space: nowrap; }
.passo.atual .passo-nome { color: var(--amber-fg); font-weight: 600; }
.passo-hora { font-size: 10.5px; font-weight: 600; color: var(--fg-2); font-variant-numeric: tabular-nums; line-height: 1; }
.passo.atual .passo-hora { color: var(--amber-fg); }
.passo.futuro .passo-hora { color: var(--fg-subtle); font-weight: 400; }

@keyframes brilho-etapa {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--amber-fg) 55%, transparent), 0 0 0 3px var(--amber-soft); }
  70%  { box-shadow: 0 0 0 9px color-mix(in srgb, var(--amber-fg) 0%, transparent), 0 0 0 3px var(--amber-soft); }
  100% { box-shadow: 0 0 0 0 transparent, 0 0 0 3px var(--amber-soft); }
}

a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }

/* ===== Login: sempre escuro, nas cores da arte (marinho + verde) ===== */
.login-tela {
  --bg: #050a17;
  --surface: #0b1428;
  --surface-3: #111d3a;
  --border: rgba(148, 163, 209, 0.14);
  --border-strong: rgba(148, 163, 209, 0.26);
  --fg: #eef2ff;
  --fg-2: #c7d0e8;
  --fg-muted: #8d9abd;
  --fg-subtle: #5d6a8e;
  --primary: #2f9e44;
  --primary-hover: #37b24d;
  --on-primary: #ffffff;
  --accent: #7aa2ff;
  --ring: 0 0 0 3px rgba(122, 162, 255, 0.3);
  --inverse: #eef2ff;
  --on-inverse: #0b1428;
  color-scheme: dark;
  position: fixed !important;
  inset: 0;
  z-index: 999;
  width: 100vw !important;
  min-height: 100vh !important;
  margin: 0 !important;
  overflow-x: hidden;
  overflow-y: auto;
  color: var(--fg);
  background:
    radial-gradient(900px 520px at 12% 8%, rgba(37, 78, 170, 0.35), transparent 70%),
    radial-gradient(700px 480px at 92% 96%, rgba(47, 158, 68, 0.16), transparent 70%),
    var(--bg) !important;
  animation: login-fundo 0.6s ease-out both;
}
/* grade técnica bem sutil, como na arte */
.login-tela::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 209, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 209, 0.05) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, #000 30%, transparent 75%);
  pointer-events: none;
}
.login-card {
  position: relative;
  z-index: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  animation: login-card 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both;
}
.login-arte { background: #0b1f4a; }
.login-arte-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: login-arte 1.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.login-arte-texto {
  background: linear-gradient(to top, rgba(5, 10, 23, 0.92), rgba(5, 10, 23, 0));
  padding-top: 72px !important;
}
.login-form { background: var(--surface); }
.login-surge { animation: login-surge 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; }
.login-form > .login-surge:nth-child(1) { animation-delay: 0.35s; }
.login-form > .login-surge:nth-child(2) { animation-delay: 0.45s; }
.login-form > .login-surge:nth-child(3), .login-form > .login-surge:nth-child(4) { animation-delay: 0.55s; }
.login-botao { box-shadow: 0 8px 24px rgba(47, 158, 68, 0.28) !important; }
.login-tela input:-webkit-autofill {
  -webkit-text-fill-color: var(--fg);
  transition: background-color 9999s ease-out;
}
.login-card.tremor { animation: login-tremor 0.4s ease-in-out; }

@keyframes login-fundo { from { opacity: 0; } to { opacity: 1; } }
@keyframes login-card { from { opacity: 0; transform: translateY(18px) scale(0.985); } to { opacity: 1; transform: none; } }
@keyframes login-arte { from { transform: scale(1.08); filter: brightness(0.6); } to { transform: scale(1); filter: none; } }
@keyframes login-surge { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes login-tremor {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Transição de acesso: o caminhão percorre a trilha */
.login-acesso {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: radial-gradient(700px 420px at 50% 45%, rgba(37, 78, 170, 0.3), transparent 70%), var(--bg);
  animation: login-fundo 0.35s ease-out both;
}
.login-acesso-caixa { animation: login-surge 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.1s both; }
.login-trilha {
  position: relative;
  width: 280px;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-3);
  margin: 14px 0 4px;
}
.login-trilha-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 4px;
  background: linear-gradient(90deg, #2f9e44, #7aa2ff);
  animation: login-trilha 1.2s cubic-bezier(0.65, 0, 0.35, 1) 0.2s both;
}
.login-caminhao {
  position: absolute;
  top: -26px;
  left: 0;
  color: var(--fg);
  transform: translateX(-50%);
  animation: login-caminhao 1.2s cubic-bezier(0.65, 0, 0.35, 1) 0.2s both;
}
.login-bemvindo { animation: login-surge 0.5s ease-out 0.9s both; }
@keyframes login-trilha { from { width: 0; } to { width: 100%; } }
@keyframes login-caminhao { from { left: 0; } to { left: 100%; } }

/* Portal aparece suave depois do acesso */
.entrada-suave { animation: login-surge 0.5s cubic-bezier(0.16, 1, 0.3, 1) both; }

/* O .hidden do Quasar vence o sm:/md:/lg: do Tailwind; estas classes mostram só a partir do breakpoint */
.so-sm-block, .so-md-flex, .so-lg-flex { display: none !important; }
@media (min-width: 640px) { .so-sm-block { display: block !important; } }
@media (min-width: 768px) { .so-md-flex { display: flex !important; } }
@media (min-width: 1024px) { .so-lg-flex { display: flex !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
