/* ==========================================================
   TIENDA ONLINE - ESTILOS VISUALES & SISTEMA DE DISEÑO
   Paleta moderna: Emerald, Slate, Amber con Glassmorphism
   ========================================================== */

:root {
    --primary: #059669;
    --primary-dark: #047857;
    --primary-light: #ecfdf5;
    --primary-hover: #10b981;
    --accent: #f59e0b;
    --accent-light: #fef3c7;
    --dark: #0f172a;
    --dark-muted: #334155;
    --light-bg: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --success: #10b981;
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.04);
    --shadow-md: 0 8px 20px rgba(0,0,0,0.06);
    --shadow-lg: 0 15px 35px rgba(0,0,0,0.1);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
}

/* --- CABECERA & NAVBAR --- */
.navbar-top {
    background-color: var(--dark);
    color: #94a3b8;
    font-size: 13px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.navbar-top .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.main-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

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

.nav-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    gap: 20px;
}

.logo-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 800;
    color: var(--primary-dark);
    letter-spacing: -0.5px;
}

.logo-icon-wrap {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(5, 150, 105, 0.3);
}

.search-bar-wrap {
    flex: 1;
    max-width: 550px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 12px 18px 12px 45px;
    border-radius: 50px;
    border: 2px solid var(--border-color);
    background: var(--light-bg);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.search-input:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.12);
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

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

.cart-btn-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid rgba(5, 150, 105, 0.2);
    padding: 10px 18px;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.cart-btn-toggle:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 6px 15px rgba(5, 150, 105, 0.25);
}

.cart-badge {
    background: var(--accent);
    color: var(--dark);
    font-size: 12px;
    font-weight: 800;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-admin-link {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-muted);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.btn-admin-link:hover {
    color: var(--primary);
    background: var(--primary-light);
}

/* --- BANNER PRINCIPAL --- */
.hero-banner {
    background: linear-gradient(135deg, #064e3b, #047857 60%, #065f46);
    color: white;
    padding: 50px 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    position: relative;
    overflow: hidden;
    margin-bottom: 40px;
}

.hero-banner::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.25), transparent 70%);
    border-radius: 50%;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    align-items: center;
    gap: 30px;
}

.hero-title {
    font-size: 38px;
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 15px;
    letter-spacing: -1px;
}

.hero-subtitle {
    font-size: 17px;
    color: #d1fae5;
    margin-bottom: 25px;
    max-width: 500px;
}

.hero-features {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.feature-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
}

/* --- CATEGORÍAS BARRA HORIZONTAL --- */
.categories-nav-section {
    margin-bottom: 35px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.categories-pills {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 10px;
    scrollbar-width: thin;
}

.cat-pill-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 50px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--dark-muted);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.cat-pill-btn:hover, .cat-pill-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.25);
}

/* --- REJILLA DE PRODUCTOS --- */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
    margin-bottom: 60px;
}

.product-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.product-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
}

.product-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-sale { background: var(--danger); color: white; }
.badge-pack { background: var(--accent); color: var(--dark); }
.badge-fresh { background: var(--primary); color: white; }
.badge-general { background: var(--dark); color: white; }

.product-img-wrap {
    height: 190px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 15px;
}

.product-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease;
}

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

.product-details {
    padding: 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-cat-name {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 4px;
}

.product-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
    line-height: 1.35;
    min-height: 44px;
}

.product-unit {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.product-price-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-top: auto;
    margin-bottom: 15px;
}

.price-current {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary-dark);
}

.price-old {
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: line-through;
}

.btn-add-cart {
    width: 100%;
    padding: 10px 14px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid rgba(5, 150, 105, 0.3);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-add-cart:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.2);
}

/* --- CARRITO LATERAL (DRAWER) --- */
.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.cart-overlay.active {
    opacity: 1;
    visibility: visible;
}

.cart-drawer {
    position: fixed;
    top: 0;
    right: -450px;
    width: 100%;
    max-width: 420px;
    height: 100vh;
    height: 100dvh;
    background: var(--card-bg);
    box-shadow: var(--shadow-lg);
    z-index: 999;
    transition: right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cart-drawer.active {
    right: 0;
}

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

.cart-drawer-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.cart-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}
.cart-close-btn:hover {
    color: var(--danger);
}

.cart-drawer-items {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px;
}

.cart-item-row {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
}

.cart-item-img {
    width: 60px;
    height: 60px;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
}

.cart-item-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

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

.cart-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 4px;
}

.cart-item-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary-dark);
}

.cart-qty-control {
    display: flex;
    align-items: center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.cart-qty-btn {
    background: var(--light-bg);
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    color: var(--dark-muted);
}
.cart-qty-btn:hover {
    background: var(--border-color);
}

.cart-qty-val {
    padding: 0 10px;
    font-size: 13px;
    font-weight: 700;
}

.cart-item-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    transition: var(--transition);
}
.cart-item-remove:hover {
    color: var(--danger);
}

.cart-drawer-footer {
    padding: 16px 20px;
    padding-bottom: max(25px, calc(16px + env(safe-area-inset-bottom, 20px)));
    border-top: 1px solid var(--border-color);
    background: var(--light-bg);
    flex-shrink: 0;
}

.cart-summary-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-muted);
}

.cart-summary-total {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px dashed var(--border-color);
    font-size: 18px;
    font-weight: 800;
    color: var(--dark);
}

.btn-checkout-cta {
    display: block;
    width: 100%;
    background: var(--primary);
    color: white;
    text-align: center;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 16px;
    margin-top: 12px;
    transition: var(--transition);
    border: none;
    cursor: pointer;
}

.btn-checkout-cta:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.3);
}

/* --- CHECKOUT Y FORMULARIOS --- */
.checkout-page-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 30px;
    margin: 40px 0 60px 0;
}

.checkout-box {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 30px;
    box-shadow: var(--shadow-sm);
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border-color);
    font-size: 15px;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}

.payment-options-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 15px;
}

.payment-radio-card {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.payment-radio-card:hover, .payment-radio-card.active {
    border-color: var(--primary);
    background: var(--primary-light);
}

.payment-radio-card input[type="radio"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
}

/* --- TOAST NOTIFICACIONES --- */
.toast-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--dark);
    color: white;
    padding: 14px 22px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInRight 0.3s ease;
}

.toast-success { background: #065f46; border-left: 4px solid var(--primary); }
.toast-error { background: #991b1b; border-left: 4px solid var(--danger); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- BOTÓN FLOTANTE WHATSAPP - BURBUJA CIRCULAR --- */
.whatsapp-float-btn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #25D366;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 6px 24px rgba(37, 211, 102, 0.5), 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: waBubblePulse 2.8s ease-in-out infinite;
}

.whatsapp-float-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2.5px solid rgba(37, 211, 102, 0.4);
    animation: waPingRing 2.8s ease-in-out infinite;
}

.whatsapp-float-btn:hover {
    background: #1db954;
    color: white;
    transform: scale(1.12) translateY(-3px);
    box-shadow: 0 12px 32px rgba(37, 211, 102, 0.65), 0 4px 12px rgba(0,0,0,0.2);
    animation: none;
}

.whatsapp-float-btn:hover::before {
    animation: none;
    border-color: transparent;
}

.whatsapp-float-icon {
    font-size: 30px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* tooltip al hacer hover */
.whatsapp-float-btn::after {
    content: attr(title);
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(15, 23, 42, 0.92);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    font-family: var(--font-heading);
}

.whatsapp-float-btn:hover::after {
    opacity: 1;
}

@keyframes waBubblePulse {
    0%, 100% { box-shadow: 0 6px 24px rgba(37, 211, 102, 0.5), 0 2px 8px rgba(0,0,0,0.15); }
    50% { box-shadow: 0 8px 30px rgba(37, 211, 102, 0.7), 0 4px 12px rgba(0,0,0,0.2); }
}

@keyframes waPingRing {
    0% { transform: scale(1); opacity: 0.7; }
    70% { transform: scale(1.25); opacity: 0; }
    100% { transform: scale(1.25); opacity: 0; }
}

/* Ocultar solo en pantallas muy pequeñas */
@media (max-width: 400px) {
    .whatsapp-float-btn { width: 52px; height: 52px; bottom: 18px; right: 18px; }
    .whatsapp-float-icon { font-size: 26px; }
}

/* --- BADGES Y AVISOS DE STOCK DINÁMICO --- */
.badge-low-stock {
    background: linear-gradient(135deg, #ea580c, #dc2626) !important;
    color: white !important;
    font-weight: 800;
    letter-spacing: 0.3px;
    animation: pulseStock 2s infinite;
}

.badge-out-of-stock {
    background: #475569 !important;
    color: #f8fafc !important;
    font-weight: 700;
}

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

.product-card.is-out-of-stock .product-img-wrap img {
    filter: grayscale(80%) opacity(0.7);
}

.product-stock-notice {
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 8px;
    padding: 3px 8px;
    border-radius: 4px;
    width: fit-content;
}

.product-stock-notice.low-stock {
    color: #c2410c;
    background: #fff7ed;
    border: 1px solid #ffedd5;
}

.product-stock-notice.out-stock {
    color: #991b1b;
    background: #fef2f2;
    border: 1px solid #fee2e2;
}

/* --- SELECTOR DE CANTIDAD EN TARJETA DE PRODUCTO - REDISEÑO PREMIUM --- */
.product-card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.product-qty-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.card-qty-control {
    display: inline-flex !important;
    align-items: center !important;
    background: #f0fdf4 !important;
    border: 1.5px solid var(--primary) !important;
    border-radius: 30px !important;
    overflow: hidden !important;
    height: 36px !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card-qty-control:focus-within {
    border-color: var(--primary-dark) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
}

.card-qty-btn {
    background: transparent !important;
    border: none !important;
    width: 30px !important;
    height: 100% !important;
    font-size: 17px !important;
    font-weight: 900 !important;
    color: var(--primary-dark) !important;
    cursor: pointer !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background 0.15s ease, color 0.15s ease;
    line-height: 1 !important;
    flex-shrink: 0 !important;
    user-select: none !important;
    padding: 0 !important;
    margin: 0 !important;
    -webkit-appearance: none !important;
}

.card-qty-btn:hover:not(:disabled) {
    background: var(--primary) !important;
    color: #ffffff !important;
}

.card-qty-btn:active:not(:disabled) {
    background: var(--primary-dark) !important;
    color: #ffffff !important;
    transform: scale(0.92);
}

.card-qty-btn:disabled {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

.card-qty-input {
    width: 26px !important;
    height: 100% !important;
    border: none !important;
    background: transparent !important;
    text-align: center !important;
    font-size: 14px !important;
    font-weight: 800 !important;
    color: var(--primary-dark) !important;
    padding: 0 !important;
    margin: 0 !important;
    -moz-appearance: textfield !important;
    -webkit-appearance: none !important;
    pointer-events: none !important;
}

.card-qty-input::-webkit-outer-spin-button,
.card-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

.btn-add-cart.is-disabled,
.btn-add-cart:disabled {
    background: #e2e8f0 !important;
    color: #94a3b8 !important;
    border-color: #cbd5e1 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    box-shadow: none !important;
    transform: none !important;
}

/* --- RESPONSIVE DESIGN - MOBILE FIRST --- */

/* ── Tablets grandes (< 1100px) ── */
@media (max-width: 1100px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 18px;
    }
    .checkout-page-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

/* ── Tablets (< 900px) ── */
@media (max-width: 900px) {
    .hero-grid {
        grid-template-columns: 1fr;
        text-align: center;
    }
    .hero-features {
        justify-content: center;
    }
    .hero-title { font-size: 30px; }
    .hero-subtitle { font-size: 15px; }

    .nav-row {
        flex-wrap: wrap;
        gap: 10px;
        padding: 12px 0;
    }
    .search-bar-wrap {
        order: 3;
        flex: 0 0 100%;
        max-width: 100%;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
}

/* ── Móvil grande (< 768px) ── */
@media (max-width: 768px) {
    /* Contenedor */
    .container { padding: 0 12px; }

    /* Barra superior oculta en móvil */
    .navbar-top { display: none !important; }

    /* ─── CABECERA COMPACTA EN 1 SOLA FILA (54px) ─── */
    .main-header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(12px);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
        border-bottom: 1px solid var(--border-color);
    }

    .nav-row {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
        padding: 8px 0 !important;
        height: 54px !important;
    }

    /* Logo compacto (solo icono en móvil para dejar espacio al buscador y cesta) */
    .logo-brand {
        flex-shrink: 0 !important;
        gap: 0 !important;
        font-size: 16px !important;
    }
    .logo-brand span {
        display: none !important;
    }
    .logo-icon-wrap {
        width: 38px !important;
        height: 38px !important;
        font-size: 18px !important;
        border-radius: 10px !important;
        flex-shrink: 0 !important;
    }

    /* Buscador ocupa el centro disponible */
    .search-bar-wrap {
        order: 2 !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        max-width: none !important;
        margin: 0 !important;
    }

    .search-input {
        height: 38px !important;
        padding: 6px 12px 6px 34px !important;
        font-size: 13px !important;
        border-radius: 30px !important;
        background: #f1f5f9 !important;
        border: 1.5px solid var(--border-color) !important;
    }
    .search-input:focus {
        background: #ffffff !important;
        border-color: var(--primary) !important;
    }

    .search-icon {
        left: 12px !important;
        font-size: 13px !important;
    }

    /* Botón de la Cesta SIEMPRE visible, compacto y destacado a la derecha */
    .header-actions {
        order: 3 !important;
        flex-shrink: 0 !important;
        gap: 0 !important;
    }

    .cart-btn-toggle {
        height: 38px !important;
        padding: 0 12px !important;
        gap: 6px !important;
        border-radius: 30px !important;
        font-size: 13px !important;
        background: var(--primary) !important;
        color: white !important;
        border: none !important;
        box-shadow: 0 3px 10px rgba(5, 150, 105, 0.35) !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .cart-btn-toggle span:first-of-type {
        display: none !important; /* Ocultar texto "Mi Cesta" para que sea un botón pill compacto */
    }

    .cart-badge {
        background: #ffffff !important;
        color: var(--primary-dark) !important;
        font-size: 11px !important;
        font-weight: 800 !important;
        width: 20px !important;
        height: 20px !important;
        border-radius: 50% !important;
    }

    /* Hero */
    .hero-banner { padding: 25px 0; margin-bottom: 20px; }
    .hero-title { font-size: 22px; letter-spacing: -0.5px; }
    .hero-subtitle { font-size: 13.5px; margin-bottom: 15px; }
    .feature-pill { font-size: 11.5px; padding: 5px 10px; }

    /* Categorías */
    .categories-pills { gap: 8px; }
    .cat-pill-btn { padding: 7px 12px; font-size: 12.5px; }
    .section-title { font-size: 18px; }

    /* Grid de productos — 2 columnas en móvil */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 35px;
    }

    /* Tarjeta de producto */
    .product-card { border-radius: 10px; }
    .product-img-wrap { height: 135px; padding: 8px; }
    .product-details { padding: 10px; }
    .product-title { font-size: 13px; min-height: 34px; margin-bottom: 4px; }
    .product-cat-name { font-size: 10.5px; }
    .product-unit { font-size: 11.5px; margin-bottom: 6px; }
    .price-current { font-size: 15.5px; }
    .price-old { font-size: 11.5px; }
    .product-price-row { margin-bottom: 8px; gap: 4px; }

    /* Acciones de tarjeta */
    .product-card-actions { gap: 5px; }
    .product-qty-row { gap: 4px; }

    .card-qty-control {
        height: 34px !important;
    }
    .card-qty-btn {
        width: 26px !important;
        font-size: 16px !important;
    }
    .card-qty-input {
        width: 22px !important;
        font-size: 12.5px !important;
    }

    .btn-add-cart {
        flex: 1;
        min-width: 0;
        padding: 7px 4px;
        font-size: 11.5px;
        gap: 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        border-radius: 8px;
    }

    /* Carrito drawer full-width en móvil */
    .cart-drawer {
        max-width: 100%;
        width: 100%;
        right: -100%;
        height: 100vh;
        height: 100dvh;
    }
    .cart-drawer.active { right: 0; }
    .cart-drawer-footer {
        padding: 14px 16px;
        padding-bottom: max(25px, calc(14px + env(safe-area-inset-bottom, 20px)));
    }

    /* Checkout */
    .checkout-page-grid { grid-template-columns: 1fr; gap: 16px; margin: 20px 0 40px 0; }
    .checkout-box { padding: 16px; }

    /* Footer */
    footer .container > div:first-of-type {
        grid-template-columns: 1fr !important;
    }
}

/* ── Móvil pequeño (< 420px) ── */
@media (max-width: 420px) {
    .container { padding: 0 10px; }
    .hero-title { font-size: 20px; }

    /* Una sola columna de productos en pantallas muy pequeñas */
    .products-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .product-img-wrap { height: 180px; }
    .product-details { padding: 14px; }
    .product-title { font-size: 15px; min-height: auto; }
    .price-current { font-size: 18px; }

    /* Volver a 2 columnas en qty row cuando hay espacio en 1-col grid */
    .product-qty-row { flex-direction: row; }
    .card-qty-control { height: 38px; }
    .card-qty-btn { width: 32px; font-size: 18px; }
    .card-qty-input { width: 28px; font-size: 14px; }
    .btn-add-cart { font-size: 13px; padding: 10px 8px; }

    /* WhatsApp bubble ajuste */
    .whatsapp-float-btn { width: 52px; height: 52px; bottom: 16px; right: 16px; }
    .whatsapp-float-icon { font-size: 26px; }
    .whatsapp-float-btn::after { display: none; }
}


