/* ============================================
   DYNAMISME.CSS - Animations & Transitions CECT
   ============================================ */

/* ============================================
   VARIABLES
   ============================================ */
:root {
    --anim-fast: 0.15s;
    --anim-normal: 0.3s;
    --anim-slow: 0.5s;
    --anim-slower: 0.8s;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* ============================================
   1. FADE-IN AU SCROLL
   ============================================ */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}

.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.reveal-right.revealed {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-out);
}
.reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   2. HOVER EFFECTS
   ============================================ */

/* Boutons */
.btn, .bouton, button[type="submit"], .btn-primary, .btn-secondary {
    transition: all var(--anim-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.btn:hover, .bouton:hover, button[type="submit"]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(14, 74, 52, 0.25);
}

.btn:active, .bouton:active, button[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(14, 74, 52, 0.15);
}

/* Effet brillance sur les boutons */
.btn-primary::before,
.bouton::before,
button[type="submit"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,.3), transparent);
    transition: left 0.6s ease;
}

.btn-primary:hover::before,
.bouton:hover::before,
button[type="submit"]:hover::before {
    left: 100%;
}

/* Cartes */
.carte, .card, .kpi, .pack-card, .section {
    transition: transform var(--anim-normal) var(--ease-out),
                box-shadow var(--anim-normal) var(--ease-out);
}

.carte:hover, .card:hover, .kpi:hover, .pack-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(16, 40, 28, 0.12);
}

/* Liens */
a {
    transition: color var(--anim-fast) var(--ease-out),
                opacity var(--anim-fast) var(--ease-out);
}

/* Badges avec pulse */
.badge-vert {
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(28, 122, 67, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(28, 122, 67, 0); }
}

/* ============================================
   3. LOADING SPINNER
   ============================================ */
#page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--anim-normal), visibility var(--anim-normal);
}

#page-loader.active {
    opacity: 1;
    visibility: visible;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #eaf4ee;
    border-top-color: #0e4a34;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   4. TOASTS / NOTIFICATIONS
   ============================================ */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 400px;
}

.toast {
    background: white;
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    border-left: 4px solid var(--primary, #0e4a34);
    transform: translateX(120%);
    transition: transform 0.4s var(--ease-out);
    opacity: 0;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(120%);
    opacity: 0;
}

.toast-success { border-left-color: #1c7a43; }
.toast-error { border-left-color: #c23b32; }
.toast-warning { border-left-color: #d97706; }
.toast-info { border-left-color: #2563eb; }

.toast-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
    font-size: 14px;
    color: #16241d;
    line-height: 1.5;
}

.toast-title {
    font-weight: 700;
    display: block;
    margin-bottom: 2px;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

/* ============================================
   5. ANIMATIONS D'ENTRÉE
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.85);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* Classes utilitaires */
.animate-fadeIn { animation: fadeIn 0.5s ease; }
.animate-fadeInUp { animation: fadeInUp 0.6s var(--ease-out); }
.animate-fadeInDown { animation: fadeInDown 0.6s var(--ease-out); }
.animate-slideInLeft { animation: slideInLeft 0.6s var(--ease-out); }
.animate-slideInRight { animation: slideInRight 0.6s var(--ease-out); }
.animate-zoomIn { animation: zoomIn 0.5s var(--ease-out); }
.animate-shake { animation: shake 0.4s ease; }
.animate-pulse { animation: pulse 2s infinite; }
.animate-bounce { animation: bounce 1s infinite; }

/* Délais */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

/* ============================================
   6. BARRE DE PROGRESSION EN HAUT
   ============================================ */
#progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: linear-gradient(90deg, #c9982f, #0e4a34);
    z-index: 99997;
    transition: width 0.3s ease;
    box-shadow: 0 0 10px rgba(201, 152, 47, 0.6);
}

/* ============================================
   7. DARK MODE (préparation)
   ============================================ */
body.dark-mode {
    --bg: #0a0f0c;
    --surface: #1a241f;
    --border: #2a3a32;
    --text: #e8ede9;
    --text-muted: #8a9b90;
    background: #0a0f0c !important;
    color: #e8ede9 !important;
}

body.dark-mode .section,
body.dark-mode .carte,
body.dark-mode .card,
body.dark-mode .kpi,
body.dark-mode .table-wrapper {
    background: #1a241f !important;
    border-color: #2a3a32 !important;
    color: #e8ede9;
}

/* ============================================
   8. BOUTON RETOUR EN HAUT
   ============================================ */
#scroll-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0e4a34, #1a7f4a);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 6px 20px rgba(14, 74, 52, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all var(--anim-normal) var(--ease-out);
    z-index: 9990;
}

#scroll-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

#scroll-top:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(14, 74, 52, 0.5);
}

/* ============================================
   9. MICRO-INTERACTIONS FORMULAIRES
   ============================================ */
input, select, textarea {
    transition: border-color var(--anim-fast), box-shadow var(--anim-fast);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--vert, #1a6b3c);
    box-shadow: 0 0 0 4px rgba(26, 107, 60, 0.1);
}

/* Checkbox animé */
input[type="checkbox"] {
    cursor: pointer;
    transition: transform var(--anim-fast) var(--ease-bounce);
}

input[type="checkbox"]:checked {
    transform: scale(1.15);
}

/* ============================================
   10. SKELETON LOADING
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   11. TABLEAUX INTERACTIFS
   ============================================ */
tbody tr {
    transition: background var(--anim-fast), transform var(--anim-fast);
}

tbody tr:hover {
    background: #f8faf9;
    transform: scale(1.005);
}

/* ============================================
   12. RESPECT DES PRÉFÉRENCES UTILISATEUR
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
/* ============================================
   DARK MODE
   ============================================ */

/* Bouton toggle */
.theme-toggle-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(20deg);
}

/* Dark mode global */
body.dark-mode {
    --bg: #0a0f0c;
    --surface: #131a16;
    --border: #1f2a24;
    --text: #e8ede9;
    --text-muted: #8a9b90;
    --primary-light: #1a2e24;
    --gray-bg: #1a241f;
    --gray-text: #8a9b90;
    --success-bg: #12261a;
    --success-text: #4ade80;
    --warning-bg: #2a1f0a;
    --warning-text: #fbbf24;
    --danger-bg: #2a1213;
    --danger-text: #f87171;
    --blue-bg: #0f1a2e;
    --violet-bg: #1a1230;
    
    background: #0a0f0c !important;
    color: #e8ede9 !important;
}

body.dark-mode .topbar {
    background: linear-gradient(120deg, #050a07 0%, #0a1a11 45%, #0d2619 100%);
}

body.dark-mode .section,
body.dark-mode .carte,
body.dark-mode .card,
body.dark-mode .kpi,
body.dark-mode .table-wrapper,
body.dark-mode .pack-card,
body.dark-mode .pack-form-card,
body.dark-mode .perso-card,
body.dark-mode .adhesion-card,
body.dark-mode .container,
body.dark-mode .notif-dropdown {
    background: #131a16 !important;
    border-color: #1f2a24 !important;
    color: #e8ede9 !important;
}

body.dark-mode th {
    background: #0a0f0c !important;
    color: #8a9b90 !important;
}

body.dark-mode tr:hover {
    background: #1a241f !important;
}

body.dark-mode tbody tr:hover {
    background: #1a241f !important;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background: #0a0f0c !important;
    border-color: #1f2a24 !important;
    color: #e8ede9 !important;
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
    border-color: #c9982f;
    box-shadow: 0 0 0 3px rgba(201, 152, 47, 0.15);
}

body.dark-mode .notif-item:hover {
    background: #1a241f !important;
}

body.dark-mode .notif-item.non-lue {
    background: #1a2e24 !important;
}

body.dark-mode .notif-dropdown .notif-header {
    border-color: #1f2a24;
}

/* Transitions douces */
body, body * {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}