/* ================================================================
   configurador.css — Personalizador de envase
   Layout de 3 columnas inspirado en editores tipo Vistaprint
================================================================ */

/* Anula el margin-bottom negativo del header (diseñado para heroes) */
.cfg-page .tf-header {
    margin-bottom: 0 !important;
}

/* ── App shell ───────────────────────────────────────────────────── */

.cfg-app {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 86px);
    overflow: hidden;
}

/* ── Top bar ─────────────────────────────────────────────────────── */

.cfg-topbar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 24px;
    height: 54px;
    min-height: 54px;
    background: #fff;
    border-bottom: 1px solid #e0e8e0;
    position: relative;
    z-index: 10;
}

.cfg-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #8a9a8b;
    text-decoration: none;
    text-transform: uppercase;
    transition: color 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.cfg-back:hover { color: var(--primary); }

.cfg-topbar-title {
    font-family: 'Syne', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #212529;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.cfg-topbar-divider {
    width: 1px;
    height: 20px;
    background: #e0e8e0;
    flex-shrink: 0;
}

.cfg-format-tabs {
    display: flex;
    gap: 6px;
}

.cfg-tab {
    padding: 7px 18px;
    border: 1.5px solid #c4d3c5;
    border-radius: 40px;
    background: transparent;
    color: #6b7e6c;
    font-family: 'Syne', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.18s;
}

.cfg-tab.active,
.cfg-tab:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ── Workspace (3 columnas) ──────────────────────────────────────── */

.cfg-workspace {
    display: grid;
    grid-template-columns: 260px 1fr 360px;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar izquierda — herramientas ────────────────────────────── */

.cfg-sidebar {
    border-right: 1px solid #e0e8e0;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 24px 18px;
    overflow-y: auto;
}

.cfg-sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #8a9a8b;
    text-transform: uppercase;
    margin-bottom: 8px;
}

/* Upload area */
.cfg-upload-area {
    border: 2px dashed #c4d3c5;
    border-radius: 14px;
    padding: 24px 14px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: #f6faf6;
}

.cfg-upload-area:hover,
.cfg-upload-area.dragging {
    border-color: var(--primary);
    background: #eef4ee;
}

.cfg-upload-area input[type="file"] { display: none; }

.cfg-upload-icon {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    color: #fff;
}

.cfg-upload-label {
    display: block;
    font-family: 'Syne', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 3px;
}

.cfg-upload-hint {
    font-size: 0.7rem;
    color: #8a9a8b;
}

/* Archivo subido */
.cfg-uploaded-preview {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #eef4ee;
    border-radius: 10px;
    border: 1px solid #c4d3c5;
}

.cfg-uploaded-preview.visible { display: flex; }

.cfg-uploaded-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.cfg-uploaded-name {
    font-size: 0.78rem;
    color: #212529;
    font-weight: 500;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cfg-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #8a9a8b;
    padding: 3px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.cfg-remove-btn:hover { color: #c05353; }

/* Info pills */
.cfg-info-pills {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cfg-info-pill {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #f6faf6;
    border-radius: 10px;
    border: 1px solid #e8eee9;
}

.cfg-info-pill-icon {
    width: 28px;
    height: 28px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    margin-top: 1px;
}

.cfg-info-pill-text strong {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: #212529;
    margin-bottom: 2px;
}

.cfg-info-pill-text span {
    font-size: 0.68rem;
    color: #8a9a8b;
    line-height: 1.4;
}

/* ── Centro: zona 3D principal ───────────────────────────────────── */

.cfg-canvas-area {
    background: #e8eee9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 16px 20px 20px;
    overflow-y: auto;
    position: relative;
}

/* Contenedor del canvas 3D central — crece para llenar el espacio */
.cfg-3d-main {
    flex: 1;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 320px;
}

.cfg-3d-main canvas {
    width: 100% !important;
    height: 100% !important;
    border-radius: 16px;
    display: block;
    cursor: grab;
}

.cfg-3d-main canvas:active { cursor: grabbing; }

.cfg-3d-badge {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: rgba(100,120,101,0.75);
    letter-spacing: 0.05em;
    pointer-events: none;
    white-space: nowrap;
}

.cfg-canvas-placeholder svg {
    opacity: 0.4;
}

.cfg-canvas-placeholder p {
    font-size: 0.82rem;
    margin: 0;
}

.cfg-hint {
    font-size: 0.7rem;
    color: #8a9a8b;
    letter-spacing: 0.05em;
    text-align: center;
}

/* ── Panel derecho — preview 3D + formulario ─────────────────────── */

.cfg-panel {
    border-left: 1px solid #e0e8e0;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

/* Preview 3D (bote) */
.cfg-preview-3d {
    background: #f0f3f5;
    padding: 16px;
    flex-shrink: 0;
}

.cfg-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cfg-preview-label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #6b7e6c;
    letter-spacing: 0.05em;
}

.cfg-live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    animation: cfg-pulse 2s ease-in-out infinite;
}

@keyframes cfg-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.8); }
}

/* Los canvas 3D viven dentro de .cfg-3d-main (ver arriba) */

/* Preview estático (doypack / stick) */
.cfg-preview-static {
    background: #f0f3f5;
    padding: 16px;
    flex-shrink: 0;
    display: none;
}

.cfg-preview-static img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 10px;
    display: block;
}

/* Formulario */
.cfg-form-area {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.cfg-form-title {
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    color: #212529;
    margin-bottom: 2px;
}

.cfg-form-sub {
    font-size: 0.75rem;
    color: #8a9a8b;
    line-height: 1.5;
}

.cfg-divider {
    height: 1px;
    background: #e8ede9;
}

.cfg-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cfg-field label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #8a9a8b;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.cfg-field input,
.cfg-field textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #e0e8e0;
    border-radius: 7px;
    font-size: 0.83rem;
    color: #212529;
    background: #f8faf8;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
}

.cfg-field input:focus,
.cfg-field textarea:focus {
    border-color: var(--primary);
    background: #fff;
}

.cfg-submit {
    width: 100%;
    padding: 13px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: 'Syne', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s;
}

.cfg-submit:hover { opacity: 0.85; transform: translateY(-1px); }
.cfg-submit:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

/* Éxito */
.cfg-success {
    display: none;
    text-align: center;
    padding: 20px 16px;
    background: #eef4ee;
    border-radius: 12px;
    border: 1px solid #c4d3c5;
}

.cfg-success.visible { display: block; }

.cfg-success-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: #fff;
}

.cfg-success-title {
    font-family: 'Syne', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    color: #212529;
    margin-bottom: 6px;
}

.cfg-success-text {
    font-size: 0.78rem;
    color: #6b7e6c;
    line-height: 1.6;
}

/* ── Toolbar de ajuste ───────────────────────────────────────────── */

.cfg-toolbar {
    display: none;   /* oculta hasta que haya etiqueta */
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #e0e8e0;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    flex-wrap: wrap;
    max-width: 100%;
}

.cfg-toolbar.visible { display: flex; }

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

.cfg-toolbar-sep {
    width: 1px;
    height: 22px;
    background: #e0e8e0;
    flex-shrink: 0;
    margin: 0 2px;
}

.cfg-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1.5px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: #6b7e6c;
    font-family: 'Inter', sans-serif;
    font-size: 0.70rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.cfg-tool-btn:hover {
    background: #eef4ee;
    color: var(--primary);
}

.cfg-tool-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Escala */
.cfg-scale-group {
    gap: 5px;
}

.cfg-scale-btn {
    width: 24px;
    height: 24px;
    border: 1.5px solid #c4d3c5;
    border-radius: 6px;
    background: #fff;
    color: #6b7e6c;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: all 0.15s;
    flex-shrink: 0;
}

.cfg-scale-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.cfg-scale-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 90px;
    height: 4px;
    border-radius: 4px;
    background: #c4d3c5;
    outline: none;
    cursor: pointer;
    flex-shrink: 0;
}

.cfg-scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.cfg-scale-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.cfg-scale-val {
    font-size: 0.68rem;
    font-weight: 600;
    color: #6b7e6c;
    min-width: 34px;
    text-align: left;
}

/* ── Panel de ajustes (desplegable) ─────────────────────────────── */

.cfg-adjusts-panel {
    display: none;
    background: #fff;
    border: 1px solid #e0e8e0;
    border-radius: 12px;
    padding: 12px 16px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    width: 100%;
    max-width: 520px;
    gap: 8px;
    flex-direction: column;
}

.cfg-adjusts-panel.open { display: flex; }

.cfg-adj-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.cfg-adj-label {
    font-size: 0.68rem;
    font-weight: 600;
    color: #8a9a8b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 72px;
}

.cfg-adj-slider {
    -webkit-appearance: none;
    appearance: none;
    flex: 1;
    height: 4px;
    border-radius: 4px;
    background: #c4d3c5;
    outline: none;
    cursor: pointer;
}

.cfg-adj-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.cfg-adj-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.18);
}

.cfg-adj-val {
    font-size: 0.68rem;
    font-weight: 600;
    color: #6b7e6c;
    min-width: 28px;
    text-align: right;
}

/* ── Selectores de color del envase ─────────────────────────────── */

.cfg-color-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cfg-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f6faf6;
    border-radius: 8px;
    border: 1px solid #e8eee9;
    gap: 8px;
}

.cfg-color-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7e6c;
}

.cfg-color-input {
    -webkit-appearance: none;
    appearance: none;
    width: 34px;
    height: 34px;
    border: 2px solid #c4d3c5;
    border-radius: 8px;
    cursor: pointer;
    padding: 2px;
    background: none;
    flex-shrink: 0;
    transition: border-color 0.2s;
}

.cfg-color-input:hover { border-color: var(--primary); }

.cfg-color-input::-webkit-color-swatch-wrapper { padding: 0; border-radius: 5px; }
.cfg-color-input::-webkit-color-swatch         { border: none; border-radius: 5px; }
.cfg-color-input::-moz-color-swatch            { border: none; border-radius: 5px; }

/* ── Medidas de etiqueta (sidebar) ──────────────────────────────── */

.cfg-dims-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f6faf6;
    border: 1px solid #e8eee9;
    border-radius: 10px;
    padding: 11px 13px;
}

.cfg-dims-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.71rem;
}

.cfg-dims-row span {
    color: #8a9a8b;
    flex: 1;
    min-width: 0;
}

.cfg-dims-row strong {
    color: #212529;
    font-weight: 700;
    white-space: nowrap;
    font-family: 'Syne', sans-serif;
    font-size: 0.72rem;
}

.cfg-dims-hint {
    font-size: 0.63rem;
    color: #aab8ab;
    margin-top: 4px;
    line-height: 1.4;
}


.cfg-flat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.cfg-flat-title {
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    color: #8a9a8b;
    text-transform: uppercase;
}

.cfg-flat-badge {
    font-size: 0.67rem;
    font-weight: 600;
    color: #607561;
    background: #eef4ee;
    padding: 2px 9px;
    border-radius: 20px;
    white-space: nowrap;
}

/* Grid: esquina | regla-top / regla-left | canvas */
.cfg-flat-editor {
    display: grid;
    grid-template-columns: 22px 1fr;
    grid-template-rows: 18px auto;
    border: 1px solid #c8d8c9;
    border-radius: 6px;
    overflow: hidden;
}

.cfg-ruler-corner {
    background: #ddeedd;
    border-right: 1px solid #c8d8c9;
    border-bottom: 1px solid #c8d8c9;
}

/* Regla horizontal */
.cfg-ruler-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 1px 3px 2px;
    background: #ddeedd;
    border-bottom: 1px solid #c8d8c9;
    user-select: none;
}

.cfg-ruler-top span {
    font-size: 0.55rem;
    color: #6b7e6c;
    font-weight: 600;
    line-height: 1;
}

/* Regla vertical */
.cfg-ruler-left {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    background: #ddeedd;
    border-right: 1px solid #c8d8c9;
    user-select: none;
}

.cfg-ruler-left span {
    font-size: 0.55rem;
    color: #6b7e6c;
    font-weight: 600;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    line-height: 1;
}

/* Área del canvas con guías de seguridad */
.cfg-flat-canvas-outer {
    position: relative;
    background: #e8eee8;
    padding: 8px;
}

/* Guías punteadas (safe area) — overlay sobre el canvas */
.cfg-flat-canvas-outer::after {
    content: '';
    position: absolute;
    inset: 12px;
    border: 1.5px dashed rgba(96,117,97,0.35);
    pointer-events: none;
    border-radius: 1px;
}

#cfg-label-flat {
    width: 100%;
    height: auto;
    display: block;
    background: #fff;
    box-shadow: 0 1px 8px rgba(0,0,0,0.12);
    position: relative;
}

/* ── Rectángulo de etiqueta estilo Vistaprint ────────────────────── */

.cfg-label-box {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 22%;                       /* aprox. zona etiqueta del bote */
    width: 72%;
    aspect-ratio: 10 / 3;              /* 200 mm × 60 mm */
    border: 2px solid rgba(59,148,255,0.80);
    box-shadow: inset 0 0 0 1px rgba(59,148,255,0.15);
    z-index: 10;
    cursor: move;
    user-select: none;
}

/* Canvas del diseño — llena todo el recuadro */
#cfg-label-flat {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    display: block;
    cursor: grab;
}
#cfg-label-flat:active { cursor: grabbing; }

/* Handles de esquina */
.cfg-lbh {
    position: absolute;
    width: 11px;
    height: 11px;
    background: #fff;
    border: 2.5px solid #3b94ff;
    border-radius: 50%;
    z-index: 2;
}
.cfg-lbh-tl { top: -6px;    left: -6px;   cursor: nw-resize; }
.cfg-lbh-tr { top: -6px;    right: -6px;  cursor: ne-resize; }
.cfg-lbh-bl { bottom: -6px; left: -6px;   cursor: sw-resize; }
.cfg-lbh-br { bottom: -6px; right: -6px;  cursor: se-resize; }

/* Etiqueta de dimensiones bajo el recuadro */
.cfg-lbdims {
    position: absolute;
    top: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.62rem;
    font-weight: 600;
    color: rgba(59,148,255,0.9);
    white-space: nowrap;
    pointer-events: none;
    text-shadow: 0 1px 4px rgba(0,0,0,0.35);
    letter-spacing: 0.03em;
}

/* (modal 3D eliminado — bote siempre visible de fondo) */

/* ── Responsive ──────────────────────────────────────────────────── */

@media (max-width: 1199px) {
    .cfg-workspace {
        grid-template-columns: 220px 1fr 320px;
    }
}

@media (max-width: 991px) {
    .cfg-app { height: auto; overflow: visible; }

    .cfg-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .cfg-sidebar {
        border-right: none;
        border-bottom: 1px solid #e0e8e0;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 16px;
    }

    .cfg-canvas-area {
        min-height: 340px;
        padding: 20px;
    }

    .cfg-canvas-wrap { aspect-ratio: auto; min-height: 280px; max-width: 100%; }
    .cfg-canvas-wrap.portrait { max-width: 100%; aspect-ratio: auto; min-height: 300px; }

    .cfg-panel {
        border-left: none;
        border-top: 1px solid #e0e8e0;
    }
}

@media (max-width: 575px) {
    .cfg-topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 16px;
        gap: 10px;
    }
    .cfg-topbar-title { display: none; }
    .cfg-sidebar { padding: 14px; gap: 12px; }
    .cfg-canvas-area { padding: 14px; }
    .cfg-form-area { padding: 16px; }
}
