/* ═══════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════ */
:root {
  --bg:          #080808;
  --surface:     rgba(255, 255, 255, 0.05);
  --surface-md:  rgba(255, 255, 255, 0.09);
  --border:      rgba(255, 255, 255, 0.10);
  --border-hi:   rgba(255, 255, 255, 0.22);

  --gold:        #f0c040;
  --gold-glow:   rgba(240, 192, 64, 0.35);
  --gold-dim:    rgba(240, 192, 64, 0.18);

  --text:        #ffffff;
  --text-dim:    rgba(255, 255, 255, 0.50);
  --text-muted:  rgba(255, 255, 255, 0.28);

  --green:       #4ade80;
  --blue:        #60a5fa;
  --orange:      #fb923c;

  --radius-sm:   8px;
  --radius-md:   16px;
  --radius-lg:   28px;
  --radius-pill: 100px;

  --blur-glass:  blur(20px) saturate(1.4);
  --transition:  0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Compensacion TV + camara rotadas 90° CCW fisicamente ──
   Rotamos el contenido 90° CW en software.
   El wrapper ocupa 100vh × 100vw (ancho/alto intercambiados)
   y se centra en el viewport antes de rotar. ── */
#app-root {
  position: fixed;
  width: 100vh;   /* dimension corta del viewport */
  height: 100vw;  /* dimension larga del viewport  */
  left: calc((100vw - 100vh) / 2);
  top:  calc((100vh - 100vw) / 2);
  transform: rotate(90deg);
  transform-origin: center;
  overflow: hidden;
  background: var(--bg);
}

button { cursor: pointer; border: none; outline: none; background: none; color: inherit; font: inherit; }
a { text-decoration: none; color: inherit; }
svg { display: block; flex-shrink: 0; }

/* ═══════════════════════════════════════════════
   SCREEN SYSTEM
═══════════════════════════════════════════════ */
.screen {
  position: absolute; inset: 0;   /* absolute dentro de #app-root */
  display: flex; flex-direction: column;
  opacity: 1;
  pointer-events: auto;
  transition: opacity var(--transition);
  will-change: opacity;
}
.screen.hidden {
  opacity: 0;
  pointer-events: none;
}
.screen.active { z-index: 1; }


/* ═══════════════════════════════════════════════
   CAMARA
═══════════════════════════════════════════════ */
#screen-camera { background: #000; }

#camera-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  transform: scaleX(-1); /* mirror effect */
}

/* gradiente inferior para legibilidad de controles */
.camera-ui {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: linear-gradient(
    to bottom,
    rgba(0,0,0,0.55) 0%,
    transparent 18%,
    transparent 55%,
    rgba(0,0,0,0.70) 80%,
    rgba(0,0,0,0.92) 100%
  );
}

/* ---- top bar ---- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 36px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--gold);
  text-shadow: 0 0 24px var(--gold-glow);
}

.brand-logo {
  height: 36px;
  width: auto;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}

.active-style-badge {
  padding: 6px 18px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--gold);
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---- bottom controls ---- */
.bottom-controls {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 0 0 36px;
}

/* ---- style track ---- */
.style-nav {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 6px;
  padding: 0 16px;
}

.style-nav-btn {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--surface-md);
  border: 1.5px solid var(--border);
  color: var(--gold);
  font-size: 1.6rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease;
  padding-bottom: 2px;
}
.style-nav-btn:hover {
  background: var(--gold-dim);
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--gold-glow);
}

.style-track-wrapper {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 0;
}
.style-track-wrapper::-webkit-scrollbar { display: none; }

.style-track {
  display: flex;
  gap: 10px;
  width: max-content;
}

.style-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 22px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--border);
  background: var(--surface);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  color: var(--text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.style-chip .chip-icon { font-size: 1rem; }
.style-chip:hover {
  border-color: var(--border-hi);
  color: var(--text);
  background: var(--surface-md);
}
.style-chip.selected {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--gold);
  box-shadow: 0 0 18px var(--gold-glow);
}

/* ---- capture area ---- */
.capture-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hint-text {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---- capture button ---- */
.capture-btn {
  position: relative;
  width: 92px; height: 92px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.15s ease;
}
.capture-btn:active { transform: scale(0.93); }

.capture-ring {
  position: absolute; inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(240, 192, 64, 0.4);
  animation: pulse-ring 2.4s ease-out infinite;
}
@keyframes pulse-ring {
  0%   { transform: scale(1);    opacity: 0.7; }
  70%  { transform: scale(1.28); opacity: 0;   }
  100% { transform: scale(1.28); opacity: 0;   }
}

.capture-core {
  display: block;
  width: 76px; height: 76px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff9e0, var(--gold) 60%, #c8920a);
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.18),
    0 0 32px var(--gold-glow),
    0 6px 24px rgba(0,0,0,0.5);
  transition: box-shadow 0.2s ease;
}
.capture-btn:hover .capture-core {
  box-shadow:
    0 0 0 3px rgba(255,255,255,0.3),
    0 0 48px rgba(240, 192, 64, 0.6),
    0 6px 24px rgba(0,0,0,0.5);
}

/* ---- countdown overlay ---- */
.countdown-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.countdown-overlay.hidden { display: none; }

.countdown-number {
  font-size: clamp(160px, 20vw, 280px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 80px var(--gold-glow), 0 0 160px var(--gold-glow);
  line-height: 1;
  animation: count-pop 0.4s cubic-bezier(0.22, 0.9, 0.36, 1.2) both;
  will-change: transform, opacity;
}
@keyframes count-pop {
  from { transform: scale(1.5); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* ---- shutter flash ---- */
.shutter-flash {
  position: absolute; inset: 0; z-index: 20;
  background: #fff;
  pointer-events: none;
}
.shutter-flash.hidden { display: none; }
.shutter-flash.firing {
  animation: flash 0.4s ease-out forwards;
}
@keyframes flash {
  0%   { opacity: 0.9; }
  100% { opacity: 0; }
}


/* ═══════════════════════════════════════════════
   PROCESANDO
═══════════════════════════════════════════════ */
#screen-processing {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.processing-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 30% 40%, rgba(240,192,64,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 75% 65%, rgba(96,165,250,0.05) 0%, transparent 70%);
  animation: bg-shift 6s ease-in-out infinite alternate;
}
@keyframes bg-shift {
  from { opacity: 0.6; }
  to   { opacity: 1;   }
}

.processing-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column;
  align-items: center; gap: 28px;
}

/* SVG spinner */
.spinner-ring {
  width: 100px; height: 100px;
}
.spinner-ring svg {
  width: 100%; height: 100%;
  transform: rotate(-90deg);
}
.spinner-track {
  fill: none;
  stroke: rgba(255,255,255,0.06);
  stroke-width: 5;
}
.spinner-arc {
  fill: none;
  stroke: url(#spinGrad);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 214;
  stroke-dashoffset: 54;
  animation: spin-arc 1.2s linear infinite;
  filter: drop-shadow(0 0 8px var(--gold));
}
@keyframes spin-arc {
  to { transform: rotate(360deg); transform-origin: center; transform-box: fill-box; }
}

/* gradient para el arco del spinner */
.spinner-ring svg defs { display: none; }

/* fallback: simpler stroke color */
.spinner-arc { stroke: var(--gold); }

.processing-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}
.processing-style {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.dot-row {
  display: flex; gap: 10px;
}
.dot-row span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: dot-pulse 1.4s ease-in-out infinite both;
}
.dot-row span:nth-child(2) { animation-delay: 0.2s; }
.dot-row span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-pulse {
  0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; }
  40%           { transform: scale(1.2); opacity: 1;   }
}


/* ═══════════════════════════════════════════════
   RESULTADO
═══════════════════════════════════════════════ */
/* ── RESULTADO: layout portrait (columna) ── */
#screen-result {
  background: #050505;
  flex-direction: column;
}

.result-image {
  flex: 1;
  min-height: 0;
  width: 100%;
  object-fit: contain;
  object-position: center top;
  padding: 16px 16px 0;
  animation: reveal-image 0.6s cubic-bezier(0.22, 0.9, 0.36, 1) both;
}
@keyframes reveal-image {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.result-panel {
  width: 100%;
  flex-shrink: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  padding: 14px 20px 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.005) 100%);
  border-top: 1px solid var(--border);
}

.qr-block {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  flex-shrink: 0;
}
.qr-img {
  width: 110px; height: 110px;
  border-radius: var(--radius-md);
  border: 2px solid rgba(255,255,255,0.1);
  background: #fff;
  box-shadow: 0 0 24px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.qr-img:hover {
  transform: scale(1.06);
  box-shadow: 0 0 32px var(--gold-glow);
}
.qr-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
  letter-spacing: 0.03em;
}

/* ── QR Modal ── */
.qr-modal {
  position: absolute; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 20px;
  cursor: pointer;
}
.qr-modal.hidden { display: none; }

.qr-modal img {
  width: min(68vw, 68vh);
  height: min(68vw, 68vh);
  border-radius: var(--radius-lg);
  background: #fff;
  border: 3px solid var(--gold);
  box-shadow: 0 0 60px var(--gold-glow), 0 0 120px rgba(240,192,64,0.15);
  animation: qr-pop 0.25s cubic-bezier(0.22, 0.9, 0.36, 1.2) both;
}
@keyframes qr-pop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.qr-modal-label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.04em;
}
.qr-modal-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.result-actions {
  display: flex; flex-direction: column;
  align-items: stretch;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.result-brand-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.result-brand-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
  border-radius: 4px;
  flex-shrink: 0;
}
.result-brand-web {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.04em;
}

.result-style-name {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  text-align: center;
  margin-bottom: 2px;
}

/* ═══════════════════════════════════════════════
   BOTONES GENERICOS
═══════════════════════════════════════════════ */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 20px;
  border-radius: var(--radius-lg);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}
.btn svg { width: 18px; height: 18px; }

.btn-download {
  background: var(--gold);
  color: #0a0a0a;
}
.btn-download:hover {
  background: #f7d060;
  box-shadow: 0 0 24px var(--gold-glow);
  transform: translateY(-1px);
}

.btn-print {
  background: var(--surface-md);
  color: var(--text);
  border: 1.5px solid var(--border-hi);
}
.btn-print:hover {
  background: rgba(251, 146, 60, 0.15);
  border-color: var(--orange);
  color: var(--orange);
  transform: translateY(-1px);
}

.btn-new {
  background: var(--surface);
  color: var(--text-dim);
  border: 1.5px solid var(--border);
}
.btn-new:hover {
  background: rgba(96,165,250,0.12);
  border-color: var(--blue);
  color: var(--blue);
  transform: translateY(-1px);
}


/* ═══════════════════════════════════════════════
   ERROR
═══════════════════════════════════════════════ */
#screen-error {
  align-items: center;
  justify-content: center;
}
.error-content {
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
  text-align: center; max-width: 420px;
  padding: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.error-icon { font-size: 3.5rem; }
.error-content h2 { font-size: 1.4rem; font-weight: 700; }
.error-content p  { font-size: 0.9rem; color: var(--text-dim); line-height: 1.6; }


/* ═══════════════════════════════════════════════
   AJUSTES / SETTINGS PANEL
═══════════════════════════════════════════════ */

.settings-gear {
  position: absolute;
  top: 18px; right: 18px;
  z-index: 150;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface-md);
  border: 1.5px solid var(--border);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
  font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  color: var(--text-dim);
}
.settings-gear:hover {
  background: var(--surface);
  border-color: var(--border-hi);
  color: var(--text);
}

.settings-panel {
  position: absolute; inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: none;
  display: flex; flex-direction: column;
  overflow-y: auto;
}
.settings-panel.hidden { display: none; }

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 28px 20px;
  border-bottom: 1px solid var(--border-hi);
  flex-shrink: 0;
  background: rgba(0, 0, 0, 0.70);
}
.settings-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}
.settings-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--surface-md);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.settings-close:hover { background: var(--surface); color: var(--text); }

.settings-body {
  display: flex; flex-direction: column;
  flex: 1;
}
.settings-section {
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.60);
}
.settings-section:last-child { border-bottom: none; }

.settings-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.settings-row {
  display: flex;
  gap: 10px;
}
.rot-btn {
  flex: 1;
  padding: 11px 6px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.2s;
}
.rot-btn:hover {
  border-color: var(--border-hi);
  color: var(--text);
  background: var(--surface-md);
}
.rot-btn.active {
  border-color: var(--gold);
  background: var(--gold-dim);
  color: var(--gold);
  box-shadow: 0 0 14px var(--gold-glow);
}


/* ── Watermark settings ── */
.watermark-settings {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wm-logo-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.wm-logo-preview {
  height: 48px;
  width: auto;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  object-fit: contain;
}
.btn-upload-label {
  padding: 9px 16px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-upload-label:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: var(--gold-dim);
}

.wm-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wm-field-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.wm-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.wm-input::placeholder { color: var(--text-muted); }
.wm-input:focus { border-color: var(--gold); }


/* ═══════════════════════════════════════════════
   PRINT MEDIA
═══════════════════════════════════════════════ */
@media print {
  body * { display: none !important; }
}
