/* ═══════════════════════════════════════════════════════
   nfe.css — Segunda Via NF-e
   Skin Luna · Cinematográfico · Syne + DM Mono · #EE8122
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Syne:wght@400;600;700;800&display=swap');

:root {
  --bg:           #0a0a0a;
  --surface:      #111111;
  --surface2:     #1a1a1a;
  --border:       #2a2a2a;
  --border2:      #333333;
  --accent:       #EE8122;
  --accent-hover: #d4711e;
  --accent-glow:  rgba(238,129,34,.35);
  --success:      #44cc88;
  --danger:       #ff4444;
  --warning:      #f5a623;
  --text:         #f0f0f0;
  --muted:        #888888; /* #666 falha WCAG AA (3.2:1); #888 = 5.5:1 */
  --mono:         'DM Mono', monospace;
  --sans:         'Syne', sans-serif;
  --ease-spring:  cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce:  cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

.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;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
:focus:not(:focus-visible) { outline: none; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  overflow-x: hidden;
}

/* ══════════════════════════════════════
   ORBS DE FUNDO (breathing + parallax)
   ══════════════════════════════════════ */
.bg-orb {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  will-change: transform;
}
.bg-orb--1 {
  width: 700px;
  height: 600px;
  background: radial-gradient(circle, rgba(238,129,34,.07) 0%, transparent 70%);
  top: -200px;
  right: -200px;
}
.bg-orb--2 {
  width: 600px;
  height: 500px;
  background: radial-gradient(circle, rgba(59,158,255,.045) 0%, transparent 70%);
  bottom: -200px;
  left: -200px;
}

/* ══════════════════════════════════════
   WIZARD
   ══════════════════════════════════════ */
.wizard-wrap {
  width: 100%;
  max-width: 480px;
  position: relative;
  z-index: 1;
}

/* ══════════════════════════════════════
   STEPS
   ══════════════════════════════════════ */
.step {
  display: none;
  flex-direction: column;
  will-change: transform, opacity, filter;
}
.step.visible { display: flex; }

/* ── Entrada cinematográfica (blur + scale) ── */
@keyframes stepEnter {
  from {
    opacity: 0;
    transform: scale(1.04) translateY(-6px);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}
@keyframes stepEnterBack {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
    filter: blur(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}
@keyframes stepExit {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
    filter: blur(8px);
  }
}

.step.anim-enter      { animation: stepEnter     320ms var(--ease-spring) forwards; }
.step.anim-enter-back { animation: stepEnterBack 320ms var(--ease-spring) forwards; }
.step.anim-exit       { animation: stepExit      200ms ease-in            forwards; }

@media (prefers-reduced-motion: reduce) {
  .step.anim-enter,
  .step.anim-enter-back,
  .step.anim-exit { animation: none !important; filter: none !important; }
  .countdown      { animation: none !important; }
  .skeleton-preview { animation: none !important; opacity: 1; }
  .skeleton       { animation: none !important; background: var(--border2); }
}

/* ══════════════════════════════════════
   HEADER / BRAND
   ══════════════════════════════════════ */
.step-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-badge {
  background: var(--accent);
  color: #000;
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  letter-spacing: .12em;
  text-transform: uppercase;
  line-height: 1;
  position: relative;
  overflow: hidden;
}
/* shimmer no badge */
.brand-badge::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,.25) 50%, transparent 60%);
  transform: translateX(-100%);
  animation: badgeShimmer 4s ease-in-out infinite 1s;
}
@keyframes badgeShimmer {
  0%, 100% { transform: translateX(-100%); }
  40%, 60% { transform: translateX(100%); }
}

.brand-name {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: .04em;
}

/* ══════════════════════════════════════
   PROGRESS DOTS
   ══════════════════════════════════════ */
.progress-dots { display: flex; gap: 7px; align-items: center; }

.dot {
  width: 6px;
  height: 6px;
  background: var(--border2);
  border-radius: 50%;
  transition:
    background .4s var(--ease-bounce),
    transform  .4s var(--ease-bounce),
    box-shadow .4s ease;
}
.dot.active {
  background: var(--accent);
  transform: scale(1.35);
  box-shadow: 0 0 8px var(--accent-glow);
}

/* ══════════════════════════════════════
   BODY DO STEP
   ══════════════════════════════════════ */
.step-body {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 32px 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.step-body--center {
  align-items: center;
  text-align: center;
  padding-top: 40px;
  padding-bottom: 44px;
}

/* ══════════════════════════════════════
   TEXTOS
   ══════════════════════════════════════ */
.step-question {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -.01em;
}
/* cursor do typewriter */
.tw-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--accent);
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: twBlink .7s step-end infinite;
}
@keyframes twBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.step-sub {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 10px;
}

/* ══════════════════════════════════════
   CARTÕES TELA INICIAL
   ══════════════════════════════════════ */
.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.tipo-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 28px 16px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  font-family: var(--sans);
  color: var(--text);
  min-height: 130px;
  justify-content: center;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition:
    border-color   .3s var(--ease-spring),
    background     .3s ease,
    transform      .3s var(--ease-spring),
    box-shadow     .3s ease;
}

.tipo-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(238,129,34,.08) 0%, transparent 70%);
  opacity: 0;
  transition: opacity .3s ease;
}

.tipo-card:hover {
  border-color: var(--accent);
  transform: translateY(-5px);
  box-shadow:
    0 12px 40px rgba(238,129,34,.18),
    0 0 0 1px rgba(238,129,34,.15);
}
.tipo-card:hover::before { opacity: 1; }

.tipo-card:active {
  transform: translateY(-2px) scale(.97);
  transition-duration: .1s;
}

.card-icon {
  color: var(--muted);
  line-height: 0;
  transition: color .3s ease, transform .4s var(--ease-bounce);
}
.tipo-card:hover .card-icon {
  color: var(--accent);
  transform: scale(1.2) rotate(8deg);
}

.card-label {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

/* ══════════════════════════════════════
   CAMPO DE INPUT
   ══════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 6px; }

.field-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .14em;
  color: var(--muted);
}

.input-wrap { position: relative; }

input[type="text"] {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  padding: 13px 16px;
  outline: none;
  transition: border-color .2s ease, box-shadow .3s ease;
}
input[type="text"]:focus {
  border-color: var(--accent);
  animation: inputPulse 2s ease-in-out infinite;
}
input[type="text"]::placeholder { color: var(--muted); font-size: 12px; }
input[type="text"]:disabled { opacity: .4; cursor: not-allowed; }

@keyframes inputPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(238,129,34,.12); }
  50%       { box-shadow: 0 0 0 4px rgba(238,129,34,.22), 0 0 20px rgba(238,129,34,.08); }
}

.field-hint {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
}

/* ══════════════════════════════════════
   BOTÕES
   ══════════════════════════════════════ */
.btn-primary,
.btn-ghost {
  width: 100%;
  padding: 15px 24px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .09em;
  cursor: pointer;
  transition: all .25s var(--ease-spring);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  min-height: 50px;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: var(--accent);
  color: #000;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  box-shadow: 0 6px 28px var(--accent-glow), 0 2px 8px rgba(0,0,0,.3);
  transform: translateY(-2px);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(.98);
  box-shadow: 0 2px 8px var(--accent-glow);
  transition-duration: .1s;
}
.btn-primary:disabled {
  opacity: .35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.btn-primary.is-loading {
  cursor: wait;
  opacity: .85;
  transform: none;
  box-shadow: none;
}

/* Barra de progresso no loading */
.btn-primary.is-loading::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  width: 40%;
  background: rgba(0,0,0,.45);
  animation: loadBar 1.4s ease-in-out infinite;
}
@keyframes loadBar {
  0%   { transform: translateX(-100%); }
  60%  { transform: translateX(250%); }
  100% { transform: translateX(250%); }
}

/* Ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  width: 4px;
  height: 4px;
  background: rgba(0,0,0,.22);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple 600ms var(--ease-spring) forwards;
  pointer-events: none;
}
@keyframes ripple {
  to { transform: translate(-50%, -50%) scale(180); opacity: 0; }
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 16px rgba(238,129,34,.08);
}

/* ══════════════════════════════════════
   TELAS DE RESULTADO
   ══════════════════════════════════════ */
.result-icon {
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid;
  margin-bottom: 4px;
  flex-shrink: 0;
  position: relative;
}
/* pulso de atenção */
.result-icon--warn::after,
.result-icon--success::after {
  content: '';
  position: absolute;
  inset: -6px;
  border: 1px solid currentColor;
  opacity: 0;
  animation: iconPulse 2.4s ease-out infinite 0.5s;
}
@keyframes iconPulse {
  0%   { inset: -2px; opacity: .5; }
  100% { inset: -14px; opacity: 0; }
}

.result-icon--warn    { color: var(--warning); border-color: rgba(245,166,35,.3); background: rgba(245,166,35,.06); }
.result-icon--muted   { color: var(--muted);   border-color: var(--border);       background: var(--surface2); }
.result-icon--success { color: var(--success); border-color: rgba(68,204,136,.3); background: rgba(68,204,136,.06); }
.result-icon--danger  { color: var(--danger);  border-color: rgba(255,68,68,.3);  background: rgba(255,68,68,.06); }

/* ══════════════════════════════════════
   CHIP DE CONTEXTO
   ══════════════════════════════════════ */
.chip-contexto {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(68,204,136,.07);
  border: 1px solid rgba(68,204,136,.2);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--success);
  line-height: 1;
}
.chip-check {
  flex-shrink: 0;
  line-height: 0;
  margin-top: 1px;
}
.chip-texto {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chip-alterar {
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  width: auto;
  min-height: auto;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  transition: color .2s ease;
}
.chip-alterar:hover { color: var(--accent); }

/* ══════════════════════════════════════
   ALERTA / AVISO INLINE
   ══════════════════════════════════════ */
.alerta-aviso {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(245,166,35,.07);
  border: 1px solid rgba(245,166,35,.2);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--warning);
  line-height: 1.55;
}

/* ══════════════════════════════════════
   ERRO INLINE DE CAMPO
   ══════════════════════════════════════ */
.field-erro {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--danger);
  line-height: 1.55;
  margin-top: 2px;
}

/* Variante danger do alerta */
.alerta-aviso--danger {
  background: rgba(255,68,68,.07);
  border-color: rgba(255,68,68,.2);
  color: var(--danger);
}

/* ══════════════════════════════════════
   CARD DE NOTA (SUCESSO)
   ══════════════════════════════════════ */
.nota-card {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  text-align: left;
}
.nota-campo {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}
.nota-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  flex-shrink: 0;
}
.nota-valor {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}
.nota-valor--destaque {
  font-size: 15px;
  font-weight: 500;
  color: var(--success);
}
.nota-divider {
  height: 1px;
  background: var(--border);
  margin: 1px 0;
}

/* ══════════════════════════════════════
   CHECK ANIMADO (SUCESSO)
   ══════════════════════════════════════ */
.check-wrap {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  position: relative;
}
.check-svg { width: 100%; height: 100%; }
.check-path {
  stroke-dasharray: 46;
  stroke-dashoffset: 46;
}
.check-path.animate {
  animation: checkDraw 600ms cubic-bezier(0.22, 1, 0.36, 1) forwards 50ms;
}
@keyframes checkDraw {
  to { stroke-dashoffset: 0; }
}

/* ══════════════════════════════════════
   COUNTDOWN (BLOQUEIO)
   ══════════════════════════════════════ */
.countdown {
  display: block;
  font-family: var(--mono);
  font-size: 44px;
  font-weight: 500;
  color: var(--warning);
  letter-spacing: .06em;
  line-height: 1;
  margin: 14px 0 2px;
  text-shadow: 0 0 24px rgba(245,166,35,.2);
  animation: countdownPulse 1s ease-in-out infinite;
}
@keyframes countdownPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .7; }
}

/* ══════════════════════════════════════
   SKELETON (Fase 4)
   ══════════════════════════════════════ */
@keyframes sk-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes skFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface2) 25%, var(--border) 50%, var(--surface2) 75%);
  background-size: 200% 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
  height: 12px;
}
.skeleton-preview {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: skFadeIn 300ms var(--ease-spring) forwards;
}
.skeleton-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.skeleton-row .skeleton:first-child { opacity: .6; }

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 520px) {
  body { padding: 0; align-items: flex-start; }
  .wizard-wrap { max-width: 100%; }
  .step-header { padding: 14px 20px; }
  .step-body   { padding: 24px 20px 28px; gap: 20px; }
  .step-question { font-size: 20px; }
  .cards-grid  { grid-template-columns: 1fr; }
  .tipo-card {
    min-height: 80px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 16px;
    padding: 18px 16px;
  }
  .tipo-card:hover { transform: translateY(-3px); }
}

@media (max-width: 360px) {
  .step-body { padding: 20px 16px 24px; }
  .step-question { font-size: 18px; }
}
