/* --- VARIABLES Y RESET BÁSICO --- */
:root {
    --primary-color: #0a192f;
    --secondary-color: #64ffda;
    --background-color: #f5f6fa;
    --text-color: #4a4a4a;
    --text-primary: #0a192f;
    --text-secondary: #777;
    --hover-color: #1d273b;
    --brand-color: #28a745;
    --accent-color: #28a745; /* Verde para botones */
    --accent-hover-color: #218838;
    --card-bg-color: #ffffff;
    --border-color: #e1e4e8;
    --header-border: #e1e4e8;
    --accent-light: #e6f4ea;
    --discount-color: #e74c3c;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-top: 80px; 
}

a {
    color: var(--accent-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.main-content img, .prose img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* --- MOBILE-FIRST: Estilos base --- */

.page {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1.5rem;
}

.sidebar-left {
    display: none; /* Oculto en móvil por defecto */
    width: 100%;
    background-color: #ffffff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    height: fit-content;
}

.sidebar-left.is-visible {
    display: block;
}

.category-toggle-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background-color: var(--accent-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    margin-bottom: 1rem;
}

.main-content {
    width: 100%;
}

/* Sidebar Left Content */
.sidebar-left h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    padding-bottom: 10px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--header-border);
}

.lista-empresas {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.empresa-link {
    display: block;
    padding: 10px 15px;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
    border: 1px solid transparent;
}

.empresa-link:hover {
    background-color: #f7f7f7;
    color: var(--brand-color);
}

.empresa-link.active {
    background-color: #fff5e6;
    color: var(--brand-color);
    font-weight: 700;
    border: 1px solid var(--brand-color);
}

/* --- BLOG (Sidebar Right) --- */

.sidebar-right .blog-section-title {
    font-size: 1.2rem;
    font-weight: 600;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.sidebar-right .blog-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Forzamos que la imagen esté arriba en móvil */
.sidebar-right .blog-card {
    display: flex;
    flex-direction: column; /* Alineación vertical: imagen arriba, texto abajo */
    background-color: var(--card-bg-color);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease;
}

.sidebar-right .blog-card:hover {
    transform: translateY(-3px);
}

/* Asegurar que el enlace de la imagen ocupe todo el ancho arriba */
.sidebar-right .blog-card a:has(.blog-img), 
.sidebar-right .blog-card > a {
    display: block;
    width: 100%;
}

.sidebar-right .blog-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

/* El contenedor del texto (div:nth-child(2)) */
.sidebar-right .blog-card div {
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.sidebar-right .blog-card h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
    color: var(--text-primary);
}

.sidebar-right .blog-card .autor {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* --- LISTADO DE CHOLLOS --- */
.chollos-list-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    align-items: stretch;
}

.chollo-list-item {
    background-color: var(--card-bg-color);
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    min-height: 380px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chollo-list-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.chollo-list-img {
    position: relative;
    width: 100%;
    height: 180px;
}

.chollo-list-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.discount-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: #e74c3c;
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: bold;
}

.chollo-list-content {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.chollo-list-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.2rem;
}

.price-container {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.price-actual {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
}

.price-habitual {
    color: #e74c3c;
    text-decoration: line-through;
    font-size: 1rem;
}

.gastos-envio {
    font-size: 0.8rem;
    color: #777;
    margin-bottom: 1rem;
}

.gastos-envio.gratis {
    color: var(--accent-color);
    font-weight: bold;
}

.chollo-list-link {
    background-color: var(--accent-color);
    color: white;
    font-weight: bold;
    text-align: center;
    padding: 12px 20px;
    border-radius: 8px;
    margin-top: auto;
    transition: background-color 0.2s ease;
}

/* --- TABLET: A partir de 768px --- */
@media (min-width: 768px) {
    .page {
        padding: 1.5rem;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }

    .category-toggle-btn {
        display: none;
    }

    .sidebar-left {
        display: block;
        flex: 0 0 220px;
        order: -1;
    }
    
    .main-content {
        flex: 1;
        min-width: 0;
    }

    .chollos-list-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* --- DESKTOP: A partir de 1024px --- */
@media (min-width: 1024px) {
    body {
        padding-top: 60px;
    }

    .sub-header-nav {
        display: block;
        position: fixed;
        top: 60px;
        left: 0;
        width: 100%;
        background-color: var(--card-bg-color);
        box-shadow: 0 2px 5px rgba(0,0,0,0.05);
        padding: 0.5rem 1rem;
        z-index: 998;
    }

    .page {
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 2rem;
    }

    .sidebar-right {
        display: block;
        flex: 0 0 280px;
    }

    .chollos-list-container {
        grid-template-columns: repeat(3, 1fr);
    }

    /* Ajuste para que en Escritorio vuelva a ser horizontal y compacto */
    .sidebar-right .blog-card {
        flex-direction: row; 
        align-items: center;
        background-color: transparent;
        box-shadow: none;
        gap: 1rem;
        margin-bottom: 1.2rem;
    }

    .sidebar-right .blog-card a:has(.blog-img), 
    .sidebar-right .blog-card > a {
        display: block;
        width: 80px; /* Tamaño fijo en escritorio lateral */
        flex: 0 0 80px;
    }

    .sidebar-right .blog-img {
        height: 80px;
        border-radius: 8px;
    }

    .sidebar-right .blog-card div {
        padding: 0;
    }

    .sidebar-right .blog-card h3 {
        font-size: 0.95rem;
    }
}

/* --- DESKTOP GRANDE: A partir de 1440px --- */
@media (min-width: 1440px) {
    .chollos-list-container {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* === PÁGINA DE DETALLE (dentro.php) === */
.chollo-detail-card {
    background-color: var(--card-bg-color);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.chollo-detail-grid {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 2rem;
}

@media (min-width: 768px) {
    .chollo-detail-grid {
        grid-template-columns: 2fr 3fr;
    }
    .chollo-detail-card {
        padding: 2rem;
    }
}

.chollo-detail-image {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
}

.chollo-detail-image img {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background-color: #fdfdfd;
}

.discount-badge-detail {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: var(--discount-color);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
}

.chollo-title {
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.price-box {
    background-color: #fff9f2;
    border: 2px dashed #ffe8d1;
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1rem;
    text-align: center;
}

.price-box .current-price {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--brand-color);
}

.coupon-box {
    border: 2px dashed #d1e7dd;
    background-color: #f8fdfb;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    text-align: center;
    margin-bottom: 1.5rem;
}

.cta-button {
    background-color: var(--accent-color);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    padding: 10px 18px;
    border-radius: 999px;
    width: auto;
    min-width: 220px;
    max-width: 280px;
    align-self: flex-start;
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.cta-button:hover {
    background-color: var(--accent-hover-color);
    transform: translateY(-1px);
}

/* --- COMENTARIOS --- */
.comments-area {
    background-color: var(--card-bg-color);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.comment-form-wrapper textarea {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 10px;
}

/* --- ESTADOS CADUCADOS --- */
.chollo-list-item.chollo-caducado {
    position: relative;
    filter: grayscale(1);
    opacity: 0.7;
}

.chollo-list-item.chollo-caducado .chollo-list-link {
    background-color: #6c757d;
    cursor: not-allowed;
}

.chollo-list-item.chollo-caducado::before {
    content: "CADUCADO";
    position: absolute;
    top: 8px;
    left: -32px;
    transform: rotate(-45deg);
    background-color: #e74c3c;
    color: #fff;
    font-size: 0.75rem;
    font-weight: bold;
    padding: 4px 40px;
    text-align: center;
    z-index: 10;
    pointer-events: none;
}
