/* === Variables globales === */
:root {
    --color-principal: #1B8F3A;
    --color-acento: green;
    --color-acento-secundario: #A67C52;
    --color-fondo: #F3F5EF;
    --color-texto: #1A1A1A;
    --color-texto-footer: #2A2A2A;
}

/* === Box-sizing global === */
*, *::before, *::after {
    box-sizing: border-box;
}

/* === Reset básico y layout general === */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: Arial, sans-serif;
    background-color: var(--color-fondo);
    color: var(--color-texto);
}

.container, .page-content {
    width: 95%;
    max-width: 1200px;
    margin: 0 auto;
    flex: 1;
}

/* === Header === */
header {
    background-color: var(--color-principal);
    color: #fff;
    padding: 25px 0 35px;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* Logo y carrito alineados */
.header-top {
    display: flex;
    justify-content: center; /* Centrado horizontal */
    align-items: center;
    gap: 20px; /* Espacio entre logo y carrito */
    position: relative;
    width: 100%;
}

header .logo img {
    width: 220px;
    height: 60px;
    object-fit: contain;
}

/* CARRITO */
.cart-link {
    font-size: 28px;
    color: #fff;
    text-decoration: none;
}

/* HAMBURGUESA */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 32px;
    color: #fff;
    cursor: pointer;
    margin-top: 15px; /* Separación debajo de logo y carrito */
}

/* === Navegación === */
nav {
    margin-top: 10px;
    width: 100%;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

nav a {
    color: #fff;
    text-decoration: none;
    margin: 0 12px;
    font-size: 1em;
    transition: color 0.2s ease;
}

nav a:hover {
    color: var(--color-acento);
}

/* ========================== */
/* === MENÚ MÓVIL PERFECTO === */
/* ========================== */
@media screen and (max-width: 768px) {

    /* Ocultar menú normal */
    nav ul {
        display: none;
    }

    .menu-toggle {
        display: block;
    }

    /* Cuando se abre el menú */
    nav.open {
        display: block;
        position: absolute;
        top: 100%; /* Justo debajo del header */
        left: 0;
        width: 100%;
        background: var(--color-principal);
        padding: 20px 0;
        animation: fadeInMenu 0.2s ease-in-out;
        z-index: 10;
        text-align: center;
    }

    nav.open ul {
        display: flex;
        flex-direction: column;
        gap: 18px;
        padding: 0;
        margin: 0 auto;
        width: 100%;
    }

    nav.open a {
        font-size: 1.2em;
        display: block;
        width: 100%;
    }

    /* Ajuste logo y carrito en móvil */
    .header-top {
        flex-direction: row;
        justify-content: center;
        gap: 15px;
    }
}

@keyframes fadeInMenu {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================================ */
/* === Barra de búsqueda (igual) === */
/* ================================ */
.search-bar {
    text-align: center;
    padding: 50px 0;
}

.search-bar input {
    width: 60%;
    max-width: 600px;
    min-width: 200px;
    padding: 20px;
    border: 1px solid #ccc;
    border-radius: 30px;
    font-size: 1em;
    text-align: center;
    color: #242424;
    background-color: #daf8dc;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--color-acento);
    box-shadow: 0 0 5px rgba(255,59,59,0.5);
}

.search-bar input::placeholder {
    color: #c6c2c2;
}

/* === Contenedor de productos === */
#productContainer {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    padding: 10px;
}

.product-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
    height: 100%;
    text-align: center;
}

.product-card:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* Imagen */
.product-images {
    width: 100%;
    background: #f8f8f8;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.product-images img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    display: none;
}

.product-images img.active {
    display: block;
}

/* Carousel */
.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 1.5em;
    border-radius: 6px;
    z-index: 2;
}

.carousel-btn.prev { left: 8px; }
.carousel-btn.next { right: 8px; }

.carousel-btn:hover {
    background: var(--color-acento);
}

/* Info */
.product-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    text-align: center;
}

/* Precio */
.product-price {
    font-weight: bold;
    color: var(--color-acento);
}
.product-price::before { content: "₡"; margin-right: 2px; }

/* Detalles */
.product-details {
    width: 100%;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 0 0 8px 8px;
    text-align: center;
}

.product-details span {
    display: inline-block;
    margin-right: 8px;
    font-size: 0.9em;
    color: #555;
}

/* === Paginación === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 30px 0;
    list-style: none;
}

.pagination a, .page-btn {
    padding: 10px 15px;
    border-radius: 6px;
    background: #ddd;
    text-decoration: none;
    color: #333;
    font-weight: bold;
    transition: 0.3s;
}

.pagination a.active, .page-btn.active {
    background: var(--color-principal);
    color: #fff;
}

.pagination a:hover, .page-btn:hover:not(.active) {
    background: var(--color-acento);
    color: #fff;
}

/* === Scroll Top === */
#backToTop {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: #333;
    color: white;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 22px;
    cursor: pointer;
    z-index: 9999;
    opacity: 0.8;
    display: none;
}

#backToTop:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* === Footer === */
footer {
    background: var(--color-principal);
    color: #fff;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
}

/* === Responsive grid === */
@media screen and (max-width: 768px) {
    #productContainer { grid-template-columns: 1fr; }
}

@media screen and (min-width: 769px) and (max-width: 1024px) {
    #productContainer { grid-template-columns: repeat(2, 1fr); }
}

@media screen and (min-width: 1025px) {
    #productContainer { grid-template-columns: repeat(4, 1fr); }
}