:root {
    /* Paleta de Colores */
    --granate: #7b2d26;
    --beige: #f2e5d7;
    --marron: #5c3b2e;
    --ocre: #c9a66b;
    --claro: #fffaf5;
    --blanco: #ffffff;

    /* Efectos */
    --sombra: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --transicion: all 0.3s ease;
}

/* --- Reseteo Básico --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--claro);
    color: var(--marron);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header y Barra Superior --- */
header {
    background-color: var(--granate);
    color: var(--blanco);
    padding: 1rem 2rem;
    box-shadow: var(--sombra);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
}

.logo img {
    height: 60px;
    display: block;
}

/* --- NAVEGACIÓN (Corrección del Menú) --- */
.nav-container {
    background-color: var(--beige);
    border-bottom: 2px solid var(--ocre);
    position: sticky;
    /* Se queda fijo al hacer scroll */
    top: 0;
    z-index: 1000;
    /* Siempre por encima del contenido */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

nav ul {
    list-style: none;
    display: flex;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
    gap: 0;
    /* Quitamos gap para que los bloques se toquen */
}

/* Items Principales */
.menu-item {
    position: relative;
    /* CRÍTICO: Ancla para el submenú */
}

.menu-item>a {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--granate);
    text-decoration: none;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.9rem;
    transition: var(--transicion);
}

.menu-item>a:hover {
    background-color: var(--ocre);
    color: var(--blanco);
}

/* SUBMENÚ DESPLEGABLE */
.submenu {
    display: none;
    /* Oculto por defecto */
    position: absolute;
    /* Flota sobre el contenido */
    top: 100%;
    /* Justo debajo del padre */
    left: 0;
    background-color: var(--granate);
    min-width: 220px;
    flex-direction: column;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    border-top: 3px solid var(--ocre);
    z-index: 1001;
}

/* Mostrar al pasar el ratón por el padre (.menu-item) */
.menu-item:hover .submenu {
    display: flex;
}

.submenu li {
    width: 100%;
}

.submenu li a {
    padding: 12px 20px;
    color: var(--blanco);
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    text-transform: none;
    transition: background 0.2s;
}

.submenu li a:hover {
    background-color: var(--marron);
    padding-left: 25px;
    /* Pequeño desplazamiento */
}

/* --- Layout Principal --- */
main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    flex: 1;
    /* Empuja el footer hacia abajo */
    width: 100%;
}

h1,
h2,
h3 {
    color: var(--granate);
    text-align: center;
    margin-bottom: 1.5rem;
}

/* --- Grid de Artículos (Tarjetas) --- */
.grid-articulos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    padding: 1rem 0;
}

.card {
    background: var(--blanco);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--sombra);
    transition: var(--transicion);
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.card-img-wrapper {
    height: 250px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
}

.card-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Recorta la imagen para llenar el hueco */
    transition: transform 0.5s ease;
}

.card:hover .card-img-wrapper img {
    transform: scale(1.08);
}

.card-body {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0 0 0.8rem 0;
    color: var(--marron);
    text-align: left;
}

.card-desc {
    font-size: 0.9rem;
    color: #666;
    flex-grow: 1;
    line-height: 1.5;
    text-align: left;
}

/* --- Utilidades --- */
.btn {
    display: inline-block;
    background: var(--granate);
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
    cursor: pointer;
    border: none;
}

.btn:hover {
    background-color: var(--marron);
}

.alert {
    padding: 1rem;
    background-color: var(--beige);
    color: var(--marron);
    border-left: 4px solid var(--granate);
    margin: 1rem 0;
    border-radius: 4px;
}

/* --- Footer --- */
footer {
    background-color: var(--marron);
    color: var(--beige);
    text-align: center;
    padding: 3rem 1rem;
    margin-top: 4rem;
}

footer a {
    color: var(--ocre);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

footer a:hover {
    color: var(--blanco);
    text-decoration: underline;
}

/* --- Modales (Lightbox y Legal) --- */

/* Estilos para el Modal de Textos Legales */
.modal-legal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    /* Efecto borroso fondo */
    justify-content: center;
    align-items: center;
}

.modal-legal-content {
    background-color: #fff;
    padding: 2.5rem;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease-out;
}

.close-legal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 30px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.close-legal:hover {
    color: var(--granate);
}

/* Contenido dentro del modal (HTML del editor) */
.legal-body {
    color: #333;
    line-height: 1.8;
    font-size: 1rem;
}

.legal-body h1,
.legal-body h2,
.legal-body h3 {
    text-align: left;
    margin-top: 1.5rem;
}

.legal-body ul,
.legal-body ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.legal-body p {
    margin-bottom: 1rem;
}

/* Estilo para el Lightbox de Imágenes (Productos) */
#lightbox {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
}

#lightbox img {
    max-width: 90%;
    max-height: 90%;
    border: 4px solid white;
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    cursor: pointer;
}

/* --- Animaciones --- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Responsive (Móvil) --- */
@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        gap: 10px;
    }

    .nav-container {
        overflow-x: auto;
    }

    /* Scroll lateral en menú móvil */

    nav ul {
        width: max-content;
        /* Permite que el menú sea más ancho que la pantalla */
        padding: 0 10px;
    }

    .menu-item>a {
        padding: 1rem 0.8rem;
        font-size: 0.8rem;
    }

    .grid-articulos {
        grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
        /* 1 columna en móvil */
    }

    /* Ajuste submenú en móvil */
    .submenu {
        position: static;
        box-shadow: none;
        border-left: 3px solid var(--ocre);
    }
}

/* --- INFO CONTACTO EN CABECERA --- */
.header-info {
    display: flex;
    gap: 2rem;
    /* Separación entre elementos */
    align-items: center;
    margin: 0 20px;
    flex-grow: 1;
    /* Ocupa el espacio disponible */
    justify-content: center;
    /* Centrado entre logo y redes */
}

.info-item {
    display: flex;
    flex-direction: column;
    /* Icono arriba o lado, texto abajo */
    align-items: center;
    font-size: 0.85rem;
    color: var(--beige);
    line-height: 1.3;
}

.info-item i {
    color: var(--ocre);
    /* Icono dorado */
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.info-item span {
    white-space: nowrap;
    /* Evita que el texto se parta feo */
}

/* En móviles ocultamos esta info de cabecera porque no cabe */
@media (max-width: 900px) {
    .header-info {
        display: none;
    }
}