/*
  Entregas AFS — identidade visual Açaí Fruit Show (Manual de Aplicações 2026).
  Cores oficiais: roxo açaí #51275D · lavanda #B99FC4 · verde oliva #BDC789
  verde claro #E0E8BA · branco. Tipografia oficial Gotham → web: Montserrat.
  Mesmos tokens do PDV (frontend/src/index.css).
*/
:root {
  --roxo: #51275d;          /* roxo açaí — botões/topo/realce */
  --roxo-md: #6f3c88;       /* roxo médio — links/labels */
  --roxo-esc: #431f4d;
  --roxo-esc2: #35193d;
  --lavanda: #b99fc4;
  --oliva: #bdc789;
  --verde-cl: #e0e8ba;
  --verde-ok: #7a8c3f;      /* verde oliva escurecido p/ status "ok" legível */

  --canvas: #f5eff7;        /* fundo da tela (lavanda suave) */
  --card: #ffffff;
  --superficie2: #efe7f4;   /* hover / chips */
  --borda: #dccfe6;
  --txt: #2a1626;           /* texto primário */
  --txt-2: #4a3557;         /* texto secundário */
  --txt-suave: #5a4869;
  --vermelho: #b3261e;
  --sombra: 0 1px 3px rgba(81,39,93,.14);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  font-family: "Montserrat", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--canvas); color: var(--txt);
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
.sem-scroll { overflow: hidden !important; height: 100%; }

/* Topo */
header {
  background: var(--roxo); color: #fff;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 10; box-shadow: var(--sombra);
}
header .voltar { font-size: 24px; cursor: pointer; line-height: 1; background: none; border: 0; color: #fff; padding: 0 4px 0 0; }
header h1 { font-size: 17px; margin: 0; flex: 1; font-weight: 700; letter-spacing: .01em; }
header .sub { font-size: 12px; opacity: .85; font-weight: 500; }
header .sair { font-size: 12px; background: rgba(255,255,255,.18); border: 0; color: #fff; padding: 6px 12px; border-radius: 8px; font-weight: 600; }

main { padding: 16px; max-width: 640px; margin: 0 auto; }

/* Login */
.login-card {
  background: var(--card); border-radius: 16px; padding: 32px 24px; box-shadow: var(--sombra);
  max-width: 360px; margin: 48px auto 0; text-align: center; border: 1px solid var(--borda);
}
.login-card .marca { font-size: 13px; font-weight: 700; letter-spacing: .14em; color: var(--roxo); text-transform: uppercase; }
.login-card h2 { margin: 6px 0 2px; font-size: 22px; font-weight: 700; color: var(--txt); }
.login-card p { margin: 0 0 24px; color: var(--txt-suave); font-size: 14px; }
label { display: block; text-align: left; font-size: 13px; color: var(--txt-2); margin: 0 0 5px; font-weight: 600; }
input {
  width: 100%; padding: 13px 14px; font-size: 16px; border: 1px solid var(--borda);
  border-radius: 10px; margin-bottom: 14px; background: #fff; color: var(--txt);
  font-family: inherit;
}
input:focus { outline: none; border-color: var(--roxo); box-shadow: 0 0 0 3px rgba(81,39,93,.12); }

button.primario {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 700; color: #fff;
  background: var(--roxo); border: 0; border-radius: 10px; cursor: pointer; font-family: inherit;
}
button.primario:active { background: var(--roxo-esc); }
button.primario:disabled { opacity: .55; }

.erro { color: var(--vermelho); font-size: 13px; margin: -6px 0 12px; min-height: 16px; text-align: left; }

/* Progresso da rota */
.progresso {
  background: var(--card); border-radius: 14px; padding: 16px; box-shadow: var(--sombra);
  margin-bottom: 14px; display: flex; align-items: center; gap: 14px; border: 1px solid var(--borda);
}
.progresso .num { font-size: 26px; font-weight: 700; color: var(--roxo); min-width: 56px; }
.progresso .barra { height: 8px; background: var(--superficie2); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.progresso .barra > i { display: block; height: 100%; background: var(--oliva); transition: width .3s; }
.progresso .txt { font-size: 13px; color: var(--txt-suave); font-weight: 500; }

/* Cartão de nota (checklist) */
.nota {
  background: var(--card); border-radius: 12px; padding: 14px 16px; box-shadow: var(--sombra);
  margin-bottom: 10px; display: flex; align-items: center; gap: 12px; cursor: pointer;
  border: 1px solid var(--borda); border-left: 4px solid var(--borda);
}
.nota.assinada { border-left-color: var(--oliva); }
.nota .check {
  width: 26px; height: 26px; border-radius: 99px; border: 2px solid var(--borda);
  flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font-size: 15px; color: #fff; font-weight: 700;
}
.nota.assinada .check { background: var(--oliva); border-color: var(--oliva); }
.nota .info { flex: 1; min-width: 0; }
.nota .cliente { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--txt); }
.nota .meta { font-size: 12px; color: var(--txt-suave); margin-top: 2px; }
.nota .valor { font-size: 13px; font-weight: 700; color: var(--txt); white-space: nowrap; }
.nota .seta { color: var(--lavanda); font-size: 20px; }

.grupo-ordem { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--roxo-md); margin: 18px 4px 8px; font-weight: 700; }

/* Abas (detalhe da nota) */
.tabs {
  display: flex; background: var(--roxo); position: sticky; top: 50px; z-index: 9;
  padding: 0 8px; box-shadow: var(--sombra);
}
.tabs .tab {
  flex: 1; background: none; border: 0; color: rgba(255,255,255,.7); font-family: inherit;
  font-size: 14px; font-weight: 600; padding: 12px 8px; cursor: pointer;
  border-bottom: 3px solid transparent;
}
.tabs .tab.ativa { color: #fff; border-bottom-color: var(--oliva); }

/* Visor da nota em CANVAS (PDF.js) — rolável, funciona no celular */
#danfe-container {
  max-height: 64vh; overflow: auto; background: #eee;
  border: 1px solid var(--borda); border-radius: 10px; padding: 8px;
  -webkit-overflow-scrolling: touch;
}
.pdf-page {
  display: block; margin: 0 auto 8px; max-width: 100%;
  box-shadow: 0 1px 5px rgba(0,0,0,.18); background: #fff;
}
.danfe-vazio { text-align: center; color: var(--txt-suave); padding: 32px 16px; font-size: 14px; }
.btn-secundario {
  display: block; width: 100%; text-align: center; margin-top: 12px; padding: 12px; border-radius: 9px;
  border: 1px solid var(--borda); background: #fff; color: var(--roxo); font-weight: 600;
  text-decoration: none; font-size: 14px; font-family: inherit; cursor: pointer;
}

/* Visor da DANFE em tela cheia (overlay dentro do app) */
.danfe-fs {
  position: fixed; inset: 0; z-index: 60; background: var(--canvas);
  display: flex; flex-direction: column; overscroll-behavior: contain;
}
.danfe-fs-topo {
  background: var(--roxo); color: #fff; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px calc(12px + env(safe-area-inset-top)); font-weight: 700; font-size: 16px;
}
.danfe-fs-acoes { display: flex; align-items: center; gap: 8px; }
.danfe-fs-zoom { background: rgba(255,255,255,.18); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 8px; font-weight: 700; font-family: inherit; font-size: 22px; line-height: 1; }
.danfe-fs-x { background: rgba(255,255,255,.18); border: 0; color: #fff; padding: 8px 14px; border-radius: 8px; font-weight: 600; font-family: inherit; font-size: 14px; }
#danfe-fs-corpo { flex: 1; overflow: auto; padding: 10px; -webkit-overflow-scrolling: touch; }
#danfe-fs-corpo .pdf-page { margin: 0 auto 12px; }

.instrucao { margin: -4px 0 14px; font-size: 13px; color: var(--txt-suave); line-height: 1.4; }

/* Status de sincronização com o Sankhya (no selo de assinada) */
.sync-linha { margin-top: 8px; font-size: 12.5px; font-weight: 600; }
.sync-ok { color: var(--verde-ok); }
.sync-pend { color: #b06a00; }

/* Detalhe / assinatura */
.bloco { background: var(--card); border-radius: 12px; padding: 16px; box-shadow: var(--sombra); margin-bottom: 14px; border: 1px solid var(--borda); }
.bloco h3 { margin: 0 0 10px; font-size: 12px; color: var(--roxo-md); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.linha { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; border-bottom: 1px solid var(--superficie2); font-size: 14px; }
.linha:last-child { border-bottom: 0; }
.linha .k { color: var(--txt-suave); }
.item { display: flex; justify-content: space-between; gap: 14px; align-items: baseline; font-size: 14px; padding: 8px 0; border-bottom: 1px solid var(--superficie2); }
.item:last-child { border-bottom: 0; }
.item > span:first-child { min-width: 0; line-height: 1.35; }   /* nome quebra certo na coluna esquerda */
.item .q { color: var(--roxo); font-weight: 700; white-space: nowrap; flex-shrink: 0; }   /* "1 CX" sempre numa linha */

canvas.assinatura {
  width: 100%; height: 200px; background: #fff; border: 2px dashed var(--borda);
  border-radius: 10px; touch-action: none; display: block;
}
.assin-acoes { display: flex; gap: 10px; margin-top: 10px; }
.assin-acoes button { flex: 1; padding: 11px; border-radius: 9px; border: 1px solid var(--borda); background: #fff; font-size: 14px; font-weight: 600; color: var(--roxo); font-family: inherit; }
.selo-assinada { background: var(--verde-cl); color: var(--roxo-esc2); border-radius: 10px; padding: 14px; font-size: 14px; text-align: center; font-weight: 600; border: 1px solid var(--oliva); }

.rodape-fixo { position: sticky; bottom: 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--canvas) 72%, transparent); }

/* Toast — verde, semitransparente, surge e some */
#toast {
  position: fixed; bottom: 28px; left: 50%;
  background: rgba(47, 133, 71, .88); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: 0 6px 20px rgba(31,90,50,.28); z-index: 50; max-width: 90%;
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  /* 0,25s aparecendo + 3s visível + 0,4s sumindo = 3,65s */
  animation: toast-vida 3.65s ease forwards;
}
@keyframes toast-vida {
  0%   { opacity: 0; transform: translateX(-50%) translateY(14px) scale(.96); }
  7%   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }      /* fim da aparição (~0,25s) */
  89%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }      /* +3s visível */
  100% { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.98); } /* fade-out */
}
@media (prefers-reduced-motion: reduce) { #toast { animation: none; opacity: 1; transform: translateX(-50%); } }
.vazio { text-align: center; color: var(--txt-suave); padding: 40px 20px; }

/* Seletor de motorista (só no usuário de teste) */
.sel-mot {
  background: var(--card); border: 1px solid var(--borda); border-radius: 12px;
  padding: 10px 14px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--sombra);
}
.sel-mot label { margin: 0; font-size: 13px; color: var(--txt-2); font-weight: 600; white-space: nowrap; }
.sel-mot select {
  flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--borda); border-radius: 9px;
  font-size: 15px; font-family: inherit; background: #fff; color: var(--txt); margin: 0;
  text-overflow: ellipsis;   /* nome longo do motorista não estoura a tela */
}

/* Assinatura em tela cheia (overlay dentro do app) */
.assin-fs { position: fixed; inset: 0; z-index: 70; background: var(--canvas); display: flex; flex-direction: column; overscroll-behavior: contain; }
.assin-fs-topo {
  background: var(--roxo); color: #fff; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-top)); font-weight: 700;
}
.assin-fs-topo > span { min-width: 0; font-size: 15px; line-height: 1.2; }
.assin-fs-acoes { display: flex; gap: 7px; flex-shrink: 0; }
.assin-fs-btn {
  background: rgba(255,255,255,.18); border: 0; color: #fff; padding: 8px 12px; border-radius: 8px;
  font-weight: 600; font-family: inherit; font-size: 13px; white-space: nowrap;
}
.assin-fs-btn.ok { background: var(--oliva); color: var(--roxo-esc2); }
.assin-fs-dica { text-align: center; font-size: 13px; color: var(--txt-suave); padding: 8px 16px 4px; }
.assin-fs-canvas { flex: 1; width: 100%; background: #fff; touch-action: none; display: block; }

/* Entrega não realizada */
.nota.nao-realizada { border-left-color: var(--vermelho); }
.nota.nao-realizada .check { background: var(--vermelho); border-color: var(--vermelho); }

.btn-nr {
  display: block; width: 100%; margin-top: 10px; padding: 12px; border-radius: 10px;
  border: 1px solid var(--vermelho); background: #fff; color: var(--vermelho);
  font-weight: 700; font-size: 15px; font-family: inherit; cursor: pointer;
}
.btn-nr:active { background: #fdecec; }

.selo-nr {
  background: #fdecec; color: #7a1c17; border: 1px solid var(--vermelho);
  border-radius: 10px; padding: 14px; font-size: 14px; text-align: center; font-weight: 600;
}

/* Modal de não realizada (overlay dentro do app) */
.nr-fs { position: fixed; inset: 0; z-index: 70; background: var(--canvas); display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain; }
.nr-fs-topo {
  background: var(--vermelho); color: #fff; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-top)); font-weight: 700;
  position: sticky; top: 0;
}
.nr-fs-topo > span { min-width: 0; font-size: 15px; line-height: 1.2; }
.nr-corpo { padding: 16px; max-width: 640px; margin: 0 auto; width: 100%; }
.nr-corpo select {
  width: 100%; padding: 13px 14px; font-size: 16px; border: 1px solid var(--borda);
  border-radius: 10px; margin-bottom: 14px; background: #fff; color: var(--txt); font-family: inherit;
}
.nr-foto-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 16px; border-radius: 10px; border: 2px dashed var(--borda);
  background: #fff; color: var(--roxo); font-weight: 700; font-size: 15px; cursor: pointer; margin-bottom: 12px;
}
.nr-foto-preview {
  display: block; width: 100%; max-height: 320px; object-fit: contain;
  border: 1px solid var(--borda); border-radius: 10px; margin-bottom: 14px; background: #fff;
}
