/* =============================================================
   Clickfu — Credits Dashboard  (Phase 3)
   clickfu-credits.css
   ============================================================= */

/* ---- Reset & Base ------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #F9FAFB;
    color: #111827;
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: #4F46E5; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Layout ------------------------------------------------- */
.cfu-header {
    background: #fff;
    border-bottom: 1px solid #E5E7EB;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.cfu-logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: #4F46E5;
    letter-spacing: -0.025em;
}
.cfu-logo span { color: #111827; }

.cfu-nav-email {
    font-size: 0.85rem;
    color: #6B7280;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cfu-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* ---- Banner ------------------------------------------------- */
.cfu-banner {
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.95rem;
    font-weight: 500;
    animation: cfu-slide-in 0.4s ease;
}
.cfu-banner.success { background: #D1FAE5; color: #065F46; border: 1px solid #6EE7B7; }
.cfu-banner.error   { background: #FEE2E2; color: #991B1B; border: 1px solid #FCA5A5; }
.cfu-banner.info    { background: #EEF2FF; color: #3730A3; border: 1px solid #C7D2FE; }
.cfu-banner-icon { font-size: 1.25rem; flex-shrink: 0; }
.cfu-banner-close {
    margin-left: auto;
    cursor: pointer;
    background: none;
    border: none;
    font-size: 1.1rem;
    color: inherit;
    opacity: 0.7;
    padding: 0 0.25rem;
}
.cfu-banner-close:hover { opacity: 1; }

@keyframes cfu-slide-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Balance Card ------------------------------------------- */
.cfu-balance-card {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    border-radius: 16px;
    padding: 2rem;
    color: #fff;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.cfu-balance-label {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.85;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.25rem;
}

.cfu-balance-amount {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1;
}

.cfu-balance-unit {
    font-size: 1rem;
    font-weight: 500;
    opacity: 0.75;
    margin-top: 0.25rem;
}

.cfu-balance-last-purchase {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.5rem;
}

.cfu-balance-actions { text-align: right; }

/* ---- Section Headers ---------------------------------------- */
.cfu-section-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---- Credit Packs Grid -------------------------------------- */
.cfu-packs-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin: 2rem 0 2.5rem;  /* extra top margin so floating ribbon isn't clipped */
    align-items: stretch;
}

@media (max-width: 640px) {
    .cfu-packs-grid { grid-template-columns: 1fr; }
}

.cfu-pack-card {
    background: #fff;
    border: 2px solid #E5E7EB;
    border-radius: 16px;
    padding: 1.5rem;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.cfu-pack-card:hover {
    border-color: #C7D2FE;
    box-shadow: 0 8px 24px rgba(79,70,229,0.1);
}
/* ---------- BEST VALUE (middle card highlight) ----------
   The middle pack gets a stronger border, subtle lift, and a
   colored ribbon driven by data-badge attribute.
   Works in both light and dark mode. */
.cfu-pack-card.popular {
    border-color: #4F46E5;
    transform: translateY(-6px);
    box-shadow: 0 14px 36px rgba(79,70,229,0.18);
}
.cfu-pack-card.popular:hover {
    transform: translateY(-9px);
    box-shadow: 0 18px 44px rgba(79,70,229,0.22);
}
.cfu-pack-card.popular::before {
    content: attr(data-badge);
    position: absolute;
    top: -14px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 5px 14px;
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(79,70,229,0.35);
}
/* Fallback if no data-badge is set */
.cfu-pack-card.popular:not([data-badge])::before { content: 'Best Value'; }

/* Dark mode treatment: lime border + lime ribbon */
[data-theme="dark"] .cfu-pack-card.popular {
    border-color: #C6FF3D;
    box-shadow: 0 14px 36px rgba(198,255,61,0.18);
}
[data-theme="dark"] .cfu-pack-card.popular:hover {
    box-shadow: 0 18px 44px rgba(198,255,61,0.25);
}
[data-theme="dark"] .cfu-pack-card.popular::before {
    background: linear-gradient(135deg, #C6FF3D 0%, #A3E635 100%);
    color: #0B0B10;
    box-shadow: 0 4px 14px rgba(198,255,61,0.4);
}

.cfu-pack-name {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6B7280;
    margin-bottom: 0.5rem;
}

.cfu-pack-price {
    font-size: 2.5rem;
    font-weight: 800;
    color: #111827;
    letter-spacing: -0.04em;
    line-height: 1;
}
.cfu-pack-price span { font-size: 1.1rem; font-weight: 500; color: #6B7280; }

.cfu-pack-credits {
    font-size: 1rem;
    font-weight: 600;
    color: #4F46E5;
    margin: 0.5rem 0;
}

.cfu-pack-per {
    font-size: 0.8rem;
    color: #9CA3AF;
    margin-bottom: 1.25rem;
}

.cfu-pack-actions { display: flex; flex-direction: column; gap: 0.5rem; }

/* ---- Buttons ------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    text-align: center;
    line-height: 1;
    width: 100%;
    text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

.btn-primary {
    background: #4F46E5;
    color: #fff;
}
.btn-primary:hover:not(:disabled) { background: #4338CA; box-shadow: 0 4px 12px rgba(79,70,229,0.35); }

.btn-outline {
    background: #fff;
    color: #374151;
    border: 1.5px solid #D1D5DB;
}
.btn-outline:hover:not(:disabled) { background: #F9FAFB; border-color: #9CA3AF; }

.btn-paypal {
    background: #FFC439;
    color: #111827;
    font-size: 0.85rem;
}
.btn-paypal:hover:not(:disabled) { background: #F0B429; }

/* PayPal SDK button container */
.cfu-paypal-btn-wrap {
    border-radius: 8px;
    overflow: hidden;
    min-height: 42px;
}

/* ---- Email prompt ------------------------------------------- */
.cfu-email-prompt {
    background: #fff;
    border: 2px solid #E5E7EB;
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.cfu-email-prompt h2 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.cfu-email-prompt p {
    color: #6B7280;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.cfu-email-row {
    display: flex;
    gap: 0.75rem;
    max-width: 420px;
    margin: 0 auto;
}

.cfu-email-row input {
    flex: 1;
    padding: 0.65rem 1rem;
    border: 1.5px solid #D1D5DB;
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
}
.cfu-email-row input:focus { border-color: #4F46E5; box-shadow: 0 0 0 3px rgba(79,70,229,0.12); }

@media (max-width: 480px) {
    .cfu-email-row { flex-direction: column; }
    .cfu-email-row .btn { width: 100%; }
}

/* ---- Ledger Table ------------------------------------------- */
.cfu-ledger-card {
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.cfu-ledger-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cfu-ledger-empty {
    padding: 2.5rem;
    text-align: center;
    color: #9CA3AF;
    font-size: 0.9rem;
}

.cfu-ledger-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.cfu-ledger-table th {
    background: #F9FAFB;
    padding: 0.6rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: #6B7280;
    border-bottom: 1px solid #E5E7EB;
}

.cfu-ledger-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #F3F4F6;
    color: #374151;
    vertical-align: middle;
}

.cfu-ledger-table tr:last-child td { border-bottom: none; }
.cfu-ledger-table tr:hover td { background: #FAFAFA; }

.cfu-delta-pos { color: #059669; font-weight: 700; }
.cfu-delta-neg { color: #DC2626; font-weight: 700; }

.cfu-reason-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: capitalize;
}
.cfu-reason-purchase  { background: #D1FAE5; color: #065F46; }
.cfu-reason-spend     { background: #FEE2E2; color: #991B1B; }
.cfu-reason-refund    { background: #FEF9C3; color: #854D0E; }
.cfu-reason-admin_grant { background: #EEF2FF; color: #3730A3; }

@media (max-width: 600px) {
    .cfu-ledger-table th:nth-child(4),
    .cfu-ledger-table td:nth-child(4) { display: none; }
}

/* ---- Skeleton loader ---------------------------------------- */
.cfu-skeleton {
    background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
    background-size: 200% 100%;
    animation: cfu-shimmer 1.5s infinite;
    border-radius: 8px;
    height: 1rem;
}
@keyframes cfu-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ---- Spinner ------------------------------------------------ */
.cfu-spinner {
    width: 18px;
    height: 18px;
    border: 2.5px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: cfu-spin 0.7s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}
.cfu-spinner.dark {
    border: 2.5px solid rgba(79,70,229,0.25);
    border-top-color: #4F46E5;
}
@keyframes cfu-spin { to { transform: rotate(360deg); } }

/* ---- Footer ------------------------------------------------- */
.cfu-footer {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 0.8rem;
    color: #9CA3AF;
}

/* ---------- FAQ items (theme-aware) ---------- */
.cfu-faq-item {
    margin-bottom: 0.75rem;
    background: #fff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 1rem 1.25rem;
}
.cfu-faq-item summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    color: #111827;
}
.cfu-faq-item p {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6B7280;
}
.cfu-faq-item a { color: #4F46E5; text-decoration: underline; }

[data-theme="dark"] .cfu-faq-item {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .cfu-faq-item summary { color: var(--text); }
[data-theme="dark"] .cfu-faq-item p { color: var(--text-mute); }
[data-theme="dark"] .cfu-faq-item a { color: var(--primary); }
