/* ==========================================================================
   SAGASON METAL HD - SIMULADOR 4K DE ESCALA REAL & ACABADOS
   Design System: Sagason 4K (Glassmorphism + Realistic Wall Textures)
   ========================================================================== */

:root {
  --bg-main: #0a0e17;
  --bg-card: rgba(18, 26, 43, 0.78);
  --bg-card-hover: rgba(28, 40, 66, 0.88);
  --border-glass: rgba(255, 255, 255, 0.09);
  --border-glass-strong: rgba(255, 255, 255, 0.2);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --accent-primary: #6366f1;
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;

  --font-heading: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-brand: 'Bebas Neue', cursive, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(10, 14, 23, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-glass);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

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

.brand-icon {
  font-size: 26px;
  background: rgba(99, 102, 241, 0.2);
  border: 1px solid rgba(99, 102, 241, 0.4);
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.top-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
}

.btn-primary:hover {
  background: #4f46e5;
}

.btn-glass {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
}

.btn-glass:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 14px;
  font-size: 0.95rem;
}

/* Layout Principal */
.sim-container {
  max-width: 1300px;
  margin: 20px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 28px;
  align-items: start;
}

/* Sección del Muro / Escenario */
.stage-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stage-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
}

.pill-group {
  display: flex;
  gap: 6px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-glass);
}

.pill-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.76rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.pill-btn.active {
  background: var(--accent-primary);
  color: #fff;
  font-weight: 700;
}

.check-container {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Muro Interactivo (Escenario 3.5m ancho x 2.6m alto) */
.wall-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  min-height: 440px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-glass-strong);
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.4s ease;
}

/* Textura 1: Ladrillo Rústico de Quincho */
.wall-viewport.brick {
  background-color: #7c2d12;
  background-image: 
    linear-gradient(335deg, rgba(0,0,0,0.3) 0px, transparent 1px),
    linear-gradient(rgba(0,0,0,0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,0,0,0.2) 1px, transparent 1px),
    radial-gradient(circle at 50% 30%, rgba(255,255,255,0.06) 0%, transparent 60%);
  background-size: 60px 30px, 60px 30px, 60px 30px, 100% 100%;
}

/* Textura 2: Hormigón Visto Terraza */
.wall-viewport.concrete {
  background-color: #334155;
  background-image: 
    radial-gradient(circle at 20% 30%, rgba(255,255,255,0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(0,0,0,0.2) 0%, transparent 40%),
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 80px 80px;
}

/* Textura 3: Madera Nativa */
.wall-viewport.wood {
  background-color: #451a03;
  background-image: 
    repeating-linear-gradient(90deg, rgba(0,0,0,0.15) 0px, rgba(0,0,0,0.15) 2px, transparent 2px, transparent 70px),
    linear-gradient(to bottom, rgba(255,255,255,0.05), rgba(0,0,0,0.3));
}

/* Textura 4: Muro Minimal Blanco */
.wall-viewport.modern {
  background-color: #1e293b;
  background-image: radial-gradient(circle at 50% 40%, rgba(255,255,255,0.08) 0%, transparent 70%);
}

/* Modificadores de Iluminación */
.wall-viewport.daylight::after {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 60%);
  pointer-events: none;
}

.wall-viewport.warm::after {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle at 50% 15%, rgba(245, 158, 11, 0.3) 0%, transparent 70%);
  pointer-events: none;
}

.wall-viewport.neutral::after {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.25);
  pointer-events: none;
}

/* Métrica del Muro */
.wall-grid-metric {
  position: absolute;
  top: 14px;
  left: 18px;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 8px;
  border-radius: 4px;
  backdrop-filter: blur(4px);
  z-index: 5;
}

/* Mueble / Parrilla en el Suelo (90cm) */
.furniture-reference {
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 80%;
  height: 25%;
  background: linear-gradient(to top, #0f172a, #1e293b);
  border-top: 3px solid #475569;
  border-radius: 8px 8px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  z-index: 2;
}

.furniture-label {
  font-size: 0.74rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Silueta Humana Escala (1.75m) */
.human-silhouette {
  position: absolute;
  bottom: 0;
  right: 6%;
  width: 50px;
  height: 52%;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 3;
  opacity: 0.75;
  transition: opacity 0.3s;
}

.human-head {
  width: 16px;
  height: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  margin-bottom: 2px;
}

.human-body {
  width: 26px;
  height: calc(100% - 20px);
  background: rgba(255, 255, 255, 0.3);
  border-radius: 8px 8px 0 0;
}

.human-tag {
  position: absolute;
  top: -20px;
  font-size: 0.65rem;
  color: #fff;
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 6px;
  border-radius: 4px;
}

/* El Cuadro Metal HD Proporcional */
.metal-canvas-wrapper {
  position: absolute;
  top: 32%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.metal-print {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 
    0 18px 36px rgba(0, 0, 0, 0.65),
    0 4px 10px rgba(0, 0, 0, 0.4);
  background: #000;
  display: flex;
}

.metal-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.metal-beveled-edge {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.6), inset 0 0 0 3px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

/* Acabado Ultra-Gloss vs Matte */
.metal-sheen-overlay {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  transition: opacity 0.3s;
}

.metal-print.gloss .metal-sheen-overlay {
  background: linear-gradient(125deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0.05) 45%, transparent 60%);
  opacity: 1;
}

.metal-print.matte .metal-sheen-overlay {
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(0.5px);
  opacity: 0.7;
}

.metal-size-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.75);
  color: #38bdf8;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
  backdrop-filter: blur(4px);
}

/* Panel de Controles Lateral */
.controls-section {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.control-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 20px;
}

.card-heading {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.card-caption {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.size-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.size-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: all 0.2s;
}

.size-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.size-btn.active {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.12);
}

.size-btn strong {
  font-size: 0.9rem;
  color: #fff;
}

.size-btn span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Finish Selector */
.finish-selector {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.finish-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: all 0.2s;
}

.finish-option input {
  margin-top: 4px;
}

.finish-option.active {
  border-color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.08);
}

.finish-option strong {
  display: block;
  font-size: 0.88rem;
  color: #fff;
}

.finish-option span {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Presets & Uploader */
.presets-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.upload-box {
  position: relative;
}

.file-input {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.file-label {
  display: block;
  text-align: center;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-glass-strong);
  border-radius: var(--radius-sm);
  color: var(--accent-cyan);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.file-label:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--accent-cyan);
}

/* Card Cotización */
.quote-summary-card {
  background: linear-gradient(135deg, rgba(18, 26, 43, 0.95) 0%, rgba(10, 14, 23, 0.95) 100%);
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-md);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.quote-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 12px;
}

.quote-eyebrow {
  font-size: 0.7rem;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 700;
}

.quote-price {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-emerald);
}

.badge-tag {
  font-size: 0.72rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 4px 8px;
  border-radius: 4px;
}

.specs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: rgba(0, 0, 0, 0.2);
  padding: 12px;
  border-radius: var(--radius-sm);
}

.spec-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.spec-label {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.spec-val {
  font-size: 0.82rem;
  color: #fff;
}

.specs-guarantee {
  font-size: 0.78rem;
  color: #cbd5e1;
  background: rgba(16, 185, 129, 0.08);
  border-left: 3px solid var(--accent-emerald);
  padding: 10px 12px;
  border-radius: 4px;
  line-height: 1.4;
}

/* Footer */
.footer-app {
  text-align: center;
  padding: 30px 20px 40px 20px;
  border-top: 1px solid var(--border-glass);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 40px;
}

/* ==========================================================================
   MODO CÁMARA AR EN VIVO & MODALES
   ========================================================================== */
.btn-ar-launch {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
  animation: pulseArBtn 2s infinite alternate;
}

@keyframes pulseArBtn {
  from { box-shadow: 0 0 10px rgba(16, 185, 129, 0.3); }
  to { box-shadow: 0 0 20px rgba(16, 185, 129, 0.7); }
}

.ar-control-bar {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(16, 185, 129, 0.4);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(12px);
}

.ar-ctrl-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ar-ctrl-label {
  font-size: 0.8rem;
  color: #e2e8f0;
}

.ar-slider {
  accent-color: var(--accent-emerald);
  cursor: pointer;
}

.ar-ctrl-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-ar-action {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-glass-strong);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transition: all 0.2s;
}

.btn-ar-action.primary {
  background: var(--accent-emerald);
  border-color: var(--accent-emerald);
}

.btn-ar-action.danger {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
  color: #fca5a5;
}

/* Feed de Video Cámara AR */
.ar-video-feed {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 1;
}

.wall-viewport.ar-active {
  background: #000 !important;
}

.wall-viewport.ar-active .ar-video-feed {
  display: block;
}

.wall-viewport.ar-active::after {
  display: none;
}

.wall-viewport.ar-active .furniture-reference,
.wall-viewport.ar-active .human-silhouette,
.wall-viewport.ar-active .wall-grid-metric {
  display: none;
}

.wall-viewport.ar-active .metal-canvas-wrapper {
  cursor: grab;
  touch-action: none;
}

.wall-viewport.ar-active .metal-canvas-wrapper:active {
  cursor: grabbing;
}

.ar-drag-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #a7f3d0;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  z-index: 20;
  pointer-events: none;
  backdrop-filter: blur(8px);
  animation: pulseHint 2s infinite alternate;
}

@keyframes pulseHint {
  from { opacity: 0.8; }
  to { opacity: 1; transform: translateX(-50%) translateY(-2px); }
}

/* Modales */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: #0f172a;
  border: 1px solid var(--border-glass-strong);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  padding: 26px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
  animation: modalScale 0.3s ease;
}

@keyframes modalScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 960px) {
  .sim-container {
    grid-template-columns: 1fr;
  }

  .wall-viewport {
    aspect-ratio: 16 / 11;
  }
}

@media (max-width: 600px) {
  .stage-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .size-buttons-grid {
    grid-template-columns: 1fr;
  }

  .top-nav {
    padding: 12px 16px;
    flex-direction: column;
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }
}