 /* ==========================================================================
   1. VARIABLES SYSTEM & RESET
    ========================================================================== */
:root {
    /* Palette colors */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --secondary-hover: #475569;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    
    /* Backgrounds & Text */
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-sidebar-hover: #1e293b;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-sidebar: #94a3b8;
    --text-sidebar-active: #ffffff;
    
    /* UI Structure */
    --border-color: #e2e8f0;
    --radius: 10px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    
    /* Animations */
    --transition-speed: 0.3s;
    --transition-curve: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

/* ==========================================================================
   2. MAIN LAYOUT CONTAINER
   ========================================================================== */
.app-layout {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* ==========================================================================
   3. SIDEBAR NAVIGATION
   ========================================================================== */
.sidebar {
    width: 180px;
    background-color: var(--bg-sidebar);
    color: var(--text-sidebar-active);
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-speed) var(--transition-curve),
                box-shadow var(--transition-speed) var(--transition-curve);
    position: relative;
    z-index: 100;
    overflow-x: hidden;
    white-space: nowrap;
    flex-shrink: 0;
}

.sidebar__toggle {
    display: none; /* Afenina amin'ny ordinateur desktop large */
    background: transparent;
    border: none;
    color: var(--text-sidebar);
    font-size: 1.4rem;
    cursor: pointer;
    margin-bottom: 12px;
    padding: 6px;
    border-radius: 6px;
    align-self: flex-start;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar__toggle:hover {
    color: var(--text-sidebar-active);
    background-color: var(--bg-sidebar-hover);
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.sidebar__divider {
    height: 1px;
    background-color: #334155;
    margin: 16px 0;
    transition: opacity var(--transition-speed);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 2px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
}

.nav-link:hover {
    background-color: var(--bg-sidebar-hover);
    color: var(--text-sidebar-active);
}

.nav-link--active {
    background-color: var(--primary-color);
    color: var(--text-sidebar-active);
}

.nav-link--active:hover {
    background-color: var(--primary-hover);
}

.nav-link--danger {
    color: #fca5a5;
}

.nav-link--danger:hover {
    background-color: #450a0a;
    color: #f87171;
}

.nav-link__icon {
    font-size: 1.2rem;
    min-width: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-link__text {
    transition: opacity var(--transition-speed);
}

.sidebar__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.sidebar__actions form {
    width: 100%;
}

/* ==========================================================================
   4. MAIN CONTENT AREA
   ========================================================================== */
.main-content {
    flex: 1;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    min-width: 0; /* Misoroka overflow amin'ny Flexbox child */
}

.main-content__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.main-content__title {
    font-size: 1.6rem;
    color: #0f172a;
    font-weight: 700;
}

/* ==========================================================================
   9. RESPONSIVE DESIGN & SIDEBAR REDUCTION
   ========================================================================== */

/* Tablet and Mobile Breakpoint (<= 1024px) */
@media (max-width: 1024px) {
    /* 1. Reduce Sidebar width */
    .sidebar {
        width: 70px;
        padding: 16px 10px;
    }

    /* 2. Show Hamburger Button */
    .sidebar__toggle {
        display: block;
    }

    /* 3. Hide Text elements in Sidebar */
    .nav-link__text,
    .btn__text,
    .sidebar__divider {
        opacity: 0;
        visibility: hidden;
        white-space: nowrap;
    }

    .sidebar__actions .btn {
        padding: 10px;
        justify-content: center;
    }

    /* 4. Expand Sidebar on Hover OR when active class added via JS */
    .sidebar:hover,
    .sidebar.sidebar--expanded {
        width: 260px;
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.25);
    }

    .sidebar:hover .nav-link__text,
    .sidebar:hover .btn__text,
    .sidebar:hover .sidebar__divider,
    .sidebar.sidebar--expanded .nav-link__text,
    .sidebar.sidebar--expanded .btn__text,
    .sidebar.sidebar--expanded .sidebar__divider {
        opacity: 1;
        visibility: visible;
    }
}

/* Mobile Breakpoint (<= 640px) */
@media (max-width: 640px) {
    .main-content {
        padding: 16px;
    }
}


    /* ================================ SUPPRESSION ============================================================ */
    /* Modal Overlay sy Card Suppression */
    .delete-modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(15, 23, 42, 0.7);
        backdrop-filter: blur(4px);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 99999;
        animation: fadeIn 0.2s ease-out;
    }

    .delete-modal-card {
        background: #ffffff;
        border-radius: 14px;
        width: 90%;
        max-width: 420px;
        padding: 24px;
        box-shadow: 0 20px 25px -5px rgba(220, 38, 38, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
        font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        border-top: 5px solid #dc2626; /* Tsipika mena eo ambony */
        animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .delete-modal-header {
        text-align: center;
        margin-bottom: 14px;
    }

    .delete-modal-header .delete-icon {
        font-size: 2.5rem;
        margin-bottom: 6px;
    }

    .delete-modal-header h3 {
        margin: 0;
        color: #991b1b;
        font-size: 1.25rem;
        font-weight: 700;
    }

    .delete-modal-body p {
        color: #475569;
        font-size: 0.92rem;
        text-align: center;
        margin: 0 0 16px 0;
        line-height: 1.4;
    }

    .delete-badge-box {
        text-align: center;
        margin-bottom: 20px;
    }

    .delete-badge-nom {
        display: inline-block;
        background-color: #fee2e2;
        color: #991b1b;
        border: 1px solid #fca5a5;
        padding: 6px 16px;
        border-radius: 20px;
        font-weight: 700;
        font-size: 1.05rem;
    }

    .delete-modal-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .btn-delete-submit {
        width: 100%;
        padding: 12px;
        background-color: #dc2626; /* Bouton mena */
        color: #ffffff;
        border: none;
        border-radius: 8px;
        font-weight: 700;
        font-size: 0.95rem;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .btn-delete-submit:hover {
        background-color: #b91c1c;
    }

    .btn-delete-cancel {
        display: block;
        text-align: center;
        width: 100%;
        padding: 10px;
        background-color: transparent;
        color: #64748b;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        font-weight: 600;
        font-size: 0.9rem;
        text-decoration: none;
        box-sizing: border-box;
        transition: all 0.2s;
    }

    .btn-delete-cancel:hover {
        background-color: #f1f5f9;
        color: #0f172a;
    }

    /* ====================== MODIFICATION =============================================================== */
    /* Overlay sy Card Modal Modification */
    .edit-modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(15, 23, 42, 0.65);
        backdrop-filter: blur(4px);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 99999;
        animation: fadeIn 0.2s ease-out;
    }

    .edit-modal-card {
        background: #ffffff;
        border-radius: 14px;
        width: 90%;
        max-width: 460px;
        padding: 24px;
        box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
        font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        animation: scaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .edit-modal-header {
        text-align: center;
        margin-bottom: 20px;
    }

    .edit-modal-header .edit-icon {
        font-size: 2.2rem;
        margin-bottom: 6px;
    }

    .edit-modal-header h3 {
        margin: 0;
        color: #0f172a;
        font-size: 1.25rem;
        font-weight: 700;
    }

    .form-group-modal {
        display: flex;
        flex-direction: column;
        gap: 6px;
        margin-bottom: 16px;
    }

    .form-group-modal label {
        font-size: 0.88rem;
        font-weight: 600;
        color: #475569;
    }

    .form-control-modal, .form-control-readonly {
        width: 100%;
        padding: 10px 12px;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        font-size: 0.95rem;
        box-sizing: border-box;
    }

    .form-control-readonly {
        background-color: #f1f5f9;
        color: #64748b;
        font-weight: 700;
        cursor: not-allowed;
    }

    .form-control-modal:focus {
        outline: none;
        border-color: #2563eb;
        box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    }

    .edit-modal-actions {
        display: flex;
        gap: 10px;
        margin-top: 22px;
    }

    .btn-edit-submit {
        flex: 1;
        padding: 11px;
        background-color: #2563eb;
        color: #ffffff;
        border: none;
        border-radius: 8px;
        font-weight: 700;
        font-size: 0.95rem;
        cursor: pointer;
        transition: background-color 0.2s;
    }

    .btn-edit-submit:hover {
        background-color: #1d4ed8;
    }

    .btn-edit-cancel {
        flex: 1;
        display: block;
        text-align: center;
        padding: 11px;
        background-color: #f1f5f9;
        color: #475569;
        border: 1px solid #cbd5e1;
        border-radius: 8px;
        font-weight: 600;
        font-size: 0.95rem;
        text-decoration: none;
        box-sizing: border-box;
        transition: all 0.2s;
    }

    .btn-edit-cancel:hover {
        background-color: #e2e8f0;
        color: #0f172a;
    }

    /* =========================================
       ENDRIKY NY ROHY (LE LIEN)
       ========================================= */
    .lien-numero {
        position: relative;
        display: inline-block;
        text-decoration: none;
        color: #475569; 
        background-color: #f1f5f9; 
        font-weight: 600;
        padding: 6px 14px;
        border-radius: 20px; 
        border: 1px solid #e2e8f0;
        transition: background-color 0.1s, color 0.1s, transform 0.1s; 
        font-size: 14px;
    }

    /* Rehefa andalovan'ny totozy (Hover) */
    .lien-numero:hover {
        color: #ffffff;
        background-color: #3b82f6; 
        border-color: #3b82f6;
        transform: translateY(-2px); 
        box-shadow: 0 4px 10px rgba(59, 130, 246, 0.4); 
    }

    /* =========================================
       ILAY SORATRA MIPOITRA (TOOLTIP) - Ao havanana
       ========================================= */
    .lien-numero::after {
        content: attr(data-tooltip);
        position: absolute;
        /* Fametrahana azy ao amin'ny sisiny havanana */
        top: 50%; 
        left: calc(100% + 10px); /* 10px miala ny sisiny ankavanana */
        transform: translateY(-50%); /* Apetraka afovoany tsara manaraka ny halavany (vertical) */
        
        background-color: #1e293b; 
        color: #ffffff;
        padding: 6px 12px;
        border-radius: 6px;
        font-size: 12px;
        font-weight: 500;
        white-space: nowrap;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
        z-index: 10;
        
        /* Afenina aloha */
        display: none; 
    }

    /* =========================================
       ILAY TELOZORO MANONDRO (LA FLÈCHE) - Mitodika miankavia
       ========================================= */
    .lien-numero::before {
        content: "";
        position: absolute;
        /* Fametrahana ny flèche eo anelanelan'ny rohy sy ny soratra */
        top: 50%;
        left: calc(100% + 4px); /* Apetaka kely eo ankavanan'ny rohy */
        transform: translateY(-50%);
        
        border-width: 6px;
        border-style: solid;
        /* Avadika ny flèche mba hanondro ny rohy (mitsivalana fa tsy mitsangana) */
        border-color: transparent #1e293b transparent transparent; 
        z-index: 10;
        
        /* Afenina aloha */
        display: none; 
    }

    /* =========================================
       FAMPIPOITRANA AZY REHEFA HOVER (Directement)
       ========================================= */
    .lien-numero:hover::after,
    .lien-numero:hover::before {
        display: block; /* Mipoitra eo ankavanana avy hatrany */
    }

    /* ======================================================================================== */

    /* ==========================================
       STYLE HO AN'NY TABILAO RESULTAT (COLONNE 1 STICKY IHANY)
       ========================================== */

    /* 1. Trano (Container) ho an'ny scrollbar */
    .bulletin-grid__table {
        width: 100%;
        max-height: 75vh;
        overflow: auto;
        border: 1px solid #e2e8f0;
        border-radius: 8px;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    }

    /* Container manome ny scrollbar raha lehibe noho ny écran ny tabilao */
    .bulletin-grid__table {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Mampalefaka ny scroll amin'ny mobile (iOS) */
    }

    /* Sakanana tsy hitambatra na hivalona ny soratra anaty tabilao */
    .bulletin-grid__table table {
        width: 100%;
        border-collapse: collapse;
        white-space: nowrap; /* Tsy mampitambatra ny soratra */
    }

    /* Ampiana padding kely ny th sy td mba hahatsara ny fisehoany */
    .bulletin-grid__table th,
    .bulletin-grid__table td {
        padding: 8
        2px 2px;
    }

    /* 2. Endrika fototry ny Tabilao */
    table.table-resultat {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        font-size: 0.85rem;
        color: #1e293b;
        background-color: #ffffff;
    }

    /* 3. Cellules rehetra (th & td) */
    table.table-resultat th,
    table.table-resultat td {
        padding: 10px 14px;
        white-space: nowrap;
        border-bottom: 1px solid #e2e8f0;
        border-right: 1px solid #e2e8f0;
    }

    /* 4. Sticky Top Header (thead) */
    table.table-resultat thead th {
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: #0f172a;
        color: #ffffff;
        font-weight: 600;
        text-align: center;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    /* 5. Sticky Column 1 IHANY (N°) */
    table.table-resultat th:first-child,
    table.table-resultat td:first-child {
        position: sticky;
        left: 0;
        z-index: 20;
        width: 60px;
        min-width: 60px;
        text-align: center;
        box-shadow: 3px 0 5px -2px rgba(0, 0, 0, 0.12); /* Aloka miankavanana eo amin'ny col 1 */
    }

    /* Loko ho an'ny tsanganana 1 ao amin'ny body */
    table.table-resultat tbody td:first-child {
        background-color: #f8fafc;
        font-weight: 600;
    }

    /* 6. Corner Sticky (Zoro ambony ankavia: Header Col 1) */
    table.table-resultat thead th:first-child {
        z-index: 30; /* Z-Index ambony indrindra */
        background-color: #0f172a;
    }

    /* 7. Effets Hover sy Click */
    table.table-resultat tbody tr:hover td {
        background-color: #e2e8f0;
        cursor: pointer;
    }

    table.table-resultat tbody tr:active td {
        background-color: #cbd5e1;
    }

    /* 8. Utility classes */
    table.table-resultat td.centre,
    table.table-resultat th.centre {
        text-align: center;
    }

    table.table-resultat td.nom,
    table.table-resultat th.nom {
        text-align: left;
    }


    /* ================================================================================================================== */