/* ============================================================
   TransMissão — Design System v1 (FASE 1)
   Tokens + componentes. Tailwind CDN cuida do layout utilitário;
   aqui ficam identidade, temas e componentes reutilizáveis.
   ============================================================ */

:root {
  --brand:        #E8261F;
  --brand-strong: #C41C16;
  --brand-soft:   rgba(232, 38, 31, .12);
  --success:      #2FBF71;
  --success-soft: rgba(47, 191, 113, .14);
  --warn:         #F5A524;
  --warn-soft:    rgba(245, 165, 36, .14);
  --radius:       18px;
  --radius-sm:    12px;
  --nav-h:        64px;
}

:root[data-theme="dark"] {
  --bg:        #0B0B0C;
  --surface:   #151517;
  --surface-2: #1D1D21;
  --border:    #27272C;
  --text:      #F5F5F6;
  --muted:     #9B9BA3;
  --logo-bg:   #000000;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg:        #F4F4F5;
  --surface:   #FFFFFF;
  --surface-2: #FAFAFA;
  --border:    #E5E5E8;
  --text:      #121214;
  --muted:     #6E6E76;
  --logo-bg:   #FFFFFF;
  color-scheme: light;
}

* { -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100%;
}

body { padding-env: 0; }

::selection { background: var(--brand); color: #fff; }

/* ---------- Marca ---------- */
/* Os arquivos da logomarca são JPEG com fundo sólido (preto/branco).
   O blend-mode funde o fundo do JPEG com a superfície do app,
   então a marca nunca aparece "dentro de uma caixa". */
.logo-swap { display: inline-block; line-height: 0; }
.logo-swap img { max-width: 100%; height: auto; }

/* Logo horizontal (não usada no header atual, mantida p/ uso futuro) */
.logo-h img { height: 42px; width: auto; max-width: 100%; }
@media (min-width: 640px) { .logo-h img { height: 46px; } }

/* Lockup do cabeçalho: ícone da marca + palavra CHECK */
.logo-lockup { display: inline-flex; align-items: center; gap: 11px; }
.logo-mark img { height: 44px; width: auto; max-width: none; }
.logo-lockup .wm-check {
  font-size: 1.6rem;
  line-height: 1;
  border-bottom-width: 2px;
  padding-bottom: 4px;
}
@media (min-width: 640px) {
  .logo-mark img { height: 48px; }
  .logo-lockup .wm-check { font-size: 1.75rem; }
}
:root[data-theme="dark"]  .logo-swap .logo-light { display: none; }
:root[data-theme="dark"]  .logo-swap .logo-dark  { display: block; mix-blend-mode: screen; }
:root[data-theme="light"] .logo-swap .logo-dark  { display: none; }
:root[data-theme="light"] .logo-swap .logo-light { display: block; mix-blend-mode: multiply; }

.wordmark {
  font-family: 'Archivo', 'Inter', sans-serif;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  line-height: 1;
}
.wordmark .wm-missao { color: var(--brand); }

/* Marca "CHECK": maiúsculas espaçadas com o traço vermelho da identidade */
.wm-check {
  letter-spacing: 0.14em;
  border-bottom: 2px solid var(--brand);
  padding-bottom: 3px;
}

/* ---------- Cartões ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px -18px rgba(0,0,0,.25);
}
.card-2 { background: var(--surface-2); }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 48px; padding: 0 1.25rem;
  border-radius: 14px; border: 1px solid transparent;
  font-weight: 600; font-size: .95rem;
  cursor: pointer; user-select: none;
  transition: transform .08s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 18px -8px rgba(232,38,31,.55); }
.btn-primary:hover { background: var(--brand-strong); }

.btn-soft    { background: var(--brand-soft); color: var(--brand); }
.btn-success { background: var(--success); color: #fff; }
.btn-success-soft { background: var(--success-soft); color: var(--success); }
.btn-warn-soft    { background: var(--warn-soft); color: var(--warn); }

.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--muted); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-lg { min-height: 56px; font-size: 1.05rem; border-radius: 16px; }
.btn-sm { min-height: 38px; padding: 0 .85rem; font-size: .85rem; border-radius: 10px; }

/* ---------- Campos ---------- */
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--muted); margin-bottom: .4rem; }
.input {
  width: 100%; min-height: 50px; padding: 0 1rem;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  font-size: 1rem; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea.input { padding: .8rem 1rem; min-height: 90px; resize: vertical; }

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .7rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}
.chip-brand   { background: var(--brand-soft);   border-color: transparent; color: var(--brand); }
.chip-success { background: var(--success-soft); border-color: transparent; color: var(--success); }
.chip-warn    { background: var(--warn-soft);    border-color: transparent; color: var(--warn); }

/* ---------- Avatar ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%; overflow: hidden;
  background: var(--brand); color: #fff; font-weight: 700;
  flex-shrink: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Cabeçalho e navegação ---------- */
:root { --header-h: 72px; }
.appheader {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.appheader-row { height: var(--header-h); }
/* Barra fixa logo abaixo do cabeçalho (respeita o notch do iPhone) */
.sticky-below-header {
  position: sticky;
  top: calc(var(--header-h) + env(safe-area-inset-top));
  z-index: 30;
}

.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; justify-content: space-around;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; flex: 1; min-height: 44px;
  font-size: .68rem; font-weight: 600; color: var(--muted);
  transition: color .15s ease;
}
.bottomnav a i { font-size: 1.45rem; }
.bottomnav a.active { color: var(--brand); }

/* !important: o Tailwind CDN injeta py-5 depois deste arquivo e venceria o empate */
.page-pad { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 1.5rem) !important; }

/* ---------- Progresso ---------- */
.progress-track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-fill  { height: 100%; border-radius: 999px; background: var(--brand); transition: width .4s cubic-bezier(.22,1,.36,1); }

.ring { transform: rotate(-90deg); }
.ring .ring-bg    { stroke: var(--surface-2); }
.ring .ring-value { stroke: var(--brand); stroke-linecap: round; transition: stroke-dashoffset .5s cubic-bezier(.22,1,.36,1); }

/* ---------- Itens do checklist ---------- */
.item-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .2s ease, opacity .2s ease;
}
.item-card .item-actions { display: flex; gap: .5rem; }
.item-card .item-panel { display: none; }
.item-card.show-panel .item-panel { display: block; }

.item-card.is-done    { border-color: color-mix(in srgb, var(--success) 45%, var(--border)); }
.item-card.is-problem { border-color: color-mix(in srgb, var(--warn) 55%, var(--border)); }
.item-card.is-na      { opacity: .62; }

.item-status-icon {
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted); font-size: 1.25rem;
  flex-shrink: 0; transition: background .2s ease, color .2s ease;
}
.item-card.is-done    .item-status-icon { background: var(--success-soft); color: var(--success); }
.item-card.is-problem .item-status-icon { background: var(--warn-soft); color: var(--warn); }

.item-card.is-done .item-title { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent); }

/* ---------- Controle segmentado ---------- */
.seg {
  display: inline-flex; padding: 4px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px;
}
.seg button, .seg label {
  min-height: 40px; padding: 0 1rem; border-radius: 10px;
  font-size: .85rem; font-weight: 600; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  cursor: pointer; transition: background .15s ease, color .15s ease;
}
.seg .active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.12); }

/* ---------- KPI ---------- */
.kpi { padding: 1rem 1.1rem; }
.kpi .kpi-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.kpi .kpi-label { font-size: .75rem; font-weight: 600; color: var(--muted); margin-top: .15rem; }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 90;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 1rem);
  display: flex; flex-direction: column; gap: .5rem; align-items: center;
  pointer-events: none; width: min(92vw, 420px);
}
.toast {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  padding: .75rem 1.1rem; font-size: .88rem; font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.4);
  display: flex; align-items: center; gap: .6rem;
  animation: toast-in .25s cubic-bezier(.22,1,.36,1);
  width: 100%;
}
.toast i { color: var(--brand); font-size: 1.2rem; }
.toast.leaving { animation: toast-out .2s ease forwards; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(8px)  scale(.97); } }

/* ---------- Skeleton ---------- */
.skeleton {
  border-radius: var(--radius-sm);
  background: linear-gradient(100deg, var(--surface-2) 40%, color-mix(in srgb, var(--surface-2) 60%, var(--surface)) 50%, var(--surface-2) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Login ---------- */
.auth-bg {
  min-height: 100dvh;
  background:
    radial-gradient(1100px 500px at 50% -10%, var(--brand-soft), transparent 60%),
    var(--logo-bg);
}
:root[data-theme="light"] .auth-bg {
  background:
    radial-gradient(1100px 500px at 50% -10%, rgba(232,38,31,.07), transparent 60%),
    var(--logo-bg);
}
.auth-card { background: var(--surface); border: 1px solid var(--border); }

/* ---------- Estado de sucesso ---------- */
.success-pop { animation: pop-in .45s cubic-bezier(.22,1.4,.36,1); }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.6); } 100% { opacity: 1; transform: scale(1); } }

.pulse-dot { position: relative; }
.pulse-dot::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--brand); opacity: 0;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0% { opacity: .7; transform: scale(.6); } 70% { opacity: 0; transform: scale(1.3); } 100% { opacity: 0; } }

/* ---------- Utilidades ---------- */
.text-muted { color: var(--muted); }
.text-brand { color: var(--brand); }
.divider { border-top: 1px solid var(--border); }
.tabular { font-variant-numeric: tabular-nums; }

@media (min-width: 768px) {
  .bottomnav { display: none; }
  .page-pad { padding-bottom: 2rem !important; }
}
