/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=Open+Sans:wght@400;600&family=Roboto+Slab:wght@400;700&display=swap');

/* --- CSS Variables --- */
:root {
    --font-primary: 'Open Sans', sans-serif;
    --font-headings: 'Playfair Display', serif; /* Elegant serif for headings */
    --font-special: 'Roboto Slab', serif; /* For specific elements if needed */

    --color-text: #333;
    --color-text-light: #555;
    --color-background: #F8F9FA; /* Very light grey, almost white */
    --color-surface: #FFFFFF; /* Pure white for cards, pop-ups */
    --color-primary: #0A0A0A; /* Dark charcoal, almost black */
    --color-accent: #B08D57; /* A refined, slightly desaturated gold */
    --color-accent-dark: #8c6d41; /* Darker gold for hover states */
    --color-border: #E0E0E0; /* Light border color */
    --color-danger: #D9534F;
    --color-success: #28a745;

    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 20px rgba(0,0,0,0.1);

    --border-radius: 8px;
    --transition-speed: 0.3s;
}

/* --- Global Resets & Base Styles --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px; /* Base font size */
}

body {
    font-family: var(--font-primary);
    background-color: var(--color-background);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-headings);
    color: var(--color-primary);
    margin-bottom: 0.75em;
    line-height: 1.2;
}

p {
    margin-bottom: 1em;
    color: var(--color-text-light);
}

a {
    color: var(--color-accent);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

a:hover {
    color: var(--color-accent-dark);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* --- Banner --- */
.banner {
    background-color: var(--color-primary); /* Color de fondo oscuro (casi negro) */
    color: var(--color-surface); /* Color del texto (blanco) */
    padding: 25px 0; /* Relleno vertical reducido para un banner más compacto */
    text-align: center;
    position: relative;
    box-shadow: var(--shadow-md); /* Sombra suave para darle profundidad */
    display: flex; /* Usamos flexbox para centrar contenido verticalmente si es necesario */
    justify-content: center; /* Centrar contenido horizontalmente */
    align-items: center; /* Centrar contenido verticalmente */
    min-height: 180px; /* Altura mínima para asegurar que no se colapse */
}

.banner-content {
    max-width: 600px; /* Reducimos el ancho máximo para el contenido principal */
    margin: 0 auto;
    padding: 0 20px; /* Relleno horizontal */
    display: flex;
    flex-direction: column; /* Apila los elementos verticalmente */
    align-items: center; /* Centra los elementos apilados */
    gap: 12px; /* Espacio uniforme entre los elementos principales del banner */
}

.banner .logo {
    width: 120px; /* Reducido de 150px a 120px */
    height: 120px;
    border-radius: 50%;
    margin: 0; /* Eliminamos el margen manual aquí para usar 'gap' del flex-container */
    border: 3px solid var(--color-accent); /* Borde dorado alrededor del logo */
    box-shadow: 0 0 0 5px rgba(176, 141, 87, 0.1); /* Anillo de sombra sutil alrededor del logo */
    transition: transform 0.3s ease;
}

.banner .logo:hover {
    transform: scale(1.05); /* Efecto de zoom sutil al pasar el mouse */
}

.banner-text p {
    font-size: 1rem; /* Reducido ligeramente de 1.1rem */
    color: #DCDCDC; /* Tono de gris un poco más claro para el texto */
    margin-bottom: 0; /* Controlamos el espacio con 'gap' del flex-container */
    font-family: var(--font-special);
    line-height: 1.4;
}

/* Search in Banner */
.buscador {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px; /* Espacio entre el input y el botón de búsqueda */
    margin-top: 15px; /* Margen superior para separarlo del texto */
    width: 100%; /* Asegura que el buscador pueda expandirse si es un item de flexbox */
}

.buscador input[type="text"] {
    padding: 12px 15px;
    font-size: 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    background-color: var(--color-surface);
    color: var(--color-text);
    width: 250px; /* Ancho fijo para el campo de búsqueda en pantallas grandes */
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

.buscador input[type="text"]:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(176, 141, 87, 0.3);
}

.buscador button {
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    background-color: var(--color-accent);
    color: var(--color-surface);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, transform var(--transition-speed) ease;
}

.buscador button:hover {
    background-color: var(--color-accent-dark);
    transform: translateY(-2px);
}

/* --- Responsive Design para el banner (ajustes específicos) --- */
@media (max-width: 575px) { /* Extra small devices (portrait phones) */
    .banner {
        padding: 20px 0; /* Ajuste para el banner en móvil */
        min-height: 150px;
    }
    .banner .logo {
        width: 90px; /* Más pequeño para móvil */
        height: 90px;
    }
    .banner-text p {
        font-size: 0.9rem; /* Texto más pequeño para móvil */
        padding: 0 10px; /* Un poco de padding horizontal para texto */
    }
    .buscador {
        flex-direction: column; /* Apila el input y el botón del buscador */
        gap: 8px; /* Espacio entre el input y el botón apilados */
        padding: 0 20px; /* Relleno lateral para el buscador apilado */
    }
    .buscador input[type="text"],
    .buscador button {
        width: 100%; /* Ocupan todo el ancho disponible al estar apilados */
        max-width: 280px; /* Evita que sean demasiado anchos en tabletas pequeñas */
    }
}

.buscador button {
    padding: 12px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    background-color: var(--color-accent);
    color: var(--color-surface);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, transform var(--transition-speed) ease;
}

.buscador button:hover {
    background-color: var(--color-accent-dark);
    transform: translateY(-2px);
}

/* --- Categories --- */
.categorias {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 30px 20px;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.categorias button {
    font-family: var(--font-primary);
    font-weight: 600;
    background-color: transparent;
    color: var(--color-text-light);
    padding: 10px 20px;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.categorias button:hover {
    background-color: var(--color-accent);
    color: var(--color-surface);
    border-color: var(--color-accent);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.categorias button.active { /* You'll need JS to add/remove this class */
    background-color: var(--color-primary);
    color: var(--color-surface);
    border-color: var(--color-primary);
}


/* --- Catalog --- */
.catalogo {
    display: grid;
    /* Default: aims for ~4 columns if space, each item at least ~280px wide */
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); /* Adjusted minmax */
    gap: 30px;
    padding: 40px 20px;
    margin: 0 auto;
    max-width: 1200px; /* Content area will not exceed this width */
}

/* Refinements for specific screen sizes */
@media (max-width: 991px) { /* Tablets and larger phones */
    .catalogo {
        /* Aims for ~2-3 columns */
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 767px) { /* Phones */
    .catalogo {
        /* Aims for ~1-2 columns */
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 20px;
        padding: 30px 15px;
    }
}

@media (max-width: 480px) { /* Smaller phones */
    .catalogo {
        grid-template-columns: 1fr; /* Always single column */
        padding: 20px 10px;
    }
}


/* --- Product Card --- */
.producto {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    text-align: center;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Stacks items from the top */
    transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    border: 1px solid transparent; /* For hover effect */
    opacity: 0; /* For Intersection Observer */
    transform: translateY(20px); /* For Intersection Observer */
}

.producto:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-accent);
}

.producto.visible { /* For Intersection Observer */
    opacity: 1;
    transform: translateY(0);
}

.producto .carousel {
    margin-bottom: 15px;
    border-radius: calc(var(--border-radius) - 4px); /* Slightly smaller radius than card */
    overflow: hidden; /* Important for image radius */
}

.producto .carousel-images img {
    border-radius: calc(var(--border-radius) - 4px);
    aspect-ratio: 1 / 1; /* Makes images square, adjust if needed */
    object-fit: cover;
}

.titulo-producto {
    font-size: 1.3rem;
    color: var(--color-primary);
    margin-top: 0;
    margin-bottom: 10px;
    min-height: 2.4em; /* Ensure titles take up similar space */
}

/* Targets the div containing description paragraphs */
.producto .titulo-producto + div {
    flex-grow: 1; /* Makes this div consume available vertical space */
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* Keeps description paragraphs stacked at the top of their flex-grow container */
    align-items: center; /* Centers paragraphs horizontally within the description div */
    padding: 0 5px; /* Small horizontal padding for text, optional */
    /* Remove any previous margin-bottom that pushes content from here */
}

.producto .titulo-producto + div p { /* Targets paragraphs within the description div */
    font-size: 0.9rem;
    color: var(--color-text-light);
    margin-bottom: 0.5em; /* Small spacing between paragraphs */
}

.producto .titulo-producto + div p:last-child {
    margin-bottom: 0; /* Ensures no extra margin after the last paragraph in description */
}


.precio {
    font-family: var(--font-headings);
    font-size: 1.6rem !important;
    font-weight: 700 !important;
    color: var(--color-accent) !important;
    margin-top: auto; /* THIS IS THE KEY: pushes this element (and anything after it) to the bottom */
    margin-bottom: 15px; /* Space between price and button */
}

/* --- General Button Style (e.g., Add to Cart) --- */
.button {
    font-family: var(--font-primary);
    font-weight: 600;
    background-color: var(--color-primary);
    color: var(--color-surface);
    border: 2px solid var(--color-primary);
    padding: 12px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    text-transform: uppercase;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    width: 100%; /* Make button take full width of its container */
}

.button:hover {
    background-color: var(--color-accent);
    border-color: var(--color-accent);
    color: var(--color-surface);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

/* --- Shopping Cart --- */
#carrito {
    position: fixed;
    right: 20px;
    top: 20px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 25px;
    border-radius: var(--border-radius);
    width: 350px;
    box-shadow: var(--shadow-lg);
    z-index: 1001; /* Above rrss-icons */
    max-height: 90vh;
    overflow-y: auto;
    display: none; /* Initially hidden, shown by JS */
}

#carrito h2 {
    font-size: 1.5rem;
    text-align: center;
    margin-bottom: 20px;
    color: var(--color-primary);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 10px;
}

.cerrar-carrito {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--color-text-light);
    cursor: pointer;
    transition: color var(--transition-speed) ease;
}

.cerrar-carrito:hover {
    color: var(--color-primary);
}

#lista-carrito {
    list-style: none;
    margin-bottom: 20px;
}

#lista-carrito li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
}

#lista-carrito li:last-child {
    border-bottom: none;
}

#lista-carrito img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 10px;
}

#lista-carrito button { /* Delete button in cart item */
    background-color: transparent;
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition-speed) ease;
}

#lista-carrito button:hover {
    background-color: var(--color-danger);
    color: var(--color-surface);
}

#total-carrito {
    font-weight: bold;
    font-size: 1.2rem;
    text-align: right;
    display: block;
    margin-bottom: 20px;
}
#total-carrito .total strong {
    color: var(--color-accent);
}


/* Customer Info in Cart */
#datos-cliente {
    margin-bottom: 20px;
}

#datos-cliente h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: var(--color-primary);
}

#datos-cliente label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--color-text-light);
}

#datos-cliente input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    margin-bottom: 10px;
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

#datos-cliente input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 2px rgba(176, 141, 87, 0.2);
}

/* Botón Enviar Pedido */
#btn-pedir {
    width: 100%;
    background-color: #6C757D; /* Gris oscuro elegante */
    color: #FFFFFF;
    padding: 10px;
    border: none;
    cursor: pointer;
    border-radius: 20px;
    margin-top: 0px;
    transition: background-color 0.3s ease, transform 0.2s ease; /* Transiciones más suaves */
}

#btn-pedir:hover {
    background-color: #495057; /* Un gris ligeramente más oscuro */
    transform: scale(1.02); /* Efecto de agrandamiento más sutil */
}

/* Botón Vaciar Carrito */
#btn-vaciar-carrito {
    width: 100%;
    background-color: #E63946; /* Rojo festivo */
    color: #FFFFFF;
    padding: 10px;
    border: none;
    cursor: pointer;
    border-radius: 20px;
    margin-top: 3px;
    transition: background-color 0.3s ease, transform 0.3s ease; /* Transiciones suaves */
}


/* --- Floating Social Icons & Cart Button --- */
.rrss-icons {
    position: fixed;
    bottom: 20px; /* Adjusted position */
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    z-index: 1000;
}

.rrss-icons a,
.boton-flotante {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--color-primary);
    color: var(--color-surface);
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    transition: background-color var(--transition-speed) ease, transform var(--transition-speed) ease;
    border: none; /* For button reset */
    cursor: pointer;
}

.rrss-icons a:hover,
.boton-flotante:hover {
    background-color: var(--color-accent);
    transform: scale(1.1) translateY(-3px);
}

.rrss-icons a img {
    width: 24px;
    height: 24px;
    /* REMOVED FILTER: brightness(0) invert(1); to ensure visibility */
}
.boton-flotante {
    font-size: 1.5rem; /* Cart icon size */
}


@keyframes inflarDesinflar {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.boton-flotante {
    animation: inflarDesinflar 2.5s ease-in-out infinite;
    position: relative; /* For counter positioning */
}

#contador-carrito {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--color-danger);
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.75rem;
    font-weight: bold;
    line-height: 1;
    min-width: 18px; /* Ensure it's circular even with single digit */
    text-align: center;
}

/* --- Carousel --- */
.carousel {
    position: relative;
    overflow: hidden;
}

.carousel-images {
    display: flex;
    /* JS will handle image switching, so flex setup is minimal here */
}

.carousel-images img {
    min-width: 100%; /* Ensure image takes full width of its container */
    /* opacity and transform for transitions are handled by JS adding/removing .active */
}

.carousel-images img.active {
    display: block;
}
.carousel-images img:not(.active) {
    display: none;
}


.carousel-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.4);
    color: var(--color-surface);
    border: none;
    cursor: pointer;
    padding: 8px 12px;
    font-size: 1.2rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition-speed) ease;
    z-index: 10;
}

.carousel-button:hover {
    background-color: rgba(0, 0, 0, 0.7);
}

.carousel-button.prev {
    left: 10px;
}

.carousel-button.next {
    right: 10px;
}

/* --- Back to Top Button (Placeholder from old CSS, assuming you have it in HTML) --- */
.volver-inicio { /* Make sure you have <button class="volver-inicio" id="btn-volver-inicio">↑</button> in HTML for this */
    position: fixed;
    bottom: 90px; /* Adjusted to be above social icons */
    right: 25px;
    background-color: var(--color-accent);
    color: var(--color-surface);
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 999;
    display: none; /* JS toggles this with .show class */
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: all var(--transition-speed) ease;
}

.volver-inicio.show {
    display: flex;
}
.volver-inicio:hover {
    background-color: var(--color-accent-dark);
    transform: scale(1.1);
}

/* --- Loading Bar --- */
#barra-carga {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: transparent; /* No background for the container */
    z-index: 9999;
}

#barra-carga .carga {
    width: 0;
    height: 100%;
    background-color: var(--color-accent);
    animation: cargar 2s ease-out forwards; /* Adjust timing */
    border-radius: 0 2px 2px 0; /* Slight rounding on the end */
}

@keyframes cargar {
    0% { width: 0; }
    100% { width: 100%; }
}


/* --- SweetAlert2 Customizations (Optional, if you want to theme them) --- */
.swal2-popup {
    font-family: var(--font-primary) !important;
    border-radius: var(--border-radius) !important;
    background-color: var(--color-surface) !important;
    box-shadow: var(--shadow-lg) !important;
}
.swal2-title {
    font-family: var(--font-headings) !important;
    color: var(--color-primary) !important;
}
.swal2-html-container {
    color: var(--color-text-light) !important;
}
.swal2-confirm, .swal2-cancel, .swal2-deny {
    border-radius: var(--border-radius) !important;
    padding: 10px 20px !important;
    font-weight: 600 !important;
    transition: background-color var(--transition-speed) ease !important;
}
.swal2-confirm {
    background-color: var(--color-accent) !important;
    color: var(--color-surface) !important;
}
.swal2-confirm:hover {
    background-color: var(--color-accent-dark) !important;
}
.swal2-cancel {
    background-color: var(--color-border) !important;
    color: var(--color-text) !important;
}
.swal2-icon.swal2-success .swal2-success-ring {
    border-color: var(--color-accent) !important;
}
.swal2-icon.swal2-success [class^=swal2-success-line] {
    background-color: var(--color-accent) !important;
}


/* --- Responsive Design (Adjustments from previous combined with .catalogo fix) --- */

@media (max-width: 767px) { /* Small devices (landscape phones, large portrait phones) */
    .banner .logo {
        width: 120px;
        height: 120px;
    }
    .banner-text p {
        font-size: 1rem;
    }
    .buscador input[type="text"] {
        width: 200px;
    }

    .producto {
        padding: 15px;
    }
    .titulo-producto {
        font-size: 1.1rem;
    }
    .precio {
        font-size: 1.4rem !important;
    }
    .button {
        padding: 10px 15px;
        font-size: 0.8rem;
    }
    #carrito {
        width: 90%;
        max-width: 320px;
        right: 5%;
        left: 5%;
        top: 10px;
    }
    .rrss-icons a, .boton-flotante {
        width: 45px;
        height: 45px;
    }
    .rrss-icons a img {
        width: 20px;
        height: 20px;
    }
    .boton-flotante {
        font-size: 1.3rem;
    }
}

@media (max-width: 575px) { /* Extra small devices (portrait phones) */
    html {
        font-size: 15px;
    }
    .banner {
        padding: 15px 0 30px;
    }
    .banner .logo {
        width: 100px;
        height: 100px;
    }
    .buscador {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 0 20px;
    }
    .buscador input[type="text"], .buscador button {
        width: 100%;
    }
    .categorias {
        padding: 20px 10px;
        gap: 8px;
    }
    .categorias button {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    #carrito {
        padding: 20px;
    }
    .rrss-icons {
        bottom: 15px;
        right: 15px;
        gap: 10px;
    }
}
