/* =============================================
   B.A.I.F - Styles globaux
   ============================================= */

/* Card institutionnelle (ex-glassmorphism, redéfinie sobre) */
.glass-card {
    background: #ffffff;
    border: 1px solid #EDEFF2;
    box-shadow: 0 1px 2px rgba(10, 36, 99, 0.04);
}
/* Variante opt-in pour les sections sur fond navy (à utiliser explicitement) */
.glass-card-dark {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: none;
}

/* Dégradé Hero */
.hero-gradient {
    background: linear-gradient(135deg, var(--color-royal) 0%, var(--color-night) 100%);
}

/* Hover institutionnel : bordure + ombre fine, pas de translation */
.hover-lift {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.hover-lift:hover {
    border-color: rgba(10, 36, 99, 0.18);
    box-shadow: 0 4px 12px rgba(10, 36, 99, 0.06);
}

/* Scrollbar custom */
::-webkit-scrollbar        { width: 6px; }
::-webkit-scrollbar-track  { background: var(--color-slate); }
::-webkit-scrollbar-thumb  { background: var(--color-royal); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--color-night); }

/* ---- Animations scroll ---- */
.will-animate {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.will-animate.animated.fade-up {
    opacity: 1;
    transform: translateY(0);
}
.will-animate.animated.fade-in {
    opacity: 1;
    transform: none;
}

/* ---- Hero interne (pages secondaires) ---- */
.page-hero {
    background: linear-gradient(135deg, var(--color-royal) 0%, var(--color-night) 100%);
    padding-top: 6rem;
    padding-bottom: 3rem;
}
@media (min-width: 768px) {
    .page-hero {
        padding-top: 8rem;
        padding-bottom: 4rem;
    }
}
.page-hero h1 {
    font-size: clamp(2rem, 5vw, 3.75rem);
    line-height: 1.1;
}
html, body { overflow-x: hidden; }

/* ---- Badges statut transaction ---- */
.badge-success { background: #D1FAE5; color: #065F46; }
.badge-pending { background: #FEF3C7; color: #92400E; }
.badge-failed  { background: #FEE2E2; color: #991B1B; }

/* ---- Accordion FAQ ---- */
.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}
.faq-answer.open {
    max-height: 400px;
}

/* ---- Stepper ---- */
.step-item::before {
    content: '';
    position: absolute;
    top: 50%;
    right: -50%;
    width: 100%;
    height: 2px;
    background: #E5E7EB;
    transform: translateY(-50%);
}
.step-item.done::before   { background: var(--color-royal); }
.step-item:last-child::before { display: none; }

/* ---- Simulateur range ---- */
input[type="range"] {
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #E5E7EB;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-royal);
    cursor: pointer;
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px var(--color-royal);
}

/* ---- Focus visible global ---- */
:focus-visible {
    outline: 2px solid var(--color-royal);
    outline-offset: 2px;
}
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--color-royal);
    outline-offset: 3px;
    border-radius: 4px;
}

/* ---- Input transitions ---- */
input, textarea, select {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

/* ---- Card focus-within (sobre) ---- */
.glass-card:focus-within {
    border-color: rgba(10, 36, 99, 0.25);
    box-shadow: 0 2px 6px rgba(10, 36, 99, 0.05);
}

/* ---- Nav scroll transition ---- */
nav.fixed {
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}

/* ---- Burger → X animation ---- */
#burger.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
#burger.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
#burger.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* ---- Mobile menu slide (uniquement sur mobile, lg:hidden gère le desktop) ---- */
@media (max-width: 1023px) {
    #mobile-menu {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.35s ease;
        display: block;
    }
    #mobile-menu.open {
        max-height: 600px;
    }
}

/* ---- Table row hover ---- */
.table-hover tbody tr {
    transition: background-color 0.15s ease;
}
.table-hover tbody tr:hover {
    background-color: rgba(10, 36, 99, 0.03) !important;
}

/* ---- Dashboard card hover (sobre, institutionnel) ---- */
.kpi-card {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.kpi-card:hover {
    border-color: rgba(10, 36, 99, 0.18);
    box-shadow: 0 4px 12px rgba(10, 36, 99, 0.06);
}

/* ---- Transaction row hover ---- */
.tx-row {
    transition: background-color 0.15s ease;
    cursor: default;
}
.tx-row:hover {
    background-color: rgba(10, 36, 99, 0.025);
    border-radius: 0.5rem;
}

/* ---- Button active feedback ---- */
/* Feedback de clic : opacité subtile, pas de transformation (style banque institutionnelle) */
button[type="submit"]:active,
.btn-primary:active {
    opacity: 0.9;
}

/* ---- Scroll shadow for overflow tables ---- */
.scroll-shadow {
    position: relative;
}
.scroll-shadow::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to left, rgba(245,245,247,0.9), transparent);
    pointer-events: none;
    border-radius: 0 1rem 1rem 0;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    .hover-lift,
    .hover-lift:hover,
    .kpi-card,
    .kpi-card:hover {
        transition: none !important;
    }
    .will-animate {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
    #burger span,
    #mobile-menu {
        transition: none !important;
    }
    .toast {
        transition: opacity 0.15s ease !important;
    }
}

/* ---- Modal overlay ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 36, 99, 0.55);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.modal-box {
    background: #fff;
    border-radius: 1rem;
    max-width: 28rem;
    width: 100%;
    box-shadow: 0 25px 60px -10px rgba(10, 36, 99, 0.35);
    transform: translateY(16px);
    transition: transform 0.2s ease;
}
.modal-overlay.open .modal-box {
    transform: translateY(0);
}

/* ---- Toast notification ---- */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    background: var(--color-royal);
    color: #fff;
    padding: 0.875rem 1.25rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(10, 36, 99, 0.3);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: 22rem;
}
.toast.show {
    transform: translateY(0);
    opacity: 1;
}
.toast.toast-success { background: #065F46; }
.toast.toast-error   { background: #991B1B; }
.toast.toast-info    { background: var(--color-royal); }

/* ---- Spinner ---- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}
.spinner-royal {
    border-color: rgba(10,36,99,0.2);
    border-top-color: var(--color-royal);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Form states ---- */
.field-error {
    border-color: #EF4444 !important;
    ring: none;
}
.field-error-msg {
    color: #DC2626;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}
.field-success {
    border-color: #10B981 !important;
}

/* ---- Loading button ---- */
.btn-loading {
    pointer-events: none;
    opacity: 0.7;
}

/* ---- Typing indicator (messagerie) ---- */
.typing-dot {
    animation: typing-dot 1.4s ease infinite;
}
@keyframes typing-dot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30%            { opacity: 1;   transform: translateY(-3px); }
}

/* =====================================================
   MINI DESIGN SYSTEM - boutons, badges, focus states
   ===================================================== */

/* ---- Boutons (utiliser comme classes utilitaires) ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.18s ease;
    cursor: pointer;
    border: none;
    text-decoration: none;
    white-space: nowrap;
    min-height: 40px;
}
.btn:disabled, .btn[disabled] { opacity: 0.6; cursor: not-allowed; pointer-events: none; }
.btn-primary  { background: var(--color-royal); color: #fff; }
.btn-primary:hover  { background: #061847; }
.btn-secondary { background: var(--color-slate); color: var(--color-royal); border: 1px solid #E5E7EB; }
.btn-secondary:hover { background: #ffffff; border-color: var(--color-royal); }
.btn-ghost     { background: transparent; color: #6B7280; border: 1px solid #E5E7EB; }
.btn-ghost:hover { background: #F9FAFB; color: var(--color-royal); border-color: var(--color-royal); }
.btn-danger    { background: #DC2626; color: #fff; }
.btn-danger:hover    { background: #B91C1C; }

/* ---- Badges status ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}
.badge-success { background: #D1FAE5; color: #047857; }
.badge-warning { background: #FEF3C7; color: #B45309; }
.badge-danger  { background: #FEE2E2; color: #B91C1C; }
.badge-info    { background: #DBEAFE; color: #1E40AF; }
.badge-neutral { background: #F3F4F6; color: #4B5563; }

/* ---- Focus visible cohérent (accessibilité) ---- */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="menuitem"]:focus-visible {
    outline: 2px solid var(--color-royal);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Annule l'outline natif UNIQUEMENT pour le focus souris (clic) ;
   le focus clavier garde le contour royal grâce à :focus-visible ci-dessus. */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
    outline: none;
}

/* =====================================================
   FORMULAIRES INSTITUTIONNELS - labels, inputs, aide, erreurs
   Classes utilitaires à appliquer dans les formulaires
   pour une cohérence cross-pages (virements, profil, crypto…).
   ===================================================== */

/* Label uniforme : petit, gris, espacement régulier */
.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

/* Input/select/textarea uniformes */
.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 0.375rem; /* 6px */
    font-size: 0.875rem;
    color: #1F2937;
    line-height: 1.4;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.form-input:hover,
.form-select:hover,
.form-textarea:hover {
    border-color: #D1D5DB;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-royal);
    box-shadow: 0 0 0 3px rgba(10, 36, 99, 0.08);
    outline: none;
}
.form-textarea {
    resize: vertical;
    min-height: 5.5rem;
    line-height: 1.5;
}
.form-input::placeholder,
.form-textarea::placeholder {
    color: #9CA3AF;
}
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background: #F9FAFB;
    color: #9CA3AF;
    cursor: not-allowed;
}

/* Aide sous champ (gris fin) */
.form-help {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: #9CA3AF;
    line-height: 1.4;
}

/* Erreur sous champ (rouge sobre) */
.form-error {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: #B91C1C;
    line-height: 1.4;
}
.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
    border-color: #DC2626;
}
.form-input.is-invalid:focus,
.form-select.is-invalid:focus,
.form-textarea.is-invalid:focus {
    border-color: #DC2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

/* Groupe de champ (label + input + aide/erreur) */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group:last-child {
    margin-bottom: 0;
}
