:root {
    /* Color Palette - Light Theme Premium */
    --primary: #0284c7; /* Sky blue */
    --primary-hover: #0369a1;
    --secondary: #0ea5e9;
    --bg-main: #f8fafc;
    --bg-card: rgba(255, 255, 255, 0.85);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: rgba(0, 0, 0, 0.05);
    
    /* Glassmorphism */
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(255, 255, 255, 0.4);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
    
    /* Variables */
    --header-height: 80px;
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ------------------- HEADER ------------------- */
.header {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 1000;
    display: flex;
    justify-content: center;
    box-shadow: var(--glass-shadow);
}

.header-container {
    width: 100%;
    max-width: 100%;
    padding: 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo img {
    height: 40px;
    border-radius: 8px;
}

.nav-links {
    display: flex;
    gap: 24px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-main);
    font-weight: 500;
    transition: var(--transition);
}

.nav-link:hover {
    color: var(--primary);
}

.header-actions {
    display: flex;
    gap: 16px;
    align-items: center;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    color: var(--text-main);
    transition: var(--transition);
    position: relative;
}

.btn-icon:hover {
    color: var(--primary);
    transform: scale(1.1);
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    height: 20px;
    min-width: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* ------------------- MAIN CONTENT ------------------- */
main {
    margin-top: 10px !important;
    min-height: calc(100vh - var(--header-height));
}

/* ------------------- BANNER CAROUSEL ------------------- */
.hero-slider {
    width: 100%;
    max-width: 100%;
    height: 0;
    padding-bottom: 26.35%; /* 506/1920 */
    position: relative;
    overflow: hidden;
    margin-bottom: 40px;
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: transparent;
}

.slide.active {
    opacity: 1;
}

/* ------------------- OFFERS SECTION ------------------- */
.section-title {
    max-width: 1400px;
    max-width: 1800px;
    margin: 40px auto 20px;
    padding: 0 24px;
    font-size: 2rem;
    font-weight: 700;
}

.offers-container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
    scroll-snap-type: x mandatory;
    scrollbar-width: none; /* Firefox */
}

.offers-container::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.offer-card {
    min-width: 280px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    scroll-snap-align: start;
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
}

.offer-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 30px -10px rgba(0,0,0,0.15);
}

.offer-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.offer-details {
    padding: 16px;
}

.offer-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.offer-price {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.3rem;
}

/* ------------------- INVENTORY GRID ------------------- */
.inventory-grid {
    max-width: 100%;
    margin: 0 auto 60px;
    padding: 0 40px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 24px;
}

.product-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    overflow: hidden;
    transition: var(--transition);
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.15);
}

.product-img-container {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: #e2e8f0;
    position: relative;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.product-card:hover .product-img {
    transform: scale(1.05);
}

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

.product-code {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.product-name {
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.3;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex-grow: 1;
}

.product-prices {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.price-unit {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
}

.price-wholesale {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
}

.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--primary);
    font-size: 1.5rem;
}

/* ------------------- MODAL ------------------- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: var(--bg-main);
    width: 90%;
    max-width: 550px;
    max-height: 90vh;
    border-radius: 24px;
    overflow-y: auto;
    transform: scale(0.95) translateY(20px);
    transition: var(--transition);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    position: relative;
    padding: 25px;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(0,0,0,0.1);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: rgba(0,0,0,0.2);
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .navbar {
        height: auto;
        min-height: 70px;
        padding: 10px 0;
    }
    
    .header-container {
        flex-wrap: wrap;
        padding: 0 12px;
        gap: 10px;
    }
    
    .search-bar {
        order: 3;
        width: 100%;
        max-width: 100%;
        margin: 5px 0 0 0;
        flex: 1 1 100%;
    }

    .hero-slider {
        border-radius: 0;
        margin-bottom: 20px;
    }
    
    .inventory-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0 12px;
    }

    .offers-container .product-card {
        min-width: 140px !important;
        max-width: 160px !important;
    }
    
    .product-img-container {
        aspect-ratio: 1;
    }
    
    .nav-links {
        width: 100% !important;
        border-radius: 0 !important;
    }

    .brand {
        font-size: 0; /* Hide text */
    }
    .brand img {
        height: 35px;
        margin-right: 0;
    }

    /* Modal adjustments for mobile */
    .modal-content {
        width: 95%;
        padding: 10px;
    }
    #modal-body > div {
        flex-direction: column !important;
    }
    .modal-close {
        top: 0 !important;
        right: 0 !important;
        width: 25px !important;
        height: 25px !important;
        font-size: 1.1rem !important;
    }

    /* Cart adjustments for mobile to free up space */
    .cart-header {
        padding: 10px 15px !important;
    }
    .cart-header h2 {
        font-size: 1.1rem !important;
        margin: 0 !important;
    }
    .cart-items {
        padding: 8px 15px !important;
        gap: 8px !important;
    }
    .cart-upsell {
        padding: 6px !important;
    }
    .cart-upsell h4 {
        margin-bottom: 2px !important;
        font-size: 0.8rem !important;
    }
    .upsell-item {
        min-width: 75px !important;
        padding: 4px !important;
    }
    .upsell-item img {
        height: 32px !important;
        margin-bottom: 2px !important;
    }
    .upsell-item div {
        font-size: 0.7rem !important;
    }
    .cart-footer {
        padding: 8px 15px !important;
    }
    .cart-total {
        font-size: 0.9rem !important;
        margin-bottom: 4px !important;
    }
    .btn-checkout {
        padding: 8px 10px !important;
        font-size: 0.85rem !important;
        margin-bottom: 4px !important;
    }
    #btn-login-checkout {
        margin-top: 4px !important;
    }
}

/* ------------------- CART SLIDE-OVER ------------------- */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 3000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.cart-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.cart-panel {
    position: absolute;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100%;
    background: var(--bg-main);
    box-shadow: -10px 0 30px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Navbar */
.navbar {
    background: var(--surface);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand img {
    height: 40px;
    border-radius: 8px;
}

#mobile-menu-btn {
    display: block;
}

.search-bar {
    flex: 1;
    max-width: 500px;
    margin: 0 20px;
    position: relative;
    display: flex;
}

.nav-links {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    width: 250px;
    background: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-radius: 0 0 12px 12px;
    padding: 10px 0;
    z-index: 90;
    border: 1px solid var(--glass-border);
}

.nav-links.active {
    display: flex;
}

.nav-links .nav-link {
    padding: 15px 25px;
    border-bottom: 1px solid #f1f5f9;
    width: 100%;
    color: var(--text-main);
    font-weight: 600;
}
.nav-links .nav-link:last-child {
    border-bottom: none;
}
.nav-links .nav-link:hover {
    background: #f8fafc;
    color: var(--primary);
}

.search-bar input[type="text"] {
    width: 100%;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--border);
    outline: none;
    font-size: 0.95rem;
    background: var(--background);
}

.search-bar > button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}



.cart-overlay.active .cart-panel {
    right: 0;
}

.cart-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cart-item {
    display: flex;
    gap: 12px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.cart-item img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    object-fit: cover;
}

.cart-item-info {
    flex: 1;
}

.cart-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cart-item-price {
    color: var(--primary);
    font-weight: bold;
    margin-top: 4px;
}

.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.cart-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: white;
    cursor: pointer;
}

.cart-upsell {
    padding: 16px;
    background: #f1f5f9;
    border-top: 1px solid var(--border-color);
}

.upsell-container {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
}

.upsell-item {
    min-width: 120px;
    background: white;
    padding: 8px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.8rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.upsell-item img {
    width: 100%;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 5px;
}

.cart-footer {
    padding: 20px;
    background: white;
    border-top: 1px solid var(--border-color);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 16px;
}

.btn-checkout {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: bold;
    color: white;
    background: #25D366;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-checkout:hover {
    filter: brightness(1.1);
}

/* FIX PARA ESCRITORIO - RESTAURAR MENU HORIZONTAL */
@media (min-width: 769px) {
    #mobile-menu-btn {
        display: none !important;
    }
    .nav-links {
        display: flex !important;
        flex-direction: row !important;
        position: static !important;
        box-shadow: none !important;
        width: auto !important;
        border: none !important;
        padding: 0 !important;
        background: transparent !important;
        gap: 24px !important;
        align-items: center !important;
    }
    .nav-links .nav-link {
        width: auto !important;
        border-bottom: none !important;
        padding: 5px 10px !important;
    }
    .nav-links .nav-link:hover {
        background: transparent !important;
    }
}

/* FIX PARA HEADER MOVIL - TODO EN UNA LINEA */
@media (max-width: 768px) {
    .header-container {
        flex-wrap: nowrap !important;
        gap: 5px !important;
        padding: 0 5px !important;
    }
    .brand-text {
        display: none !important;
    }
    .brand {
        gap: 0 !important;
        margin-right: 5px !important;
    }
    .brand img {
        height: 32px !important;
        margin: 0 !important;
    }
    .search-bar {
        order: 2 !important;
        width: auto !important;
        flex: 1 !important;
        margin: 0 !important;
        max-width: none !important;
    }
    .search-bar input[type="text"] {
        padding: 8px 30px 8px 12px !important;
        font-size: 0.85rem !important;
    }
    #btn-search-main {
        right: 35px !important;
    }
    #btn-filter {
        right: 10px !important;
    }
    #mobile-menu-btn {
        margin-right: 5px !important;
        font-size: 1.2rem !important;
    }
    .header-actions {
        gap: 8px !important;
        order: 3 !important;
    }
    .btn-icon {
        font-size: 1.1rem !important;
    }
}

/* ------------------- LOCATION MODAL MOBILE ------------------- */
@media (max-width: 768px) {
    .location-swal-mobile { padding: 15px !important; width: 85% !important; }
    .location-swal-title { font-size: 1.2rem !important; }
    .location-swal-html { font-size: 0.9rem !important; line-height: 1.4 !important; }
    .location-swal-html p { margin: 5px 0 !important; }
    .location-swal-html a { padding: 8px 15px !important; font-size: 0.9rem !important; }
    .location-swal-btn { padding: 8px 15px !important; font-size: 0.9rem !important; }
}

/* ------------------- CHECKOUT MODAL ------------------- */
#checkout-modal .modal-content {
    padding: 25px;
    border-radius: 16px;
}
#checkout-modal .form-group input, #checkout-modal .form-group select, #checkout-modal .form-group textarea {
    transition: border-color 0.2s, box-shadow 0.2s;
}
#checkout-modal .form-group input:focus, #checkout-modal .form-group select:focus, #checkout-modal .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ------------------- BANNER MOBILE FIX ------------------- */
.slide img { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block; }

/* ------------------- MOBILE SPACING FIX ------------------- */
@media (max-width: 768px) {
    main { margin-top: 10px !important; }
    .hero-slider { padding-bottom: 26.35% !important; margin-bottom: 15px !important; }
    .section-title { margin-top: 15px !important; font-size: 1.6rem !important; }
    .offers-container { margin-bottom: 20px !important; }
    .product-name { font-size: 0.8rem; }
    .price-unit { font-size: 1rem; }
}

/* Favorites Filter Logic */
body.show-favorites .product-card:not(.is-favorite) {
    display: none !important;
}
body.show-favorites #hero {
    display: none !important;
}
