/* --- Variables de Color (Basadas en el logo) --- */
:root {
    --color-primary-red: #E60000;  /* Rojo principal del logo */
    --color-primary-yellow: #FFC300; /* Amarillo/Dorado del logo */
    --color-text-light: #FFFFFF;
    --color-text-dark: #333333;
    --color-background: #f4f4f4;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* --- Estilos Globales --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
/* --- Variables de Color (Basadas en el logo) --- */
:root {
    --color-primary-red: #E60000;  /* Rojo principal del logo */
    --color-primary-yellow: #FFC300; /* Amarillo/Dorado del logo */
    --color-text-light: #FFFFFF;
    --color-text-dark: #333333;
    --color-background: #f4f4f4;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

body {
    font-family: Arial, sans-serif;
    background-color: var(--color-background);
    color: var(--color-text-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- 1. Encabezado --- */
.main-header {
    background-color: var(--color-primary-red);
    color: var(--color-text-light);
    padding: 10px 0;
    box-shadow: var(--shadow);
}

/* NUEVOS ESTILOS PARA LA INFORMACIÓN DEL ENCABEZADO */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-info {
    text-align: left;
}

.store-name {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 3px;
    letter-spacing: 1px;
}

.store-slogan {
    font-size: 1rem;
    font-style: italic;
    margin-bottom: 8px;
    opacity: 0.9;
}

.contact-info {
    font-size: 0.85rem;
    opacity: 0.8;
}

.contact-info a {
    color: var(--color-text-light); /* Enlaces blancos */
    text-decoration: none;
    font-weight: bold;
}

.contact-info a:hover {
    text-decoration: underline;
}
/* FIN DE NUEVOS ESTILOS */

.logo-and-cart {
    display: flex;
    align-items: center; /* Alinea verticalmente el logo y el carrito */
    gap: 30px; /* Espacio entre el logo y el carrito */
}

.header-logo {
    height: 150px; /* Altura definida para el logo */
    width: auto; /* Mantiene la proporción */
}


.cart-widget {
    font-size: 1.5rem;
    font-weight: bold;
}

/* --- 2. Contenido Principal (Layout) --- */
.page-content {
    display: grid;
    /* Corrección: Definir 3 columnas explícitas */
    grid-template-columns: 200px 1fr 300px; 
    gap: 30px;
    margin-top: 30px;
}

/* --- Cuadrícula de Productos --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.product-card {
    background-color: var(--color-text-light);
    border-radius: 8px;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.product-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background-color: #eee;
}

.product-card-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-card-info h3 {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.product-price {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--color-primary-red);
    margin-bottom: 15px;
}

.btn-add-cart {
    background-color: var(--color-primary-red);
    color: var(--color-text-light);
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    margin-top: auto; /* Empuja el botón al fondo */
    transition: background-color 0.2s;
}

.btn-add-cart:hover {
    background-color: #c00000; /* Rojo más oscuro */
}

/* --- Barra lateral del Carrito --- */
.cart-sidebar {
    background-color: var(--color-text-light);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
    align-self: flex-start; /* Se queda arriba */
}

.cart-sidebar h2 {
    background-color: var(--color-primary-yellow);
    color: var(--color-text-dark);
    padding: 10px;
    text-align: center;
    border-radius: 5px;
    margin: -20px -20px 20px -20px; /* Se ajusta al padding del padre */
}

#cart-items {
    list-style: none;
    margin-bottom: 20px;

    /* --- LÍNEAS NUEVAS --- */
    flex-grow: 1;              /* 1. Hace que la lista ocupe todo el espacio libre */
    overflow-y: auto;          /* 2. AÑADE EL SCROLL si la lista es muy larga */
    padding-right: 5px;        /* 3. (Opcional) Espacio para que el scrollbar no tape el texto */
}

#cart-items li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.cart-empty {
    color: #888;
    text-align: center;
}

.cart-total {
    font-size: 1.3rem;
    text-align: right;
    margin-bottom: 20px;
}

.btn-checkout {
    background-color: #008000; /* Verde para finalizar compra */
    color: white;
    border: none;
    padding: 12px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    width: 100%;
    font-size: 1.1rem;
    transition: background-color 0.2s;
}

.btn-checkout:hover {
    background-color: #006400; /* Verde más oscuro */
}

/* --- Estilos Adicionales para el Carrito --- */

/* Sobrescribimos el 'li' básico para que use Flexbox */
#cart-items li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.cart-item-info {
    flex-grow: 1; /* Ocupa el espacio disponible */
    font-size: 0.9rem;
}

/* Pone el precio total del item debajo del nombre */
.cart-item-info span {
    display: block; 
    font-size: 0.8rem;
    color: #555;
}

.cart-item-controls {
    display: flex;
    align-items: center;
}

.quantity-controls {
    display: flex;
    align-items: center;
    margin-right: 10px;
}

/* Estilo para los botones [+] y [-] */
.quantity-controls button {
    background-color: #eee;
    border: none;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-weight: bold;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.quantity-controls button:hover {
    background-color: #ddd;
}

/* El número de la cantidad (ej: "3") */
.quantity-controls span {
    padding: 0 10px;
    font-weight: bold;
    min-width: 20px;
    text-align: center;
}

/* Estilo para el botón de Quitar [X] */
.btn-remove-item {
    background-color: #ffcccc; /* Rojo claro */
    color: var(--color-primary-red);
    border: none;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-weight: bold;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 25px; /* Centra la 'x' */
    transition: all 0.2s;
}

.btn-remove-item:hover {
    background-color: var(--color-primary-red);
    color: white;
}
.product-grid-header {
    font-size: 1.5rem;
    margin-bottom: 20px; /* Le da espacio antes de la cuadrícula */
    color: var(--color-text-dark);
}

/* --- Estilos para los Filtros --- */
.filter-controls {
    display: flex;
    gap: 15px; /* Espacio entre la barra y el select */
    margin-bottom: 20px; /* Espacio antes de la cuadrícula */
}

.filter-controls input,
.filter-controls select {
    padding: 10px;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.filter-controls input[type="text"] {
    flex-grow: 1; /* Hace que la barra de búsqueda ocupe el espacio */
}

.filter-controls select {
    background-color: white;
}

/* --- Estilo para el botón "Cargar Más" --- */
.btn-load-more {
    display: block; /* Ocupa todo el ancho */
    width: 100%;
    padding: 15px;
    margin-top: 20px; /* Espacio después de la cuadrícula */
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--color-primary-red);
    background-color: white;
    border: 2px solid var(--color-primary-red);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-load-more:hover {
    background-color: var(--color-primary-red);
    color: white;
}

/* Para ocultar el botón si no hay más productos */
.btn-load-more.hidden {
    display: none;
}

/* --- Barra lateral del Carrito --- */
.cart-sidebar {
    background-color: var(--color-text-light);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
    align-self: flex-start; 
    position: sticky;
    top: 20px;

    /* --- LÍNEAS NUEVAS --- */
    display: flex;             /* 1. Activa Flexbox */
    flex-direction: column;    /* 2. Apila los hijos (título, lista, total) */
    max-height: 90vh;          /* 3. Altura máxima = 90% de la altura de la pantalla */
                               /* (vh = viewport height) */
}

/* --- Estilos para controles de peso --- */
.weight-controls {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-top: auto; /* Empuja al fondo */
}
.weight-input {
    width: 60%; /* Ocupa la mayoría del espacio */
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}
.weight-controls span {
    font-weight: bold;
}
.btn-add-weight {
    background-color: var(--color-primary-red);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    flex-grow: 1; /* Ocupa espacio restante */
}

/* --- Estilos del Modal de Checkout --- */

.modal-overlay {
    /* Oculto por defecto */
    display: none; 
    
    /* Fondo oscuro semitransparente */
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);

    /* Centrado (movido a la clase .active) */
    justify-content: center;
    align-items: center;
}

/* Clase que le pondremos con JS para mostrarlo */
.modal-overlay.active {
    display: flex;
}

.modal-content {
    background-color: white;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    width: 90%;
    max-width: 500px; /* Ancho máximo */
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    margin-bottom: 20px;
    padding-bottom: 10px;
}

.close-modal {
    font-size: 2.5rem;
    font-weight: bold;
    color: #888;
    cursor: pointer;
    line-height: 1;
}
.close-modal:hover {
    color: #333;
}

/* Estilos del Formulario */
#checkout-form p {
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: #555;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.form-group input, .form-group select {
    width: 100%;
    padding: 10px;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.btn-checkout-submit {
    /* Reutilizamos el estilo del botón verde */
    background-color: #008000;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    width: 100%;
    font-size: 1.1rem;
    margin-top: 10px;
}

.btn-checkout-submit:hover {
    background-color: #006400;
}

/* --- Estilos para el Stock --- */
.product-stock {
    font-size: 0.9rem;
    margin-bottom: 5px;
    font-weight: bold;
}

/* Stock normal (Verde oscuro o Gris) */
.stock-normal {
    color: #28a745; /* Verde confianza */
}

/* Stock bajo (Rojo urgencia) */
.stock-low {
    color: #dc3545; /* Rojo alerta */
    animation: pulse 2s infinite; /* (Opcional) Un efecto sutil */
}

/* (Opcional) Animación para llamar la atención si hay poco */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* --- Estilos para Notificaciones Toast --- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000; /* Asegura que esté por encima de todo */
}

.toast {
    background-color: var(--color-text-dark);
    color: var(--color-text-light);
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    opacity: 0; /* Empieza invisible */
    transition: opacity 0.3s, transform 0.3s;
    transform: translateY(10px);
    min-width: 250px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Tipos de Toast */
.toast.success { background-color: #28a745; } /* Verde para éxito */
.toast.warning { background-color: var(--color-primary-yellow); color: var(--color-text-dark); } /* Amarillo para alerta */
.toast.error { background-color: var(--color-primary-red); } /* Rojo para errores */

/* --- Nuevos estilos para la barra lateral de anuncios --- */
.ad-sidebar {
    background-color: var(--color-text-light);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 20px;
    align-self: flex-start; 
    position: sticky;
    top: 20px;
}

.ad-sidebar h2 {
    background-color: var(--color-primary-yellow);
    color: var(--color-text-dark);
    padding: 10px;
    text-align: center;
    border-radius: 5px;
    margin: -20px -20px 20px -20px;
}

.ad-card {
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.ad-placeholder {
    padding: 15px;
    text-align: center;
    color: #888;
}

.ad-content img {
    width: 100%;
    height: auto;
    display: block;
}

.header-separator {
    width: 2px; /* Ancho de la línea vertical */
    height: 60px; /* Altura para centrarlo con la información */
    background-color: var(--color-primary-yellow); /* Color llamativo */
    margin: 0 25px; /* Espacio a los lados del separador */
    border-radius: 1px;
    box-shadow: 0 0 5px rgba(255, 195, 0, 0.5); /* Efecto suave de brillo */
}

