:root {
    /* PALETA DE COLORES */
    --primary-color: #64313e;
    /* Bordó vino tinto */
    --secondary-color: #8a1c34;
    /* Rojo rubí */
    --accent-color: #d4af37;
    /* Dorado etiqueta */
    --background-color: #f9f5f0;
    /* Crema suave (papel antiguo) */
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --dark-gray: #1a1a1a;
    --medium-gray: #666;

    /* SOMBRAS SUAVES */
    --shadow: 0 10px 30px rgba(100, 49, 62, 0.15);
    --shadow-hover: 0 15px 40px rgba(100, 49, 62, 0.25);
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--background-color);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%2364313e' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

/* HEADER HERO */
.hero-header {
    background: linear-gradient(135deg, var(--primary-color), #481e28);
    color: white;
    padding: 60px 20px 40px;
    text-align: center;
    border-bottom-left-radius: 50% 30px;
    border-bottom-right-radius: 50% 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    margin-bottom: 40px;
    position: relative;
}

.logo-container {
    margin-bottom: 30px;
}

.logo {
    max-width: 180px;
    height: auto;
    border-radius: 50%;
    border: 4px solid var(--accent-color);
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.5);
    margin-bottom: 15px;
    background: white;
    padding: 5px;
}

h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3.5em;
    margin: 0;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.hero-header p {
    font-size: 1.2em;
    font-weight: 300;
    opacity: 0.9;
    letter-spacing: 1px;
    font-style: italic;
    margin-top: 10px;
}

/* BUSCADOR */
.search-container {
    margin-top: 30px;
    display: flex;
    justify-content: center;
}

.search-input {
    width: 100%;
    max-width: 500px;
    padding: 16px 25px;
    border-radius: 30px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 1.1em;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    outline: none;
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.search-input:focus {
    background: white;
    color: var(--primary-color);
    border-color: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* TOP 5 FEATURED */
.featured-section {
    margin-bottom: 50px;
    padding: 0 20px;
    text-align: center;
}

.featured-title {
    text-align: center;
    font-family: 'Playfair Display', serif;
    color: var(--primary-color);
    margin-bottom: 25px;
    font-size: 2rem;
    position: relative;
    display: block;
    width: 100%;
}

.featured-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: var(--accent-color);
    margin: 10px auto 0;
}

.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

.featured-card {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 15px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
    text-align: left;
}

.featured-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.featured-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-color);
    color: white;
    font-size: 0.7em;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.featured-info h3 {
    margin: 15px 0 5px;
    font-size: 1.1em;
    color: var(--primary-color);
    line-height: 1.3;
}

.featured-bodega {
    font-size: 0.85em;
    color: var(--medium-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.featured-price {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--secondary-color);
    margin-top: 15px;
    text-align: right;
    font-family: 'Playfair Display', serif;
}

/* BODEGAS CONTAINER (HOME) */
.bodegas-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 30px;
    max-width: 1300px;
    margin: 0 auto;
}

.bodega-card {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 35px 30px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: all 0.4s ease;
    cursor: pointer;
    user-select: none;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.bodega-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

.bodega-card:hover {
    transform: translateY(-10px) scale(1.02);
    box-shadow: var(--shadow-hover);
}

.bodega-card h3 {
    font-size: 1.6em;
    color: var(--dark-gray);
    margin-bottom: 15px;
    font-weight: 600;
}

.bodega-card .wine-count {
    color: #000 !important;
    font-size: 1em;
    background: linear-gradient(135deg, #ffffff, #f8f9fa);
    padding: 10px 22px;
    border-radius: 25px;
    display: inline-block;
    font-weight: 700;
    border: 2px solid rgba(100, 49, 62, 0.3);
    box-shadow: 0 4px 12px rgba(100, 49, 62, 0.2);
    margin-top: 10px;
}

/* === MODAL VIEW FOR BODEGAS (CRITICAL FIX) === */
.page {
    display: none;
    padding-bottom: 50px;
}

.page.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

#home {
    display: block;
}

/* Home always potentially visible underneath, or controlled via js */

/* Modal Style for #bodega */
#bodega {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--background-color);
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%2364313e' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    z-index: 9999;
    overflow-y: auto;
    padding: 20px;
    box-sizing: border-box;
    display: none;
    /* Hidden by default */
}

#bodega.active {
    display: block !important;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.back-btn {
    position: sticky;
    top: 0;
    z-index: 10000;
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 12px 28px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.back-btn:hover {
    background: var(--primary-color);
    color: white;
}

#bodega-name {
    color: var(--primary-color);
    text-align: center;
    font-size: 2.6em;
    margin-bottom: 40px;
    font-weight: 700;
}

.vinos-container {
    max-width: 900px;
    margin: 0 auto;
}

.vino-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 28px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border-left: 5px solid var(--primary-color);
}

.vino-card:hover {
    transform: translateX(8px);
    box-shadow: var(--shadow-hover);
}

.vino-info {
    flex: 1;
}

.vino-name {
    font-size: 1.3em;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 8px;
}

.vino-price {
    font-size: 1.5em;
    font-weight: bold;
    color: var(--primary-color);
    text-align: right;
    font-family: 'Playfair Display', serif;
}

.last-update {
    text-align: center;
    color: var(--medium-gray);
    margin-top: 50px;
    font-size: 0.95em;
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.error {
    color: white;
    text-align: center;
    padding: 25px;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    border-radius: 15px;
    margin: 20px;
    box-shadow: var(--shadow);
}

.loading {
    text-align: center;
    color: var(--primary-color);
    font-weight: bold;
    margin: 40px 0;
}

/* SEARCH RESULTS */
.search-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    margin-bottom: 20px;
    background: white;
    border-radius: 15px;
    border: 1px solid rgba(100, 49, 62, 0.1);
    box-shadow: var(--shadow);
}

.search-header h3 {
    color: var(--primary-color);
    margin: 0;
}

.wine-count-badge {
    background: var(--primary-color);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 0.9em;
}

.search-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 15px;
}

/* RESPONSIVE */
@media (max-width: 768px) {

    .bodegas-container,
    .featured-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }

    @media (max-width: 370px) {

        .bodegas-container,
        .featured-grid {
            grid-template-columns: 1fr;
        }
    }

    .page {
        padding: 15px;
    }

    h1 {
        font-size: 2.2em;
    }

    #bodega-name {
        font-size: 2em;
    }

    .vino-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 20px;
    }

    .vino-price {
        align-self: flex-end;
        font-size: 1.3em;
        border-top: 1px solid #eee;
        width: 100%;
        margin-top: 10px;
        padding-top: 10px;
    }

    /* Mobile Centering Fix */
    .bodega-card {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        min-height: 180px;
        /* Ensure uniform height */
    }

    .bodega-card h3 {
        margin-top: 0;
        text-align: center;
    }
}