:root {
    --primary-color: #fca311;
    --secondary-color: #14213d;
    --bg-color: #f8f9fa;
    --text-color: #333;
    --border-color: #ddd;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: var(--bg-color); color: var(--text-color); }
a { text-decoration: none; color: inherit; }

/* Header */
.site-header { background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,0.1); padding: 15px 0; position: sticky; top: 0; z-index: 100; }
.header-container { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; }
.logo-container .logo { max-height: 80px; } /* Logo más grande */

/* Buscador con overflow visible */
.search-bar { 
    display: flex; 
    flex-grow: 1; 
    max-width: 500px; 
    margin: 0 20px; 
    border: 1px solid var(--border-color); 
    border-radius: 4px; 
    overflow: visible !important; /* CAMBIO CRÍTICO: Permitir que los resultados salgan del contenedor */
    position: relative; 
    background: #fff;
}

.search-bar input { flex-grow: 1; padding: 10px; border: none; outline: none; background: transparent; }
.search-bar button { padding: 10px 15px; background: var(--primary-color); border: none; color: #fff; cursor: pointer; }
.header-nav { display: flex; gap: 20px; align-items: center; }
.header-nav a { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.cart-link { position: relative; }
.cart-count { background: var(--primary-color); color: #fff; border-radius: 50%; padding: 2px 6px; font-size: 12px; position: absolute; top: -10px; right: -15px; }

/* Layout Grid */
.store-container { max-width: 1200px; margin: 30px auto; display: flex; gap: 30px; padding: 0 20px; }

/* Sidebar Categorías */
.sidebar { width: 250px; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); height: fit-content; }
.sidebar h3 { font-size: 18px; margin-bottom: 15px; border-bottom: 2px solid var(--primary-color); padding-bottom: 5px; }
.category-list { list-style: none; margin-bottom: 30px; }
.category-list li { margin-bottom: 10px; }
.category-list a { color: #555; transition: color 0.2s; }
.category-list a:hover { color: var(--primary-color); }
.price-filter input.slider { width: 100%; }

/* Productos Utama */
.product-area { flex-grow: 1; }
.products-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; background: #fff; padding: 15px 20px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.sort-by { padding: 8px; border-radius: 4px; border: 1px solid var(--border-color); }

/* Tarjetas */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.product-card { background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: transform 0.2s, box-shadow 0.2s; display: flex; flex-direction: column; }
.product-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.product-image img { width: 100%; height: 200px; object-fit: cover; }
.product-info { padding: 15px; display: flex; flex-direction: column; flex-grow: 1; }
.category { font-size: 12px; color: #888; text-transform: uppercase; margin-bottom: 5px; }
.product-title { font-size: 16px; margin-bottom: 10px; color: var(--secondary-color); font-weight: 600; }
.price { font-size: 18px; font-weight: bold; color: var(--primary-color); margin-bottom: 15px; }
.btn-add { margin-top: auto; width: 100%; padding: 10px; background: var(--secondary-color); color: #fff; border: none; border-radius: 4px; cursor: pointer; transition: background 0.2s; font-weight: 500; }
.btn-add:hover { background: var(--primary-color); }

/* Footer */
.site-footer { background: var(--secondary-color); color: #fff; padding: 30px 0; text-align: center; margin-top: 50px; }

/* Estilos mejorados para el Carrito */
.cart-page { padding: 40px 0; }
.cart-header { margin-bottom: 30px; border-bottom: 1px solid #eee; padding-bottom: 15px; }
.cart-table { width: 100%; border-collapse: separate; border-spacing: 0 15px; margin-top: -15px; }
.cart-table th { padding: 10px 20px; color: #888; text-transform: uppercase; font-size: 13px; text-align: left; }
.cart-item-row { background: #fff; box-shadow: 0 2px 10px rgba(0,0,0,0.03); border-radius: 8px; transition: transform 0.2s; }
.cart-item-row:hover { transform: scale(1.01); }
.cart-item-row td { padding: 20px; }
.cart-item-row td:first-child { border-radius: 8px 0 0 8px; }
.cart-item-row td:last-child { border-radius: 0 8px 8px 0; }

.cart-product-info { display: flex; align-items: center; gap: 20px; }
.cart-product-img { width: 80px; height: 80px; object-fit: contain; background: #f9f9f9; border-radius: 4px; border: 1px solid #eee; }
.cart-product-name { font-weight: 600; color: var(--secondary-color); font-size: 16px; }

.qty-control { display: flex; align-items: center; gap: 10px; border: 1px solid #ddd; border-radius: 4px; width: fit-content; padding: 5px; }
.qty-btn { background: #eee; border: none; width: 25px; height: 25px; border-radius: 3px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-weight: bold; }
.qty-btn:hover { background: var(--primary-color); color: white; }
.qty-input { border: none; width: 40px; text-align: center; font-weight: bold; background: transparent; -moz-appearance: textfield; }
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.subtotal-cell { font-weight: bold; color: var(--secondary-color); font-size: 18px; }
.remove-item { color: #ff4d4d; cursor: pointer; font-size: 18px; transition: color 0.2s; border: none; background: none; }
.remove-item:hover { color: #cc0000; }

.cart-summary { background: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); margin-top: 20px; text-align: right; }
.summary-line { display: flex; justify-content: flex-end; gap: 40px; margin-bottom: 20px; align-items: baseline; }
.summary-label { font-size: 18px; color: #666; }
.summary-value { font-size: 28px; font-weight: bold; color: var(--primary-color); }

.cart-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 30px; }
.btn-continue { color: var(--secondary-color); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.btn-checkout { padding: 15px 40px; background: var(--primary-color); color: white; border: none; border-radius: 6px; font-size: 18px; font-weight: bold; cursor: pointer; transition: background 0.3s, transform 0.2s; box-shadow: 0 4px 15px rgba(252, 163, 17, 0.3); }
.btn-checkout:hover { background: #e6950f; transform: translateY(-2px); }

.empty-cart-msg { text-align: center; padding: 60px 0; }
.empty-cart-msg i { font-size: 60px; color: #ddd; margin-bottom: 20px; }

/* Vista Detalle del Producto */
.product-details-container { display: flex; gap: 40px; background: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); width: 100%; }
.product-image-section { flex: 1; display: flex; justify-content: center; align-items: center; background: #f9f9f9; border-radius: 8px; padding: 20px; }
.product-image-section img { max-width: 100%; max-height: 450px; object-fit: contain; }
.product-info-section { flex: 1; }
.product-price { font-size: 28px; font-weight: bold; color: var(--primary-color); margin: 20px 0; }
.product-description { margin-top: 30px; padding-top: 20px; border-top: 1px solid #eee; }
.product-description h3 { margin-bottom: 10px; color: var(--secondary-color); }
.product-description p { color: #666; line-height: 1.6; }
.product-description ul { margin-top: 15px; padding-left: 20px; color: #666; }

/* ==========================================
   HERO SLIDER (PROMOCIONES)
   ========================================== */
.hero-slider {
    position: relative;
    width: 100%;
    height: 350px;
    overflow: hidden;
    background: #f5f5f5;
    margin-bottom: 20px;
}

.slider-container {
    display: flex;
    height: 100%;
    transition: transform 0.5s ease-in-out;
}

.slide {
    min-width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    padding: 0 8%;
}

.slide-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 8px;
    max-width: 450px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    animation: slideUp 0.8s ease forwards;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-content h2 {
    font-size: 1.8em;
    color: #222;
    margin-bottom: 10px;
    line-height: 1.2;
}

.slide-content p {
    font-size: 1em;
    color: #666;
    margin-bottom: 20px;
    line-height: 1.5;
}

.btn-shop {
    display: inline-block;
    background: var(--primary-color);
    color: white;
    padding: 10px 25px;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: background 0.3s;
}

.btn-shop:hover {
    background: var(--secondary-color);
}

.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.7);
    border: none;
    width: 40px;
    height: 60px;
    font-size: 1.5em;
    color: #333;
    cursor: pointer;
    transition: background 0.3s, opacity 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.slider-btn:hover {
    background: white;
}

.prev-btn { left: 0; border-radius: 0 5px 5px 0; }
.next-btn { right: 0; border-radius: 5px 0 0 5px; }

.slider-dots {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: background 0.3s;
}

.dot.active {
    background: var(--primary-color);
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
}

/* ==========================================
   PRELOADER & LOADERS
   ========================================== */
#preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s;
}

#preloader.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.loader-logo {
    max-width: 120px;
    animation: pulse 1.5s infinite ease-in-out;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(0.95); opacity: 0.8; }
}

/* Loader específico para el área de productos */
.products-loader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.products-loader-overlay .loader-content {
    background: white;
    padding: 30px;
    border-radius: 50%;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Skeleton Loading para productos */
.skeleton-card {
    background: #fff;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.skeleton-img {
    width: 100%;
    height: 150px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Sugerencias del Buscador Asíncrono */
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white !important;
    border: 1px solid #ddd !important;
    border-top: none !important;
    border-radius: 0 0 8px 8px !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3) !important;
    z-index: 9999999 !important; /* Valor extremo para forzar visibilidad */
    max-height: 450px !important;
    overflow-y: auto !important;
    display: none; /* Se controla por JS */
}

.search-item {
    display: flex !important;
    align-items: center !important;
    padding: 12px 15px !important;
    gap: 15px !important;
    text-decoration: none !important;
    color: #333 !important;
    border-bottom: 1px solid #eee !important;
    transition: background 0.2s !important;
    background: white !important;
}

.search-item:last-child {
    border-bottom: none !important;
}

.search-item:hover {
    background: #fdf2f2 !important;
}

.search-item img {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    object-fit: contain !important;
    background: #fff !important;
    border-radius: 6px !important;
    border: 1px solid #f0f0f0 !important;
}

.search-item-info {
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.search-item-name {
    font-size: 0.9em !important;
    font-weight: bold !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.search-item-price {
    font-size: 0.85em !important;
    color: var(--primary-color) !important;
    margin-top: 4px !important;
}

.no-results {
    padding: 20px !important;
    text-align: center !important;
    color: #888 !important;
    font-style: italic !important;
    font-size: 0.95em !important;
    background: white !important;
}

/* ==========================================
   RESPONSIVE DESIGN (Media Queries)
   ========================================== */

/* Tablets y pantallas medianas (hasta 992px) */
@media (max-width: 992px) {
    .store-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        margin-bottom: 20px;
    }

    .product-details-container {
        flex-direction: column;
    }

    .search-bar {
        max-width: none;
        margin: 15px 0;
        order: 3;
    }

    .header-container {
        flex-wrap: wrap;
    }
}

/* Dispositivos Móviles (hasta 768px) */
@media (max-width: 768px) {
    .header-container {
        padding: 10px;
    }

    .logo-container .logo {
        max-height: 50px;
    }

    .header-nav {
        gap: 15px;
    }

    .header-nav a span {
        display: none; /* Ocultar texto "Mi Cuenta" */
    }

    .search-bar {
        margin: 10px 0 0 0;
        width: 100%;
    }

    /* Grid de productos a 2 columnas en móvil */
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .product-image img {
        height: 150px;
    }

    .product-title {
        font-size: 14px;
        height: 35px;
        overflow: hidden;
    }

    .price {
        font-size: 16px;
    }

    /* Vista Detalle Móvil */
    .product-details-container {
        padding: 15px;
    }
    
    .product-image-section img {
        max-height: 300px;
    }

    .product-info-section .product-title {
        font-size: 20px;
        height: auto;
    }

    /* Carrito Móvil */
    .cart-table thead {
        display: none;
    }

    .cart-item-row {
        display: block;
        margin-bottom: 15px;
        padding: 10px;
    }

    .cart-item-row td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 10px 5px;
        border-bottom: 1px solid #f1f1f1;
    }

    .cart-item-row td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #888;
        font-size: 13px;
    }

    .cart-product-info {
        width: 100%;
        gap: 10px;
    }
    
    .cart-product-name {
        font-size: 14px;
    }

    .cart-product-img {
        width: 50px;
        height: 50px;
    }

    .cart-summary {
        text-align: center;
    }

    .summary-line {
        justify-content: space-between;
        gap: 10px;
    }

    .cart-actions {
        flex-direction: column-reverse;
        gap: 15px;
    }

    .btn-checkout {
        width: 100%;
    }
}

/* Móviles pequeños (hasta 480px) */
@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: 1fr;
    }
}
