/* ====================================================================
   Quota Reached Overlay + Buy Credits modal
   ==================================================================== */

.quota-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(6px);
    z-index: 99000;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: quotaFadeIn 0.25s ease-out;
}

.quota-overlay.open {
    display: flex;
}

@keyframes quotaFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.quota-modal {
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
    border-radius: 18px;
    box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.45), 0 0 0 1px rgba(255,255,255,0.4) inset;
    max-width: 980px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    animation: quotaSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes quotaSlideUp {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to   { transform: translateY(0) scale(1);     opacity: 1; }
}

.quota-modal-header {
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%);
    color: white;
    padding: 28px 32px;
    border-radius: 18px 18px 0 0;
    position: relative;
    overflow: hidden;
}

.quota-modal-header::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 20%, rgba(255,255,255,0.18), transparent 50%);
    pointer-events: none;
}

.quota-modal-header h2 {
    margin: 0 0 4px 0;
    font-size: 1.55rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.quota-modal-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 0.95rem;
    position: relative;
    z-index: 1;
}

.quota-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255,255,255,0.18);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.4rem;
    line-height: 1;
    z-index: 2;
    transition: all 0.2s;
}
.quota-modal-close:hover { background: rgba(255,255,255,0.32); transform: rotate(90deg); }

.quota-status-bar {
    background: #FEF3C7;
    border-left: 4px solid #F59E0B;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #92400E;
    font-weight: 500;
}
.quota-status-bar svg { flex-shrink: 0; }

.quota-modal-body {
    padding: 28px 32px;
}

.quota-modal-section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1F2937;
    margin: 0 0 16px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.quota-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.quota-product-card {
    background: white;
    border: 2px solid #E5E7EB;
    border-radius: 14px;
    padding: 22px 20px;
    transition: all 0.25s ease;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.quota-product-card:hover {
    border-color: #6366F1;
    transform: translateY(-3px);
    box-shadow: 0 12px 28px -8px rgba(99, 102, 241, 0.35);
}

.quota-product-card.selected {
    border-color: #6366F1;
    background: linear-gradient(180deg, #EEF2FF 0%, #FFFFFF 100%);
    box-shadow: 0 0 0 4px rgba(99,102,241,0.15);
}

.quota-product-badge {
    position: absolute;
    top: -10px;
    right: 14px;
    padding: 4px 12px;
    border-radius: 20px;
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

.quota-product-icon {
    font-size: 2.2rem;
    margin-bottom: 10px;
}

.quota-product-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 6px;
}

.quota-product-desc {
    font-size: 0.85rem;
    color: #6B7280;
    line-height: 1.4;
    margin-bottom: 16px;
    flex-grow: 1;
}

.quota-product-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin-bottom: 14px;
}
.quota-product-price-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #1F2937;
    background: linear-gradient(135deg, #6366F1, #EC4899);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.quota-product-price-currency {
    font-size: 0.85rem;
    color: #6B7280;
    font-weight: 600;
}

.quota-product-amount {
    font-size: 0.78rem;
    color: #6366F1;
    background: #EEF2FF;
    padding: 6px 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    margin-bottom: 12px;
}

.quota-product-buy {
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    color: white;
    border: none;
    padding: 11px 18px;
    border-radius: 9px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: auto;
}

.quota-product-buy:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(99,102,241,0.45);
}

.quota-product-buy:disabled {
    background: #9CA3AF;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.quota-modal-footer {
    padding: 16px 32px 24px;
    border-top: 1px solid #E5E7EB;
    background: #F9FAFB;
    border-radius: 0 0 18px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 0.82rem;
    color: #6B7280;
}

.quota-modal-footer .stripe-badge {
    display: flex;
    align-items: center;
    gap: 6px;
}

.quota-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: #6B7280;
}

/* Utilise la classe .spinner globale de l'app pour cohérence */
.quota-loader-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(99, 102, 241, 0.15);
    border-top-color: #6366F1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ====================================================================
   MODE FORCE (modale bloquante apres login pour utilisateurs sans credits)
   ==================================================================== */

body.quota-overlay-forced-open {
    overflow: hidden !important;
    height: 100vh;
}

.quota-overlay.quota-overlay-forced .quota-modal-close {
    display: none !important;
}

.quota-overlay.quota-overlay-forced {
    /* Empecher la fermeture visuelle + passer au-dessus de l'init-overlay (z-index 99999) */
    backdrop-filter: blur(4px);
    background: rgba(15, 23, 42, 0.7);
    z-index: 100000 !important;
}

.quota-usage-breakdown {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 18px;
    box-shadow: 0 2px 4px rgba(146, 64, 14, 0.08);
}

.quota-usage-breakdown table {
    width: 100%;
    font-size: 0.85rem;
    border-collapse: collapse;
    color: #451a03;
}

.quota-usage-breakdown th {
    font-weight: 600;
    padding: 4px 6px;
    font-size: 0.78rem;
    color: #78350f;
}

.quota-usage-breakdown td {
    padding: 4px 6px;
}

.quota-usage-breakdown tbody tr {
    border-bottom: 1px dashed rgba(146, 64, 14, 0.2);
}

.quota-usage-breakdown .total-row td {
    border-top: 2px solid #92400e;
    padding-top: 8px !important;
}

/* ====================================================================
   MODE FORCE — STYLE BLEU PROFOND APP (gradient AcadIA-M)
   ==================================================================== */

/* Override du header gradient en mode forcé : bleu profond app */
.quota-overlay.quota-overlay-forced .quota-modal-header {
    background: linear-gradient(135deg, #0c1445 0%, #1B4F72 50%, #0a2540 100%);
    padding: 24px 32px 28px;
}

.quota-overlay.quota-overlay-forced .quota-modal-header h2 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.45rem;
    color: #fff;
}

/* Indicateur 2 étapes */
.quota-step-indicator {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.quota-step-dot {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.quota-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.6);
    font-weight: 700;
    font-size: 0.85rem;
    border: 2px solid transparent;
    transition: all 0.25s;
}

.quota-step-dot.active .quota-step-num {
    background: #3B82F6;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
}

.quota-step-dot.done .quota-step-num {
    background: #10B981;
    color: #fff;
}

.quota-step-label {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
}

.quota-step-dot.active .quota-step-label {
    color: #fff;
    font-weight: 600;
}

.quota-step-line {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.18);
    margin: 0 12px;
    border-radius: 2px;
}

.quota-step-line.done {
    background: #10B981;
}

/* Hero step 1 : grand affichage du total */
.quota-forced-hero {
    text-align: center;
    padding: 28px 20px 24px;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
    border-radius: 12px;
    margin-bottom: 18px;
    border: 1px solid #e2e8f0;
}

.quota-forced-hero-label {
    font-size: 0.85rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.quota-forced-hero-amount {
    font-size: 3.4rem;
    font-weight: 800;
    line-height: 1.05;
    background: linear-gradient(135deg, #0c1445 0%, #1B4F72 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: #1B4F72;
    letter-spacing: -0.02em;
    margin: 6px 0 8px;
}

.quota-forced-hero-currency {
    font-size: 1.8rem;
    font-weight: 600;
    color: #1B4F72;
    -webkit-text-fill-color: #1B4F72;
}

.quota-forced-hero-subtitle {
    font-size: 0.9rem;
    color: #64748b;
    font-style: italic;
}

/* Bouton CTA "Voir mon plan d'abonnement" */
.quota-forced-step-actions {
    text-align: center;
    margin-top: 20px;
}

.quota-forced-next-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #1B4F72 0%, #0c1445 100%);
    color: #fff;
    border: none;
    padding: 14px 28px;
    border-radius: 10px;
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(12, 20, 69, 0.25);
    transition: all 0.2s;
}

.quota-forced-next-btn:hover {
    background: linear-gradient(135deg, #1e5a85 0%, #11195a 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(12, 20, 69, 0.35);
}

.quota-forced-next-btn:active {
    transform: translateY(0);
}

/* Étape 2 : abonnements */
.quota-forced-step2-header {
    margin-bottom: 8px;
}

.quota-forced-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: #1B4F72;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
}

.quota-forced-back-btn:hover {
    color: #0c1445;
    text-decoration: underline;
}

.quota-forced-step2-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0c1445;
    margin: 8px 0 4px;
}

.quota-forced-step2-subtitle {
    font-size: 0.9rem;
    color: #64748b;
    margin: 0 0 18px;
    font-style: italic;
}

.quota-forced-subscriptions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.quota-product-price-recurrence {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
    margin-left: 4px;
}

/* Responsive */
@media (max-width: 640px) {
    .quota-forced-hero-amount { font-size: 2.6rem; }
    .quota-step-label { display: none; }
    .quota-step-line { margin: 0 8px; }
}

/* ====================================================================
   SECTIONS CREDITS vs ABONNEMENTS (separation visuelle dans la modale)
   ==================================================================== */

.quota-products-section {
    margin-bottom: 24px;
}

.quota-products-section:last-child {
    margin-bottom: 0;
}

.quota-products-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 4px 0;
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
    padding-bottom: 6px;
    border-bottom: 2px solid #e2e8f0;
}

.quota-products-section-desc {
    margin: 0 0 14px 0;
    font-size: 0.82rem;
    color: #64748b;
    font-style: italic;
}

.quota-products-section-subscriptions {
    margin-top: 28px;
    padding-top: 20px;
    border-top: 3px dashed #c7d2fe;
}

.quota-products-section-subscriptions .quota-products-section-title {
    color: #4f46e5;
    border-bottom-color: #c7d2fe;
}

/* ====================================================================
   BOUTON ANNULER + SE DECONNECTER (modale forcee)
   ==================================================================== */

.quota-forced-cancel-wrap {
    width: 100%;
    text-align: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.quota-forced-cancel-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.15s;
}

.quota-forced-cancel-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    color: #1e293b;
}

/* ====================================================================
   BANNIERE D'USAGE (rappel persistant + invite abonnement)
   ==================================================================== */

.acadia-usage-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 98000;
    background: linear-gradient(90deg, #6366F1 0%, #8B5CF6 50%, #EC4899 100%);
    color: #fff;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
    animation: slideDownBanner 0.4s ease-out;
}

@keyframes slideDownBanner {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}

.acadia-usage-banner-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
    max-width: 1400px;
    margin: 0 auto;
    flex-wrap: wrap;
    font-size: 0.88rem;
}

.acadia-usage-banner-icon {
    font-size: 1.3rem;
    flex-shrink: 0;
}

.acadia-usage-banner-text {
    flex: 1;
    min-width: 250px;
}

.acadia-usage-banner-text strong { font-weight: 600; }

.acadia-usage-banner-cta-text {
    opacity: 0.92;
    margin-left: 4px;
}

.acadia-usage-banner-cta {
    background: rgba(255, 255, 255, 0.95);
    color: #6366F1;
    border: none;
    padding: 7px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.acadia-usage-banner-cta:hover {
    background: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.acadia-usage-banner-close {
    background: transparent;
    color: rgba(255, 255, 255, 0.85);
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 8px;
    transition: color 0.15s;
    flex-shrink: 0;
}

.acadia-usage-banner-close:hover { color: #fff; }

/* Pousser le contenu pour que la banniere ne masque pas le header */
body.acadia-usage-banner-shown {
    padding-top: 48px;
}

@media (max-width: 768px) {
    .acadia-usage-banner-inner { font-size: 0.78rem; padding: 8px 10px; gap: 8px; }
    .acadia-usage-banner-cta-text { display: none; }
    body.acadia-usage-banner-shown { padding-top: 64px; }
}
