/* ════════════════════════════════════════════════════
   BUNDLE SELECTOR MODAL
   Warm, soft spring palette matching site aesthetic.
   Two-section layout for split-format bundles (PNG + PDF).
   ════════════════════════════════════════════════════ */

/* ── Overlay ────────────────────────────────────── */
.bs-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(61, 46, 36, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.bs-overlay.open {
    display: flex;
}

/* ── Modal container ────────────────────────────── */
.bs-modal {
    background: #FFFDF9;
    border-radius: 20px;
    box-shadow: 0 24px 64px rgba(61, 46, 36, 0.18), 0 4px 16px rgba(61, 46, 36, 0.08);
    width: 100%;
    max-width: 760px;
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ── Header ─────────────────────────────────────── */
.bs-header {
    padding: 24px 28px 20px;
    border-bottom: 1px solid rgba(163, 159, 127, 0.18);
    flex-shrink: 0;
    background: linear-gradient(135deg, #FDF6EE 0%, #FBF0E8 100%);
}

.bs-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.bs-bundle-icon {
    font-size: 28px;
    line-height: 1;
    flex-shrink: 0;
}

.bs-header-text {
    flex: 1;
    min-width: 0;
}

.bs-bundle-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 20px;
    font-weight: 700;
    color: #3D2E24;
    margin: 0 0 4px;
    line-height: 1.2;
}

.bs-bundle-subtitle {
    font-size: 13px;
    color: #8B7355;
    margin: 0;
    line-height: 1.4;
}

.bs-close-btn {
    background: rgba(163, 159, 127, 0.12);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #8B7355;
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}
.bs-close-btn:hover {
    background: rgba(163, 159, 127, 0.24);
    color: #3D2E24;
}

/* ── Progress counter (simple mode) ─────────────── */
.bs-counter-bar {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.bs-counter-text {
    font-size: 14px;
    font-weight: 600;
    color: #3D2E24;
    white-space: nowrap;
    min-width: 90px;
}

.bs-counter-text .bs-count-current {
    color: #C47B5A;
    font-size: 18px;
}

.bs-progress-track {
    flex: 1;
    height: 6px;
    background: rgba(163, 159, 127, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.bs-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #C47B5A, #D4877A);
    border-radius: 3px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

.bs-counter-pill {
    background: rgba(196, 123, 90, 0.12);
    color: #C47B5A;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid rgba(196, 123, 90, 0.2);
}

/* ── Split counter (PNG + PDF mode) ─────────────── */
.bs-split-counter {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.bs-split-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bs-split-label {
    font-size: 12px;
    font-weight: 700;
    color: #3D2E24;
    white-space: nowrap;
    min-width: 52px;
    letter-spacing: 0.02em;
}

.bs-split-progress-track {
    flex: 1;
    height: 6px;
    background: rgba(163, 159, 127, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.bs-progress-png {
    height: 100%;
    background: linear-gradient(90deg, #5BA4CF, #74B8E0);
    border-radius: 3px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

.bs-progress-pdf {
    height: 100%;
    background: linear-gradient(90deg, #C47B5A, #D4877A);
    border-radius: 3px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 0%;
}

.bs-split-tally {
    font-size: 12px;
    font-weight: 600;
    color: #8B7355;
    white-space: nowrap;
    min-width: 28px;
    text-align: right;
}

.bs-pill-png {
    background: rgba(91, 164, 207, 0.12);
    color: #3A7FA8;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid rgba(91, 164, 207, 0.25);
    min-width: 38px;
    text-align: center;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.bs-pill-png.done {
    background: rgba(74, 158, 74, 0.12);
    color: #2E7D32;
    border-color: rgba(74, 158, 74, 0.25);
}

.bs-pill-pdf {
    background: rgba(196, 123, 90, 0.12);
    color: #C47B5A;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 20px;
    white-space: nowrap;
    border: 1px solid rgba(196, 123, 90, 0.2);
    min-width: 38px;
    text-align: center;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.bs-pill-pdf.done {
    background: rgba(74, 158, 74, 0.12);
    color: #2E7D32;
    border-color: rgba(74, 158, 74, 0.25);
}

/* ── Section tabs (PNG / PDF picker switch) ─────── */
/* Two prominent tabs that switch between the PNG picking grid and PDF picking grid */
.bs-section-tabs {
    display: flex;
    gap: 0;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(163, 159, 127, 0.18);
    background: #FFFDF9;
}

.bs-section-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #8B7355;
    transition: background 0.18s, color 0.18s, box-shadow 0.18s;
    position: relative;
    border-bottom: 3px solid transparent;
}

.bs-section-tab:hover {
    background: rgba(163, 159, 127, 0.06);
}

.bs-section-tab-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.bs-section-tab-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bs-section-tab-count {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
    background: rgba(163, 159, 127, 0.12);
    color: #8B7355;
    transition: background 0.2s, color 0.2s;
}

/* PNG tab active */
.bs-section-tab-png.active {
    color: #3A7FA8;
    border-bottom-color: #5BA4CF;
    background: rgba(91, 164, 207, 0.06);
}
.bs-section-tab-png.active .bs-section-tab-count {
    background: rgba(91, 164, 207, 0.15);
    color: #3A7FA8;
}

/* PDF tab active */
.bs-section-tab-pdf.active {
    color: #B8694A;
    border-bottom-color: #C47B5A;
    background: rgba(196, 123, 90, 0.06);
}
.bs-section-tab-pdf.active .bs-section-tab-count {
    background: rgba(196, 123, 90, 0.15);
    color: #B8694A;
}

/* Tab done state — green checkmark */
.bs-section-tab.done .bs-section-tab-count {
    background: rgba(74, 158, 74, 0.12);
    color: #2E7D32;
}

/* ── Other-section badge on cards ────────────────── */
/* Shows a subtle label when a design is also selected in the other format section */
.bs-other-badge {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 8px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
}

.bs-other-png {
    background: rgba(91, 164, 207, 0.15);
    color: #3A7FA8;
    border: 1px solid rgba(91, 164, 207, 0.25);
}

.bs-other-pdf {
    background: rgba(196, 123, 90, 0.12);
    color: #C47B5A;
    border: 1px solid rgba(196, 123, 90, 0.2);
}

/* ── Filter tabs (collection filter) ───────────── */
.bs-filter-bar {
    padding: 12px 28px;
    border-bottom: 1px solid rgba(163, 159, 127, 0.12);
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: #FFFDF9;
}
.bs-filter-bar::-webkit-scrollbar { display: none; }

.bs-filter-btn {
    background: transparent;
    border: 1px solid rgba(163, 159, 127, 0.25);
    border-radius: 20px;
    padding: 5px 14px;
    font-size: 12px;
    font-weight: 500;
    color: #8B7355;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    flex-shrink: 0;
}
.bs-filter-btn:hover {
    background: rgba(163, 159, 127, 0.1);
    color: #3D2E24;
}
.bs-filter-btn.active {
    background: #3D2E24;
    border-color: #3D2E24;
    color: #FDF6EE;
}

/* ── Grid ───────────────────────────────────────── */
.bs-grid-wrap {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 16px;
    overscroll-behavior: contain;
}
.bs-grid-wrap::-webkit-scrollbar { width: 4px; }
.bs-grid-wrap::-webkit-scrollbar-track { background: transparent; }
.bs-grid-wrap::-webkit-scrollbar-thumb { background: rgba(163, 159, 127, 0.3); border-radius: 2px; }

.bs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

/* ── Design card ────────────────────────────────── */
.bs-card {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.18s, transform 0.15s, box-shadow 0.15s;
    aspect-ratio: 9/16;
    display: flex;
    flex-direction: column;
    user-select: none;
    -webkit-user-select: none;
}

.bs-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(61, 46, 36, 0.14);
}

.bs-card.selected {
    border-color: #C47B5A;
    box-shadow: 0 0 0 1px rgba(196, 123, 90, 0.3), 0 8px 24px rgba(196, 123, 90, 0.18);
    transform: translateY(-2px);
}

/* Split mode: PNG selection is blue, PDF is the warm terracotta */
.bs-card.sel-png {
    border-color: #5BA4CF;
    box-shadow: 0 0 0 1px rgba(91, 164, 207, 0.35), 0 8px 24px rgba(91, 164, 207, 0.2);
}
.bs-card.sel-png .bs-card-check {
    background: #5BA4CF;
}
.bs-card.sel-pdf {
    border-color: #C47B5A;
    box-shadow: 0 0 0 1px rgba(196, 123, 90, 0.3), 0 8px 24px rgba(196, 123, 90, 0.18);
}
.bs-card.sel-pdf .bs-card-check {
    background: #C47B5A;
}

.bs-card.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Preview area — shows the full design without clipping.
   Uses position:relative so the border accent frame can sit behind the text. */
.bs-card-preview {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px 10px;
    gap: 3px;
    position: relative;
    overflow: hidden;
}

/* Decorative inset border — mirrors the accent frame visible on the
   actual printable design so the thumbnail faithfully previews it. */
.bs-card-border-accent {
    position: absolute;
    inset: 5px;
    border: 1.5px solid currentColor;
    border-radius: 3px;
    opacity: 0.35;
    pointer-events: none;
}

.bs-card-quote {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 8px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    letter-spacing: 0.01em;
    max-width: 90%;
    word-break: break-word;
    /* Auto-scale long quotes so nothing is clipped */
    overflow-wrap: break-word;
}

.bs-card-dash {
    width: 14px;
    height: 1.5px;
    border-radius: 1px;
    margin: 2px 0;
    opacity: 0.6;
    flex-shrink: 0;
}

.bs-card-brand {
    font-size: 5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.55;
    text-align: center;
    flex-shrink: 0;
}

/* ── Checkmark overlay ──────────────────────────── */
.bs-card-check {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 22px;
    height: 22px;
    background: #C47B5A;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.18s, transform 0.18s;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(196, 123, 90, 0.4);
}
.bs-card.selected .bs-card-check {
    opacity: 1;
    transform: scale(1);
}
.bs-card-check svg {
    width: 12px;
    height: 12px;
}

/* ── Selection number badge ─────────────────────── */
.bs-card-num {
    position: absolute;
    top: 7px;
    left: 7px;
    width: 20px;
    height: 20px;
    background: rgba(61, 46, 36, 0.75);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: #FDF6EE;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.18s, transform 0.18s;
    pointer-events: none;
}
.bs-card.selected .bs-card-num {
    opacity: 1;
    transform: scale(1);
}

/* ── Format indicator ───────────────────────────── */
.bs-card-format {
    position: absolute;
    bottom: 5px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 7px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.45;
}

/* ── Footer ─────────────────────────────────────── */
.bs-footer {
    padding: 16px 20px 20px;
    border-top: 1px solid rgba(163, 159, 127, 0.15);
    flex-shrink: 0;
    background: #FFFDF9;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.bs-footer-info {
    font-size: 13px;
    color: #8B7355;
    line-height: 1.4;
}
.bs-footer-info strong {
    color: #3D2E24;
}

.bs-add-btn {
    background: linear-gradient(135deg, #C47B5A, #B8694A);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 13px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, transform 0.12s, box-shadow 0.15s, opacity 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(196, 123, 90, 0.35);
    letter-spacing: 0.01em;
}
.bs-add-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #B8694A, #A85C3E);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(196, 123, 90, 0.45);
}
.bs-add-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}
.bs-add-btn.ready {
    animation: bs-pulse-btn 2s ease-in-out infinite;
}

@keyframes bs-pulse-btn {
    0%, 100% { box-shadow: 0 4px 14px rgba(196, 123, 90, 0.35); }
    50%       { box-shadow: 0 4px 22px rgba(196, 123, 90, 0.55); }
}

/* ── Success flash ──────────────────────────────── */
.bs-success-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #3D2E24;
    color: #FDF6EE;
    padding: 12px 22px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    z-index: 9999;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(61, 46, 36, 0.25);
}
.bs-success-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ── Empty state ────────────────────────────────── */
.bs-empty {
    text-align: center;
    padding: 48px 24px;
    color: #8B7355;
}
.bs-empty p {
    margin: 0;
    font-size: 14px;
}

/* ── Mobile ─────────────────────────────────────── */
@media (max-width: 600px) {
    .bs-modal {
        border-radius: 16px;
        max-height: calc(100dvh - 24px);
    }
    .bs-header {
        padding: 18px 20px 16px;
    }
    .bs-bundle-title {
        font-size: 17px;
    }
    .bs-filter-bar {
        padding: 10px 16px;
    }
    .bs-grid-wrap {
        padding: 14px 12px 12px;
    }
    .bs-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    .bs-footer {
        padding: 12px 16px 16px;
        flex-direction: column;
        align-items: stretch;
    }
    .bs-add-btn {
        text-align: center;
        padding: 14px;
    }
    .bs-footer-info {
        text-align: center;
    }
    .bs-split-label {
        min-width: 44px;
        font-size: 11px;
    }
    /* Section tabs stack vertically on small screens */
    .bs-section-tabs {
        flex-direction: column;
    }
    .bs-section-tab {
        padding: 10px 12px;
        font-size: 12px;
        border-bottom: none;
        border-left: 3px solid transparent;
    }
    .bs-section-tab-png.active {
        border-left-color: #5BA4CF;
        border-bottom-color: transparent;
    }
    .bs-section-tab-pdf.active {
        border-left-color: #C47B5A;
        border-bottom-color: transparent;
    }
    .bs-section-tab-label {
        font-size: 12px;
    }
    /* Smaller quote text on mobile so full design fits in narrower cards */
    .bs-card-quote {
        font-size: 6.5px;
        line-height: 1.35;
    }
    .bs-card-preview {
        padding: 12px 8px 8px;
    }
    .bs-card-border-accent {
        inset: 4px;
        border-width: 1px;
    }
}

@media (max-width: 380px) {
    .bs-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    .bs-card-quote {
        font-size: 5.5px;
    }
    .bs-card-preview {
        padding: 10px 6px 6px;
    }
}
