/* Google Fonts - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

/* Tailwind 2.2.19 — hébergé localement (évite Tracking Prevention / stockage tiers sur le CDN jsDelivr). */
@import url('/css/tailwind.min.css');

/* ===== THÈME CLAIR (par défaut) ===== */
:root {
    /* Couleurs primaires */
    --zanura-primary: #1E90FF;
    --zanura-primary-dark: #1873CC;
    --zanura-primary-light: #4DA6FF;
    
    /* Couleurs de fond */
    --bg-primary: #F5F7FA;
    --bg-secondary: #FFFFFF;
    --bg-tertiary: #E5E9F0;
    --bg-card: #FFFFFF;
    --bg-sidebar: #071A39;
    --bg-header: #FFFFFF;
    
    /* Couleurs de texte */
    --text-primary: #071A39;
    --text-secondary: #4A5568;
    --text-tertiary: #718096;
    --text-muted: #A0AEC0;
    --text-inverse: #FFFFFF;
    
    /* Bordures */
    --border-primary: #E2E8F0;
    --border-secondary: #CBD5E0;
    
    /* États */
    --color-success: #10B981;
    --color-success-bg: #ECFDF5;
    --color-warning: #F59E0B;
    --color-warning-bg: #FFFBEB;
    --color-error: #EF4444;
    --color-error-bg: #FEF2F2;
    --color-info: #3B82F6;
    --color-info-bg: #EFF6FF;

    /* Alias legacy (pages isolées) */
    --success: var(--color-success);
    --warning: var(--color-warning);
    --error: var(--color-error);
    --info: var(--color-info);
    
    /* Catégories élèves */
    --categorie-total: #10B981;
    --categorie-partiel: #F59E0B;
    --categorie-exonere: #3B82F6;
    
    /* Ombres */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Transition */
    --theme-transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;

    /* ===== Alias charte (compat pages isolées) ===== */
    --primary: var(--bg-sidebar);
    --accent: var(--zanura-primary);
    --bg-light: var(--bg-primary);
    --text-dark: #1F2937;
    --text-muted: var(--text-tertiary);
    --primary-dark: var(--text-primary);
    --primary-light: var(--bg-primary);
    --accent-hover: var(--zanura-primary-dark);
}

/* ===== THÈME SOMBRE ===== */
[data-theme="dark"] {
    /* Couleurs de fond */
    --bg-primary: #0D1421;
    --bg-secondary: #1A2332;
    --bg-tertiary: #243044;
    --bg-card: #1A2332;
    --bg-sidebar: #0A0F1A;
    --bg-header: #1A2332;
    
    /* Couleurs de texte */
    --text-primary: #F7FAFC;
    --text-secondary: #CBD5E0;
    --text-tertiary: #A0AEC0;
    --text-muted: #718096;
    --text-inverse: #0D1421;
    
    /* Bordures */
    --border-primary: #2D3748;
    --border-secondary: #4A5568;
    
    /* États ajustés pour le dark mode */
    --color-success-bg: #064E3B;
    --color-warning-bg: #78350F;
    --color-error-bg: #7F1D1D;
    --color-info-bg: #1E3A5F;

    /* Alias legacy (pages isolées) */
    --success: var(--color-success);
    --warning: var(--color-warning);
    --error: var(--color-error);
    --info: var(--color-info);
    
    /* Ombres plus subtiles */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.2);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);

    /* ===== Alias charte (compat pages isolées) ===== */
    --primary: var(--bg-sidebar);
    --accent: var(--zanura-primary);
    --bg-light: var(--bg-primary);
    --text-dark: #E5E7EB;
    --text-muted: var(--text-tertiary);
    --primary-dark: var(--text-primary);
    --primary-light: var(--bg-primary);
    --accent-hover: var(--zanura-primary-dark);
}

/* ===== STYLES DE BASE ===== */
body, html {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--theme-transition);
}

.font-poppins {
    font-family: 'Poppins', sans-serif;
}

/* ===== BOUTONS ===== */
.btn-primary {
    background-color: var(--zanura-primary);
    color: white;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--zanura-primary-dark);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Loader sur boutons (tâche en cours) */
.btn-spinner,
.spinner-small {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-right: 0.5rem;
    vertical-align: middle;
    flex-shrink: 0;
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-primary);
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-secondary:hover {
    background-color: var(--border-primary);
}

.btn-outline {
    border: 2px solid var(--zanura-primary);
    color: var(--zanura-primary);
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-outline:hover {
    background-color: var(--zanura-primary);
    color: white;
}

.btn-danger {
    background-color: var(--color-error);
    color: white;
    font-weight: 600;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md);
    transition: all 0.2s;
}

.btn-danger:hover {
    opacity: 0.9;
}

/* ===== CARDS ===== */
.card {
    background-color: var(--bg-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-primary);
    transition: var(--theme-transition);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-primary);
}

.card-body {
    padding: 1.5rem;
}

/* ===== BADGES ===== */
.badge-total {
    background-color: var(--color-success-bg);
    color: var(--color-success);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-partiel {
    background-color: var(--color-warning-bg);
    color: var(--color-warning);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-exonere {
    background-color: var(--color-info-bg);
    color: var(--color-info);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* ===== INPUTS ===== */
.input {
    width: 100%;
    padding: 0.5rem 1rem;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.input:focus {
    outline: none;
    border-color: var(--zanura-primary);
    box-shadow: 0 0 0 3px rgba(30, 144, 255, 0.2);
}

.input::placeholder {
    color: var(--text-muted);
}

.input-error {
    border-color: var(--color-error);
}

.input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

/* ===== TABLES ===== */
.table-container {
    background-color: var(--bg-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--border-primary);
}

.table {
    min-width: 100%;
    border-collapse: collapse;
}

.table thead {
    background-color: var(--bg-tertiary);
}

.table th {
    padding: 0.75rem 1.5rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.table td {
    padding: 1rem 1.5rem;
    white-space: nowrap;
    font-size: 0.875rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-primary);
}

.table tbody tr {
    transition: background-color 0.2s;
}

.table tbody tr:hover {
    background-color: var(--bg-tertiary);
}

/* ===== STAT CARDS ===== */
.stat-card {
    background-color: var(--bg-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-md);
    padding: 1.5rem;
    border-left: 4px solid;
    transition: var(--theme-transition);
}

.stat-card-blue {
    border-left-color: var(--zanura-primary);
}

.stat-card-green {
    border-left-color: var(--color-success);
}

.stat-card-yellow {
    border-left-color: var(--color-warning);
}

.stat-card-red {
    border-left-color: var(--color-error);
}

/* ===== SIDEBAR (Dark theme reste le même) ===== */
.sidebar {
    background-color: var(--bg-sidebar);
    color: var(--text-inverse);
}

[data-theme="dark"] .sidebar {
    background-color: #0A0F1A;
    border-right: 1px solid var(--border-primary);
}

/* ===== HEADER ===== */
.header {
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border-primary);
    transition: var(--theme-transition);
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
    position: relative;
    width: 56px;
    height: 28px;
    background-color: var(--bg-tertiary);
    border-radius: 9999px;
    cursor: pointer;
    transition: background-color 0.3s;
    border: 1px solid var(--border-primary);
}

.theme-toggle.active {
    background-color: var(--zanura-primary);
}

.theme-toggle-circle {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

.theme-toggle.active .theme-toggle-circle {
    transform: translateX(28px);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(30, 144, 255, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(30, 144, 255, 0); }
}

.animate-pulse-glow {
    animation: pulse-glow 2s infinite;
}

/* ===== SPINNER ===== */
.spinner {
    animation: spin 1s linear infinite;
    border-radius: 50%;
    height: 2rem;
    width: 2rem;
    border: 4px solid var(--zanura-primary);
    border-top-color: transparent;
}

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

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background-color: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background-color: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-tertiary);
}

/* ===== UTILITAIRES DARK MODE ===== */
.dark\:text-white {
    color: var(--text-primary);
}

.bg-page {
    background-color: var(--bg-primary);
}

.bg-surface {
    background-color: var(--bg-secondary);
}

.text-heading {
    color: var(--text-primary);
}

.text-body {
    color: var(--text-secondary);
}

.text-subtle {
    color: var(--text-tertiary);
}

.border-subtle {
    border-color: var(--border-primary);
}

/* ===== RAPPORTS FINANCE (impression dédiée) ===== */
/*
 * RapportJournalierCaisse / RapportMensuelCaisse : un second bloc HTML (.finance-print-only)
 * sert de « vrai » document pour window.printFinanceReport() (voir wwwroot/js/app.js).
 * finance-print.css n’est chargé que dans la fenêtre d’impression : sans règle ici, ce clone
 * reste visible en bas de page dans l’app (doublon type « ECOLE DEMO » + tableaux bruts).
 */
.finance-print-only {
    display: none !important;
}

/* Rapport effectifs (Classes) : clone HTML pour fenêtre d'impression dédiée */
.effectifs-print-only {
    display: none !important;
}

/* ===== PRINT ===== */
@media print {
    .no-print {
        display: none !important;
    }

    /*
     * Rapports Finance (journalier / mensuel / annuel) : Ctrl+P du navigateur doit imprimer
     * le bloc .finance-print-only (tableaux), pas le dashboard (.finance-screen-only : graphiques,
     * flex, sauts de page incorrects). Le bouton « Imprimer » utilise une fenêtre dédiée + finance-print.css.
     */
    .finance-screen-only {
        display: none !important;
    }

    .finance-print-only {
        display: block !important;
    }

    /* Mise en forme minimale des tableaux du document (finance-print.css absent sur cette page) */
    .fr-doc-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 11pt;
        margin: 0 0 0.75rem;
    }

    .fr-doc-table th,
    .fr-doc-table td {
        border: 1px solid #d1d5db;
        padding: 0.35rem 0.5rem;
        text-align: left;
        vertical-align: top;
    }

    .fr-doc-table thead th {
        background: #f3f4f6;
        font-weight: 600;
    }

    .fr-th-num,
    .fr-td-num {
        text-align: right !important;
    }

    .fr-doc-h2 {
        font-size: 11pt;
        font-weight: 600;
        color: #1e40af;
        margin: 0 0 0.35rem;
    }

    .fr-doc-title {
        font-size: 13pt;
        font-weight: 700;
        color: #071a39;
        text-transform: uppercase;
        margin: 0 0 0.25rem;
    }

    .fr-doc-subtitle {
        margin: 0;
        font-size: 10pt;
        color: #4b5563;
    }

    .fr-doc-ecole-block {
        text-align: center;
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #e5e7eb;
    }

    .fr-doc-ecole-nom {
        font-weight: 700;
        font-size: 11pt;
        color: #071a39;
    }

    .fr-doc-ecole-adresse {
        font-size: 9pt;
        color: #4b5563;
        white-space: pre-line;
    }

    .fr-doc-section {
        margin-bottom: 0.85rem;
        break-inside: avoid;
    }

    .fr-doc-footer-signatures {
        margin-top: 1.25rem;
        padding-top: 0.75rem;
        border-top: 2px solid #071a39;
        break-inside: avoid;
    }

    .fr-doc-sig-grid {
        display: flex;
        gap: 2rem;
    }

    .fr-doc-sig-cell {
        flex: 1;
    }

    .fr-doc-sig-label {
        font-size: 8pt;
        font-weight: 600;
        text-transform: uppercase;
    }

    .fr-doc-sig-line {
        border-bottom: 1px solid #111827;
        min-height: 2rem;
        margin-top: 0.25rem;
    }

    .fr-doc-sceau-zone {
        margin-top: 0.75rem;
        text-align: center;
    }

    .fr-doc-sceau-img {
        max-height: 72px;
        max-width: 140px;
    }
    
    body {
        font-size: 12pt;
        background-color: white !important;
        color: black !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ccc !important;
    }
}

/* ===== RESPONSIVE FIXES ===== */
@media (max-width: 768px) {
    .card-body {
        padding: 1rem;
    }
    
    .table th, .table td {
        padding: 0.5rem 1rem;
    }
}
