﻿/* ============================================
   CUPONES MODULE — Mobile-First
   ============================================ */

/* --- Auto-hide Header --- */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    z-index: 100;
}

.main-header.header-hidden {
    transform: translateY(-100%);
}

/* --- Page Layout --- */
.cupones-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.cupones-scroll-area {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* --- Hero Banner --- */
.cupones-hero {
    background: linear-gradient(135deg, var(--brand-red), #b71c1c);
    color: #fff;
    padding: 84px 20px 20px;
    text-align: center;
}

.cupones-hero h1 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.cupones-hero p {
    font-size: 0.72rem;
    opacity: 0.85;
    font-weight: 500;
}

/* --- Category Bar (Sticky) --- */
.category-bar-wrapper {
    position: sticky;
    top: 56px;
    z-index: 50;
    background: var(--bg-canvas);
    border-bottom: 1px solid var(--border-subtle);
    transition: top 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s;
}

.category-bar-wrapper.header-hidden {
    top: 0;
}

.category-bar-wrapper.scrolled {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.category-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.category-bar::-webkit-scrollbar {
    display: none;
}

.category-chip {
    flex-shrink: 0;
    scroll-snap-align: start;
    padding: 6px 16px;
    border-radius: 20px;
    font-family: var(--font);
    font-size: 0.7rem;
    font-weight: 700;
    border: 2px solid var(--border-subtle);
    background: var(--card-surface);
    color: var(--text-gray);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.category-chip:hover {
    border-color: var(--brand-red);
    color: var(--brand-red);
}

.category-chip.active {
    background: var(--brand-red);
    border-color: var(--brand-red);
    color: #fff;
    box-shadow: 0 2px 8px rgba(234, 118, 0, 0.3);
}

/* --- Coupon Count --- */
.cupones-count {
    padding: 8px 16px 0;
    font-size: 0.65rem;
    color: var(--text-gray);
    font-weight: 600;
}

/* --- Coupon Grid --- */
.cupones-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 16px 100px;
}

/* --- Coupon Card --- */
.cupon-card {
    display: flex;
    gap: 14px;
    background: var(--card-surface);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow-card);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.25s ease;
    position: relative;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    border: 1px solid var(--border-subtle);
}

.cupon-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.cupon-card:active {
    transform: scale(0.98);
}

/* card used up / expired */
.cupon-card.used-up,
.cupon-card.expired {
    opacity: 0.5;
    filter: grayscale(0.5);
    pointer-events: none;
}

/* --- Card Image --- */
.cupon-img-wrap {
    width: 90px;
    height: 90px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    background: #f5f5f5;
}

.cupon-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Card Info --- */
.cupon-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-width: 0;
}

.cupon-title {
    font-family: var(--font);
    font-weight: 800;
    font-size: 0.82rem;
    color: var(--text-dark);
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cupon-desc {
    font-size: 0.65rem;
    color: var(--text-gray);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cupon-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.cupon-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.58rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

.badge-uso {
    background: #E3F2FD;
    color: #1565C0;
}

.badge-vigente {
    background: #E8F5E9;
    color: #2E7D32;
}

.badge-por-vencer {
    background: #FFF8E1;
    color: #F57F17;
}

.badge-vence-hoy {
    background: #FFEBEE;
    color: #C96500;
    animation: badgePulseUrgent 1.2s ease-in-out infinite;
}

.badge-agotado {
    background: #FFEBEE;
    color: #C96500;
}

.badge-ultimos {
    background: #FFF3E0;
    color: #E65100;
    animation: badgePulseUrgent 2s ease-in-out infinite;
}

/* --- Price Tag --- */
.cupon-price {
    position: absolute;
    top: 10px;
    right: 10px;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--brand-red);
    background: rgba(255, 255, 255, 0.95);
    padding: 2px 8px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* --- Urgency Pulse --- */
@keyframes badgePulseUrgent {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* ============================================
   BOTTOM SHEET — Redemption Modal
   ============================================ */
.cupon-sheet-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.cupon-sheet-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

.cupon-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--card-surface);
    border-radius: 20px 20px 0 0;
    z-index: 201;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 90vh;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

.cupon-sheet.visible {
    transform: translateY(0);
}

.sheet-drag-handle {
    width: 36px;
    height: 4px;
    background: var(--border-subtle);
    border-radius: 2px;
    margin: 10px auto 0;
}

.sheet-content {
    padding: 16px 20px 20px;
}

.sheet-cupon-img {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 12px;
}

.sheet-cupon-title {
    font-family: var(--font);
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 4px;
}

.sheet-cupon-desc {
    font-size: 0.75rem;
    color: var(--text-gray);
    text-align: center;
    line-height: 1.4;
    margin-bottom: 12px;
}

.sheet-meta-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-bottom: 16px;
}

.sheet-meta-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 8px;
    background: #f5f5f5;
    color: #555;
}

/* --- Sheet Steps (Detail → Confirm → QR) --- */
.sheet-step {
    display: none;
}

.sheet-step.active {
    display: block;
}

/* --- Redeem Button --- */
.btn-redeem-cupon {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, var(--brand-red), #b71c1c);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 15px rgba(234, 118, 0, 0.3);
    -webkit-tap-highlight-color: transparent;
}

.btn-redeem-cupon:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(234, 118, 0, 0.4);
}

.btn-redeem-cupon:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-redeem-cupon:disabled {
    background: #ccc;
    color: #888;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-redeem-cupon.used {
    background: #e0e0e0;
    color: #888;
}

.btn-close-sheet {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-subtle);
    border-radius: 12px;
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-gray);
    background: transparent;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.btn-close-sheet:hover {
    background: #f5f5f5;
}

/* --- QR Step --- */
.qr-container {
    text-align: center;
    padding: 20px 0;
}

.qr-code-box {
    width: 200px;
    height: 200px;
    margin: 0 auto 16px;
    background: #fff;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 2px solid #eee;
}

.qr-code-box canvas {
    border-radius: 8px;
}

.qr-instruction {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.qr-timer {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    color: var(--brand-red);
    margin-bottom: 4px;
}

.qr-timer-label {
    font-size: 0.6rem;
    color: var(--text-gray);
    font-weight: 600;
}

.qr-timer.expiring {
    animation: badgePulseUrgent 0.8s ease-in-out infinite;
}

/* --- Confirmation Warning --- */
.confirm-warning {
    padding: 12px 14px;
    background: #FFF3E0;
    border-left: 3px solid #FF9800;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    color: #E65100;
    line-height: 1.4;
    margin-bottom: 16px;
}

/* --- Empty State --- */
.cupones-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-gray);
}

.cupones-empty .empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

.cupones-empty p {
    font-size: 0.8rem;
    font-weight: 600;
}

/* ============================================
   RESPONSIVE — Tablet + Desktop
   ============================================ */
@media (min-width: 600px) {
    .cupones-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
        padding: 16px 24px 100px;
    }

    .cupon-img-wrap {
        width: 100px;
        height: 100px;
    }

    .cupones-hero h1 {
        font-size: 2rem;
    }
}

@media (min-width: 1024px) {
    .cupones-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
        padding: 20px 40px 100px;
        max-width: 1200px;
        margin: 0 auto;
    }

    .cupon-card {
        padding: 16px;
    }

    .cupon-img-wrap {
        width: 110px;
        height: 110px;
    }

    .cupones-hero {
        padding: 92px 40px 28px;
    }

    .category-bar {
        padding: 12px 40px;
        justify-content: center;
    }

    .cupones-count {
        max-width: 1200px;
        margin: 0 auto;
        padding: 10px 40px 0;
    }

    /* Bottom sheet becomes a centered modal on desktop */
    .cupon-sheet {
        left: 50%;
        right: auto;
        width: 480px;
        transform: translate(-50%, 100%);
        border-radius: 20px 20px 0 0;
    }

    .cupon-sheet.visible {
        transform: translate(-50%, 0);
    }
}

/* ============================================
   WHATSAPP FAB
   ============================================ */
.whatsapp-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 90;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #25D366;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
    cursor: pointer;
    transition: transform 0.2s;
    text-decoration: none;
}

.whatsapp-fab:hover {
    transform: scale(1.1);
}

.whatsapp-fab svg {
    width: 26px;
    height: 26px;
}