/* ==========================================================================
   Bakof Tec Engenharia — design system compartilhado (wizard + painel)
   ========================================================================== */

:root {
  --navy: #223876;
  --navy-800: #1b2d61;
  --navy-900: #14224b;
  --yellow: #f9c400;
  --yellow-soft: #fff6d6;
  --teal: #008076;
  --teal-600: #00968a;
  --teal-400: #2bb3a6;
  --teal-100: #d5f0ec;
  --teal-50: #edf8f6;

  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e7ef;
  --border-strong: #cfd6e2;
  --text: #182234;
  --text-2: #3a4658;
  --muted: #6b778a;

  --danger: #d23f3f;
  --danger-bg: #fdecec;
  --success: #0f8a5f;
  --success-bg: #e3f6ee;
  --warning: #a8670a;
  --warning-bg: #fff3dc;
  --info: #2a5bd7;
  --info-bg: #e8efff;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-xs: 0 1px 2px rgba(20, 34, 75, .06);
  --shadow-sm: 0 1px 3px rgba(20, 34, 75, .08), 0 1px 2px rgba(20, 34, 75, .04);
  --shadow: 0 4px 16px rgba(20, 34, 75, .08), 0 1px 3px rgba(20, 34, 75, .05);
  --shadow-lg: 0 18px 48px rgba(20, 34, 75, .16), 0 4px 12px rgba(20, 34, 75, .06);
  --ring: 0 0 0 4px rgba(0, 150, 138, .18);

  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);

  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color-scheme: light;
}

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

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; color: var(--text); }

a { color: var(--teal); text-decoration: none; font-weight: 500; }
a:hover { color: var(--teal-600); text-decoration: underline; text-underline-offset: 3px; }

::selection { background: var(--teal-100); }

:focus-visible { outline: 2px solid var(--teal-600); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }
.small { font-size: .86em; }
.nowrap { white-space: nowrap; }

/* ---------- Botões ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  min-height: 44px;
  padding: .65em 1.25em;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-weight: 600;
  font-size: .95em;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none !important;
  white-space: nowrap;
  transition: background .18s var(--ease), border-color .18s var(--ease), color .18s var(--ease),
              box-shadow .18s var(--ease), transform .12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(1px) scale(.985); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; box-shadow: none; transform: none; }
.btn svg { width: 1.1em; height: 1.1em; flex: none; }

.btn-primary { --btn-bg: var(--teal); --btn-fg: #fff; --btn-bd: var(--teal); }
.btn-primary:hover { --btn-bg: var(--teal-600); --btn-bd: var(--teal-600); color: #fff; }
.btn-secondary { --btn-bg: var(--surface); --btn-fg: var(--teal); --btn-bd: var(--teal-400); }
.btn-secondary:hover { --btn-bg: var(--teal-50); color: var(--teal); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover { --btn-bg: var(--surface-2); box-shadow: none; }
.btn-danger { --btn-bg: var(--surface); --btn-fg: var(--danger); --btn-bd: #f0c2c2; }
.btn-danger:hover { --btn-bg: var(--danger-bg); color: var(--danger); }
.btn-whatsapp { --btn-bg: #1faa59; --btn-fg: #fff; --btn-bd: #1faa59; }
.btn-whatsapp:hover { --btn-bg: #1b9950; color: #fff; }
.btn-sm { min-height: 34px; padding: .4em .85em; font-size: .86em; }
.btn-lg { min-height: 52px; padding: .8em 1.6em; font-size: 1.02em; }
.btn-block { width: 100%; }

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after { border-color: var(--teal-100); border-top-color: var(--teal); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card-title { margin: 0 0 4px; font-size: 1.05em; font-weight: 700; }
.card-sub { margin: 0 0 18px; color: var(--muted); font-size: .9em; }

/* ---------- Formulários ---------- */
.field { margin-bottom: 22px; }
.field:last-child { margin-bottom: 0; }
.field > label, .field-label {
  display: block;
  font-weight: 600;
  font-size: .95em;
  margin-bottom: 8px;
  color: var(--text);
}
.field .req { color: var(--danger); margin-left: 2px; font-weight: 700; }
.field .opt { color: var(--muted); font-weight: 500; font-size: .88em; margin-left: 4px; }
.field .help { font-size: .85em; color: var(--muted); margin-top: 8px; display: flex; gap: 6px; }

.input, .field input[type="text"], .field input[type="tel"], .field input[type="email"],
.field input[type="number"], .field input[type="password"], .field input[type="search"],
.field textarea, .field select {
  width: 100%;
  min-height: 48px;
  padding: .7em .95em;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* evita zoom automático no iOS */
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
.field select {
  padding-right: 2.6em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b778a' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1em center;
  cursor: pointer;
}
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: #a3adbd; }
.input:hover, .field input:hover, .field textarea:hover, .field select:hover { border-color: #b7c1d1; }
.input:focus, .field input:focus, .field textarea:focus, .field select:focus {
  outline: none;
  border-color: var(--teal-600);
  box-shadow: var(--ring);
}

.field .error-msg {
  display: none;
  align-items: center;
  gap: 6px;
  color: var(--danger);
  font-size: .86em;
  font-weight: 500;
  margin-top: 8px;
}
.field.invalid > .error-msg { display: flex; animation: fadeUp .25s var(--ease); }
.field.invalid > input, .field.invalid > textarea, .field.invalid > select {
  border-color: var(--danger);
  background: #fffafa;
}
.field.invalid > input:focus, .field.invalid > textarea:focus { box-shadow: 0 0 0 4px rgba(210,63,63,.15); }
.field.invalid > .options-list .option-item { border-color: #efb8b8; }
.field.shake { animation: shake .4s var(--ease); }

/* Opções (radio / checkbox) com indicador customizado */
.options-list { display: grid; gap: 10px; }
.option-item {
  position: relative;
  display: block;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease), transform .12s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.option-item:hover { border-color: var(--teal-400); background: var(--teal-50); }
.option-item:active { transform: scale(.995); }
.option-item.selected { border-color: var(--teal); background: var(--teal-50); box-shadow: 0 0 0 3px rgba(0,128,118,.10); }
.option-item:focus-within { box-shadow: var(--ring); }
.option-row { display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; }
.option-row input { position: absolute; opacity: 0; pointer-events: none; }
.option-label { flex: 1; font-weight: 500; color: var(--text-2); padding-top: 1px; }
.option-item.selected .option-label { color: var(--text); font-weight: 600; }

.indicator {
  flex: none;
  width: 22px; height: 22px;
  margin-top: 1px;
  border: 2px solid var(--border-strong);
  background: #fff;
  display: grid; place-items: center;
  transition: border-color .18s var(--ease), background .18s var(--ease);
}
.indicator.radio { border-radius: 50%; }
.indicator.check { border-radius: 6px; }
.indicator::after {
  content: "";
  transform: scale(0);
  transition: transform .22s var(--ease-spring);
}
.indicator.radio::after { width: 10px; height: 10px; border-radius: 50%; background: #fff; }
.indicator.check::after {
  width: 11px; height: 6px;
  border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff;
  transform: rotate(-45deg) scale(0);
  margin-top: -3px;
}
.option-item.selected .indicator { border-color: var(--teal); background: var(--teal); }
.option-item.selected .indicator.radio::after { transform: scale(1); }
.option-item.selected .indicator.check::after { transform: rotate(-45deg) scale(1); }

.option-detail {
  padding: 4px 16px 16px 50px;
  cursor: default;
  animation: expandIn .28s var(--ease);
}
.option-detail .field { margin-bottom: 16px; }
.option-detail .field:last-child { margin-bottom: 0; }
.option-detail .field > label { font-size: .9em; color: var(--text-2); }

/* ---------- Badges de status ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: .3em .75em;
  border-radius: 999px;
  font-size: .78em;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-2);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-rascunho { background: #eef1f6; color: #5d6a7e; }
.badge-em_preenchimento { background: var(--warning-bg); color: var(--warning); }
.badge-completo { background: var(--teal-100); color: #00665e; }
.badge-completo::before { animation: pulseDot 1.6s ease-in-out infinite; }
.badge-analisado { background: var(--info-bg); color: var(--info); }
.badge-em_andamento { background: #efe9ff; color: #6a46c9; }
.badge-baixado { background: var(--success-bg); color: var(--success); }
.badge-expirado { background: var(--danger-bg); color: var(--danger); }
.badge-ativo { background: var(--success-bg); color: var(--success); }
.badge-inativo { background: #eef1f6; color: #7a8698; }

/* ---------- Progresso ---------- */
.progress-bar-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #e4e9f1;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--teal-400));
  transition: width .6s var(--ease);
  position: relative;
}
.progress-bar-fill::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.45), transparent);
  transform: translateX(-100%);
  animation: sheen 2.4s ease-in-out infinite;
}

/* ---------- Alertas ---------- */
.alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: .92em;
  animation: fadeUp .35s var(--ease);
}
.alert-icon { flex: none; font-size: 1.1em; line-height: 1.3; }
.alert strong { display: block; margin-bottom: 2px; }
.alert-error { background: var(--danger-bg); color: #9b2c2c; border-color: #f5c9c9; }
.alert-success { background: var(--success-bg); color: #0b6b4a; border-color: #bfe7d5; }
.alert-info { background: var(--info-bg); color: #23459f; border-color: #cddafb; }
.alert-warning { background: var(--warning-bg); color: #86520a; border-color: #f5dcaa; }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  z-index: 1000;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--navy-900);
  color: #fff;
  font-size: .92em;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn .35s var(--ease-spring);
}
.toast.leaving { animation: toastOut .25s var(--ease) forwards; }
.toast-success .toast-icon { color: #5ee0b0; }
.toast-error { background: #7d2222; }

/* ---------- Estados vazios / telas centrais ---------- */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .empty-icon { font-size: 2.6em; margin-bottom: 8px; }
.empty-state h2, .empty-state h3 { margin: 6px 0 8px; }
.empty-state p { color: var(--muted); max-width: 420px; margin: 0 auto 20px; }
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.center-screen .card { max-width: 440px; width: 100%; }

/* ---------- Skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, #e9edf3 25%, #f4f6fa 50%, #e9edf3 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
  border-radius: var(--radius-sm);
}

/* ---------- Animações ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slideInRight { from { opacity: 0; transform: translateX(28px); } to { opacity: 1; transform: none; } }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-28px); } to { opacity: 1; transform: none; } }
@keyframes expandIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes popIn { 0% { opacity: 0; transform: scale(.85); } 100% { opacity: 1; transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes sheen { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }
@keyframes pulseDot { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.7); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }
@keyframes ringGrow { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.anim-fade-up { animation: fadeUp .45s var(--ease) both; }
.stagger > * { animation: fadeUp .45s var(--ease) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }
.stagger > *:nth-child(n+7) { animation-delay: .26s; }

/* Check animado (tela de sucesso) */
.success-mark { width: 88px; height: 88px; margin: 0 auto 18px; }
.success-mark circle { fill: var(--teal-50); stroke: var(--teal); stroke-width: 3; transform-origin: center; animation: ringGrow .45s var(--ease-spring) both; }
.success-mark path { fill: none; stroke: var(--teal); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 60; stroke-dashoffset: 60; animation: drawCheck .45s .3s var(--ease) forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
