/*
 * carousel.css — Virtual Card Arc Carousel
 * ALL styles scoped to .cs-* prefix. No global selectors.
 * To verify no conflicts: temporarily disable this file and
 * confirm all other pages render identically.
 */

/* ─── Layout wrapper ─────────────────────────────────────── */
.cs-carousel-section {
    position: relative;
    padding: 1rem 0 0;
}

/* ─── Swiper + Arrow Wrapper ─────────────────────────────── */
.cs-carousel-track {
    display: flex;
    align-items: center;
    gap: 0;
    position: relative;
    overflow: hidden;
}

/* ─── Navigation arrows ──────────────────────────────────── */
.cs-arrow-left,
.cs-arrow-right {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--border-strong, rgba(26, 43, 107, 0.18));
    background: var(--bg, #F0F1F6);
    color: var(--text-secondary, #5A6480);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s, opacity 0.2s, color 0.2s;
    z-index: 10;
    position: relative;
    min-width: 40px;
    min-height: 40px;
}

/* Dark mode: lighter arrows */
html[data-theme="dark"] .cs-arrow-left,
html[data-theme="dark"] .cs-arrow-right {
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.7);
}

.cs-arrow-left:hover,
.cs-arrow-right:hover {
    background: rgba(0, 191, 255, 0.1);
    border-color: rgba(0, 191, 255, 0.4);
    color: #00BFFF;
}

.cs-arrow-left:disabled,
.cs-arrow-right:disabled {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

/* Single card: hide arrows */
.cs-single-card .cs-arrow-left,
.cs-single-card .cs-arrow-right {
    visibility: hidden;
    pointer-events: none;
}

/* Mobile: smaller arrows, still visible for navigation */
@media (max-width: 767px) {
    .cs-arrow-left,
    .cs-arrow-right {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }
    .cs-arrow-left svg,
    .cs-arrow-right svg {
        width: 14px;
        height: 14px;
    }
}

/* ─── Swiper container ───────────────────────────────────── */
/* CRITICAL: overflow MUST be hidden for coverflow 3D effect + touch containment */
.cs-carousel-section .cs-swiper,
.cs-carousel-section .swiper {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    position: relative;
    padding: 20px 0;
    touch-action: pan-y;
    /* 3D perspective for coverflow arc effect */
    perspective: 1200px;
}

/* touch-action: pan-y allows vertical page scroll, captures horizontal swipe */
.cs-carousel-section .swiper-wrapper {
    touch-action: pan-y;
}

/* ─── Individual slide ───────────────────────────────────── */
.cs-slide {
    width: 300px !important; /* Swiper needs explicit width for slidesPerView: auto */
    max-width: 340px;
    display: flex;
    justify-content: center;
    padding: 20px 0 28px; /* top/bottom padding for glow to show */
}

@media (max-width: 767px) {
    .cs-slide {
        width: 260px !important;
        max-width: 280px;
    }
}

/* ─── Swiper coverflow slide shadows ─────────────────────── */
.cs-carousel-section .swiper-slide-shadow-left,
.cs-carousel-section .swiper-slide-shadow-right {
    border-radius: 16px;
    background: linear-gradient(to left, rgba(0,0,0,0.25), transparent);
}
.cs-carousel-section .swiper-slide-shadow-left {
    background: linear-gradient(to right, rgba(0,0,0,0.25), transparent);
}

/* ─── Card face ──────────────────────────────────────────── */
.cs-card {
    /* Standard credit card ratio: 85.6mm × 53.98mm ≈ 1.586:1 */
    width: 300px;
    height: 189px; /* 300 / 1.586 */
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    font-family: 'Space Grotesk', sans-serif;
    /* Background gradient via CSS variable — always dark */
    background: var(--cs-bg-gradient, linear-gradient(145deg, #1A2B6B 0%, #0d1a42 100%));
    /* Active glow applied via .cs-card-active */
    transition: box-shadow 0.3s ease;
    /* Minimum touch target */
    min-height: 44px;
    /* Ensure card stays dark in both themes */
    color: #ffffff;
}

@media (max-width: 767px) {
    .cs-card {
        width: 260px;
        height: 164px;
    }
}

/* Active (center) card glow */
.swiper-slide-active .cs-card {
    box-shadow: 0 0 0 2px #00BFFF, 0 0 15px rgba(0, 191, 255, 0.3), 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* Non-active: subtle shadow only */
.swiper-slide:not(.swiper-slide-active) .cs-card {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ─── Background image layer ─────────────────────────────── */
.cs-card-bg-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 16px;
    /* Dark overlay for text readability — only for custom images */
    opacity: 0;
    transition: opacity 0.3s;
}

.cs-card-bg-image.has-image {
    opacity: 1;
}

.cs-card-bg-image.has-image::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 16px;
}

/* Decorative circles (same as existing vc-real-card) */
.cs-card::before {
    content: '';
    position: absolute;
    top: -30%;
    right: -10%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    pointer-events: none;
    z-index: 1;
}

.cs-card::after {
    content: '';
    position: absolute;
    bottom: -20%;
    left: 20%;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    pointer-events: none;
    z-index: 1;
}

/* ─── Card inner content ─────────────────────────────────── */
.cs-card-inner {
    position: absolute;
    inset: 0;
    padding: 18px 20px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 2;
}

.cs-card-row1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cs-card-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.7);
}

/* chip — reuses .vc-chip from existing CSS */

.cs-card-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
}

.cs-card-number {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    color: rgba(255, 255, 255, 0.85);
    margin-top: 2px;
}

.cs-card-row3 {
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
}

.cs-card-field-label {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 2px;
}

.cs-card-field-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.05em;
}

/* CVV wrap inside card */
.cs-cvv-wrap {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* ─── Sync overlay (reused pattern) ─────────────────────── */
/* .vc-sync-overlay already exists in main CSS, so we just make sure it works in cs-card context */
.cs-card .vc-sync-overlay {
    z-index: 3;
    border-radius: 16px;
}

/* ─── Card actions bar (below carousel, for active card) ─── */
.cs-actions-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    min-height: 44px;
}

.cs-action-btn {
    padding: 7px 16px;
    border-radius: 8px;
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    background: transparent;
    color: var(--text-secondary, #5A6480);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    min-height: 44px;
    font-family: 'Space Grotesk', sans-serif;
}

.cs-action-btn:hover {
    border-color: #00BFFF;
    color: #00BFFF;
}

.cs-action-btn.cs-delete-btn {
    border-color: rgba(239, 68, 68, 0.25);
    color: #ef4444;
}

.cs-action-btn.cs-delete-btn:hover {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.06);
}

/* Backing row integrated below carousel */
.cs-backing-row-wrap {
    margin: 0.5rem 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── Per-card subscription section ─────────────────────── */
.cs-sub-section {
    margin-top: 1.25rem;
}

.cs-sub-section-heading {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary, #5A6480);
    margin-bottom: 0.6rem;
}

.cs-sub-list {
    height: 280px;
    overflow-y: auto;
    transition: opacity 0.2s ease;
    scrollbar-width: thin;
}

.cs-sub-list.cs-fading {
    opacity: 0;
}

.cs-sub-empty {
    padding: 1rem;
    background: var(--bg, #F0F1F6);
    border-radius: 10px;
    border: 1px dashed var(--border-strong, rgba(26,43,107,0.12));
    text-align: center;
    color: var(--text-muted, #8892A8);
    font-size: 0.85rem;
}

.cs-sub-empty .cs-sub-empty-hint {
    font-size: 0.77rem;
    margin-top: 0.25rem;
    color: var(--text-muted, #8892A8);
}

/* ─── Unassigned subs section separator ─────────────────── */
.cs-unassigned-heading {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary, #5A6480);
    margin: 1.5rem 0 0.6rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border, rgba(26,43,107,0.08));
}

/* ─── Card style picker (in Edit modal) ──────────────────── */
.cs-style-presets {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.cs-preset-swatch {
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    border: 2.5px solid transparent;
    transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    position: relative;
    overflow: hidden;
}

.cs-preset-swatch:hover {
    transform: scale(1.06);
}

.cs-preset-swatch.cs-selected {
    border-color: #00BFFF;
    box-shadow: 0 0 8px rgba(0, 191, 255, 0.35);
}

.cs-preset-swatch .cs-swatch-label {
    position: absolute;
    bottom: 3px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.58rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
    letter-spacing: 0.04em;
    pointer-events: none;
}

/* Upload area */
.cs-upload-area {
    margin-top: 0.75rem;
    border: 1.5px dashed var(--border-strong, rgba(26,43,107,0.18));
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    background: transparent;
}

.cs-upload-area:hover {
    border-color: #00BFFF;
    background: rgba(0, 191, 255, 0.04);
}

.cs-upload-area.cs-selected {
    border-color: #00BFFF;
    background: rgba(0, 191, 255, 0.05);
}

.cs-upload-label {
    font-size: 0.82rem;
    color: var(--text-secondary, #5A6480);
    margin-bottom: 0.3rem;
}

.cs-upload-hint {
    font-size: 0.72rem;
    color: var(--text-muted, #8892A8);
}

.cs-upload-input {
    display: none;
}

/* Image preview */
.cs-img-preview {
    width: 100%;
    max-height: 80px;
    object-fit: cover;
    border-radius: 6px;
    margin-top: 0.5rem;
    display: none;
}

.cs-img-preview.show {
    display: block;
}

/* Uploading spinner inside upload area */
.cs-upload-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(0, 191, 255, 0.25);
    border-top-color: #00BFFF;
    border-radius: 50%;
    animation: cs-spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

@keyframes cs-spin {
    to { transform: rotate(360deg); }
}

/* ─── 1-card mode: no arc, centered ─────────────────────── */
.cs-single-card .swiper-slide {
    transform: none !important;
    opacity: 1 !important;
}

/* ─── Fallback row (if Swiper.js fails to load) ─────────── */
.cs-fallback-row {
    display: none;
    overflow-x: auto;
    gap: 16px;
    padding: 12px 0 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.cs-fallback-active .cs-fallback-row {
    display: flex;
}

.cs-fallback-active .cs-carousel-track {
    display: none;
}

.cs-fallback-row .cs-card {
    flex-shrink: 0;
    cursor: pointer;
}

.cs-fallback-row .cs-card.cs-fallback-selected {
    box-shadow: 0 0 0 2px #00BFFF, 0 0 15px rgba(0, 191, 255, 0.3);
}

/* ─── Reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    /* Disable 3D and transitions; show flat horizontal row */
    .cs-carousel-section .cs-carousel-track {
        display: none;
    }
    .cs-carousel-section .cs-fallback-row {
        display: flex;
    }
    .cs-card {
        transition: none;
        box-shadow: none;
    }
    .cs-card.cs-fallback-selected {
        box-shadow: 0 0 0 2px #00BFFF;
    }
    .cs-sub-list {
        transition: none;
    }
}

/* ─── Dark mode overrides ────────────────────────────────── */
/* Cards always stay dark (they are credit cards) — no dark-mode override needed */

html[data-theme="dark"] .cs-sub-empty {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
}

html[data-theme="dark"] .cs-action-btn {
    border-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.8);
}

html[data-theme="dark"] .cs-upload-area {
    border-color: rgba(255, 255, 255, 0.12);
}

html[data-theme="dark"] .cs-upload-label {
    color: rgba(255, 255, 255, 0.6);
}

html[data-theme="dark"] .cs-upload-hint {
    color: rgba(255, 255, 255, 0.4);
}

html[data-theme="dark"] .cs-unassigned-heading {
    border-top-color: rgba(255, 255, 255, 0.08);
}

/* ─── Responsive: large screens ─────────────────────────── */
@media (min-width: 1200px) {
    .cs-slide {
        width: 320px !important;
        max-width: 340px;
    }
    .cs-card {
        width: 320px;
        height: 202px;
    }
}
