/* --- VARIABLES Y CONFIGURACIÓN BASE --- */
:root { 
    --primary-wood: #8b5a2b; 
    --dark-wood: #4a2c10; 
    --accent-red: #e4002b; 
}

html {
    scroll-behavior: smooth;
}

body { 
    margin: 0; 
    font-family: 'Roboto', sans-serif; 
    background: #f4f4f4; 
    color: #202124; 
}

/* --- HEADER Y NAVEGACIÓN PRINCIPAL --- */
.custom-header { 
    background: #fff; 
    padding: 15px 0px 0px 0px; 
    box-shadow: 0 2px 15px rgba(0,0,0,0.1); 
}

.header-container { 
    max-width: 1200px; 
    margin: 0 auto; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 0 20px; 
}

.logo-img { max-height: 80px; }

.main-nav-custom a { 
    text-decoration: none; 
    color: var(--dark-wood); 
    font-weight: 700; 
    margin-left: 20px; 
    text-transform: uppercase; 
    font-family: 'Roboto Condensed'; 
}

/* --- STICKY NAV (BARRA DE CATEGORÍAS) --- */
.sticky-nav { 
    position: sticky; 
    top: 0; 
    z-index: 999; 
    background: #fff; 
    border-bottom: 1px solid #ddd; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.nav-container { 
    max-width: 1200px; 
    margin: 0 auto; 
    display: flex; 
    overflow-x: auto; 
    white-space: nowrap; 
    cursor: grab; 
    scrollbar-width: none; 
}

.nav-container::-webkit-scrollbar { display: none; }

.nav-item { 
    padding: 15px 25px; 
    font-family: 'Roboto Condensed'; 
    font-weight: 700; 
    text-decoration: none; 
    color: #333; 
    border-bottom: 4px solid transparent; 
    transition: all 0.3s;
    text-transform: uppercase !important;
    font-size: 14px;
}

.nav-item:hover { color: var(--accent-red); }

.nav-item.active {
    color: var(--accent-red) !important;
    border-bottom: 4px solid var(--accent-red) !important;
}

/* --- GRID Y TARJETAS DE PRODUCTO --- */
.main-content { max-width: 1200px; margin: 30px auto; padding: 0 15px; }

.cat-box { 
    background: #fff; 
    border-radius: 20px; 
    padding: 35px; 
    margin-bottom: 40px; 
    box-shadow: 0 1px 6px rgba(0,0,0,0.05); 
}

.cat-title { 
    font-family: 'Roboto Condensed'; 
    font-size: 28px; 
    border-left: 5px solid var(--accent-red); 
    padding-left: 15px; 
    text-transform: uppercase; 
}

.grid-layout { 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 20px; 
}

.product-card { 
    display: flex; 
    gap: 12px; 
    background: #fff;
    padding: 10px;
    border-radius: 12px;
    height: 100%;
    border: 1px solid #eee;
    box-sizing: border-box;
}

.card-img { 
    width: 100px; 
    height: 100px; 
    border-radius: 12px; 
    object-fit: cover; 
}

.product-info { 
    display: flex; 
    flex-direction: column; 
    flex: 1; 
}

.price-tag { 
    color: var(--accent-red); 
    font-weight: 800; 
    font-size: 16px; 
    margin-bottom: 2px;
}

.product-info h3 { 
    margin: 5px;
    font-size: 17px;
    line-height: 1.1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-transform: uppercase;
}

.product-desc { 
    font-size: 12px; 
    color: #777; 
    margin: 2px 0 8px 0;
    line-height: 1.2;
    flex-grow: 1; 
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.add-btn { 
    background: #202124; 
    color: #fff; 
    border: none; 
    padding: 8px 15px; 
    border-radius: 30px; 
    font-weight: 700; 
    cursor: pointer; 
    margin-top: auto;
    font-size: 12px;
    transition: 0.3s;
}

.add-btn:hover { background: var(--accent-red); }

/* --- ESTADOS DE STOCK --- */
.oos-card { opacity: 0.6; filter: grayscale(0.8); }
.status-msg { color: var(--accent-red); font-weight: bold; font-size: 11px; margin-bottom: 4px; }
.add-btn.disabled { background: #999 !important; cursor: not-allowed; }

/* --- MODAL (CORREGIDO CON SCROLL INTERNO) --- */
#modal-overlay { 
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    transition: opacity 0.3s, visibility 0.3s;
    overflow-y: auto;
}

#modal-overlay.modal-hidden { 
    visibility: hidden; 
    opacity: 0; 
}

.modal-container { 
    position: relative;
    max-height: 90vh;
    width: 90%;
    max-width: 800px;
    display: flex;
    flex-direction: row;
    background: #fff;
    border-radius: 25px;
    overflow: hidden;
    box-shadow: 0 10px 50px rgba(0,0,0,0.5);
    margin: auto;
}

.close-x { 
    position: absolute; 
    top: 15px; 
    right: 20px; 
    font-size: 30px; 
    border: none; 
    background: rgba(255,255,255,0.95);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer; 
    z-index: 10;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.3s;
}

.close-x:hover {
    background: var(--accent-red);
    color: #fff;
    transform: rotate(90deg);
}

.modal-left { 
    flex: 1; 
    background: #f4f4f4; 
    padding: 20px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    min-height: 250px;
}

#modal-img { 
    max-width: 100%; 
    max-height: 400px;
    object-fit: cover; 
    border-radius: 20px; 
}

.modal-right { 
    flex: 1.2;
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header-info {
    padding: 30px 30px 10px 30px;
    flex-shrink: 0;
}

#modal-title {
    margin: 0 0 10px 0;
    font-size: 22px;
    line-height: 1.2;
}

#modal-desc {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    margin-bottom: 10px;
}

.modal-price-val { 
    font-size: 24px; 
    color: var(--accent-red); 
    font-weight: 800; 
    margin-bottom: 15px; 
}

#product-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#variation-wrap {
    padding: 0 30px;
    margin-bottom: 15px;
    flex-shrink: 0;
}

#variation-wrap > div {
    margin-bottom: 15px;
}

#variation-wrap label {
    display: block;
    font-weight: bold;
    font-size: 13px;
    text-transform: uppercase;
    margin-bottom: 5px;
    color: #333;
}

.variant-select { 
    width: 100%; 
    padding: 12px; 
    border-radius: 10px; 
    border: 2px solid #eee; 
    font-weight: 600; 
    background: #fff;
    font-size: 14px;
    transition: border-color 0.3s;
}

.variant-select:focus {
    outline: none;
    border-color: var(--accent-red);
}

.modal-footer-actions {
    padding: 20px 30px;
    background: #fff;
    border-top: 1px solid #eee;
    box-shadow: 0 -5px 10px rgba(0,0,0,0.05);
    flex-shrink: 0;
    margin-top: auto;
}

.qty-input {
    width: 70px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    text-align: center;
    font-size: 14px;
}

.modal-submit { 
    background: var(--accent-red); 
    color: #fff; 
    border: none; 
    padding: 15px; 
    border-radius: 40px; 
    width: 100%; 
    font-weight: 800; 
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s;
    margin-top: 15px;
}

.modal-submit:hover {
    background: #c40024;
    transform: scale(1.02);
}

/* --- FOOTER --- */
.custom-footer { 
    background: #202124; 
    color: #fff; 
    padding: 40px 20px; 
    margin-top: 50px; 
}

.footer-grid { 
    max-width: 1200px; 
    margin: 0 auto; 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 20px; 
}

.webpay-logo {
    max-width: 150px;
    margin-top: 10px;
}

/* --- RESPONSIVE --- */
@media(max-width: 900px) {
    /* ★ HEADER MOBILE */
    .header-container {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        padding: 10px 20px;
    }
    .logo-img {
        max-height: 65px;
    }
    .main-nav-custom {
        display: flex;
        justify-content: center;
        align-items: center;
        flex-wrap: nowrap;
        gap: 0;
    }
    .main-nav-custom a {
        margin-left: 0;
        padding: 5px 14px;
        font-size: 13px;
        border-right: 1px solid #ddd;
        line-height: 1.3;
    }
    .main-nav-custom a:last-child {
        border-right: none;
    }

    /* GRID Y FOOTER */
    .grid-layout { 
        grid-template-columns: 1fr; 
    }
    
    .footer-grid { 
        grid-template-columns: 1fr; 
    }
    
    /* MODAL */
    .modal-container { 
        flex-direction: column;
        width: 95%;
        max-height: 95vh;
        max-height: 95dvh;
        overflow-y: auto;
    }
    
    .modal-left { 
        max-height: 180px;
        min-height: 120px;
        padding: 15px;
        flex-shrink: 0;
    }
    
    #modal-img {
        max-height: 150px;
    }
    
    .modal-right {
        max-height: none;
        overflow-y: visible;
        flex: 1;
    }
    
    .modal-header-info {
        padding: 20px 20px 10px 20px;
    }
    
    #variation-wrap {
        padding: 0 20px;
    }
    
    .modal-footer-actions {
        padding: 15px 20px;
        padding-bottom: calc(15px + env(safe-area-inset-bottom));
        position: sticky;
        bottom: 0;
        background: #fff;
        z-index: 10;
        box-shadow: 0 -3px 10px rgba(0,0,0,0.08);
    }
}

@media (max-width: 600px) {
    .cat-box { 
        padding: 20px; 
    }
    
    .product-card { 
        gap: 10px; 
    }
    
    .card-img { 
        width: 80px; 
        height: 80px; 
    }
    
    #modal-overlay {
        padding: 10px;
    }
}