/* =========================================
   ESTILOS GENERALES Y RESET
   ========================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overflow-x: hidden; /* EVITA LA FRANJA BLANCA EN MÓVILES */
    width: 100%;
    max-width: 100vw;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f9; 
    color: #333;
}

/* =========================================
   CABECERA (HEADER)
   ========================================= */
header {
    background-color: #ff7b00; /* Naranja Chollos */
    color: white;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.header-contenedor {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    max-width: 1300px;
    margin: 0 auto;
    padding: 30px 20px;
}

.header-titulo-central {
    text-align: center;
    width: 100%;
}

.header-titulo-central h1 {
    font-size: 2.4em;
    margin-bottom: 5px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.header-titulo-central p {
    font-size: 1.2em;
    opacity: 0.95;
}

.header-info-columnas {
    display: flex;
    justify-content: center;
    gap: 25px;
    width: 100%;
    flex-wrap: wrap;
    align-items: flex-start;
}

/* =========================================
   SISTEMA DE ACORDEONES (Cajas Desplegables)
   ========================================= */
.info-caja {
    background: rgba(255, 255, 255, 0.15); 
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    padding: 15px 25px;
    flex: 1;
    min-width: 300px;
    max-width: 580px;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: background 0.3s ease;
}

.info-caja:hover {
    background: rgba(255, 255, 255, 0.25);
}

.caja-cabecera {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid transparent; 
    transition: all 0.3s ease;
}

.caja-cabecera h3 {
    margin: 0;
    font-size: 1.25em;
    font-weight: 600;
}

.flecha {
    font-size: 0.8em;
    transition: transform 0.4s ease; 
}

.caja-contenido {
    max-height: 0; 
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.5s ease, opacity 0.5s ease, padding-top 0.3s ease;
}

/* --- Estilo de párrafos dentro del acordeón --- */
.caja-contenido p {
    margin-bottom: 15px; 
    font-size: 0.95em;
    line-height: 1.6;
    text-align: justify;
}

.caja-contenido p:last-of-type {
    margin-bottom: 0;
}

.aviso-afiliado {
    opacity: 0.85;
    text-align: center !important;
    margin-top: 15px !important;
    display: block;
}

/* Estado del acordeón cuando se abre */
.info-caja.abierta .caja-cabecera {
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    padding-bottom: 10px;
}

.info-caja.abierta .caja-contenido {
    max-height: 1000px; 
    opacity: 1;
    padding-top: 15px;
}

.info-caja.abierta .flecha {
    transform: rotate(180deg); 
}

/* =========================================
   VENTANA MODAL (INSTALAR APP)
   ========================================= */
.btn-app {
    margin-top: 15px;
    background-color: #2c3e50; 
    color: white;
    border: 2px solid white;
    padding: 10px 20px;
    font-size: 1em;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.15);
}

.btn-app:hover {
    background-color: white;
    color: #ff7b00;
}

.modal-oculto {
    display: none; 
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7); 
    align-items: center;
    justify-content: center;
}

.modal-contenido {
    background-color: #f4f7f9;
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    text-align: center;
    position: relative;
    color: #333;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.cerrar {
    position: absolute;
    top: 10px;
    right: 15px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.cerrar:hover {
    color: #333;
}

.modal-contenido h2 {
    color: #ff7b00;
    margin-bottom: 5px;
}

.modal-sub {
    font-size: 0.9em;
    color: #666;
    margin-bottom: 20px;
}

.instrucciones-app {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.os-box {
    background: white;
    border-radius: 10px;
    padding: 15px;
    text-align: left;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border-left: 5px solid #ccc;
}

.os-box.ios { border-left-color: #000; }
.os-box.android { border-left-color: #3DDC84; }

.os-box h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.os-box p {
    font-size: 0.9em;
    margin-bottom: 5px;
    line-height: 1.4;
}

.icono-mas {
    background: #e5e5ea;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: bold;
}

/* =========================================
   CUADRÍCULA DE TARJETAS (MÓDULO PRINCIPAL)
   ========================================= */
.contenedor-chollos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    max-width: 1300px;
    margin: 30px auto;
    padding: 0 20px;
}

/* =========================================
   DISEÑO DE LAS TARJETAS Y ANTI-CLS
   ========================================= */
.tarjeta {
    background-color: white;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    position: relative;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
    text-align: center;
}

.tarjeta:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.etiqueta-descuento {
    position: absolute;
    top: 12px;
    left: 12px;
    background-color: #e74c3c;
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.85em;
    z-index: 2;
}

/* CAJA DE IMAGEN BLINDADA CONTRA SALTOS VISUALES */
.imagen-contenedor {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* Cuadrado perfecto rígido */
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.imagen-contenedor img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* CAJA DE IMAGEN PARA LA PÁGINA INDIVIDUAL (chollo.php) */
.imagen-grande-wrapper {
    position: relative;
    width: 100%;
    max-width: 350px;
    aspect-ratio: 1 / 1;
    margin: 15px auto 25px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
}

.imagen-grande-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.tarjeta h3 {
    font-size: 0.95em;
    color: #2c3e50;
    margin-bottom: 12px;
    height: 42px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.3;
    font-weight: 600;
}

.caja-precios {
    margin-top: auto;
    margin-bottom: 12px;
}

.precio-anterior {
    font-size: 0.85em;
    color: #95a5a6;
    margin-bottom: 2px;
    min-height: 18px;
}

.precio-final {
    font-size: 1.45em;
    font-weight: bold;
    color: #ff7b00;
}

/* --- BOTONERA FLEXIBLE DOUBLE (IR AL CHOLLO + COMPARTIR) --- */
.botones-accion {
    display: flex;
    gap: 10px;
    width: 100%;
}

.boton {
    flex: 1; /* Estira el botón principal */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #2c3e50;
    color: white;
    text-decoration: none;
    padding: 11px 10px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.95em;
    transition: background-color 0.2s;
}

.boton:hover {
    background-color: #1a252f;
}

.boton-compartir {
    background-color: #bdc3c7; /* Botón gris */
    color: #333;
    border: none;
    padding: 0 15px;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.boton-compartir:hover {
    background-color: #95a5a6;
}

/* Efecto Verde cuando se copia el link */
.boton-compartir.exito {
    background-color: #27ae60 !important;
    color: white !important;
}

.boton-compartir:active {
    transform: scale(0.95);
}

.sin-datos {
    text-align: center;
    font-size: 1.2em;
    color: #7f8c8d;
    grid-column: 1 / -1;
    margin-top: 60px;
}

/* =========================================
   RESPONSIVE - ADAPTACIÓN PARA MÓVILES (2 COLUMNAS PERFECTAS)
   ========================================= */
@media (max-width: 768px) {
    .header-info-columnas {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .info-caja {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important; 
        padding: 15px;
    }

    .header-titulo-central h1 {
        font-size: 1.8em;
    }
    
    .btn-app {
        font-size: 0.9em;
        padding: 8px 16px;
    }

    /* TRUCO ANTI-DESBORDAMIENTO EN MÓVIL */
    .contenedor-chollos {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important; 
        gap: 10px !important; 
        padding: 10px !important;
        margin: 10px auto !important;
        width: 100% !important;
    }

    .tarjeta {
        padding: 10px !important;
        border-radius: 10px !important;
        min-width: 0 !important; 
        word-wrap: break-word !important; 
    }

    .imagen-contenedor {
        margin-bottom: 8px !important;
        /* NOTA: Eliminado el height: 130px para que el aspect-ratio funcione perfecto en móvil */
    }

    .tarjeta h3 {
        font-size: 0.8em !important;
        margin-bottom: 6px !important;
        height: 34px !important; 
    }

    .precio-anterior {
        font-size: 0.7em !important;
        min-height: 14px !important;
    }

    .precio-final {
        font-size: 1.1em !important;
    }

    .botones-accion {
        gap: 6px !important;
    }
    
    .boton {
        padding: 8px 4px !important;
        font-size: 0.8em !important;
        border-radius: 6px !important;
    }
    
    .boton-compartir {
        padding: 0 10px !important;
        font-size: 1em !important;
        border-radius: 6px !important;
    }

    .etiqueta-descuento {
        font-size: 0.7em !important;
        padding: 2px 4px !important;
        top: 6px !important;
        left: 6px !important;
        border-radius: 4px !important;
    }
}