/* ============================================================================
   Assistente SPDA — "Instrumento técnico refinado"
   Profundidade escura + acento âmbar molten, coerente com o Portal do Raio.
   Usa os tokens --pr-* da portal-common.css; a tipografia mantém o stack de
   sistema do portal (offline-first, coerência com a Calculadora).
   ========================================================================== */

:root {
  --asst-amber:      #f59e0b;
  --asst-amber-2:    #fcd34d;
  --asst-amber-deep: #d97706;
  --asst-ink:        #e7edf5;
  --asst-dim:        #94a3b8;
  --asst-muted:      #64748b;
  --asst-panel:      #131f2e;
  --asst-panel-2:    #172436;
  --asst-inset:      #0c1826;
  --asst-line:       rgba(245, 158, 11, 0.16);
  --asst-line-soft:  rgba(255, 255, 255, 0.07);
  --asst-glow:       rgba(245, 158, 11, 0.22);
}

/* Slot do header fixo do portal (48px) */
body {
  padding-top: 48px;
  color: var(--asst-ink);
  background: #08111d;
  -webkit-font-smoothing: antialiased;
}

/* ── Atmosfera: brasa âmbar no topo + grelha "blueprint" ténue ────────────── */
body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
body::before {
  background:
    radial-gradient(1100px 520px at 78% -8%, rgba(245, 158, 11, 0.16), transparent 60%),
    radial-gradient(760px 420px at 8% 4%, rgba(59, 130, 246, 0.10), transparent 62%),
    linear-gradient(180deg, #0b1420 0%, #08111d 46%, #070e18 100%);
}
body::after {
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 46px 46px, 46px 46px;
  mask-image: radial-gradient(circle at 50% 22%, #000 0%, transparent 78%);
  -webkit-mask-image: radial-gradient(circle at 50% 22%, #000 0%, transparent 78%);
  opacity: 0.7;
}

/* ── Contentor ────────────────────────────────────────────────────────────── */
.asst-shell {
  position: relative;
  z-index: 1;
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 128px;
}

/* ── Cabeçalho ────────────────────────────────────────────────────────────── */
.asst-header {
  position: relative;
  padding: 4px 0 0 72px;
  margin-bottom: 26px;
  min-height: 60px;
}
/* Emblema-relâmpago */
.asst-header::before {
  content: "⚡";
  position: absolute;
  left: 0;
  top: 0;
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  font-size: 26px;
  border-radius: 16px;
  color: #1a1206;
  background: linear-gradient(150deg, var(--asst-amber-2), var(--asst-amber) 55%, var(--asst-amber-deep));
  box-shadow: 0 10px 26px rgba(245, 158, 11, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}
.asst-header .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 6px;
  color: #fbbf24;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.asst-header .eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--asst-amber), transparent);
}
.asst-header h1 {
  margin: 0;
  font-size: clamp(28px, 6vw, 40px);
  font-weight: 900;
  letter-spacing: -0.025em;
  line-height: 1.02;
  background: linear-gradient(180deg, #ffffff 0%, #cdd8e6 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.asst-header .subtitle {
  margin: 10px 0 0;
  max-width: 60ch;
  color: var(--asst-dim);
  font-size: 0.96rem;
  line-height: 1.55;
}

/* ── Progresso ────────────────────────────────────────────────────────────── */
.asst-progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.02em;
}
.asst-progress-meta .passo {
  color: var(--asst-dim);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.asst-progress-meta .passo b { color: var(--asst-amber-2); font-weight: 900; }
.asst-progress-meta .titulo { color: var(--asst-muted); font-weight: 600; }

.asst-progress {
  position: relative;
  height: 7px;
  background: var(--asst-inset);
  border: 1px solid var(--asst-line-soft);
  border-radius: 999px;
  margin: 0 0 30px;
  overflow: hidden;
}
#asst-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--asst-amber-deep), var(--asst-amber) 55%, var(--asst-amber-2));
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.55);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ── Esquema técnico ao vivo ──────────────────────────────────────────────── */
.asst-desenho {
  margin: 0 0 26px;
  padding: 12px 12px 10px;
  border-radius: 16px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(245, 158, 11, 0.07), transparent 70%),
    linear-gradient(180deg, var(--asst-panel-2), var(--asst-inset));
  border: 1px solid var(--asst-line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--pr-shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.25));
}
.asst-desenho svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 220px;
}
.asst-desenho figcaption { margin-top: 8px; }
.asst-desenho-legenda {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}
.asst-desenho-chip {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fbbf24;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.28);
  animation: asst-enter 0.35s ease both;
}

/* ── Ecrãs ────────────────────────────────────────────────────────────────── */
.asst-ecra { animation: asst-enter 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
.asst-ecra > h2 {
  margin: 0 0 6px;
  font-size: clamp(1.2rem, 3.4vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.015em;
  color: #f4f7fb;
}
.ajuda {
  color: var(--asst-dim);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 6px 0 2px;
}
.asst-erro {
  margin: 12px 0 0;
  padding: 10px 14px;
  border-radius: 10px;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ── Cartões de escolha ───────────────────────────────────────────────────── */
.asst-cartoes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 20px 0 6px;
}
@media (min-width: 540px) { .asst-cartoes { grid-template-columns: 1fr 1fr; } }

.asst-cartao {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px 16px 16px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--asst-ink);
  text-align: left;
  cursor: pointer;
  min-height: 68px;
  background: linear-gradient(158deg, var(--asst-panel-2), var(--asst-panel));
  border: 1px solid var(--asst-line-soft);
  border-radius: 15px;
  box-shadow: var(--pr-shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.25));
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}
.asst-cartao .ico {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  border-radius: 12px;
  background: radial-gradient(120% 120% at 30% 20%, rgba(245, 158, 11, 0.18), rgba(245, 158, 11, 0.05));
  border: 1px solid var(--asst-line);
  transition: transform 0.16s ease;
}
.asst-cartao:hover {
  transform: translateY(-2px);
  border-color: var(--asst-line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}
.asst-cartao:hover .ico { transform: scale(1.06) rotate(-3deg); }
.asst-cartao:focus-visible {
  outline: none;
  border-color: var(--asst-amber);
  box-shadow: 0 0 0 3px var(--asst-glow);
}
.asst-cartao.activo {
  border-color: var(--asst-amber);
  background:
    linear-gradient(158deg, rgba(245, 158, 11, 0.16), rgba(245, 158, 11, 0.05)),
    linear-gradient(158deg, var(--asst-panel-2), var(--asst-panel));
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.18), inset 0 0 0 1px rgba(245, 158, 11, 0.25);
}
.asst-cartao.activo .ico {
  background: linear-gradient(150deg, var(--asst-amber-2), var(--asst-amber-deep));
  border-color: transparent;
}
/* Marca de selecção */
.asst-cartao.activo::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 12px;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 900;
  color: #1a1206;
  border-radius: 999px;
  background: var(--asst-amber);
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.5);
}

/* ── Campos numéricos / dimensões ─────────────────────────────────────────── */
.asst-campos { display: grid; gap: 14px; margin-top: 18px; }
@media (min-width: 540px) { .asst-campos { grid-template-columns: 1fr 1fr; } }

.asst-campos label,
.asst-num {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 14px 0 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--asst-dim);
}
.asst-campos input,
.asst-num input {
  padding: 13px 14px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--asst-ink);
  background: var(--asst-inset);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 11px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.asst-campos input::placeholder,
.asst-num input::placeholder { color: var(--asst-muted); font-weight: 500; }
.asst-campos input:focus,
.asst-num input:focus {
  outline: none;
  border-color: var(--asst-amber);
  box-shadow: 0 0 0 3px var(--asst-glow);
}

.asst-check {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0 0;
  padding: 14px 16px;
  font-size: 0.98rem;
  font-weight: 500;
  color: var(--asst-ink);
  background: linear-gradient(158deg, var(--asst-panel-2), var(--asst-panel));
  border: 1px solid var(--asst-line-soft);
  border-radius: 13px;
  cursor: pointer;
}
.asst-check:hover { border-color: var(--asst-line); }
.asst-check input {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--asst-amber);
  cursor: pointer;
}

/* ── Resumo (folha de especificação) ──────────────────────────────────────── */
.asst-ecra[data-ecra="resumo"] { }
.asst-tabela {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 18px 0;
  font-size: 0.92rem;
  background: linear-gradient(180deg, var(--asst-panel-2), var(--asst-panel));
  border: 1px solid var(--asst-line);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--pr-shadow, 0 4px 20px rgba(0, 0, 0, 0.35));
}
.asst-tabela thead th {
  padding: 12px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.08);
  border-bottom: 1px solid var(--asst-line);
}
.asst-tabela tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--asst-line-soft);
  vertical-align: middle;
}
.asst-tabela tbody tr:last-child td { border-bottom: none; }
.asst-tabela tbody tr:hover td { background: rgba(245, 158, 11, 0.05); }
/* Coluna do código do pormenor — tratamento monospaced/chip */
.asst-tabela tbody td:first-child {
  font-family: "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", monospace;
  font-weight: 700;
  font-size: 0.86rem;
  color: #fcd34d;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.asst-tabela tbody td:nth-child(2) { color: var(--asst-dim); }
.asst-tabela input {
  width: 84px;
  padding: 8px 10px;
  font-size: 0.95rem;
  font-weight: 700;
  text-align: right;
  color: var(--asst-ink);
  background: var(--asst-inset);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 8px;
}
.asst-tabela input:focus {
  outline: none;
  border-color: var(--asst-amber);
  box-shadow: 0 0 0 2px var(--asst-glow);
}
.asst-tabela .rm {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--asst-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.asst-tabela .rm:hover {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
}

#resumo-notas { display: grid; gap: 10px; margin: 14px 0; }
#resumo-notas .nota {
  position: relative;
  padding: 12px 14px 12px 40px;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #dbe4f0;
  background: rgba(59, 130, 246, 0.10);
  border: 1px solid rgba(59, 130, 246, 0.28);
}
#resumo-notas .nota::before {
  content: "ℹ";
  position: absolute;
  left: 14px;
  top: 12px;
  font-weight: 900;
  color: #93c5fd;
}

.asst-aviso {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  margin: 18px 0;
  border-radius: 12px;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #f0d9ae;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid var(--asst-line);
  border-left: 3px solid var(--asst-amber);
}
.asst-aviso a { color: var(--asst-amber-2); font-weight: 700; }

.asst-export { display: flex; flex-wrap: wrap; gap: 10px; margin: 20px 0 4px; }

/* ── Botões (não estavam estilizados!) ────────────────────────────────────── */
.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.14s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}
.button:disabled { opacity: 0.42; cursor: not-allowed; }
.button.primary {
  color: #1a1206;
  background: linear-gradient(150deg, var(--asst-amber-2), var(--asst-amber) 60%, var(--asst-amber-deep));
  box-shadow: 0 8px 22px rgba(245, 158, 11, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.button.primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(245, 158, 11, 0.42); }
.button.primary:active:not(:disabled) { transform: translateY(0); }
.button.secondary {
  color: var(--asst-ink);
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--asst-line);
}
.button.secondary:hover:not(:disabled) {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--asst-amber);
  transform: translateY(-2px);
}
.button:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--asst-glow); }

/* ── Barra de navegação flutuante (vidro) ─────────────────────────────────── */
.asst-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(10, 18, 29, 0.4), rgba(8, 14, 22, 0.92));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--asst-line);
}
.asst-nav .button { min-height: 50px; }
.asst-nav #btn-seguinte { flex: 1; max-width: 320px; }
#btn-recomecar { margin-left: auto; }

/* Centrar o conteúdo da nav no mesmo eixo do shell */
@media (min-width: 800px) {
  .asst-nav {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }
  .asst-nav > * { }
  .asst-nav {
    padding-inline: max(20px, calc((100% - 760px) / 2 + 20px));
    justify-content: flex-start;
  }
}

/* ── Motion ───────────────────────────────────────────────────────────────── */
@keyframes asst-enter {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
/* Entrada escalonada dos cartões/campos dentro do ecrã activo */
.asst-ecra > .asst-cartoes > .asst-cartao,
.asst-ecra > .asst-campos > label,
.asst-ecra > .asst-num,
.asst-ecra > .asst-check {
  animation: asst-enter 0.44s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.asst-ecra > .asst-cartoes > .asst-cartao:nth-child(1) { animation-delay: 0.04s; }
.asst-ecra > .asst-cartoes > .asst-cartao:nth-child(2) { animation-delay: 0.09s; }
.asst-ecra > .asst-cartoes > .asst-cartao:nth-child(3) { animation-delay: 0.14s; }
.asst-ecra > .asst-cartoes > .asst-cartao:nth-child(4) { animation-delay: 0.19s; }

@media (prefers-reduced-motion: reduce) {
  .asst-ecra,
  .asst-ecra > .asst-cartoes > .asst-cartao,
  .asst-ecra > .asst-campos > label,
  .asst-ecra > .asst-num,
  .asst-ecra > .asst-check { animation: none; }
  #asst-progress-bar { transition: none; }
  .asst-cartao, .button { transition: none; }
}
