/**
 * Estilos de la Tienda Online - Versión Refactorizada
 * Sistema de Tienda Online - Restaurante
 *
 * PRINCIPIOS:
 * - Sin !important (excepto utilidades)
 * - Selectores específicos y claros
 * - Variables CSS para mantenibilidad
 * - Mobile-First responsive
 */

/* ===================================
   RESET Y BASE
=================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--light, #f8f9fa);
    color: var(--dark, #2c3e50);
    line-height: 1.6;
    padding-top: 90px;
}

/* ===================================
   HEADER STICKY
=================================== */

.header-sticky {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--white, #ffffff);
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    z-index: 1000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 18px 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--dark, #2c3e50);
    flex-shrink: 0;
}

.header-logo img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Buscador */
.header-search {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.header-search input {
    width: 100%;
    padding: 10px 40px;
    border: 2px solid #e8e8e8;
    border-radius: 25px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.header-search input:focus {
    outline: none;
    border-color: var(--secondary, #fcc600);
    box-shadow: 0 0 0 3px rgba(252, 198, 0, 0.15);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--gray, #666);
    pointer-events: none;
}

.clear-search {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    color: var(--gray, #666);
    cursor: pointer;
    display: none;
    transition: color 0.2s ease;
}

.clear-search:hover {
    color: var(--danger, #ff4757);
}

/* Botones del header */
.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-tracking {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--light, #f8f9fa);
    color: var(--dark, #2c3e50);
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn-tracking:hover {
    background: #e8e8e8;
    transform: translateY(-1px);
}

.btn-cart-wrapper {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.btn-cart {
    width: 45px;
    height: 45px;
    background: var(--secondary, #fcc600);
    color: var(--black, #000);
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-cart:hover {
    transform: scale(1.05);
    background: var(--secondary-dark, #e6b300);
    box-shadow: 0 4px 12px rgba(252, 198, 0, 0.3);
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger, #ff4757);
    color: var(--white, #fff);
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--white, #fff);
    z-index: 10;
    animation: cartPulse 0.3s ease;
}

@keyframes cartPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ===================================
   CATEGORÍAS STICKY
=================================== */

.categorias-sticky {
    position: sticky;
    top: 106px;
    background: var(--white, #fff);
    border-bottom: 1px solid #e8e8e8;
    z-index: 999;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.categorias-sticky::-webkit-scrollbar {
    display: none;
}

.categorias-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 16px 40px;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.categoria-pill {
    padding: 8px 20px;
    background: var(--light, #f8f9fa);
    color: var(--dark, #2c3e50);
    border: 2px solid transparent;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.categoria-pill:hover {
    background: #e8e8e8;
    transform: translateY(-1px);
}

.categoria-pill.active {
    background: var(--secondary, #fcc600);
    color: var(--black, #000);
    border-color: var(--secondary, #fcc600);
    font-weight: 700;
}

/* ===================================
   PRODUCTOS LISTA
=================================== */

.productos-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 30px 40px;
}

.productos-header {
    margin-bottom: 20px;
}

.productos-header h2 {
    font-size: 24px;
    color: var(--dark, #2c3e50);
    margin-bottom: 5px;
}

.productos-header p {
    color: var(--gray, #666);
    font-size: 14px;
}

.categoria-seccion {
    font-size: 28px;
    font-weight: 800;
    color: var(--dark, #2c3e50);
    margin: 40px 0 20px 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.categoria-seccion:first-of-type {
    margin-top: 0;
}

.productos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

/* ===================================
   TARJETA DE PRODUCTO - VERSIÓN LIMPIA
=================================== */

.producto-card {
    background: var(--white, #fff);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    position: relative;
    display: flex;
    padding: 12px;
    gap: 15px;
    align-items: stretch;
    overflow: hidden;
}

.producto-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.12);
}

/* Wrapper de imagen */
.producto-card-image-wrapper {
    position: relative;
    flex-shrink: 0;
    width: 140px;
    height: 140px;
    border-radius: 8px;
    overflow: hidden;
}

.producto-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    background: #f8f8f8;
    transition: transform 0.5s ease;
}

.producto-card:hover .producto-card-image {
    transform: scale(1.08);
}

/* Badges sobre la imagen */
.producto-badges {
    position: absolute;
    top: 5px;
    left: 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    z-index: 2;
}

.producto-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    color: var(--white, #fff);
    background: var(--black, #000);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
}

.badge-descuento {
    background: var(--danger, #ff4757);
    font-size: 12px;
}

.badge-stock {
    font-size: 10px;
    padding: 3px 8px;
}

.badge-stock-agotado {
    background: #e74c3c;
    animation: pulseBadge 2s ease-in-out infinite;
}

.badge-stock-bajo {
    background: #f39c12;
}

@keyframes pulseBadge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Contenido del producto */
.producto-card-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

/* REEMPLAZO DE SELECTOR FRÁGIL > div:first-child */
.producto-info-header {
    display: block;
    margin-bottom: 8px;
    min-height: 40px;
}

.producto-card-content h3 {
    font-size: 15px;
    margin-bottom: 4px;
    color: var(--dark, #2c3e50);
    font-weight: 700;
    line-height: 1.3;
}

.producto-descripcion {
    font-size: 12px;
    color: var(--gray, #666);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.producto-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.producto-precios {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.producto-precio-original {
    font-size: 11px;
    color: var(--gray, #666);
    text-decoration: line-through;
    line-height: 1.2;
}

.producto-precio {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark, #2c3e50);
    line-height: 1.2;
}

/* BOTÓN AGREGAR - SIN !IMPORTANT */
.producto-card .btn-agregar {
    width: 35px;
    height: 35px;
    min-width: 35px;
    min-height: 35px;
    background: var(--secondary, #fcc600);
    color: var(--black, #000);
    border: none;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
}

.producto-card .btn-agregar:hover {
    background: var(--secondary-dark, #e6b300);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.producto-card .btn-agregar:active {
    transform: scale(0.95);
}

/* Estados del botón */
.producto-card .btn-agregar.btn-agotado,
.producto-card .btn-disabled {
    background: #95a5a6;
    color: #e0e0e0;
    cursor: not-allowed;
    opacity: 0.6;
}

.producto-card .btn-agregar.btn-agotado:hover,
.producto-card .btn-disabled:hover {
    background: #95a5a6;
    transform: none;
    box-shadow: none;
}

/* ===================================
   EMPTY STATE
=================================== */

.empty-state {
    text-align: center;
    padding: 80px 20px;
    grid-column: 1 / -1;
}

.empty-state-icon {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    color: var(--dark, #2c3e50);
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--gray, #666);
}

/* ===================================
   FOOTER
=================================== */

.footer {
    background: var(--dark, #2c3e50);
    color: var(--white, #fff);
    margin-top: 60px;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 60px 20px 30px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
}

.footer-section h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--white, #fff);
}

.footer-section p {
    color: rgba(255,255,255,0.8);
    margin-bottom: 10px;
    line-height: 1.8;
}

.footer-section a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-section a:hover {
    color: var(--white, #fff);
}

.horarios-list {
    list-style: none;
}

.horarios-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 14px;
}

.horarios-list li:last-child {
    border-bottom: none;
}

.redes-sociales {
    display: flex;
    gap: 12px;
}

.red-social {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    text-decoration: none;
    transition: all 0.3s ease;
}

.red-social:hover {
    transform: scale(1.1) translateY(-2px);
}

.red-facebook { background: #1877f2; color: white; }
.red-instagram {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: white;
}
.red-twitter { background: #1da1f2; color: white; }
.red-tiktok { background: #000; color: white; }

.footer-bottom {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
    color: rgba(255,255,255,0.6);
    font-size: 14px;
}

/* ===================================
   TOAST NOTIFICATION
=================================== */

.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--success, #2ecc71);
    color: var(--white, #fff);
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateX(400px);
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 2000;
}

.toast.show {
    transform: translateX(0);
}

.toast-icon {
    font-size: 24px;
}

/* ===================================
   RESPONSIVE - TABLET
=================================== */

@media (max-width: 1024px) and (min-width: 769px) {
    .productos-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .producto-card-image-wrapper {
        width: 110px;
        height: 110px;
    }
}

/* ===================================
   RESPONSIVE - MÓVIL
=================================== */

@media (max-width: 768px) {
    body {
        padding-top: 75px;
    }

    .header-content {
        padding: 12px 15px;
        gap: 10px;
    }

    .header-logo img {
        width: 50px;
        height: 50px;
    }

    .header-search {
        max-width: none;
    }

    .header-search input {
        padding: 8px 35px;
        font-size: 13px;
    }

    /* --- CORRECCIÓN BOTÓN RASTREAR MÓVIL --- */
    .btn-tracking {
        padding: 0;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--light, #f8f9fa);
    }

    /* Ocultamos SOLO el texto (el segundo span) */
    .btn-tracking span:last-child {
        display: none;
    }

    /* Aseguramos que el icono (el primer span) sea visible */
    .btn-tracking span:first-child {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .btn-tracking svg {
        width: 20px;
        height: 20px;
    }
    /* --- FIN CORRECCIÓN --- */

    .btn-cart {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .categorias-sticky {
        top: 5px;
        position: relative;
    }

    .categorias-sticky::after {
        content: '';
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 30px;
        background: linear-gradient(to right, transparent, var(--white, #fff));
        pointer-events: none;
        z-index: 1;
    }

    .categorias-container {
        padding: 12px 15px;
        justify-content: flex-start;
        scroll-padding-left: 15px;
    }

    .productos-section {
        padding: 20px 15px;
    }

    .categoria-seccion {
        font-size: 22px;
        margin: 30px 0 15px 0;
    }

    .productos-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* MÓVIL: Tarjeta vertical */
    .producto-card {
        flex-direction: column;
        padding: 10px;
        gap: 0;
        min-height: auto;
    }

    .producto-card-image-wrapper {
        width: 100%;
        height: 140px;
        margin-bottom: 12px;
    }

    .producto-card-content {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .producto-info-header {
        margin-bottom: 10px;
        min-height: 35px;
    }

    .producto-card-content h3 {
        font-size: 14px;
        font-weight: 700;
        line-height: 1.4;
        margin: 0 0 4px 0;
    }

    .producto-descripcion {
        display: none;
    }

    .producto-footer {
        margin-top: auto;
    }

    .producto-precio {
        font-size: 14px;
    }

    .producto-precio-original {
        font-size: 10px;
    }

    .producto-card .btn-agregar {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
        font-size: 16px;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
        padding: 40px 20px 20px;
    }

    .toast {
        right: 15px;
        left: 15px;
        bottom: 20px;
    }
}

/* ===================================
   UTILIDADES (Solo aquí es válido usar !important)
=================================== */

.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* ===================================
   INFINITE SCROLL
=================================== */

.productos-contenedor {
    /* Contenedor principal - sin estilos específicos */
}

.infinite-scroll-trigger {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 20px;
    margin: 20px 0;
}

.infinite-scroll-trigger .loader {
    text-align: center;
}

.infinite-scroll-trigger .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f8f9fa;
    border-top-color: #fcc600;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.infinite-scroll-trigger p {
    color: #666;
    font-size: 14px;
    font-weight: 600;
}

.scroll-end-message {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 16px;
}

.scroll-end-message p {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}