﻿/* =====================================================
   VARIABLES
   ===================================================== */
:root {
    --navy: #1a1f3a;
    --navy-mid: #252c4a;
    --navy-light: #2e3660;
    --gold: #f59e0b;
    --gold-soft: rgba(245,158,11,0.12);
    --gold-border: rgba(245,158,11,0.30);
    --green: #10b981;
    --green-dark: #059669;
    --red: #ef4444;
    --gray-bg: #f4f6fb;
    --gray-card: #f9fafb;
    --border: #e8eaf0;
    --text-dark: #1a1f3a;
    --text-mid: #4b5563;
    --text-muted: #9ca3af;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --sidebar-w: 380px;
}

/* =====================================================
   BASE
   ===================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', sans-serif;
    background: var(--gray-bg);
    min-height: 100vh;
    color: var(--text-dark);
}

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.15);
    border-radius: 4px;
}

/* =====================================================
   HEADER
   ===================================================== */
.store-header {
    background: var(--navy);
    color: #fff;
    padding: 12px 0 10px;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 2px solid var(--gold);
}

    .store-header .container {
        padding: 0 16px;
    }

/* Fila 1: brand */
.header-brand {
    margin-bottom: 10px;
}

/* Fila 2: búsqueda + acciones */
.header-bottom {
    display: flex;
    align-items: center;
    gap: 10px;
}

    .header-bottom .header-search {
        flex: 1;
        margin-bottom: 0;
    }

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.store-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #fff;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.3px;
}

    .store-logo i {
        color: var(--gold);
        font-size: 1.2rem;
    }

.store-tagline {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.55);
    margin-top: 1px;
    font-weight: 400;
}

.ecf-badge {
    background: var(--gold-soft);
    border: 1px solid var(--gold-border);
    color: var(--gold);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 20px;
    margin-left: 6px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hdr-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.2s;
    position: relative;
    text-decoration: none;
}

    .hdr-btn:hover {
        background: rgba(255,255,255,0.18);
    }

    .hdr-btn.gold {
        background: var(--gold);
        border-color: var(--gold);
        color: var(--navy);
        font-weight: 700;
    }

.cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 17px;
    height: 17px;
    background: var(--gold);
    color: var(--navy);
    border-radius: 50%;
    font-size: 9px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Barra de búsqueda en header */
.header-search {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 24px;
    padding: 7px 14px;
    gap: 8px;
}

    .header-search i {
        color: rgba(255,255,255,0.5);
        font-size: 13px;
    }

    .header-search input {
        background: transparent;
        border: none;
        outline: none;
        color: #fff;
        font-size: 13px;
        width: 100%;
        font-family: inherit;
    }

        .header-search input::placeholder {
            color: rgba(255,255,255,0.45);
        }

/* Usuario autenticado */
.user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: rgba(255,255,255,0.85);
    font-size: 12px;
    font-weight: 500;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gold);
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
}

/* =====================================================
   BARRA DE CATEGORÍAS
   ===================================================== */
.categories-bar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
}

    .categories-bar .container {
        padding: 6px 14px;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }

.category-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--gray-bg);
    border: 1.5px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    margin-right: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-mid);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

    .category-btn:hover {
        border-color: var(--navy);
        color: var(--navy);
    }

    .category-btn.active {
        background: var(--navy);
        border-color: var(--navy);
        color: #fff;
    }

    .category-btn i {
        font-size: 11px;
    }

/* =====================================================
   BÚSQUEDA (bajo categorías, mobile)
   ===================================================== */
.search-bar {
    padding: 12px 14px 0;
    max-width: 100%;
}

.search-input {
    border-radius: 24px;
    padding: 10px 18px;
    border: 1.5px solid var(--border);
    background: #fff;
    font-size: 13px;
    width: 100%;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
}

    .search-input:focus {
        border-color: var(--navy);
        box-shadow: 0 0 0 3px rgba(26,31,58,0.08);
    }

/* =====================================================
   GRID DE PRODUCTOS — 2 por fila móvil, 3 tablet, 4 desktop
   ===================================================== */
.products-section {
    padding: 14px;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

    .section-title::after {
        content: '';
        flex: 1;
        height: 1px;
        background: var(--border);
    }

#productsGrid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

@media (min-width: 576px) {
    #productsGrid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}

@media (min-width: 768px) {
    #productsGrid {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }
}

@media (min-width: 1024px) {
    #productsGrid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}

/* =====================================================
   PRODUCT CARD
   ===================================================== */
.product-card {
    background: #fff;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1.5px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.22s, box-shadow 0.22s, border-color 0.22s;
    position: relative;
}

    .product-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 12px 32px rgba(26,31,58,0.12);
        border-color: rgba(26,31,58,0.25);
    }

/* Imagen del producto */
.product-image {
    width: 100%;
    height: 140px;
    background: linear-gradient(135deg, #e8eaf6, #dde1f5);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

@media (min-width: 768px) {
    .product-image {
        height: 180px;
    }
}

@media (min-width: 1024px) {
    .product-image {
        height: 200px;
    }
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s;
}

.product-card:hover .product-image img {
    transform: scale(1.06);
}

.product-image .placeholder-icon {
    font-size: 2.5rem;
    color: rgba(26,31,58,0.2);
}

/* Badges */
.product-badge {
    position: absolute;
    top: 7px;
    left: 7px;
    font-size: 9px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 10px;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    z-index: 2;
}

.badge-new {
    background: var(--navy);
    color: #fff;
}

.badge-off {
    background: var(--red);
    color: #fff;
}

.badge-hot {
    background: var(--gold);
    color: var(--navy);
}

.badge-out {
    background: #e5e7eb;
    color: var(--text-muted);
}

/* Favorito */
.fav-btn {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #d1d5db;
    font-size: 13px;
    transition: color 0.2s;
    z-index: 2;
}

    .fav-btn:hover, .fav-btn.active {
        color: var(--red);
    }

/* Body */
.product-body {
    padding: 10px 11px 11px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1.35;
    margin-bottom: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

@media (min-width: 768px) {
    .product-title {
        font-size: 13px;
    }
}

.product-meta {
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

    .product-meta i {
        font-size: 9px;
    }

.stock-ok {
    color: var(--green);
}

.stock-out {
    color: var(--red);
}

.product-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.price-block {
    display: flex;
    flex-direction: column;
}

.product-price {
    font-size: 14px;
    font-weight: 800;
    color: var(--navy);
    line-height: 1.1;
}

@media (min-width: 768px) {
    .product-price {
        font-size: 15px;
    }
}

.product-old-price {
    font-size: 10px;
    color: var(--text-muted);
    text-decoration: line-through;
    line-height: 1;
}

.add-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--navy);
    border: none;
    color: var(--gold);
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.18s, transform 0.18s;
}

    .add-btn:hover {
        background: var(--navy-light);
        transform: scale(1.1);
    }

    .add-btn:active {
        transform: scale(0.95);
    }

/* Botón completo (cuando no hay stock / no autenticado) */
.btn-add-cart {
    width: 100%;
    background: var(--navy);
    color: var(--gold);
    border: none;
    padding: 9px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

    .btn-add-cart:hover {
        background: var(--navy-light);
    }

.btn-add-cart-login {
    width: 100%;
    padding: 9px;
    background: #f3f4f6;
    color: var(--text-mid);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

    .btn-add-cart-login:hover {
        background: var(--navy);
        color: #fff;
        border-color: var(--navy);
    }

.btn-add-cart-disabled {
    width: 100%;
    padding: 9px;
    background: #f3f4f6;
    color: var(--text-muted);
    border: 1.5px dashed #d1d5db;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: not-allowed;
    margin-top: 8px;
    text-align: center;
}

/* =====================================================
   PAGINACIÓN
   ===================================================== */
.pagination-wrap {
    padding: 16px 14px 24px;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

    .pagination .page-link {
        color: var(--navy);
        border: 1.5px solid var(--border);
        padding: 6px 12px;
        border-radius: var(--radius-sm);
        font-size: 12px;
        font-weight: 600;
        transition: all 0.2s;
        background: #fff;
    }

        .pagination .page-link:hover {
            background: var(--gray-bg);
            border-color: var(--navy);
        }

    .pagination .page-item.active .page-link {
        background: var(--navy);
        border-color: var(--navy);
        color: #fff;
    }

    .pagination .page-item.disabled .page-link {
        color: var(--text-muted);
        pointer-events: none;
        background: var(--gray-bg);
    }

.pagination-info {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* =====================================================
   CARRITO LATERAL
   ===================================================== */
.cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
    z-index: 1999;
    display: none;
}

    .cart-overlay.show {
        display: block;
    }

.cart-sidebar {
    position: fixed;
    right: -100%;
    left: auto;
    top: 0;
    width: min(var(--sidebar-w), 100%);
    height: 100vh;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0,0,0,0.18);
    transition: right 0.28s cubic-bezier(0.4,0,0.2,1);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

    .cart-sidebar.open {
        right: 0;
        left: auto;
    }

.cart-header {
    background: var(--navy);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--gold);
    flex-shrink: 0;
}

    .cart-header h3 {
        font-size: 15px;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 8px;
    }

        .cart-header h3 i {
            color: var(--gold);
        }

.cart-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

    .cart-close:hover {
        background: rgba(255,255,255,0.2);
        transform: rotate(90deg);
    }

.cart-items {
    flex-grow: 1;
    overflow-y: auto;
    padding: 12px;
    background: var(--gray-bg);
}

.empty-cart {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

    .empty-cart i {
        font-size: 3rem;
        margin-bottom: 1rem;
        opacity: 0.4;
        display: block;
    }

    .empty-cart p {
        font-size: 13px;
    }

.cart-item {
    display: flex;
    gap: 10px;
    padding: 10px;
    background: #fff;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    align-items: center;
    transition: box-shadow 0.2s;
}

    .cart-item:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }

.cart-item-image {
    width: 52px;
    height: 52px;
    background: linear-gradient(135deg, #e8eaf6, #dde1f5);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--navy);
    font-size: 1.4rem;
    flex-shrink: 0;
}

.cart-item-details {
    flex-grow: 1;
    min-width: 0;
}

.cart-item-title {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.cart-item-price {
    color: var(--navy);
    font-weight: 800;
    font-size: 13px;
}

.quantity-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
}

.qty-btn {
    width: 26px;
    height: 26px;
    border: 1.5px solid var(--border);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.18s;
}

    .qty-btn:hover {
        background: var(--navy);
        color: #fff;
        border-color: var(--navy);
    }

.qty-display {
    font-size: 13px;
    font-weight: 700;
    min-width: 20px;
    text-align: center;
}

.remove-item {
    background: transparent;
    border: none;
    color: #d1d5db;
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    transition: color 0.2s;
}

    .remove-item:hover {
        color: var(--red);
    }

.cart-footer {
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: #fff;
    flex-shrink: 0;
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

    .cart-total span:first-child {
        font-size: 13px;
        color: var(--text-mid);
        font-weight: 500;
    }

    .cart-total span:last-child {
        font-size: 18px;
        font-weight: 800;
        color: var(--navy);
    }

.btn-checkout {
    width: 100%;
    background: var(--navy);
    color: var(--gold);
    border: none;
    padding: 13px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

    .btn-checkout:hover {
        background: var(--navy-light);
    }

    .btn-checkout:active {
        transform: scale(0.99);
    }

/* =====================================================
   PANEL DE PEDIDOS FLOTANTE
   ===================================================== */
.pedido-flotante {
    position: fixed;
    top: 90px;
    right: 16px;
    width: min(400px, calc(100vw - 32px));
    max-height: 580px;
    overflow-y: auto;
    z-index: 1050;
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: 0 12px 40px rgba(0,0,0,0.18);
    border: 1px solid var(--border);
}

    .pedido-flotante .card {
        margin-bottom: 0;
        border: none;
    }

    .pedido-flotante .card-header {
        background: var(--navy);
        color: #fff;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
        font-weight: 700;
        font-size: 13px;
        padding: 10px 14px;
        border-bottom: 2px solid var(--gold);
    }

    .pedido-flotante .card-body {
        padding: 10px;
        max-height: 480px;
        overflow-y: auto;
    }

.pedido-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    background: #fff;
    transition: box-shadow 0.2s;
}

    .pedido-card:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    }

    .pedido-card .card-body {
        padding: 10px !important;
        max-height: none !important;
        overflow-y: visible !important;
    }

/* =====================================================
   BARRA INFERIOR (MOBILE NAV)
   ===================================================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-top: 1px solid var(--border);
    padding: 8px 0 10px;
    z-index: 900;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        justify-content: space-around;
    }
}

.bn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 600;
    cursor: pointer;
    padding: 0 12px;
    transition: color 0.2s;
    border: none;
    background: none;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

    .bn-item i {
        font-size: 18px;
    }

    .bn-item.active {
        color: var(--navy);
    }

/* Espacio para que el contenido no quede bajo la bottom nav */
@media (max-width: 768px) {
    body {
        padding-bottom: 64px;
    }
}

/* =====================================================
   ESTADO VACÍO / ERROR
   ===================================================== */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

    .empty-state i {
        font-size: 3rem;
        margin-bottom: 1rem;
        display: block;
        opacity: 0.4;
    }

    .empty-state p {
        font-size: 13px;
    }

    .empty-state .btn-retry {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        margin-top: 12px;
        padding: 8px 18px;
        background: var(--navy);
        color: var(--gold);
        border: none;
        border-radius: var(--radius-sm);
        font-size: 12px;
        font-weight: 700;
        cursor: pointer;
    }

/* =====================================================
   SPINNER DE CARGA
   ===================================================== */
.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem 1rem;
}

.spinner-ko {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid var(--navy);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* =====================================================
   RESPONSIVE — AJUSTES FINOS
   ===================================================== */
@media (max-width: 480px) {
    .store-logo {
        font-size: 1rem;
    }

    .product-image {
        height: 120px;
    }

    .product-price {
        font-size: 13px;
    }

    .add-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}
