/* Kiwi PWA — TRE-PI palette */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy-900: #0f1e52;
  --navy-800: #1c2d6b;
  --navy-700: #1e3580;
  --navy-600: #2a4299;
  --navy-100: #dce8f8;
  --navy-50:  #eaf1fb;
  --yellow:   #f5c200;
  --yellow-dk:#c49a00;
  --teal:     #2ab5c8;
  --teal-dk:  #1e8fa0;
  --gray-700: #374151;
  --gray-500: #6b7280;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --white:    #ffffff;
  --error:    #dc2626;
  --warning:  #d97706;
  --radius:   14px;
  --shadow:   0 2px 12px rgba(15,30,82,.14);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--navy-50);
  color: var(--gray-700);
  -webkit-tap-highlight-color: transparent;
}

/* ── Layout ── */
#app { min-height: 100%; display: flex; flex-direction: column; }

.screen { display: none; flex: 1; flex-direction: column; opacity: 0; transition: opacity .25s ease; }
.screen.active { display: flex; }
.screen.visible { opacity: 1; }

/* ── Header (tela principal) ── */
header {
  background: var(--white);
  box-shadow: 0 2px 8px rgba(15,30,82,.12);
  flex-shrink: 0;
}

.header-stripe-top  { height: 5px; background: var(--navy-800); }
.header-stripe-bottom { height: 3px; background: var(--yellow); }

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}

.header-logo { height: 36px; width: auto; display: block; }

.header-divider {
  width: 1px;
  height: 28px;
  background: var(--gray-200);
  flex-shrink: 0;
}

.header-system {
  font-size: 13px;
  font-weight: 700;
  color: var(--navy-800);
}

/* ── Login screen ── */
#screen-login {
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  gap: 0;
  background: var(--navy-50);
}

/* hero ocupa toda a parte superior */
.login-hero {
  width: 100%;
  background: var(--white);
  box-shadow: 0 2px 10px rgba(15,30,82,.12);
  flex-shrink: 0;
}

.hero-stripe-top    { height: 5px; background: var(--navy-800); }
.hero-stripe-bottom { height: 3px; background: var(--yellow); }

.hero-logo-box {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 32px 20px;
}

.hero-logo-box img { height: 56px; width: auto; display: block; }

.hero-subtitle {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-800);
  padding: 0 16px 18px;
  opacity: .8;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 28px 24px;
  box-shadow: var(--shadow);
  width: calc(100% - 32px);
  max-width: 360px;
  margin: 24px auto 0;
}

.login-card h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--navy-800);
  margin-bottom: 4px;
}

.login-card .hint {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 24px;
  line-height: 1.4;
}

/* ── Field group (label + input) ── */
.field-group { margin-bottom: 20px; }

.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 8px;
}

.cpf-input {
  width: 100%;
  height: 52px;
  border: 2px solid var(--gray-300);
  border-radius: 10px;
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 2px;
  color: var(--navy-800);
  background: var(--white);
  box-sizing: border-box;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.cpf-input::placeholder { color: var(--gray-300); letter-spacing: 1px; font-weight: 400; }
.cpf-input:focus {
  outline: none;
  border-color: var(--navy-600);
  box-shadow: 0 0 0 3px rgba(42,66,153,.18);
}
.cpf-input.filled {
  border-color: var(--teal);
  background: #f0fbfd;
}

.btn-primary {
  width: 100%;
  height: 52px;
  background: var(--navy-800);
  color: var(--white);
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .2px;
  transition: background .15s, transform .1s;
}

.btn-primary:active { transform: scale(.98); background: var(--navy-900); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.error-msg {
  margin-top: 14px;
  padding: 10px 14px;
  background: #fee2e2;
  color: var(--error);
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  display: none;
}
.error-msg.visible { display: block; }

.manual-link {
  margin-top: 18px;
  font-size: 12px;
  text-align: center;
}
.manual-link a {
  color: var(--navy-800);
  font-weight: 600;
  text-decoration: none;
}
.manual-link a:hover { text-decoration: underline; }

/* ── Confirmação de lotação ── */
.confirmar-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 20px 24px;
}

.confirmar-pergunta {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy-800);
  line-height: 1.4;
  padding: 4px 0 16px;
}

.confirmar-lotacao {
  background: var(--white);
  border: 2px solid var(--navy-100);
  border-radius: var(--radius);
  padding: 22px 20px;
  font-size: 17px;
  font-weight: 800;
  color: var(--navy-800);
  text-align: center;
  box-shadow: var(--shadow);
}

.confirmar-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.btn-secondary {
  width: 100%;
  height: 52px;
  background: var(--white);
  color: var(--navy-800);
  border: 2px solid var(--gray-300);
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn-secondary:active { transform: scale(.98); background: var(--gray-100); }
.btn-secondary:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* ── Tela de agradecimento (recusa) ── */
.recusado-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 28px;
  gap: 14px;
}
.recusado-icon { font-size: 56px; line-height: 1; }
.recusado-card h2 { font-size: 20px; font-weight: 800; color: var(--navy-800); }
.recusado-card p {
  font-size: 15px;
  color: var(--gray-500);
  line-height: 1.6;
  max-width: 340px;
}

/* ── Main screen ── */
#screen-main { padding: 0; }

.mesario-info {
  background: var(--navy-800);
  color: var(--white);
  padding: 14px 20px 16px;
}

.mesario-info .nome { font-weight: 700; font-size: 16px; }
.mesario-info .detalhes { opacity: .75; margin-top: 2px; font-size: 13px; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 20px 20px 10px;
}

/* ── Status buttons ── */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 20px;
}

.btn-status {
  min-height: 110px;
  border: 2.5px solid transparent;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  overflow: hidden;
}

.btn-status:active { transform: scale(.93); }

.btn-status .icon { font-size: 32px; line-height: 1; }

.btn-status[data-status="ATE_15"]     { background: #f0fdf4; border-color: #22c55e; color: #14532d; }
.btn-status[data-status="DE_16_A_30"] { background: #fefce8; border-color: #eab308; color: #713f12; }
.btn-status[data-status="DE_31_A_45"] { background: #fff7ed; border-color: #f97316; color: #7c2d12; }
.btn-status[data-status="MAIS_DE_45"] { background: #fef2f2; border-color: #ef4444; color: #7f1d1d; }

.btn-status.enviando { opacity: .6; pointer-events: none; }

/* ── Último status ── */
.ultimo-status-card {
  margin: 0 16px 16px;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  transition: background .3s, border-color .3s;
  border: 2px solid var(--gray-200);
  background: var(--white);
}

.ultimo-status-card .label {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 6px;
}

.ultimo-status-card .valor {
  font-size: 18px;
  font-weight: 800;
  color: var(--navy-800);
}

.ultimo-status-card .horario {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 3px;
}

.ultimo-status-card.vazio .valor { color: var(--gray-500); font-weight: 400; font-size: 14px; }

.ultimo-status-card.s-ATE_15     { background: #f0fdf4; border-color: #22c55e; }
.ultimo-status-card.s-ATE_15     .valor { color: #15803d; }
.ultimo-status-card.s-DE_16_A_30 { background: #fefce8; border-color: #eab308; }
.ultimo-status-card.s-DE_16_A_30 .valor { color: #a16207; }
.ultimo-status-card.s-DE_31_A_45 { background: #fff7ed; border-color: #f97316; }
.ultimo-status-card.s-DE_31_A_45 .valor { color: #c2410c; }
.ultimo-status-card.s-MAIS_DE_45 { background: #fef2f2; border-color: #ef4444; }
.ultimo-status-card.s-MAIS_DE_45 .valor { color: #b91c1c; }

/* ── Confirm overlay ── */
#status-confirm {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 30, 82, .88);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

#status-confirm.show {
  opacity: 1;
  pointer-events: auto;
}

.confirm-ring {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  margin-bottom: 20px;
  animation: pop .3s cubic-bezier(.175,.885,.32,1.275);
}

@keyframes pop {
  0%   { transform: scale(.5); opacity: 0; }
  100% { transform: scale(1);  opacity: 1; }
}

.confirm-text {
  font-size: 22px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -.3px;
}

.confirm-sub {
  font-size: 14px;
  color: rgba(255,255,255,.7);
  margin-top: 6px;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--gray-700);
  color: var(--white);
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  transition: transform .25s ease, opacity .25s ease;
  opacity: 0;
  z-index: 100;
  white-space: nowrap;
  max-width: calc(100vw - 48px);
  text-align: center;
}

#toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
#toast.warning { background: var(--warning); }
#toast.error   { background: var(--error); }

/* ── Seleção de seção (Coordenador de Acessibilidade) ── */
/* O atributo `hidden` é a primeira linha de defesa contra o mesário comum ver
   controles do coordenador (T-07-21): garante que ele vença qualquer regra de
   display de classe, mesmo se o JS falhar. */
[hidden] { display: none !important; }

#screen-selecionar-secao .hint {
  font-size: 13px;
  color: var(--gray-500);
  line-height: 1.4;
  padding: 0 20px 4px;
}

/* Os 12px laterais alinham o campo com o `padding: 12px 12px 8px` do grid logo abaixo.
   Nada de largura em px: ela recriaria o overflow que o grid responsivo acabou de fechar. */
.filtro-secoes {
  width: calc(100% - 24px);
  margin: 4px 12px 0;
  padding: 10px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: var(--navy-800);
  background: var(--white);
  -webkit-appearance: none;
}
.filtro-secoes::placeholder { color: var(--gray-500); }
.filtro-secoes:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(42, 181, 200, .18);
}

/* O piso da trilha é `min(140px, 100%)`, não `140px` puro: num container mais estreito
   que 140px o piso em px fixo vaza para fora e nasce scroll horizontal na página toda.
   Com 12px de padding lateral sobram 296px num viewport de 320px — (296 - 10) / 2 = 143px,
   então já cabem 2 colunas no menor celular em uso, e ~8 em 1280px. */
.lista-secoes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
  gap: 10px;
  padding: 12px 12px 8px;
}

/* `grid-column: 1 / -1` é obrigatório: sem ele a mensagem ocuparia uma única trilha de
   ~140px e sairia espremida numa coluna do grid. */
.lista-secoes .sem-resultado {
  grid-column: 1 / -1;
  padding: 16px 4px;
  text-align: center;
  font-size: 13px;
  color: var(--gray-500);
}

.item-secao {
  min-width: 0;
  min-height: 60px;
  background: var(--white);
  color: var(--navy-800);
  border: 2px solid var(--gray-300);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
}
.item-secao:active { transform: scale(.98); background: var(--gray-100); }

.item-secao .secao-titulo {
  font-size: 14px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.item-secao .secao-municipio {
  font-size: 11.5px;
  color: var(--gray-500);
  margin-top: 2px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.item-secao.ativa {
  border-color: var(--teal);
  background: #f0fbfd;
}

#btn-trocar-secao {
  width: calc(100% - 32px);
  margin: 0 16px;
}

/* ── Logout ── */
.btn-logout {
  margin: auto 16px 28px;
  background: none;
  border: 1.5px solid var(--gray-300);
  border-radius: 10px;
  padding: 11px;
  width: calc(100% - 32px);
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.btn-logout:hover { border-color: var(--gray-500); color: var(--gray-700); }
