/*
 * FILE: chance2win-theme/assets/css/pick-a-number-popup.css
 * ACTION: Created
 * PURPOSE: Modal popup for Pick-a-Number on shop/home/archive pages.
 *
 * Uses CSS variables so all 6 skins are supported automatically.
 * Responsive verified: 375px | 768px | 1280px
 */

/* ── Backdrop / overlay ─────────────────────────────────────────── */
.c2w-dbn-popup {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.c2w-dbn-popup[hidden] {
    display: none !important;
}

.c2w-dbn-popup__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

/* ── Dialog box ─────────────────────────────────────────────────── */
.c2w-dbn-popup__dialog {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: c2w-dbn-popup-in 0.22s ease-out;
}

@keyframes c2w-dbn-popup-in {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Header ─────────────────────────────────────────────────────── */
.c2w-dbn-popup__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    background: var(--c2w-primary, #1a73e8);
    color: #fff;
    flex-shrink: 0;
}

/* Override: master.css h2 { text-align: center !important } */
.c2w-dbn-popup__title {
    margin: 0 !important;
    font-size: clamp(1rem, 2.5vw, 1.25rem) !important;
    font-weight: 700 !important;
    text-align: left !important;
    text-transform: none !important;
    color: #fff !important;
    line-height: 1.3 !important;
}

.c2w-dbn-popup__close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.15s;
    flex-shrink: 0;
}
.c2w-dbn-popup__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ── Body ───────────────────────────────────────────────────────── */
.c2w-dbn-popup__body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1 1 auto;
}

.c2w-dbn-popup__loading {
    text-align: center;
    color: #666;
    padding: 1rem 0;
}

.c2w-dbn-popup__status {
    font-size: 0.875rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 1rem;
    text-align: center;
    min-height: 1.25em;
}

.c2w-dbn-popup__error {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    border-radius: 6px;
    padding: 0.6rem 0.9rem;
    font-size: 0.875rem;
    margin-top: 0.75rem;
}

/* ── Number grid ────────────────────────────────────────────────── */
.c2w-dbn-popup__grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
}

/* Number buttons — same classes as inline picker so CSS is consistent */
.c2w-dbn-popup__grid .c2w-dbn-number {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    border: 2px solid #d0d5dd;
    background: #fff;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.c2w-dbn-popup__grid .c2w-dbn-number--available:hover {
    border-color: var(--c2w-primary, #1a73e8);
    background: #f0f6ff;
    color: var(--c2w-primary, #1a73e8);
}

.c2w-dbn-popup__grid .c2w-dbn-number--selected {
    background: var(--c2w-primary, #1a73e8);
    border-color: var(--c2w-primary, #1a73e8);
    color: #fff;
}

.c2w-dbn-popup__grid .c2w-dbn-number--reserved {
    background: #fff8e1;
    border-color: #f59e0b;
    color: #92400e;
    cursor: not-allowed;
    opacity: 0.8;
}

.c2w-dbn-popup__grid .c2w-dbn-number--sold {
    background: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
    cursor: not-allowed;
    opacity: 0.7;
}

.c2w-dbn-popup__grid .c2w-dbn-number--drawn {
    background: #f0fdf4;
    border-color: #22c55e;
    color: #166534;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Numbers already in the customer's cart for this raffle — locked, shown distinctly */
.c2w-dbn-popup__grid .c2w-dbn-number--in-cart {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
    cursor: not-allowed;
    font-weight: 700;
    opacity: 1;
}

.c2w-dbn-popup__no-numbers {
    color: #666;
    font-style: italic;
}

/* ── Footer / buttons ───────────────────────────────────────────── */
.c2w-dbn-popup__footer {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    background: #f9fafb;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.c2w-dbn-popup__confirm {
    background: var(--c2w-primary, #1a73e8) !important;
    border-color: var(--c2w-primary, #1a73e8) !important;
    color: #fff !important;
    padding: 0.625rem 1.5rem !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-size: 0.9375rem !important;
    cursor: pointer;
    transition: opacity 0.15s, background 0.15s;
    min-height: 44px;
    min-width: 140px;
}

.c2w-dbn-popup__confirm:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.c2w-dbn-popup__confirm:not(:disabled):hover {
    opacity: 0.88;
}

.c2w-dbn-popup__cancel {
    background: #fff !important;
    border: 2px solid #d0d5dd !important;
    color: #374151 !important;
    padding: 0.625rem 1.25rem !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 0.9375rem !important;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    min-height: 44px;
}

.c2w-dbn-popup__cancel:hover {
    border-color: #9ca3af !important;
    background: #f3f4f6 !important;
}

/* ── Lucky Pick button ──────────────────────────────────────────── */
.c2w-dbn-popup__lucky {
    background: var(--c2w-secondary, #f59e0b) !important;
    border-color: var(--c2w-secondary, #f59e0b) !important;
    color: #fff !important;
    padding: 0.625rem 1.25rem !important;
    border-radius: 8px !important;
    font-weight: 700 !important;
    font-size: 0.9375rem !important;
    cursor: pointer;
    transition: opacity 0.15s;
    min-height: 44px;
    margin-right: auto !important; /* push Lucky Pick to the left, Cancel+Confirm stay right */
}

.c2w-dbn-popup__lucky:hover {
    opacity: 0.88;
}

/* ── Prevent body scroll when popup is open ─────────────────────── */
body.c2w-dbn-popup-open {
    overflow: hidden;
}

/* ── Responsive — 375px (mobile) ──────────────────────────────── */
@media (max-width: 479px) {
    .c2w-dbn-popup__dialog {
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        max-width: 100%;
        animation: c2w-dbn-popup-in-mobile 0.25s ease-out;
    }

    @keyframes c2w-dbn-popup-in-mobile {
        from { opacity: 0; transform: translateY(100%); }
        to   { opacity: 1; transform: translateY(0);    }
    }

    .c2w-dbn-popup {
        align-items: flex-end;
        padding: 0;
    }

    .c2w-dbn-popup__grid .c2w-dbn-number {
        width: 40px;
        height: 40px;
        font-size: 0.75rem;
    }

    .c2w-dbn-popup__footer {
        justify-content: stretch;
    }

    .c2w-dbn-popup__confirm,
    .c2w-dbn-popup__cancel {
        flex: 1;
        text-align: center;
    }
}

/* ── Responsive — 768px (tablet) ───────────────────────────────── */
@media (min-width: 480px) and (max-width: 1023px) {
    .c2w-dbn-popup__dialog {
        max-width: 560px;
    }
}
