/* =========================================
   1. VARIABLES Y CONFIGURACIÓN GLOBAL
   ========================================= */
:root {
    --primary-color: #e74c3c;   /* Rojo Pizza */
    --secondary-color: #2ecc71; /* Verde WhatsApp */
    --accent-color: #e67e22;    /* Naranja Combos */
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-dark: #2d3436;
    --border-radius: 12px;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    margin: 0;
    padding-bottom: 90px; /* Espacio extra para que no se tape con la barra negra */
    color: var(--text-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px;
}

/* =========================================
   2. HEADER Y TÍTULOS
   ========================================= */
header {
    background: var(--primary-color);
    color: white;
    padding: 20px;
    text-align: center;
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

header h1 { margin: 0; font-size: 1.8rem; }
header p { margin: 5px 0 0; opacity: 0.9; }

.titulo-seccion {
    border-bottom: 2px solid var(--primary-color);
    margin: 30px 0 15px 0;
    padding-bottom: 5px;
    color: var(--text-dark);
    font-size: 1.4rem;
}

/* =========================================
   3. BOTONES GENERALES
   ========================================= */
/* Botón de Añadir en Card */
.btn-open-variants {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 0;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-open-variants:hover { background-color: #c0392b; }

/* Botón Añadir Genérico */
.btn-add {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
}

/* Botones de Módulos Especiales (Index) */
.btn-mitad, .btn-combo {
    background: white;
    width: 100%;
    padding: 15px;
    border-radius: var(--border-radius);
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 15px;
    cursor: pointer;
    transition: transform 0.1s;
}

.btn-mitad {
    border: 2px dashed var(--primary-color);
    color: var(--primary-color);
}

.btn-combo {
    border: 2px dashed var(--accent-color);
    color: var(--accent-color);
}

.btn-mitad:active, .btn-combo:active { transform: scale(0.98); }

/* =========================================
   4. GRID DE PRODUCTOS (LAYOUT)
   ========================================= */
.grid-productos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

/* ESTILOS ESPECÍFICOS PARA MÓVILES */
@media (max-width: 600px) {
    .container { padding: 8px; }

    .grid-productos {
        grid-template-columns: repeat(3, 1fr) !important; /* Forzamos 3 columnas */
        gap: 8px;
    }

    .card {
        border-radius: 8px; /* Borde un poco menos redondo en móvil */
    }

    .card-header { padding: 5px 2px; }

    .card h3 {
        font-size: 0.7rem; 
        line-height: 1.1;
        height: 2.2em; /* Altura fija para alineación */
        margin-bottom: 0;
        
        /* Truncar texto a 2 líneas */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .card-footer { padding: 5px; }
    
    .btn-open-variants {
        font-size: 0.75rem;
        padding: 5px 0;
    }
}

/* =========================================
   5. TARJETAS DE PRODUCTO (CARD)
   ========================================= */
.card {
    background: var(--card-bg);
    border: 1px solid #e0e0e0; /* Gris muy suave en lugar de negro */
    border-radius: var(--border-radius);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.card-header {
    padding: 10px;
    background: #fdfdfd;
    border-bottom: 1px solid #eee;
    text-align: center;
}

.card-header h3 {
    font-size: 0.7rem;
    margin: 0;
    color: #333;
    text-transform: uppercase;
}

.card-body {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: #fff;
    min-height: 80px; /* Altura mínima para la imagen */
}

.card-body img {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

.card-footer {
    padding: 10px;
    background: #fff;
    border-top: 1px solid #f9f9f9;
}

/* =========================================
   6. MODALES (GENERAL)
   ========================================= */
/* IMPORTANTE: El fix del scroll está aquí */
.modal {
    display: none; 
    position: fixed; 
    z-index: 2000; 
    left: 0; 
    top: 0;
    width: 100%; 
    height: 100%; 
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px); /* Efecto borroso bonito */
    
    /* SOLUCIÓN AL PROBLEMA DEL SCROLL */
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch;
}

.modal-content {
    background-color: white;
    margin: 40px auto; /* Margen arriba/abajo para permitir scroll */
    padding: 25px 20px;
    width: 90%; 
    max-width: 500px;
    border-radius: 20px; 
    text-align: center;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #aaa;
    cursor: pointer;
}

.close:hover { color: #000; }

/* =========================================
   7. LÓGICA MITAD Y MITAD & VARIANTES
   ========================================= */
.pizza-selector {
    display: flex; 
    gap: 10px; 
    margin: 20px 0;
}

.mitad-box { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    text-align: left;
}

.mitad-box label { font-size: 0.9rem; margin-bottom: 5px; font-weight: bold; }
.mitad-box select { padding: 10px; border-radius: 8px; border: 1px solid #ccc; width: 100%; }

.variantes-selector {
    text-align: left;
    background: #f9f9f9;
    padding: 15px;
    border-radius: 10px;
    margin-top: 15px;
    border: 1px solid #eee;
}

.opcion-tamano {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.opcion-tamano input { width: 20px; height: 20px; accent-color: var(--primary-color); }

.btn-variante-opcion {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 15px;
    margin-bottom: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-variante-opcion:active {
    background: #f0f0f0;
    border-color: var(--primary-color);
}

.btn-variante-opcion .v-nombre { font-weight: bold; color: var(--text-dark); }
.btn-variante-opcion .v-precio { color: var(--primary-color); font-weight: bold; }

/* =========================================
   8. LÓGICA DE COMBOS (ESTILO TÁCTIL)
   ========================================= */
.grupo-combo {
    background: #fff;
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    text-align: left;
    border: 1px solid transparent; /* Para el borde rojo de error */
}

.grupo-combo h4 {
    margin-top: 0;
    color: var(--primary-color);
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    font-size: 1.1rem;
}

.opciones-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 10px;
}

.opcion-card {
    display: flex;
    align-items: center;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

/* Estado Seleccionado (Combo) */
.opcion-card.active {
    border-color: var(--accent-color);
    background-color: #fff8f0;
    box-shadow: inset 0 0 0 1px var(--accent-color);
}

.opcion-check {
    width: 22px;
    height: 22px;
    border: 2px solid #ccc;
    border-radius: 50%;
    margin-right: 12px;
    position: relative;
    flex-shrink: 0;
}

.opcion-card.active .opcion-check {
    border-color: var(--accent-color);
    background: var(--accent-color);
}

.opcion-card.active .opcion-check::after {
    content: '✓';
    color: white;
    font-size: 14px;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

.opcion-info {
    flex-grow: 1;
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.opcion-extra { color: #27ae60; font-weight: bold; margin-left: 5px; }

/* =========================================
   9. FORMULARIO FINAL (CHECKOUT)
   ========================================= */
.subtitulo-modal { color: #666; margin-bottom: 20px; font-size: 0.9em; }

.form-group { margin-bottom: 15px; text-align: left; }
.form-group label { display: block; margin-bottom: 5px; font-weight: bold; color: var(--text-dark); }

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
}

.form-input:focus { border-color: var(--primary-color); outline: none; }

/* Radio Buttons grandes para Delivery/Recojo */
.radio-group { display: flex; gap: 10px; }
.radio-btn { flex: 1; }
.radio-btn input[type="radio"] { display: none; }

.radio-btn span {
    display: block;
    padding: 12px;
    text-align: center;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
}

.radio-btn input:checked + span {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Lista Resumen en Modal */
.resumen-carrito-container {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 10px;
    background: #fafafa;
}

.item-resumen {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed #ddd;
    padding: 10px 0;
}
.item-resumen:last-child { border-bottom: none; }

.item-info { text-align: left; flex-grow: 1; font-size: 0.9rem; }
.item-info small { color: #7f8c8d; display: block; font-size: 0.8rem; }

.btn-eliminar-item {
    background: none; border: none;
    color: #e74c3c; font-size: 1.4rem;
    padding: 0 10px; cursor: pointer;
}

.total-modal {
    text-align: right;
    font-size: 1.3rem;
    color: var(--primary-color);
    margin: 15px 0;
    font-weight: bold;
}

/* Botonera de Acciones */
.acciones-finales { display: flex; gap: 10px; margin-bottom: 15px; }

.btn-danger {
    flex: 1; background: #fff; border: 1px solid #e74c3c; color: #e74c3c;
    padding: 10px; border-radius: 8px; cursor: pointer; font-weight: bold;
}

.btn-secondary {
    flex: 1; background: #f0f0f0; border: 1px solid #ccc; color: #333;
    padding: 10px; border-radius: 8px; cursor: pointer; font-weight: bold;
}

.btn-whatsapp-final {
    width: 100%;
    background: #25D366;
    color: white;
    padding: 15px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(37, 211, 102, 0.2);
}

/* =========================================
   10. BARRA FLOTANTE (FOOTER STICKY)
   ========================================= */
.cart-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--text-dark);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.cart-total span { font-size: 0.9rem; opacity: 0.8; }
.cart-total strong { font-size: 1.3rem; display: block; }

.btn-whatsapp {
    background: var(--secondary-color);
    color: white;
    padding: 10px 25px;
    border-radius: 25px;
    text-decoration: none;
    font-weight: bold;
    border: none;
    cursor: pointer;
}