/* ===========================
   🎨 VARIABLES Y RESET
   Los colores están en tema.css (se carga antes que este archivo).
=========================== */
:root {
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===========================
   TOPBAR
=========================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

.brand-link { display: flex; align-items: center; }

.brand-logo {
  height: 100px;
  width: auto;
  display: block;
  border-radius: 0;
  object-fit: contain;
}

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

.brand-icon {
  font-size: 22px;
}

.brand-name {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ===========================
   BOTONES
=========================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  text-decoration: none;           /* los botones que son enlaces (<a class="btn">) no se subrayan */
  transition: background 0.15s, transform 0.1s, opacity 0.15s;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
  background: var(--secondary);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--secondary-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ===========================
   WORKSPACE
=========================== */
.workspace {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ===========================
   SIDEBAR
=========================== */
.sidebar {
  width: clamp(180px, 16vw, 220px);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 12px 0;
  min-height: 0;
}

.sidebar-section {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section:last-child {
  border-bottom: none;
}

.sidebar-bottom {
  margin-top: auto;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.sidebar-hint {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 6px;
  font-style: italic;
}

/* ───── SHAPES GRID ───── */
.shapes-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.shape-btn,
.mask-btn {
  aspect-ratio: 1;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1;
}

.shape-btn:hover,
.mask-btn:hover {
  background: var(--secondary-hover);
  border-color: var(--primary);
  color: var(--primary);
}

.mask-btn.active {
  background: rgba(var(--primary-rgb), 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

/* ───── SHADOW TOGGLE ───── */
.shadow-toggle-row {
  margin-bottom: 8px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.toggle-label input[type="checkbox"] {
  display: none;
}

.toggle-track {
  width: 32px;
  height: 18px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-thumb {
  width: 12px;
  height: 12px;
  background: var(--text-muted);
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.2s, background 0.2s;
}

.toggle-label input:checked + .toggle-track {
  background: var(--primary);
}

.toggle-label input:checked + .toggle-track .toggle-thumb {
  transform: translateX(14px);
  background: #fff;
}

.shadow-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: opacity 0.2s;
}

.shadow-controls.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Tool buttons en sidebar */
.tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  margin-bottom: 6px;
  transition: background 0.15s, border-color 0.15s;
}

.tool-btn:hover {
  background: var(--secondary-hover);
  border-color: var(--primary);
}

.tool-btn:last-child { margin-bottom: 0; }

.tool-icon {
  width: 22px;
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
/* Iconos de línea (mismo trazo en todas las herramientas; toman el color de acento) */
.tool-icon svg { width: 17px; height: 17px; display: block; }
.mobile-cat-btn .tool-icon svg { width: 20px; height: 20px; }

/* Tipografía */
.control-input {
  width: 100%;
  padding: 7px 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 12px;
  margin-bottom: 8px;
  appearance: none;
  cursor: pointer;
}

.control-input:focus {
  outline: none;
  border-color: var(--primary);
}

.style-row {
  display: flex;
  gap: 6px;
}

.style-btn {
  flex: 1;
  padding: 7px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: serif;
}

.style-btn:hover {
  background: var(--secondary-hover);
  border-color: var(--primary);
}

.style-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

/* Color */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

#colorPicker,
#mugColorPicker {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.color-hex {
  font-size: 12px;
  font-family: monospace;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Capas */
.layers-list {
  list-style: none;
  max-height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layers-list li {
  padding: 7px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--text-muted);
  cursor: grab;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s, color 0.15s;
  user-select: none;
}

.layers-list li::before {
  content: "≡";
  color: var(--text-dim);
  font-size: 14px;
}

.layers-list li:hover {
  border-color: var(--primary);
  color: var(--text);
}

.layers-list li.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.1);
}

.layers-list li:active { cursor: grabbing; }

.layers-list li.dragging {
  opacity: 0.4;
  border-style: dashed;
}

/* ===========================
   CANVAS AREA
=========================== */
.canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: clamp(10px, 2vh, 20px);
  background: #0a0a0e;
  min-width: 0;
  min-height: 0;
}

.canvas-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 14px;
}

.canvas-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.canvas-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* Wrapper del canvas (para overlay) */
.canvas-wrapper {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px var(--border);
  width: min(1100px, 100%, calc((100vh - 160px) * 1.5));
  aspect-ratio: 3 / 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Canvas Fabric */
#canvas2d {
  display: block;
  max-width: 100%;
}

/* Zona de impresión overlay */
.print-zone {
  position: absolute;
  border: 2px dashed var(--print-zone-border);
  background: var(--print-zone);
  border-radius: 4px;
  pointer-events: none;
  transition: opacity 0.25s, border-radius 0.3s;
}

.print-zone.forma-circle {
  border-radius: 50%;
}

.print-zone.zona-transitioning {
  opacity: 0;
}

.print-zone::before {
  content: "Zona de impresión";
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

/* ===========================
   PANEL 3D
=========================== */
.panel-3d {
  width: clamp(260px, 22vw, 420px);
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(8px, 1.5vh, 16px);
  gap: clamp(6px, 1vh, 10px);
  overflow-y: auto;
  min-height: 0;
}

.panel-3d-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
#threeContainer {
  width: min(480px, 42vh, 100%);
  aspect-ratio: 1 / 1;
  height: auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
  background: #111118;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

#threeContainer canvas {
  display: block;
  border: none !important;
  border-radius: 0 !important;
}

.loading-msg {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
  background: #111118;
  z-index: 2;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.auto-rotate-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* ===========================
   CALIBRACIÓN DE TEXTURA
=========================== */
.calibration-panel {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.calib-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.calib-reset {
  font-size: 11px;
  padding: 3px 8px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.calib-reset:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.calib-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.calib-row label {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

.calib-row label span {
  color: var(--primary);
  font-family: monospace;
  font-size: 11px;
}

.calib-row input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  height: 4px;
  padding: 0;
  background: transparent;
}

.calib-hint {
  font-size: 10px;
  color: var(--success);
  text-align: center;
  min-height: 14px;
  transition: opacity 0.3s;
}

.calib-mode-row {
  display: flex;
  gap: 6px;
  margin-bottom: 2px;
}

.calib-mode-btn {
  flex: 1;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.calib-mode-btn:hover {
  border-color: var(--primary);
  color: var(--text);
}

.calib-mode-btn.active {
  background: rgba(var(--primary-rgb), 0.15);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.calib-mode-hint {
  font-size: 10px;
  color: var(--text-dim);
  margin-bottom: 4px;
  text-align: center;
  font-style: italic;
}

/* ===========================
   TOAST
=========================== */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-2);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Fila móvil: Ver 3D + selector de zonas — oculta en escritorio */
.mobile-zone-row {
  display: none;
}

.mobile-view3d-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--secondary);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.mobile-view3d-btn:active { transform: scale(0.97); }

/* Barra inferior móvil — oculta en escritorio */
.mobile-toolbar {
  display: none;
}

.mobile-popup-backdrop {
  display: none;
}

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 1100px) {
  .panel-3d {
    width: clamp(240px, 28vw, 340px);
  }
}

/* ===========================
   MOBILE (≤768px)
=========================== */
@media (max-width: 768px) {

  /* Topbar: solo iconos, sin texto */
  .topbar {
    padding: 0 10px;
    height: 48px;
  }
  .brand-logo { height: 60px; }
  .topbar-actions { gap: 4px; }
  .btn { padding: 8px; }
  .btn-text { display: none; }

  /* El panel 3D fijo y el sidebar vertical de escritorio se ocultan */
    /* El panel 3D fijo se oculta por completo (no tiene hijos que necesiten "escapar") */
    /* El panel 3D ya no se oculta: se muestra arriba del todo, antes que el resto */
  .panel-3d {
    display: flex;
    order: -1;
    width: 100%;
    border-left: none;
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    align-items: center;
    padding: 8px;
    gap: 4px;
    flex-shrink: 0;
  }

  /* Ocultar el texto/controles extra del panel 3D en mobile — solo queremos el cuadro */
  .panel-3d-header,
  #btnExpand3D,
  .auto-rotate-hint,
  .toggle-label {
    display: none;
  }

  #threeContainer {
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 30vh;
  }

  /* El sidebar NO puede llevar display:none: sus .sidebar-section son
     position:fixed y necesitan que el padre siga "presente" en el DOM
     para poder mostrarse como popup. Lo sacamos del layout de otra forma. */
  .sidebar {
    position: absolute;
    width: 0;
    height: 0;
    padding: 0;
    border: none;
    overflow: visible;
  }

  .workspace {
    flex-direction: column;
    overflow: hidden;
    padding-bottom: 64px; /* alto de .mobile-toolbar, para no quedar tapado por ella */
  }

  /* Fila móvil: Ver 3D + selector de zonas */
  .mobile-zone-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  .canvas-header { display: none; }

   .canvas-area {
    flex: 1;
    flex-direction: column;
    justify-content: flex-start;
    padding: 8px;
    gap: 8px;
    min-height: 0;
  }

  .mobile-zone-row {
    flex-shrink: 0;
  }

  .canvas-wrapper {
    width: 100%;
    max-width: 100%;
    aspect-ratio: auto;
    flex: 1;
    min-height: 0;
  }

  /* Barra inferior móvil (categorías de herramientas) */
  .mobile-toolbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 500;
  }

  .mobile-cat-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 10px;
    cursor: pointer;
  }
  .mobile-cat-btn .tool-icon { font-size: 18px; }
  .mobile-cat-btn.active { color: var(--primary); }

  .mobile-popup-backdrop.open {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 400;
  }

  /* Cada sección del sidebar se convierte en un popup flotante sobre la barra inferior */
  .sidebar-section {
    display: none;
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 72px;
    max-height: 50vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px;
    box-shadow: var(--shadow);
    z-index: 500;
  }
  .sidebar-section.mobile-open {
    display: block;
  }

  /* Modal 3D más grande en mobile, ya que es la única forma de ver el 3D */
  .modal-box { width: 92vw; height: 70vh; }
  #threeContainerModal { width: 100%; height: 100%; }
}

/* Scrollbar oscuro */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }


.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

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

.modal-box {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 0 60px rgba(0,0,0,0.8);
  width: 80vw;
  height: 80vh;
}

#threeContainerModal {
  width: 100%;
  height: 100%;
}

#threeContainerModal canvas {
  width: 100% !important;
  height: 100% !important;
  border: none !important;
  border-radius: 0 !important;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  background: rgba(0,0,0,0.6);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s;
}

.modal-close:hover {
  background: var(--danger);
}

/* ===========================
   BARRA CONTEXTUAL FLOTANTE
=========================== */
.context-bar {
  position: fixed;
  top: 66px; /* debajo del topbar */
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  padding: 6px 10px;
  flex-wrap: nowrap;
  max-width: calc(100vw - 40px);
  overflow-x: auto;
  transition: opacity 0.18s, transform 0.18s;
}

.context-bar.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(-8px);
}

.ctx-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.ctx-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Selector de fuente */
.ctx-select {
  height: 30px;
  padding: 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  width: 130px;
  cursor: pointer;
  appearance: none;
}

.ctx-select:focus { outline: none; border-color: var(--primary); }

/* Botones B / I / delete */
.ctx-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.ctx-btn:hover { background: var(--secondary-hover); border-color: var(--primary); }
.ctx-btn.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.ctx-btn-danger:hover { background: var(--danger); border-color: var(--danger); }

/* Color pickers */
.ctx-color {
  width: 30px;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
  background: var(--surface-2);
  flex-shrink: 0;
}

/* Grupos de slider */
.ctx-slider-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.ctx-label {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

.ctx-range {
  width: 70px;
  accent-color: var(--primary);
  cursor: pointer;
  height: 4px;
}

.ctx-val {
  font-size: 10px;
  font-family: monospace;
  color: var(--primary);
  min-width: 22px;
  text-align: right;
}

/* Toggle sombra en barra */
.ctx-toggle-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.ctx-toggle-label input { display: none; }

.ctx-toggle-track {
  width: 28px;
  height: 16px;
  background: var(--border);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.ctx-toggle-thumb {
  width: 10px;
  height: 10px;
  background: var(--text-muted);
  border-radius: 50%;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.2s, background 0.2s;
}

.ctx-toggle-label input:checked + .ctx-toggle-track { background: var(--primary); }
.ctx-toggle-label input:checked + .ctx-toggle-track .ctx-toggle-thumb {
  transform: translateX(12px);
  background: #fff;
}

/* Dropdown compacto de sombra */
.ctx-shadow-dropdown {
  position: relative;
}

#ctxShadowToggleBtn {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ctx-shadow-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.15s;
}

#ctxShadowToggleBtn.active .ctx-shadow-dot {
  background: var(--primary);
}

#ctxShadowToggleBtn.active {
  background: rgba(var(--primary-rgb), 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

.ctx-shadow-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 200px;
  z-index: 300;
}

.ctx-shadow-popover.hidden {
  display: none;
}

.ctx-shadow-popover-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ctx-shadow-popover-row .ctx-label {
  width: 56px;
  flex-shrink: 0;
}

.ctx-shadow-popover-row .ctx-range {
  flex: 1;
  width: auto;
}

.ctx-shadow-popover-row .ctx-val {
  width: 26px;
  text-align: right;
}

.ctx-shadow-remove-btn {
  margin-top: 4px;
  padding: 6px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--danger);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}

.ctx-shadow-remove-btn:hover {
  background: rgba(224,92,106,0.12);
}

/* Botones de máscara en barra */
.ctx-mask-row {
  display: flex;
  gap: 4px;
}

.ctx-mask-btn {
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.ctx-mask-btn:hover { border-color: var(--primary); color: var(--primary); }
.ctx-mask-btn.active { background: rgba(var(--primary-rgb), 0.15); border-color: var(--primary); color: var(--primary); }




/* ===========================
   OVERLAY QUITAR FONDO
=========================== */
.bg-remove-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 14, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 50;
  border-radius: var(--radius);
  backdrop-filter: blur(2px);
  transition: opacity 0.2s;
}

.bg-remove-overlay.hidden {
  display: none;
}

.bg-remove-overlay p {
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.bg-remove-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Guardando el diseño: mismo círculo que "Quitar fondo", pero bloquea toda la página */
.guardando-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(10, 10, 14, 0.78);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  cursor: wait;
}
.guardando-overlay.hidden { display: none; }
.guardando-overlay .bg-remove-spinner { width: 52px; height: 52px; }
.guardando-overlay p { color: var(--text); font-size: 14px; font-weight: 600; }

/* Reutiliza @keyframes spin si ya existe en tu CSS; si no, agrega: */
@keyframes spin {
  to { transform: rotate(360deg); }
}




.crop-confirm-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  padding: 8px 14px;
  z-index: 600;
}

.crop-confirm-bar.hidden {
  display: none;
}



.zonas-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.zona-tab {
  padding: 7px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.zona-tab:hover {
  border-color: var(--primary);
  color: var(--text);
}

.zona-tab.active {
  background: rgba(var(--primary-rgb), 0.15);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}



.ctx-marker-shape-btn {
  width: 28px;
  height: 28px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.ctx-marker-shape-btn:hover { border-color: var(--primary); color: var(--primary); }
.ctx-marker-shape-btn.active { background: rgba(var(--primary-rgb), 0.15); border-color: var(--primary); color: var(--primary); }
.tool-btn.active { border-color: var(--primary); background: rgba(var(--primary-rgb), 0.15); color: var(--primary); }






/* ===========================
   MIS DISEÑOS
=========================== */
.page-disenos {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Las páginas de listado (Mis diseños, Pedidos) sí hacen scroll:
   anula el "html, body { height:100%; overflow:hidden }" pensado para el editor */
html.pagina-scroll,
html.pagina-scroll body {
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
}

.disenos-hero {
  padding: 40px 32px 20px;
}

.disenos-title {
  font-family: 'Poppins', sans-serif;
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 6px;
}

.disenos-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.disenos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  padding: 10px 32px 60px;
}

.disenos-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80px 20px;
  color: var(--text-dim);
  gap: 12px;
}

.disenos-empty p {
  font-size: 14px;
}

.diseno-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.diseno-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
}

.diseno-card-img-link {
  display: block;
}

.diseno-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
}

.diseno-card-body {
  padding: 12px 14px 8px;
}

.diseno-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.diseno-card-product {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.diseno-card-date {
  font-size: 10px;
  color: var(--text-dim);
}

.diseno-card-actions {
  display: flex;
  gap: 6px;
  padding: 0 14px 12px;
}

.diseno-card-btn {
  flex: 1;
  padding: 6px 8px;
  font-size: 11px;
  font-family: 'Inter', sans-serif;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: block;
  transition: background 0.15s;
  border: 1px solid;
}

.diseno-card-btn-edit {
  background: rgba(var(--primary-rgb), 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

.diseno-card-btn-edit:hover {
  background: rgba(var(--primary-rgb), 0.25);
}

.diseno-card-btn-del {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}

.diseno-card-btn-del:hover {
  background: rgba(224,92,106,0.12);
}




/* ===========================
   NAVEGACIÓN TOPBAR
=========================== */
.topbar-nav {
  display: flex;
  gap: 4px;
}

.topbar-nav-link {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.topbar-nav-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.topbar-nav-link.active {
  background: rgba(var(--primary-rgb), 0.15);
  color: var(--primary);
}

/* ===========================
   CARRITO — ICONO
=========================== */
.cart-icon-btn {
  position: relative;
  width: 38px;
  height: 38px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s;
}

.cart-icon-btn:hover { border-color: var(--primary); }

.cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
}

/* ===========================
   POPUP GENÉRICO
=========================== */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.popup-overlay.hidden { display: none; }

.popup-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}

.popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.popup-title {
  font-size: 15px;
  font-weight: 600;
}

.popup-close {
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.popup-close:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* ===========================
   CARRITO — ITEMS
=========================== */
.cart-items { padding: 14px 20px; display: flex; flex-direction: column; gap: 10px; }

.cart-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  padding: 20px 0;
}

.cart-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
}

.cart-item img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  background: #111;
  flex-shrink: 0;
}

.cart-item-info { flex: 1; min-width: 0; }

.cart-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-product { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.cart-item-remove {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.cart-item-remove:hover { color: var(--danger); }

/* ===========================
   CARRITO — FORMULARIO
=========================== */
.cart-form { padding: 0 20px 20px; }

.cart-form-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.cart-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 8px;
}

.cart-input {
  width: 100%;
  padding: 9px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.15s;
}

.cart-input:focus { border-color: var(--primary); }
.cart-textarea { resize: vertical; min-height: 72px; }

/* ===========================
   BADGE COMPRADO
=========================== */
.diseno-card.is-pedido { opacity: 0.75; }

.diseno-card-img-link { position: relative; display: block; }

.diseno-badge-pedido {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(78,201,148,0.9);
  color: var(--on-success);
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.diseno-card-btn-cart {
  background: rgba(var(--primary-rgb), 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

.diseno-card-btn-cart:hover { background: rgba(var(--primary-rgb), 0.25); }

.diseno-card-btn-dup {
  background: rgba(78,201,148,0.1);
  border-color: rgba(78,201,148,0.9);
  color: rgb(78,201,148);
}

.diseno-card-btn-dup:hover { background: rgba(78,201,148,0.25); }

/* ===========================
   PEDIDOS
=========================== */
.pedidos-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 32px 60px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.pedido-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.pedido-card:hover { border-color: var(--primary); }

.pedido-card-id {
  font-size: 11px;
  font-family: monospace;
  color: var(--primary);
  margin-bottom: 4px;
}

.pedido-card-name { font-size: 14px; font-weight: 600; }

.pedido-card-date { font-size: 11px; color: var(--text-dim); margin-top: 3px; }

.pedido-card-right { display: flex; align-items: center; gap: 12px; }

.pedido-badge {
  background: rgba(var(--primary-rgb), 0.15);
  color: var(--primary);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
}

.pedido-info-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 20px;
}

.pedido-info-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.pedido-info-row span { color: var(--text-muted); }

.pedido-items-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 20px 20px;
}

.pedido-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px;
}

.pedido-item img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 6px;
  background: #111;
}

.pedido-item-name { font-size: 13px; font-weight: 500; }
.pedido-item-product { font-size: 11px; color: var(--text-muted); }



/* ===========================
   CARRITO — CANTIDAD
=========================== */
.cart-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cart-qty-btn {
  width: 24px;
  height: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  line-height: 1;
  flex-shrink: 0;
}

.cart-qty-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.cart-qty-val {
  font-size: 13px;
  font-weight: 600;
  min-width: 20px;
  text-align: center;
  color: var(--text);
}

/* ===========================
   ESTADO DEL PEDIDO
=========================== */
.pedido-estado-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255,159,90,0.15);
  color: var(--accent);
  border: 1px solid rgba(255,159,90,0.3);
}

.pedido-item-qty {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
  min-width: 30px;
  text-align: right;
} 


.diseno-card-btn-del:disabled,
.diseno-card-btn-del.btn-disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}




/* Zonas: visible en desktop, oculto en mobile (está dentro de mobile-zone-row) */
#zonasSelector {
  display: flex;
}

@media (max-width: 600px) {
  /* En mobile ocultar el selector de arriba */
  #zonasSelector {
    display: none;
  }

  /* Clonar el selector dentro de mobile-zone-row */
  .mobile-zone-row #zonasSelector-mobile {
    display: flex;
  }
}








.avatar-menu { position: relative; }
.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--on-primary); font-weight: 700; font-size: 14px;
  font-family: 'Poppins', sans-serif;
  border: 2px solid var(--primary);
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar-dropdown {
  position: absolute; top: 44px; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); min-width: 180px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 200; overflow: hidden; display: none;
}
.avatar-dropdown.open { display: block; }
.avatar-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; font-size: 13px; color: var(--text);
  cursor: pointer; text-decoration: none;
  transition: background 0.15s; border: none;
  background: transparent; width: 100%;
  font-family: 'Inter', sans-serif;
}
.avatar-dropdown-item:hover { background: var(--surface-2); }
.avatar-dropdown-item.danger { color: #e05c6a; }
.avatar-dropdown-divider { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

.avatar-btn {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: var(--on-primary); font-weight: 700; font-size: 14px;
  font-family: 'Poppins', sans-serif;
  border: 2px solid var(--primary);
  cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  flex-shrink: 0;
}


/* ===========================
   DESGLOSE DE PRECIOS (carrito y detalle de pedido) — ver js/precios.js
=========================== */
.pz-linea {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.pz-unitario {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 6px;
  font-size: 12px;
}
.pz-anterior { color: var(--text-muted); text-decoration: line-through; }
.pz-pct {
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--discount);
  padding: 1px 6px;
  border-radius: 999px;
}
.pz-final     { color: var(--text); font-weight: 600; }
.pz-x         { color: var(--text-muted); }
.pz-importe   { font-size: 13px; font-weight: 700; color: var(--text); white-space: nowrap; }
.pz-pendiente { font-size: 11px; color: var(--text-muted); font-style: italic; }

.pz-resumen {
  margin: 12px 20px 4px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.pz-fila {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}
.pz-fila span:last-child { color: var(--text); font-weight: 600; }
.pz-ahorro span:last-child { color: #4ec994; }
.pz-total {
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid var(--border);
  font-size: 15px;
  color: var(--text);
  font-weight: 700;
}
.pz-total span:last-child { font-family: 'Poppins', sans-serif; font-size: 17px; font-weight: 700; }
.pz-nota { font-size: 11px; color: var(--text-muted); font-style: italic; }


/* ===========================
   FONDOS DEL EDITOR (sección "Fondo" de la barra lateral)
=========================== */
.fondos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.fondo-btn {
  aspect-ratio: 1;
  padding: 0;
  background: var(--surface-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, transform 0.15s;
}
.fondo-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.fondo-btn:hover  { border-color: var(--primary); transform: scale(1.04); }
.fondo-btn.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.35); }
.fondo-btn.cargando { opacity: 0.5; cursor: wait; }
