/* ==========================================================================
   Variables CSS (:root) - Paleta Global
   ========================================================================== */
:root {
    --primary-color: #FF4747;
    --primary-hover: #E63E3E;
    --bg-color: #F4F5F7;
    --surface-color: #FFFFFF;
    --text-main: #1A1A1A;
    --text-muted: #767676;
    --border-color: #EAEAEA;
    --star-color: #FFA534;
    
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
    --shadow-xl: 0 24px 64px rgba(0, 0, 0, 0.2);
    --shadow-primary: 0 4px 14px rgba(255, 71, 71, 0.35);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-blur: blur(12px);
}

/* ==========================================================================
   Reset CSS y Estilos Base
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a {
    text-decoration: none;
    color: inherit;
}
ul {
    list-style: none;
}
img {
    max-width: 100%;
    display: block;
}
.w-100 { width: 100%; }
.text-center { text-align: center; }

/* Botones Comunes */
.btn-primary {
    background: var(--primary-color);
    color: white;
    padding: 16px 36px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 1.05rem;
    display: inline-block;
    text-align: center;
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-primary);
}
.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ==========================================================================
   Header Global
   ========================================================================== */
#main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--surface-color);
    z-index: 1000;
    transition: var(--transition-smooth);
    border-bottom: 1px solid var(--border-color);
}
#main-header.scrolled {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid transparent;
}
.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 32px;
}
.logo {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.logo span {
    color: var(--primary-color);
}
.search-bar {
    flex: 1;
    max-width: 650px;
    display: flex;
    position: relative;
    border-radius: 999px;
    overflow: visible; /* Changed from hidden to allow dropdown */
    border: 2px solid var(--primary-color);
    background: var(--surface-color);
    transition: var(--transition-smooth);
}
.search-bar:focus-within {
    box-shadow: var(--shadow-primary);
}
.search-bar input {
    width: 100%;
    padding: 12px 24px;
    border: none;
    outline: none;
    font-size: 0.95rem;
    font-family: inherit;
    background: transparent;
}
.search-bar button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0 28px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background var(--transition-fast);
    border-radius: 0 999px 999px 0; /* Add border radius to match container */
}
.search-bar button:hover {
    background: var(--primary-hover);
}

/* Search Autocomplete Dropdown */
.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: all var(--transition-smooth);
    border: 1px solid var(--border-color);
}
.search-dropdown.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.95rem;
    transition: background 0.2s;
}
.search-result-item:hover {
    background: var(--bg-color);
}
.search-result-item i {
    color: var(--text-muted);
    font-size: 1.1rem;
}
.search-result-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-img {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
}
.search-result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.search-result-title {
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.search-result-price {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 700;
    margin-top: 2px;
}

.header-actions {
    display: flex;
    gap: 24px;
    align-items: center;
}
.action-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--text-main);
    transition: color var(--transition-fast);
    position: relative;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
}
.action-icon i {
    font-size: 1.6rem;
}
.action-icon:hover {
    color: var(--primary-color);
}
.cart-icon .cart-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--surface-color);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.cart-icon.bump .cart-badge {
    transform: scale(1.3);
}

/* Categorías (Debajo del Header) */
.category-nav {
    margin-top: 85px;
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    overflow-x: auto;
    scrollbar-width: none;
}
.category-nav::-webkit-scrollbar { display: none; }
.nav-list {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}
.nav-list li a {
    display: inline-block;
    padding: 16px 20px;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text-main);
    white-space: nowrap;
    position: relative;
    transition: color var(--transition-fast);
}
.nav-list li a:hover,
.nav-list li a.active {
    color: var(--primary-color);
}
.nav-list li a.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20px;
    right: 20px;
    height: 3px;
    background: var(--primary-color);
    border-radius: 3px 3px 0 0;
}
.nav-list li a.highlight {
    color: var(--primary-color);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ==========================================================================
   Footer Global
   ========================================================================== */
footer {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 72px 24px 24px;
}
.footer-container {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 48px;
    margin-bottom: 48px;
}
.footer-col h4 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 24px;
}
.footer-col ul {
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.footer-col ul li a {
    color: var(--text-muted);
    transition: color var(--transition-fast);
}
.footer-col ul li a:hover {
    color: var(--primary-color);
}
.payment-icons {
    display: flex;
    gap: 16px;
    font-size: 2.2rem;
    color: var(--text-muted);
}
.newsletter-form {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.newsletter-form input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
}
.newsletter-form input:focus {
    border-color: var(--primary-color);
}
.newsletter-form button {
    background: var(--text-main);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
}
.footer-bottom {
    max-width: 1400px;
    margin: 0 auto;
    text-align: center;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ==========================================================================
   Sistema de Notificaciones (Toasts)
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.toast {
    background: var(--surface-color);
    color: var(--text-main);
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 14px;
    border-left: 5px solid var(--primary-color);
    animation: slideIn 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
    font-weight: 500;
    font-size: 1rem;
    min-width: 300px;
}
.toast i {
    color: var(--primary-color);
    font-size: 1.4rem;
}
.toast.fade-out {
    animation: fadeOut 0.3s ease forwards;
}
@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut {
    to { transform: translateX(120%); opacity: 0; }
}

/* Media Queries Base */
@media (max-width: 768px) {
    .header-container { flex-wrap: wrap; padding: 12px 16px; gap: 16px; }
    .search-bar { order: 3; max-width: 100%; width: 100%; }
    .action-text { display: none; }
    .category-nav { margin-top: 125px; }
    .toast-container { bottom: 16px; right: 16px; left: 16px; }
    .toast { min-width: 0; width: 100%; }
}

/* ==========================================================================
   RESPONSIVE OPTIMIZATION (MOBILE & TABLET)
   ========================================================================== */
@media (max-width: 768px) {
    /* Header - Mobile Layout */
    .header-container { flex-wrap: wrap !important; gap: 12px; padding: 12px 16px; justify-content: space-between; }
    .logo { font-size: 1.6rem; flex: 0 1 auto; white-space: nowrap !important; }
    .header-actions { flex: 0 1 auto; gap: 12px; }
    .search-bar { order: 3 !important; flex: 1 1 100% !important; min-width: 100% !important; margin-top: 8px; }
    .action-text { display: none; } /* Ocultar texto, mostrar solo iconos */
    
    /* Category Navigation */
    .category-nav ul { 
        justify-content: flex-start; 
        overflow-x: auto; 
        white-space: nowrap; 
        padding-bottom: 8px; 
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .category-nav ul::-webkit-scrollbar { display: none; }
    
    /* Product Grids (2 columns on mobile) */
    .products-grid, .main-products-grid, .flash-grid, #main-products-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }
    
    /* Product Cards */
    .product-card { padding: 12px; }
    .product-img { height: 130px; }
    .product-img img { height: 100%; width: 100%; object-fit: contain; }
    .product-title { font-size: 0.85rem; }
    .price-container { flex-direction: column; align-items: flex-start; gap: 2px; }
    
    /* Product Detail Page */
    .product-detail-container { flex-direction: column; gap: 24px; padding: 16px; }
    .product-image-container { max-width: 100%; height: auto; }
    .product-info-container { padding: 0; }
    
    /* Cart and Checkout */
    .cart-container, .checkout-container { flex-direction: column; padding: 16px; gap: 24px; }
    .cart-items, .checkout-form { width: 100%; }
    .cart-summary, .order-summary { width: 100%; position: static; }
}

/* Anti-overflow global fix */
html, body {
    overflow-x: hidden !important;
    width: 100%;
    max-width: 100vw; overflow-x: hidden;
}
* {
    max-width: 100%;
    
}
