/* ==========================================================================
   1. VARIABLES GLOBALES & PALETTE DE COULEURS
   ========================================================================== */
:root {
    /* Couleurs de la Sidebar */
    --bg-sidebar: #1e2640;          /* Bleu nuit professionnel */
    --bg-sidebar-hover: #262f4c;    /* Survol légèrement plus clair */
    --text-muted-custom: #94a3b8;   /* Gris doux pour le texte secondaire */
    
    /* Couleurs de l'application */
    --primary-custom: #3b82f6;      /* Bleu moderne (Bootstrap primary révisé) */
    --bg-light-app: #f8fafc;        /* Fond de page ultra-pro et reposant */
}

/* ==========================================================================
   2. STRUCTURE GLOBALE (Layout type Logiciel)
   ========================================================================== */
html, body {
    height: 100vh;
    min-height: 100vh;
    overflow: hidden; /* Empêche la page entière de scroller */
    margin: 0;
    padding: 0;
    background-color: var(--bg-light-app);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Bloc contenant la Topbar + le Contenu Principal */
.main-layout-container {
    flex-grow:1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Zone dynamique où HTMX injecte les pages (Seule cette zone peut scroller) */
main#main-content {
    height: calc(100vh - 70px); /* Hauteur totale moins la topbar */
    overflow-y: auto;           /* Scroll vertical uniquement si nécessaire */
    background-color: var(--bg-light-app);
}

/* ==========================================================================
   3. MODULE : SIDEBAR (`partials/sidebar.html`)
   ========================================================================== */
.bg-dark-sidebar {
    background-color: var(--bg-sidebar) !important;
    width: 280px;
    height: 100vh !important; /* Force la hauteur sur toute la longueur */
    transition: all 0.3s ease;
}

/* Style du logo dans la sidebar */
.sidebar-logo {
    height: 45px;          /* Hauteur parfaite pour s'aligner avec le texte sans déformer le menu */
    width: auto;           /* Conserve les proportions circulaires du logo */
    border-radius: 50%;    /* Épouse parfaitement la forme ronde du logo */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15); /* Un léger relief très subtil */
    transition: transform 0.3s ease;
}

/* Effet dynamique discret au survol du bloc logo */
#sidebar-container a:hover .sidebar-logo {
    transform: scale(1.05); /* Le logo grossit très légèrement quand on le survole */
}

.tracking-wide {
    letter-spacing: 0.5px;
}



.text-primary-custom {
    color: var(--primary-custom) !important;
}

/* Boutons de navigation de la sidebar */
#sidebar-menu .nav-link {
    background: transparent;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    color: var(--text-muted-custom) !important;
    transition: all 0.2s ease-in-out;
}

/* Effet au survol (Hover) */
#sidebar-menu .nav-link:hover {
    background-color: var(--bg-sidebar-hover) !important;
    color: #ffffff !important;
    transform: translateX(4px); /* Léger décalage vers la droite très élégant */
}

/* Élément Actif (Page en cours) */
#sidebar-menu .nav-link.active {
    background-color: var(--primary-custom) !important;
    color: #ffffff !important;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
    transform: none;
}

.bg-secondary-custom {
    background-color: #334155;
    color: #cbd5e1;
}

  /*  SOUS-MENUS DÉROULANTS DE LA SIDEBAR */

/* Style pour les sous-boutons */
.sub-nav-link {
    font-size: 0.88rem !important;
    padding-left: 0.75rem !important;
    background-color: rgba(255, 255, 255, 0.02) !important;
    border-radius: 6px !important;
}

/* Animation fluide du chevron lors de l'ouverture */
.sidebar-dropdown-toggle .chevron-icon {
    transition: transform 0.2s ease;
}

/* Pivoter le chevron de 180° lorsque le menu est ouvert */
.sidebar-dropdown-toggle[aria-expanded="true"] .chevron-icon {
    transform: rotate(180deg);
    color: var(--primary-custom) !important;
}

/* Différencier l'état actif sur un sous-menu */
.sub-nav-link.active {
    background-color: rgba(59, 130, 246, 0.15) !important; /* Fond bleu translucide discret */
    color: var(--primary-custom) !important;
    font-weight: 600;
    box-shadow: none !important;
}

/* ==========================================================================
   4. MODULE : TOPBAR (`partials/topbar.html`)
   ========================================================================== */
.navbar {
    min-height: 70px;
    height: 70px;
}

.bg-light-badge {
    background-color: #f1f5f9 !important;
}

/* Supprime les contours bleus désagréables de Bootstrap sur les boutons transparents */
.btn-link:focus, .btn-link:active, .btn-check:focus + .btn, .btn:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* ==========================================================================
   5. COMPOSANTS RÉUTILISABLES (Pour vos futures pages & fragments)
   ========================================================================== */
/* Cartes blanches au design épuré pour le dashboard et les formulaires */
.custom-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   6. RESPONSIVE MEDIA QUERIES (Ajustements Mobile)
   ========================================================================== */
@media (max-width: 991.98px) {
    /* Sur mobile, le container droit prend 100% de la largeur nativement */
    .main-layout-container {
        width: 100%;
    }
    
    /* On adoucit les paddings dans le contenu principal sur petit écran */
    main#main-content {
        padding: 1rem !important;
    }

    /* Supprime l'effet de décalage au survol sur mobile pour éviter les bugs tactiles */
    #sidebar-menu .nav-link:hover {
        transform: none;
    }
}


/* ==========================================================================
   7. STYLE DU TABLEAU DE BORD (DASHBOARD)
   ========================================================================== */

/* Fonds adoucis pour icônes (Soft Backgrounds) */
.bg-primary-soft { background-color: rgba(59, 130, 246, 0.12) !important; }
.bg-success-soft { background-color: rgba(34, 197, 94, 0.12) !important; }
.bg-warning-soft { background-color: rgba(234, 179, 8, 0.12) !important; }
.bg-info-soft    { background-color: rgba(6, 182, 212, 0.12) !important; }

/* Bordure en pointillés pour les boutons d'actions rapides */
.border-dashed {
    border-style: dashed !important;
    border-width: 1.5px !important;
}
.border-dashed:hover {
    background-color: #f1f5f9 !important;
}

/* Polices de taille ultra-fine */
.extra-small {
    font-size: 0.75rem;
    display: block;
}

.small-badge {
    font-size: 0.75rem !important;
    font-weight: 500;
}

.border-bottom-dashed {
    border-bottom: 1px dashed #e2e8f0;
}

/* Animation fluide d'entrée de page */
.animate-fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   10. MODULE STYLE GRILLE DE CLASSES (Inspiré de la maquette)
   ========================================================================== */
:root {
    --emerald-primary: #0f766e;      /* Vert sapin / émeraude de la maquette */
    --emerald-hover: #115e59;
    --emerald-soft: #ccfbf1;
}

/* Bouton principal Nouvelle Classe et Générer */
.btn-emerald {
    background-color: var(--emerald-primary) !important;
    color: #ffffff !important;
    border: none;
    font-weight: 500;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    transition: all 0.2s ease;
}
.btn-emerald:hover {
    background-color: var(--emerald-hover) !important;
}

/* Boutons d'actions à l'intérieur des cartes */
.btn-emerald-action {
    background-color: var(--emerald-primary) !important;
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}
.btn-emerald-action:hover {
    background-color: var(--emerald-hover) !important;
}

.btn-outline-custom {
    background-color: #ffffff !important;
    color: #334155 !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.15s ease;
}
.btn-outline-custom:hover {
    background-color: #f8fafc !important;
}

/* Couleurs douces pour badges d'effectifs */
.bg-emerald-soft {
    background-color: var(--emerald-soft) !important;
    color: var(--emerald-primary) !important;
    font-weight: 600;
}

.progress-bar.bg-emerald {
    background-color: var(--emerald-primary) !important;
}


/* ==========================================================================
   9. STYLE DE LA GESTION DES ÉLÈVES
   ========================================================================== */

/* Coins arrondis spécifiques pour les cadres de photos d'élèves */
.rounded-secondary {
    border-radius: 8px !important;
}

/* Harmonisation visuelle de la table des élèves */
.table tbody tr:hover {
    background-color: rgba(248, 250, 252, 0.7) !important;
}

/* Style des petits boutons icônes seuls */
.table .btn-sm:has(span) {
    padding: 0.4rem 0.75rem;
}
.table .btn-sm:not(:has(span)) {
    padding: 0.4rem 0.5rem;
}


/* ==========================================================================
   12. MODULE LISTE DES CARTES GÉNÉRÉES (PDF)
   ========================================================================== */

/* Couleur rouge spécifique pour l'icône PDF */
.text-danger {
    color: #ef4444 !important;
}

/* Effet de survol sur les cartes de lots pour donner une sensation d'interactivité */
#grid-lots-container .custom-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#grid-lots-container .custom-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05) !important;
    border-color: var(--emerald-primary) !important; /* La carte s'illumine subtilement aux couleurs du projet */
}


/* ==========================================================================
   13. ARCHITECTURE GRAPHIQUE DU RECTO UNIQUE (NORME MINESEC / CR80)
   ========================================================================== */

/* Layout principal de la carte */
.recto-only-layout {
    position: relative;
    width: 460px; /* Légèrement élargi pour faire respirer le triptyque */
    height: 280px;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    overflow: hidden;
}

/* Gestion de la couche transparente du filigrane de fond au centre */
.card-watermark-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 180px;
    opacity: 0.05; /* Filigrane très discret pour ne pas nuire à la clarté */
    pointer-events: none;
    z-index: 1;
}
.card-watermark-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Couche de contenu forcée au-dessus du filigrane */
.card-content-layer {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

/* --- ZONE 1 : L'EN-TÊTE TRIPTYQUE --- */
.zone-1-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border-bottom: 2px solid var(--emerald-primary);
    padding: 6px 10px;
    gap: 4px;
}
.header-col {
    flex: 1;
    font-family: 'Arial', sans-serif;
}
.state-mention {
    font-size: 0.52rem;
    color: var(--bg-sidebar);
    line-height: 1.1;
}
.state-sub {
    font-size: 0.45rem;
    color: #64748b;
    font-style: italic;
}
.ministry-mention {
    font-size: 0.42rem;
    color: #475569;
    line-height: 1.1;
    margin-top: 1px;
}
.college-name {
    font-size: 0.52rem;
    margin-top: 2px;
}
.header-center-logo {
    height: 36px;
    width: 36px;
    object-fit: contain;
}

/* --- ZONE 2 : LE CORPS EN DEUX BLOCS --- */
.recto-only-layout {
    position: relative;
    width: 460px; 
    height: 280px;
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    overflow: hidden;
}

/*titre de la zone 2 */
.titre-carte{
	text-align: center;
	font-size: 0.75rem;
	background-color: #008080;
	margin-left: 50px;
	margin-right: 50px;
	border-radius: 6px;
}

.titre-carte p{
		color: #ffffff;
		font-weight: bold;
		margin: 0;
		padding: 2px 0;
	}
.titre-carte span {
	font-size: 0.6rem;
	font-style: italic;
}

/* Zone 2 réorganisée en flux vertical */
.zone-2-body-vertical {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* Modification du conteneur du Nom pour occuper 100% de la largeur */
.student-fullname-display {
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 2px;
    width: 100%;
}

.label-name-prefix {
    font-size: 0.70rem;
    color: #64748b;
    font-weight: 600;
    line-height: 1;
}

/* Taille du nom adaptée pour ne pas casser la ligne même si le nom est long */
.fs-custom-name {
    font-size: 0.82rem;
    margin-top: 1px;
    line-height: 1.1;
}

/* Petits labels pour les traductions anglaises */
.label-en {
    font-size: 0.65rem;
    color: #94a3b8;
    font-style: italic;
    font-weight: normal;
}

.label-en-inline {
    font-size: 0.65rem;
    color: #94a3b8;
    font-style: italic;
    font-weight: normal;
}

/* Bloc Photo adapté */
/* 🟢 1. Conteneur vertical fixé à la largeur stricte de la photo */
.photo-and-year-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 74px; /* Force le bloc à ne pas dépasser la taille de la photo */
    position: relative; /* Permet le positionnement de l'année en dessous */
}
.student-photo-box {
    width: 74px;
    height: 88px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/*  Style du bloc Année Scolaire calé sous la photo */
.annee-scolaire-under-photo {
    position: absolute; 
    margin-left: 8rem; 
    top: 84px; 
    width: max-content;
    white-space: nowrap;
    z-index: 10;     
}

/* On ajuste les tailles pour que le bloc reste compact et élégant */
.label-annee-title {
    font-size: 0.5rem;
    color: #64748b;
    font-weight: bold;
}

.value-annee-text {
    font-size: 0.70rem;
    margin-left: 3px; 
}

/* Tableau des spécifications techniques de l'élève */
.student-specs-box {
    margin-left: 4px;
}
.table-card-spec {
    width: 100%;
    font-size: 0.70rem; 
}
.table-card-spec td {
    padding: 1px 0; /* Espacement condensé */
    color: #334155;
    vertical-align: middle;
}
.table-card-spec .label-spec {
    color: #475569;
    font-weight: 700;
    width: 95px; 
    font-size: 0.58rem;
}

/* Alignement de la zone visa */
.authority-visa-box {
    width: 90px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    align-self: flex-start;
    margin-top: 5px;
}
.visa-title {
    font-size: 0.52rem;
    line-height: 1;
}
.visa-subtitle {
    font-size: 0.45rem;
    font-style: italic;
    line-height: 1;
}
.visa-free-space {
    width: 100%;
    height: 48px; /* Ajusté pour laisser la place au tampon sans déborder sur le footer */
}

/* --- ZONE 3 : LE PIED DE CARTE COORDONNÉES --- */
.zone-3-footer {
    background: var(--bg-sidebar);
    padding: 5px 10px;
    border-top: 1px solid #e2e8f0;
}
.footer-legal-grid {
    display: flex;
    justify-content: space-between;
    font-size: 0.52rem;
    color: #cbd5e1;
    font-weight: 500;
}
.footer-legal-grid span {
    display: inline-flex;
    align-items: center;
}

/* ==========================================================================
   .  🟢 STYLE DÉDIÉ UNIQUEMENT À L'IMPRESSION PHYSIQUE DE CARTE
   ========================================================================== */

@media print {
    /* 1. Masquer totalement l'arbre de mise en page pour libérer l'espace (Zéro page blanche) */
    html, body, #main-content, .container-fluid, .row, .col-12, .custom-card, .flip-card-wrapper {
        background: transparent !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Masquer tous les éléments parasites du layout global */
    sidebar, .sidebar, #sidebar, .topbar, #topbar-title, .btn, .badge, #preview-actions-zone, .bg-light {
        display: none !important;
    }

    /* 2. Isoler et forcer l'affichage de la carte */
    #carte-a-imprimer {
        display: block !important;
        visibility: visible !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        z-index: 9999999 !important;
    }

    /* S'assurer que le contenu généré par Thymeleaf/HTMX à l'intérieur est bien visible */
    #carte-a-imprimer * {
        visibility: visible !important;
    }

    /* 3. Nettoyer les marges physiques de la feuille de papier */
    @page {
        size: auto;
        margin: 0mm;
    }
}



/* ==========================================================================
   14. COMPOSANTS DU MODULE PARAMÈTRES
   ========================================================================== */

/* Zone de Drag and Drop de fichier */
.upload-dropzone {
    border: 2px dashed #cbd5e1;
    transition: all 0.2s ease-in-out;
}

.upload-dropzone:hover {
    border-color: var(--emerald-primary);
    background-color: rgba(15, 118, 110, 0.02) !important;
}

/* Forcer le pointeur main sur les éléments interactifs d'options */
.cursor-pointer {
    cursor: pointer;
}

/* Personnalisation de l'interrupteur (Switch) de Bootstrap aux couleurs Émeraude */
.form-check-input:checked {
    background-color: var(--emerald-primary) !important;
    border-color: var(--emerald-primary) !important;
}

/* ==========================================================================
   15. COMPOSANTS ET DESIGN DU MODULE RAPPORTS & STATS
   ========================================================================== */

/* Couleur d'arrière-plan adoucie spécifique pour le rouge alerte */
.bg-danger-soft {
    background-color: rgba(239, 68, 68, 0.12) !important;
}

/* Bordures colorées épaisses pour les cartes d'alertes à droite */
.border-danger { border-left-width: 4px !important; }
.border-warning { border-left-width: 4px !important; }
.border-info { border-left-width: 4px !important; }

/* Force la couleur émeraude par défaut sur les barres de progression réussies */
.progress-bar.bg-emerald {
    background-color: var(--emerald-primary) !important;
}

/* ==========================================================================
   16. STYLE POUR LE MODAL AJOUT EN MASSE D'ÉLÈVES DU FICHIER ADDELEVES-GROUP.HTML
   ========================================================================== */
   /* Bordure en pointillés professionnels pour le dépôt de fichier */
.border-dashed {
    border: 2px dashed #cbd5e1 !important;
    transition: all 0.2s ease-in-out;
}

/* Effet au survol de la zone Excel */
.upload-dropzone:hover {
    border-color: var(--emerald-primary) !important;
    background-color: rgba(15, 118, 110, 0.02) !important;
}

/* Animation de rotation pour l'icône de traitement de la BDD */
.animate-spin {
    animation: spin 1.2s linear infinite;
    display: inline-block;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Style de couleur pour le succès adouci */
.bg-success-soft {
    background-color: rgba(34, 197, 94, 0.12) !important;
}

/* Assure que le modal injecté par HTMX se place bien au-dessus de la topbar et sidebar */
.modal {
    z-index: 1055 !important;
}
.modal-backdrop {
    z-index: 1050 !important;
}