/* ==========================================================================
   PERSONALIZADOR DE TERMOS - CSS COMPLETO CORREGIDO
   ========================================================================== */

/* Contenedor principal */
.personalizador-termos-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    background: #f8fafc;
    border-radius: 20px;
}

.personalizador-header {
    text-align: center;
    margin-bottom: 40px;
}

.personalizador-header h2 {
    font-size: 2.5rem;
    color: #1e293b;
    margin-bottom: 10px;
}

.personalizador-header p {
    font-size: 1.1rem;
    color: #64748b;
}

/* Wrapper principal */
.personalizador-wrapper {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 40px;
    align-items: start;
}

/* COLUMNA 1: Vista Previa + Diseños */
.columna-izquierda {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.vista-previa-panel {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
}

/* --- VISTA PREVIA INTERACTIVA (CORREGIDO) --- */

.termo-preview {
    position: relative;
    width: 100%;
    height: 600px; 
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
    /* Eliminamos flex para que el absolute del overlay funcione sobre el centro real */
}

.termo-base {
    width: 100%;
    height: 100%;
    transform: scale(1.6); 
    /* Centramos la imagen dentro de su propio marco */
    object-fit: contain;
    object-position: center;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
    transition: all 0.4s ease;
}

/* --- CORRECCIÓN DEL OVERLAY (DISEÑO) --- */
.diseño-overlay {
    position: absolute;
    top: 50%; 
    left: 50%;
    transform: translate(-50%, -50%);
    /* Ajustamos el tamaño para que coincida con el zoom 1.6 del termo */
    width: 50%; 
    height: 50%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: brightness(0) invert(1) !important;
    pointer-events: none;
    z-index: 10;
}

.diseno-blanco {
    filter: brightness(0) invert(1) !important;
}

/* Panel de Diseños */
.disenos-panel.full-width {
    margin-top: 30px;
    width: 100%;
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.disenos-panel h3 {
    margin: 0 0 20px 0;
    color: #1e293b;
    font-size: 1.3rem;
}

/* COLUMNA 2: Controles */
.columna-derecha {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.control-group {
    background: white;
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.08);
}

.control-group h3 {
    margin: 0 0 20px 0;
    color: #1e293b;
    font-size: 1.3rem;
}

/* Colores */
.colores-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(75px, 1fr)); 
    gap: 15px;
    justify-content: center;
}

.color-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px 5px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #e2e8f0;
    background: white;
}

.color-option:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
}

.color-option.active {
    background: #e0f2fe !important;
    border-color: #0ea5e9 !important;
    box-shadow: 0 4px 10px rgba(14, 165, 233, 0.2);
    transform: translateY(-2px);
}

.color-swatch {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.color-option span {
    font-size: 0.9rem;
    font-weight: 500;
    color: #475569;
}

/* Resumen del pedido (Gradiente Original) */
.resumen-pedido {
    background: linear-gradient(135deg, #0ea5e9, #0369a1);
    color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
}

.resumen-pedido h3 {
    margin: 0 0 20px 0;
    font-size: 1.4rem;
}

.resumen-details {
    background: rgba(255,255,255,0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.resumen-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

/* Categorías de diseños */
.categorias-disenos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.categoria-btn {
    background: #e2e8f0;
    border: 2px solid transparent !important;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
    color: #334155;
    margin: 5px;
}

.categoria-btn:hover {
    filter: brightness(0.95);
    transform: translateY(-1px);
}

.categoria-btn.active {
    background: #0ea5e9;
    color: white;
    border-color: #0ea5e9 !important;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transform: scale(1.05);
}

/* Grid de diseños */
.disenos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); 
    gap: 20px;
    max-height: 500px;
    overflow-y: auto;
    padding: 15px;
}

.diseno-option {
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    transition: all 0.3s ease;
    background-color: #ffffff;
}

.diseno-option:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.diseno-option.active {
    border-color: #0ea5e9 !important;
    background-color: #f0f9ff !important;
}

.diseno-option img {
    width: 100%;
    max-width: 150px;
    height: auto;
}

.diseno-option .precio-extra {
    display: none;
}

/* Cantidad y Precio */
.cantidad-selector { margin: 20px 0; }
.cantidad-controls { display: flex; align-items: center; justify-content: center; gap: 15px; }
.btn-cantidad { background: #e5e7eb; border: none; width: 35px; height: 35px; border-radius: 50%; cursor: pointer; font-weight: bold; }
.input-cantidad { width: 50px; text-align: center; border: 1px solid #ddd; border-radius: 5px; padding: 5px; }
.precio-total { margin: 20px 0; }
.precio-final { font-size: 2rem; font-weight: bold; color: #fbbf24; }

/* Botón Carrito */
.btn-agregar-carrito {
    background: #22c55e;
    color: white;
    border: none;
    padding: 18px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: background 0.3s;
    display: none;
}

.btn-agregar-carrito:hover { background: #16a34a; }

.btn-ver-previo {
    background: #0ea5e9;
    color: white;
    border: none;
    padding: 18px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: all 0.3s ease;
    display: block;
}

.btn-ver-previo:hover {
    background: #0284c7;
    transform: translateY(-2px);
}

/* Estilos del Modal */
.modal-personalizador {
    display: none; 
    position: fixed;
    z-index: 1000;
    left: 0; 
    top: 0;
    width: 100%; 
    height: 100%;
    background-color: rgba(0,0,0,0.85);
    backdrop-filter: blur(5px);
    /* Permitir scroll en la capa negra si el contenido es muy alto */
    overflow-y: auto; 
    padding: 20px 0;
}

.modal-content {
    background-color: #fff;
    margin: 20px auto; /* Separación para que no pegue arriba/abajo */
    padding: 25px;
    width: 90%;
    max-width: 600px;
    border-radius: 20px;
    text-align: center;
    position: relative;
    /* Evita que el contenido se corte */
    height: auto; 
    max-height: none; 
}

.close-modal {
    position: absolute;
    right: 20px; top: 10px;
    font-size: 30px; cursor: pointer;
}

.zoom-container {
    position: relative;
    width: 100%;
    height: 500px;
    overflow: hidden;
    background: #f1f5f9;
    border-radius: 10px;
}

#zoom-termo-base, #modal-termo-final {
    width: 180%;
    position: absolute;
    top: -40%;
    left: -40%;
}

/* EL OVERLAY DEL MODAL */
#zoom-diseno-overlay, #modal-diseno-final-overlay {
    position: absolute;
    top: 57%; /* Específico para el modal */
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40%; 
    height: 55%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: brightness(0) invert(1) !important;
    z-index: 20;
    transition: filter 0.3s ease, background-image 0.3s ease;
}

/* Advertencia y Resumen Modal */
.resumen-confirmacion-lista { text-align: left; margin-bottom: 20px; padding: 10px; background: #fdfdfd; border-radius: 8px; }
.resumen-linea { margin-bottom: 8px !important; font-size: 1rem; color: #334155; line-height: 1.2; }
.resumen-linea strong { color: #0ea5e9; }
.advertencia-personalizacion { background: #fffbeb; border: 1px solid #fef3c7; padding: 15px; border-radius: 8px; margin-top: 15px; text-align: left;}
.advertencia-titulo { margin-bottom: 10px !important; color: #92400e; font-size: 0.95rem; }
.advertencia-item { margin-bottom: 5px !important; font-size: 0.85rem; color: #b45309; line-height: 1.4; }

/* Responsive General */
@media (max-width: 1024px) {
    .personalizador-wrapper { grid-template-columns: 1fr; }
}

/* --- AJUSTES MÓVILES (LO QUE ME PEDISTE) --- */
@media (max-width: 768px) {
    .termo-preview {
        height: 450px;
    }

    .termo-base {
        width: 150%; 
        top: -36%; 
        left: -24%;
    }

    .diseño-overlay {
        width: 55%; 
        height: 70%;
        top: 50%; /* Centrado corregido para el zoom móvil */
    }

    /* 4 COLUMNAS DE COLORES FIJAS */
    .colores-grid {
        grid-template-columns: repeat(4, 1fr) !important; 
        gap: 8px;
    }

    .color-option { padding: 8px 2px; }
    .color-swatch { width: 45px; height: 45px; }
    .color-option span { font-size: 0.65rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

    .disenos-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    
    .zoom-container { height: 380px; }
}

/* --- CORRECCIÓN DE POSICIONAMIENTO DE IMAGEN BASE --- */

.termo-preview {
    position: relative;
    width: 100%;
    height: 600px; 
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
    /* Eliminamos flex para que el absolute del overlay funcione sobre el centro real */
}

.termo-base {
    width: 100%;
    height: 100%;
    /* En lugar de top/left negativos, usamos scale para el zoom */
    transform: scale(1.6); 
    /* Centramos la imagen dentro de su propio marco */
    object-fit: contain;
    object-position: center;
    position: absolute;
    top: -70px;
    left: 0;
    z-index: 1;
    transition: all 0.4s ease;
}

/* --- CORRECCIÓN DEL OVERLAY (DISEÑO) --- */
.diseño-overlay {
    position: absolute;
    top: 50%; 
    left: 50%;
    transform: translate(-50%, -50%);
    /* Ajustamos el tamaño para que coincida con el zoom 1.6 del termo */
    width: 50%; 
    height: 50%;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    filter: brightness(0) invert(1) !important;
    pointer-events: none;
    z-index: 10;
}

/* --- CORRECCIÓN DEL MODAL (VISTA PREVIA FINAL) --- */
.zoom-container {
    position: relative;
    width: 100%;
    height: 540px;
    overflow: hidden;
    background: #f1f5f9;
    border-radius: 10px;
}

#modal-termo-final {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    transform: scale(1.1); /* Un poco más de zoom en el modal */
    position: absolute;
    top: 0;
    left: 0;
}

#modal-diseno-final-overlay {
    position: absolute;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 35%; 
    height: 35%;
    z-index: 20;
}

/* --- AJUSTE PARA MÓVIL --- */
@media (max-width: 768px) {
    .termo-preview {
        height: 450px;
    }
    .termo-base {
        transform: scale(1.9); /* Más zoom en móvil para llenar la pantalla */
    }
    .diseño-overlay {
        width: 60%;
        height: 60%;
    }
}