/* css/style.css - COMPLETO (Versión MENÚ CORREGIDO + AJUSTE COLUMNAS) */
:root {
    --primary-color: #0075ff; /* Verde principal */
    --dark-text: #001e30;
    --light-text: #555;
    --background-light: #f4f7f6;
    --card-background: #ffffff;
    --border-light: #e0e0e0;
    --header-height: 70px; /* Altura fija para el header, ajústala si es necesario */
    --card-margin: 10px; /* Margen uniforme para las tarjetas */
}

body {
    font-family: "Figtree", 'Montserrat', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-light);
    color: var(--dark-text);
    line-height: 1.6;
    padding-top: var(--header-height);
}

.container {
    width: 90%;
    max-width: 1300px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Loader */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease-out, visibility 0s 0.5s;
    visibility: visible;
}
#page-loader.loader-hidden {
    opacity: 0;
    visibility: hidden;
}
.spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary-color);
    animation: spin 1s ease infinite;
}
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Header */
.site-header {
    background: #fff;
    padding: 11px 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--header-height);
    display: flex;
    align-items: center;
}
.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1300px;
    margin: 0 auto;
}
.logo img {
    height: 52px;
    vertical-align: middle;
}

/* --- Navegación Principal --- */
.main-navigation {
    position: relative; /* Para el posicionamiento absoluto del submenú móvil */
}

/* Botón de Hamburguesa (Solo visible en móvil) */
.menu-toggle {
    display: none; /* Oculto por defecto, se muestra en media query */
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1005;
    width: 30px;
    height: 40px;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
}
.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background-color: var(--dark-text);
    transition: all 0.3s ease-in-out;
    border-radius: 3px;
}
.menu-toggle.active span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* Contenedor del menú principal (UL) */
.menu-lista-principal {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Estilos para ESCRITORIO (cuando no se aplica la media query de móvil) */
.menu-lista-principal {
    display: flex; /* Menú horizontal en escritorio */
    align-items: center;
}
.menu-item-con-hijos {
    position: relative; /* Para el submenú */
}
.enlace-desplegable-escritorio {
    text-decoration: none;
    color: var(--dark-text);
    padding: 10px 15px;
    display: block;
    font-weight: 500;
    white-space: nowrap;
}
.enlace-desplegable-escritorio:hover {
    color: var(--primary-color);
}
.flecha-desplegable {
    font-size: 0.7em;
    margin-left: 4px;
}
.sub-menu-categorias {
    display: none; /* Oculto por defecto en escritorio, se muestra con hover */
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--card-background);
    min-width: 240px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
    border-radius: 0 0 6px 6px;
    padding: 10px 0;
    z-index: 1001;
    border-top: 3px solid var(--primary-color);
    border-top: 3px solid #1bed2e;
}
.menu-item-con-hijos:hover > .sub-menu-categorias {
    display: block; /* Mostrar en hover para escritorio */
}
.sub-menu-categorias li {
    display: block;
}
.sub-menu-categorias li a {
    padding: 10px 20px;
    text-decoration: none;
    color: var(--light-text);
    display: block;
    white-space: nowrap;
    font-size: 0.9em;
}
.sub-menu-categorias li a:hover {
    background-color: #f0f0f0;
    color: var(--primary-color);
}
.titulo-menu-movil { /* El título "Ver promos por categoría" */
    display: none; /* Oculto en escritorio por defecto */
}

/* Estilos para MÓVIL (max-width: 1000px o el breakpoint que definas) */
@media (max-width: 1000px) {
    .menu-toggle {
        display: flex; /* Mostrar botón hamburguesa */
    }

    .menu-lista-principal { /* El UL se convierte en el contenedor desplegable */
        display: none; /* Oculto por defecto, JS lo activa */
        flex-direction: column; /* Items apilados verticalmente */
        position: absolute;
        top: calc(var(--header-height) - 1px); /* Justo debajo del header */
        right: 0;
        width: 280px;
        max-width: 85vw;
        background-color: var(--card-background);
        box-shadow: -5px 5px 15px rgba(0,0,0,0.15);
        border-left: 1px solid var(--border-light);
        border-bottom: 1px solid var(--border-light);
        border-radius: 0 0 0 8px;
        padding: 0; /* El padding lo tendrán los elementos internos */
        z-index: 999;
        max-height: calc(100vh - var(--header-height) - 10px);
        overflow-y: auto;
    }
    .menu-lista-principal.active {
        display: block; /* JS añade esta clase para mostrar */
    }

    /* Ocultar el enlace de "Promociones por Categoría" en el <li> principal en móvil */
    .menu-item-con-hijos > .enlace-desplegable-escritorio {
        display: none;
    }

    /* El submenú se muestra directamente dentro del .menu-lista-principal en móvil */
    .menu-item-con-hijos .sub-menu-categorias {
        display: block !important; /* Asegurar que esté visible cuando el menú móvil esté activo */
        position: static !important;
        box-shadow: none !important;
        border: none !important;
        min-width: 100% !important;
        border-radius: 0 !important;
        padding: 0;
    }

    .titulo-menu-movil {
        display: block; /* Mostrar el título en el menú móvil desplegado */
        padding: 15px 20px;
        font-weight: bold;
        color: var(--dark-text);
        background-color: #f0f3f7;
        border-bottom: 1px solid var(--border-light);
        font-size: 1.05em;
        cursor: default; /* No es clicable */
    }

    .sub-menu-categorias li a { /* Estilos para los enlaces de categoría en móvil */
        padding: 13px 20px;
        border-bottom: 1px solid #f0f0f0;
    }
    .sub-menu-categorias li:last-child a {
        border-bottom: none;
    }
}


/* Hero Section */
.hero-section {
    /*background: var(--primary-color);*/
    background: #000;
    color: #fff;
    padding: 60px 0 70px;
    text-align: center;
}
.hero-section h1 {
    font-size: 2.5em;
    margin-bottom: 25px;
    font-weight: 800;
}
#typed-output {
    white-space: pre;
}
.category-quick-links {
    margin-top: 20px;
}
.category-quick-links a {
    display: inline-block;
    background: rgba(255,255,255,0.9);
    color: var(--dark-text);
    padding: 8px 18px;
    border-radius: 25px;
    margin: 5px 8px;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    transition: background-color 0.3s ease, transform 0.2s ease;
}
.category-quick-links a:hover {
    background-color: #fff;
    transform: translateY(-2px);
}

/* Secciones de Promociones */
.promo-section {
    padding: 50px 0;
}
.promo-section h2 {
    text-align: left;
    margin-bottom: 30px;
    font-size: 2.2em;
    color: var(--dark-text);
    font-weight: 700;
    border-bottom: 0px solid var(--primary-color);
    padding-bottom: 10px;
    display: inline-block;
}
.promo-grid {
    display: flex;
    flex-wrap: wrap;
    margin: 0 calc(var(--card-margin) * -1); /* Para compensar el padding/margin de las tarjetas */
}
.promo-card {
    background: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 50, 20, 0.08);
    overflow: visible;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin: var(--card-margin); /* Espacio uniforme alrededor de cada tarjeta */
    box-sizing: border-box;
}
.promo-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 10px 30px rgba(0, 50, 20, 0.12);
}

.promo-grid--destacadas .promo-card {
    /* Por defecto (móvil), 1 columna. Las media queries lo ajustarán. */
    flex-basis: calc(100% - (var(--card-margin) * 2));
}
.promo-grid--destacadas .promo-image-wrap {
    height: 320px;
}

.promo-grid--category .promo-card {
    /* Por defecto (móvil), 1 columna */
    flex-basis: calc(100% - (var(--card-margin) * 2));
}

/* --- AJUSTE DE COLUMNAS PARA PROMOS DE CATEGORÍA --- */

/* Móviles muy pequeños (opcional, si quieres ser más granular) */
/* @media (max-width: 480px) { ... } */

/* Móviles y tablets pequeñas (1 columna por defecto ya está arriba) */
@media (min-width: 601px) { /* A partir de 601px, intenta 2 columnas */
    .promo-grid--category .promo-card {
        flex-basis: calc(50% - (var(--card-margin) * 2));
    }
    .promo-grid--destacadas .promo-card { /* Destacadas también a 2 columnas */
        flex-basis: calc(50% - (var(--card-margin) * 2));
    }
}

@media (min-width: 992px) { /* A partir de 992px, intenta 3 columnas para categorías */
    .promo-grid--category .promo-card {
        flex-basis: calc(33.333% - (var(--card-margin) * 2));
    }
    /* Destacadas pueden seguir a 2 columnas o ajustarse si es necesario */
}

/* Para pantallas grandes: 4 columnas para categorías */
@media (min-width: 1200px) {
    .promo-grid--category .promo-card {
        flex-basis: calc(25% - (var(--card-margin) * 2)); /* 4 columnas */
    }
    /* Destacadas pueden seguir a 2 columnas o ajustarse si es necesario */
}


.promo-image-wrap {
    position: relative;
    width: 100%;
    height: 200px;
    border-radius: 12px 12px 0 0;
}
.post-featured-img {
    display: block;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    border-radius: 12px 12px 0 0;
    background-image: url('../archive/loading.gif'); /* Fallback mientras carga data-bg */
}

/*
.merchant-logo {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 8px;
    border-radius: 50%;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
*/

.merchant-logo {
    position: absolute;
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 8px;
    border-radius: 20px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
    width: 120px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}


.merchant-logo img {
    max-width: 85%;
    max-height: 85%;
    object-fit: contain;
}
.offer-tag {
    position: absolute;
    top: 15px;
    left: 15px;
    background: var(--primary-color);
    background: #01c258 !important;
    color: #fff;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.8em;
    font-weight: bold;
    z-index: 1;
}

.promo-content {
    padding: 50px 20px 20px 20px;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.promo-content h3 {
    font-size: 1.3em;
    margin-top: 0;
    margin-bottom: 12px;
    color: var(--dark-text);
    font-weight: 700;
    min-height: 48px; /* Ajusta para 2 líneas de título promedio */
    display: -webkit-box; /* Opcional: para truncar texto a X líneas */
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.promo-body {
    font-size: 0.95em;
    color: var(--light-text);
    margin-bottom: 20px;
    flex-grow: 1; /* Para que ocupe espacio disponible */
    min-height: 60px; /* Para unas 3 líneas */
    /*display: -webkit-box; /* Opcional: para truncar texto a X líneas *
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;*/
    overflow: hidden;
}
.promo-body b, .promo-body strong { font-weight: 700; }
.promo-actions {
    margin-top: auto; /* Empuja botones al final */
}
.promo-actions .cta-button, .promo-actions .tyc-button {
    display: inline-block;
    padding: 10px 22px;
    text-decoration: none;
    border-radius: 25px;
    font-weight: 500;
    margin: 8px 5px;
    transition: background-color 0.3s ease, transform 0.2s ease;
    cursor: pointer;
    border: 0px solid transparent;
    font-size: 0.9em;
}
.promo-actions .cta-button {
    background-color: var(--primary-color);
    background-color: #1bed2e;
    color: #000;
    border: solid 3px #111;
}
.promo-actions .cta-button:hover {
    /*background-color: #007a37;*/
    background-color: #10b61f;
    transform: translateY(-1px);
}
.promo-actions .tyc-button {
    /*background-color: #f0f0f0;
    color: #444;
    border-color: #ccc;*/
    color: #07b817;
    background-color: #fff;
}
.promo-actions .tyc-button:hover {
    /*background-color: #e0e0e0;*/
    transform: translateY(-1px);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    padding-top: 5vh;
}
.modal.active {
    display: block;
}
.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border: none;
    border-radius: 8px;
    width: 80%;
    max-width: 700px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.25);
    position: relative;
    animation: modalAppear 0.3s ease-out;
}
@keyframes modalAppear {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}
.close-modal-button {
    color: #777;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 30px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
}
.close-modal-button:hover,
.close-modal-button:focus {
    color: #000;
    text-decoration: none;
}
.modal-content h4 {
    margin-top: 0;
    color: var(--dark-text);
    font-size: 1.5em;
    margin-bottom: 20px;
}
.modal-body {
    font-size: 0.95em;
    line-height: 1.7;
    color: var(--light-text);
    max-height: 60vh;
    overflow-y: auto;
}
.modal-body p {
    margin-bottom: 1em;
}

/* Footer */
.site-footer {
    background: #2b2b2b;
    color: #ccc;
    background: #ededed;
    color: #373737;
    text-align: center;
    padding: 30px 0;
    margin-top: 50px;
    font-size: 0.9em;
}

/* Error Messages */
.error-message {
    background-color: #ffdddd;
    border: 1px solid #ffaaaa;
    color: #d8000c;
    padding: 15px;
    margin: 20px 0;
    border-radius: 5px;
}
.error-message ul {
    margin: 0;
    padding-left: 20px;
}