/* ---- PERSONALIZADOR ----
   Interfaz común a todos los personalizadores (neón, llaveros, nombre articulado...).

   Estructura de la página:
     #pm-esquina          arriba a la izquierda: botón de cuenta (lo pone cuenta.js) + .pm-titulo (volver y nombre)
     #canvas-container    el lienzo 3D, ocupa todo menos la barra lateral
     #barra-herr          (opcional) barra de herramientas centrada arriba del lienzo
     #pestanas            pestañas verticales (.tool-btn data-panel="clave")
     #paneles             un <section class="panel" data-panel-body="clave"> por pestaña (assets/js/paneles.js)

   El color de acento se cambia por producto redefiniendo --acento* en :root. */

:root {
    --tabs: 84px;
    --panel: 340px;
    --acento: #059669;
    --acento-osc: #047857;
    --acento-claro: #10b981;
    --acento-2: #14b8a6; /* segundo color del degradé del botón principal */
}

/* ---------- Esquina superior izquierda: cuenta + título ---------- */
#pm-esquina { position: fixed; top: 16px; left: 16px; z-index: 40; display: flex; align-items: center; gap: 10px; max-width: calc(100vw - var(--tabs) - var(--panel) - 32px); }
.pm-titulo { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 8px 16px; border-radius: 9999px; background: rgba(255,255,255,.75); backdrop-filter: blur(10px); box-shadow: 0 6px 20px -8px rgba(15,23,42,.35); border: 1px solid rgba(255,255,255,.6); }
.pm-titulo h1 { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--acento-osc); }
.pm-titulo .pm-volver { color: var(--acento-osc); flex-shrink: 0; }
.pm-titulo .pm-volver:hover { color: #0f172a; }
.pm-titulo .pm-logo { width: 26px; height: 26px; flex-shrink: 0; display: block; }
.pm-sep { width: 1px; height: 22px; background: #cbd5e1; flex-shrink: 0; }

/* ---------- Lienzo ---------- */
#canvas-container { right: calc(var(--tabs) + var(--panel)); width: auto; }

/* ---------- Barra de herramientas sobre el lienzo ---------- */
/* a la derecha del lienzo, para no chocar con la esquina de la cuenta */
#barra-herr { position: absolute; top: 16px; left: 0; right: calc(var(--tabs) + var(--panel) + 16px); z-index: 25; display: flex; justify-content: flex-end; pointer-events: none; }
#barra-herr > div { pointer-events: auto; display: flex; gap: 4px; padding: 5px; border-radius: 9999px; background: rgba(255,255,255,.75); backdrop-filter: blur(10px); box-shadow: 0 6px 20px -8px rgba(15,23,42,.35); border: 1px solid rgba(255,255,255,.6); }
.barra-btn { display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 9999px; font-size: 13px; font-weight: 600; color: #334155; transition: background .15s, color .15s; }
.barra-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--acento) 10%, transparent); color: var(--acento-osc); }
.barra-btn.activo { background: var(--acento); color: #fff; }
.barra-btn:disabled { opacity: .4; cursor: default; }

/* ---------- Pestañas verticales ---------- */
/* Panel pegado al borde derecho; las pestañas salen de su lado izquierdo, hacia el lienzo */
#pestanas { position: fixed; top: 0; bottom: 0; right: var(--panel); width: var(--tabs); z-index: 30; display: flex; flex-direction: column; gap: 6px; padding: 14px 0 14px 8px; overflow-y: auto; background: linear-gradient(90deg, #e2e8f0, #eef2f6); }
.tool-btn { position: relative; width: 100%; padding: 10px 4px 9px; display: flex; flex-direction: column; align-items: center; gap: 4px; color: #64748b; border-radius: 14px 0 0 14px; transition: background .15s, color .15s, box-shadow .15s; }
.tool-btn:hover { background: rgba(255,255,255,.65); color: var(--acento-osc); }
.tool-btn.activo { background: #fff; color: var(--acento-osc); box-shadow: -4px 2px 12px -4px rgba(15,23,42,.18); }
.tool-btn.activo::before { content: ''; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 3px; background: var(--acento-claro); }
/* curvitas que unen la pestaña activa con el panel */
.tool-btn.activo::after { content: ''; position: absolute; right: 0; top: -14px; width: 14px; height: calc(100% + 28px); background: radial-gradient(circle at 0 0, transparent 13.5px, #fff 14px) top right / 14px 14px no-repeat, radial-gradient(circle at 0 100%, transparent 13.5px, #fff 14px) bottom right / 14px 14px no-repeat; pointer-events: none; }
.tool-label { font-size: 10.5px; font-weight: 600; line-height: 1.15; text-align: center; }

/* ---------- Paneles ---------- */
#paneles { position: fixed; top: 0; bottom: 0; right: 0; width: var(--panel); z-index: 20; background: #fff; box-shadow: -10px 0 30px -18px rgba(15,23,42,.35); }
.panel { height: 100%; display: flex; flex-direction: column; }
.panel.hidden { display: none; }
.panel-cab { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid rgba(0,0,0,.07); }
.panel-cab h2 { font-size: 18px; font-weight: 700; color: var(--acento-osc); }
.panel-x { display: none; }
.panel-cuerpo { flex: 1; padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Campos ---------- */
.campo-label { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; margin-bottom: 8px; opacity: .85; }
.campo-valor { color: var(--acento); }
.rango { width: 100%; accent-color: var(--acento); cursor: pointer; }
.campo-num, .campo-select { width: 100%; padding: 8px 10px; border-radius: 10px; border: 1px solid rgba(0,0,0,.15); background: rgba(255,255,255,.8); }
.campo-num:focus, .campo-select:focus { outline: 2px solid color-mix(in srgb, var(--acento) 45%, transparent); outline-offset: 0; }
.campo-color { position: relative; height: 44px; border-radius: 10px; overflow: hidden; border: 1px solid rgba(0,0,0,.15); }
.campo-color input { position: absolute; top: -8px; left: -8px; width: calc(100% + 16px); height: calc(100% + 16px); cursor: pointer; border: 0; padding: 0; }
.ayuda { font-size: 12px; opacity: .65; margin-top: 6px; }
.info-lista > div { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed rgba(0,0,0,.1); font-size: 14px; }
.info-lista dt { opacity: .7; }
.info-lista dd { font-weight: 700; text-align: right; }

/* ---------- Botones ---------- */
.btn-pri { width: 100%; display: flex; justify-content: center; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 12px; font-weight: 700; color: #fff; background: linear-gradient(90deg, var(--acento), var(--acento-2)); box-shadow: 0 10px 15px -3px rgba(0,0,0,.12); transition: filter .15s, transform .15s; }
.btn-pri:hover { filter: brightness(.93); transform: translateY(-1px); }
.btn-pri:disabled { opacity: .6; transform: none; cursor: default; }
.btn-sec { padding: 8px; border-radius: 10px; font-weight: 600; color: var(--acento-osc); background: color-mix(in srgb, var(--acento) 10%, transparent); }
.btn-sec:hover { background: color-mix(in srgb, var(--acento) 18%, transparent); }
.hist-btn { color: var(--acento-osc); padding: 2px; border-radius: 8px; flex-shrink: 0; }
.hist-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--acento) 12%, transparent); }
.hist-btn:disabled { opacity: .3; cursor: default; }

/* "Mis diseños" se abre desde su pestaña, no con el botón flotante de disenos.js */
#disenos-btn { display: none !important; }

/* ---------- Celular ---------- */
/* Las pestañas pasan a una barra abajo y los paneles a una hoja que sube desde abajo.
   La hoja arranca cerrada para que el 3D ocupe la pantalla; se abre tocando una pestaña
   y se cierra con la ×, deslizándola hacia abajo o tocando otra vez la pestaña activa
   (assets/js/paneles.js pone la clase hoja-abierta en <body>). */
@media (max-width: 767px) {
    :root { --tabs: 0px; --panel: 0px; --barra-alto: calc(62px + env(safe-area-inset-bottom)); --hoja: min(52dvh, 460px); }
    #canvas-container { position: fixed; top: 0; left: 0; right: 0; bottom: var(--barra-alto); width: auto; height: auto; }
    body.hoja-abierta #canvas-container { bottom: calc(var(--barra-alto) + var(--hoja)); }
    body.hoja-abierta.hoja-grande #canvas-container { bottom: var(--barra-alto); }

    #pm-esquina { top: 10px; left: 10px; gap: 6px; max-width: calc(100vw - 20px); }
    .pm-titulo { padding: 6px 12px; gap: 8px; }
    .pm-titulo h1 { display: none; }
    #barra-herr { top: 62px; right: 10px; z-index: 15; }
    .barra-btn { padding: 6px 12px; font-size: 12px; }

    /* barra de pestañas abajo, con scroll horizontal si no entran */
    #pestanas { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--barra-alto); flex-direction: row; gap: 2px; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; background: #fff; border-top: 1px solid rgba(15,23,42,.08); box-shadow: 0 -8px 24px -16px rgba(15,23,42,.4); z-index: 31; }
    #pestanas::-webkit-scrollbar { display: none; }
    #pestanas.mas-der { -webkit-mask-image: linear-gradient(90deg, #000 82%, transparent); mask-image: linear-gradient(90deg, #000 82%, transparent); }
    #pestanas.mas-izq { -webkit-mask-image: linear-gradient(270deg, #000 82%, transparent); mask-image: linear-gradient(270deg, #000 82%, transparent); }
    #pestanas.mas-izq.mas-der { -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); }
    .tool-btn { flex: 1 0 62px; width: auto; height: 50px; padding: 5px 2px 4px; gap: 2px; border-radius: 12px; justify-content: center; }
    .tool-btn svg { width: 22px; height: 22px; }
    .tool-label { font-size: 10px; white-space: nowrap; }
    .tool-btn.activo { background: transparent; box-shadow: none; }
    .tool-btn.activo::before { left: 18px; right: 18px; top: -6px; bottom: auto; width: auto; height: 3px; }
    .tool-btn.activo::after { display: none; }
    body:not(.hoja-abierta) .tool-btn.activo { color: #64748b; }
    body:not(.hoja-abierta) .tool-btn.activo::before { display: none; }
    body.hoja-abierta .tool-btn.activo { background: color-mix(in srgb, var(--acento) 10%, transparent); }

    /* hoja de abajo */
    #paneles { top: auto; left: 0; right: 0; bottom: var(--barra-alto); width: auto; height: var(--hoja); z-index: 30; border-radius: 20px 20px 0 0; box-shadow: 0 -12px 30px -14px rgba(15,23,42,.45); transform: translateY(calc(100% + var(--barra-alto))); visibility: hidden; transition: transform .25s ease, height .25s ease, visibility 0s .25s; }
    body.hoja-abierta #paneles { transform: none; visibility: visible; transition: transform .25s ease, height .25s ease; }
    body.hoja-grande #paneles { height: calc(100dvh - var(--barra-alto) - 64px); }
    .panel-cab { position: relative; padding: 18px 14px 10px 18px; touch-action: none; cursor: grab; }
    /* manija para arrastrar */
    .panel-cab::before { content: ''; position: absolute; top: 7px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: #cbd5e1; }
    .panel-cab h2 { font-size: 16px; }
    .panel-x { display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 9999px; font-size: 22px; line-height: 1; color: #64748b; background: #f1f5f9; }
    .panel-cuerpo { padding: 14px 18px 20px; gap: 16px; overscroll-behavior: contain; }
}
