/* ============================================================
   TIENDARTE — simulador.css  (simulador.html)

   ÍNDICE
    1. Base
    2. Navbar
    3. Layout general (panel de diseño + escena 3D)
    4. Panel de diseño (pestañas, lienzo, controles)
    5. Escena 3D (canvas, carga, acciones)
    6. Responsive
   ============================================================ */

/* ── 1. BASE ──────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%; overflow-x: hidden; /* el scroll vertical se permite para poder bajar al mug en pantallas pequeñas o con zoom */
  font-family: 'DM Sans', sans-serif;
  background: #111; color: #fff;
}
[hidden] { display: none !important; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid #3dd6d0; outline-offset: 2px; }


/* ── 2. NAVBAR ────────────────────────────── */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: 56px; padding: 0 5%;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(17,17,17,.97);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.nav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.nav-logo img { height: 36px; }
.nav-logo span { color: #fff; font-size: 15px; font-weight: 600; }
.nav-back {
  display: flex; align-items: center; gap: 6px;
  color: rgba(255,255,255,.5); font-size: 13px; text-decoration: none;
  transition: color .2s;
}
.nav-back:hover { color: #3dd6d0; }


/* ── 3. LAYOUT GENERAL ────────────────────── */
#app { display: flex; height: calc(100vh - 56px); min-height: 520px; margin-top: 56px; }

#design-panel {
  flex: 0 0 420px; width: 420px;
  display: flex; flex-direction: column; overflow: hidden;
  background: #1a1a1a; border-right: 1px solid rgba(255,255,255,.06);
}
#three-panel {
  position: relative; flex: 1 1 auto;
  background: radial-gradient(ellipse at center, #1a1a2e 0%, #0d0d1a 100%);
}


/* ── 4. PANEL DE DISEÑO ───────────────────── */
#design-toolbar {
  flex: 0 0 auto; padding: 10px 14px;
  display: flex; align-items: center; gap: 7px;
  background: #161616; border-bottom: 1px solid rgba(255,255,255,.06);
}
.toolbar-title {
  margin-right: auto;
  font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.4);
}

#design-tabs { display: flex; flex: 0 0 auto; background: #111; border-bottom: 1px solid rgba(255,255,255,.06); }
.dtab {
  flex: 1; padding: 10px;
  background: none; border: none; border-bottom: 2px solid transparent;
  font-size: 12px; font-weight: 500; text-align: center;
  color: rgba(255,255,255,.35); cursor: pointer;
  transition: all .2s;
}
.dtab.active { color: #3dd6d0; border-bottom-color: #3dd6d0; }

/* Fondo de cuadritos para que se note la zona de impresión */
#design-stage {
  position: relative; flex: 1 1 auto; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  background:
    linear-gradient(45deg, #252525 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #252525 25%, transparent 25%) 0 8px / 16px 16px,
    linear-gradient(45deg, transparent 75%, #252525 75%) 8px -8px / 16px 16px,
    linear-gradient(-45deg, transparent 75%, #252525 75%) -8px 0 / 16px 16px,
    #1e1e1e;
}
#design-stage .canvas-container { position: absolute !important; } /* contenedor que crea Fabric.js */

/* Borde punteado de la zona de impresión.
   Es un <div> ENCIMA del lienzo (no un objeto de Fabric) para que NO se pinte en la textura del mug. */
#print-border {
  position: absolute; pointer-events: none;
  border: 1px dashed rgba(61,214,208,.7);
}

#design-controls {
  flex: 0 0 auto; padding: 14px;
  background: #161616; border-top: 1px solid rgba(255,255,255,.06);
}
.ctrl-section-title {
  margin-bottom: 8px;
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: rgba(255,255,255,.35);
}

.upload-btn {
  position: relative; display: block;
  width: 100%; padding: 10px;
  background: #b5d832; color: #111;
  border-radius: 10px;
  font-size: 13px; font-weight: 700; text-align: center;
  cursor: pointer; transition: background .2s;
}
.upload-btn:hover { background: #c8f020; }
.upload-btn input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

.color-grid { display: flex; gap: 7px; flex-wrap: wrap; }
.color-btn,
.fondo-btn {
  width: 28px; height: 28px; padding: 0;
  border: 2px solid transparent;
  cursor: pointer; transition: all .2s;
}
.color-btn { border-radius: 50%; }
.fondo-btn { border-radius: 6px; border-color: rgba(255,255,255,.18); } /* borde suave para que se vean los fondos oscuros */
.color-btn.active,
.fondo-btn.active { border-color: #fff; transform: scale(1.15); }


/* ── 5. ESCENA 3D ─────────────────────────── */
#canvas3d {
  position: absolute; inset: 0; display: block;
  width: 100%; height: 100%;
  cursor: grab; touch-action: none; /* touch-action: evita que el dedo haga scroll en vez de rotar */
}
#canvas3d:active { cursor: grabbing; }

.canvas-hint {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  padding: 7px 16px; border-radius: 100px;
  background: rgba(255,255,255,.07); pointer-events: none; white-space: nowrap;
  font-size: 11px; color: rgba(255,255,255,.3);
}

.loading-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  padding: 24px; text-align: center;
  background: #0d0d1a;
  transition: opacity .6s;
}
.loading-overlay.hidden { opacity: 0; pointer-events: none; }
.loading-texto { font-size: 13px; color: rgba(255,255,255,.4); max-width: 320px; line-height: 1.5; }
.loading-overlay.error .loading-texto { color: #ff8a8a; }
.loading-overlay.error .spinner { display: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,.08); border-top-color: #b5d832; border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#bottom-actions {
  position: absolute; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 10px;
}

.zoom-bar-wrap {
  min-width: 200px; padding: 10px 16px; border-radius: 100px;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.1);
}
.zoom-bar-label { font-size: 11px; color: rgba(255,255,255,.5); white-space: nowrap; }
.zoom-bar-icon {
  padding: 0 2px; background: none; border: none;
  font-size: 15px; color: rgba(255,255,255,.4); cursor: pointer;
  user-select: none; transition: color .2s;
}
.zoom-bar-icon:hover { color: #b5d832; }
#zoom-slider {
  flex: 1; height: 3px;
  -webkit-appearance: none; appearance: none;
  background: rgba(255,255,255,.15); border-radius: 100px; outline: none; cursor: pointer;
}
#zoom-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%;
  background: #b5d832; cursor: pointer; transition: transform .2s;
}
#zoom-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
#zoom-slider::-moz-range-thumb { width: 14px; height: 14px; border: none; border-radius: 50%; background: #b5d832; cursor: pointer; }

.btn-cap {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 100px;
  background: rgba(255,255,255,.08); color: rgba(255,255,255,.7);
  border: 1px solid rgba(255,255,255,.1);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all .2s;
}
.btn-cap:hover { background: rgba(255,255,255,.14); color: #fff; }

.btn-wa {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 100px;
  background: #25d366; color: #fff;
  font-size: 14px; font-weight: 700; text-decoration: none;
  box-shadow: 0 4px 20px rgba(37,211,102,.3);
  transition: all .2s;
}
.btn-wa:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(37,211,102,.4); }


/* ── 6. RESPONSIVE ────────────────────────── */
@media (max-width: 768px) {
  /* Panel de diseño arriba y mug 3D debajo: la página hace scroll para llegar al mug */
  #app { flex-direction: column; height: auto; min-height: 0; }
  #design-panel { flex: 0 0 auto; width: 100%; height: 52vh; min-height: 340px; border-right: none; }
  #three-panel { flex: 0 0 auto; height: 75vh; min-height: 420px; }
  #canvas3d { touch-action: pan-y; } /* deslizar vertical = scroll de página; horizontal = rotar el mug */
  #design-controls { padding: 10px 12px; }
  #design-toolbar { display: none; } /* solo tenía el título, en móvil ocupa espacio sin aportar */
  .upload-btn { padding: 12px; font-size: 14px; }
  #bottom-actions { bottom: 12px; right: 12px; gap: 8px; }
  .btn-wa { padding: 10px 16px; font-size: 13px; }
  .btn-cap { padding: 8px 12px; font-size: 11px; }
  .canvas-hint { bottom: 10px; padding: 5px 12px; font-size: 10px; }
}

@media (max-width: 480px) {
  #design-panel { height: 55vh; }
  #three-panel { height: 70vh; }
  .dtab { padding: 8px 4px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition: none !important; }
}
