:root, [data-bs-theme="light"] {
    --bs-primary: #1c4e80;
    --bs-primary-rgb: 28, 78, 128;
    --bs-body-bg: #f7f8fa;
    --ingridd-primary-dark: #123a5e;
    --ingridd-accent: #f2a03d;
    --ingridd-accent-dark: #d98a26;
    --ingridd-link: #1c4e80;
    --ingridd-surface: #ffffff;
    --ingridd-empty-icon: #d7dee6;
    --ingridd-border: rgba(28, 78, 128, 0.09);
    --ingridd-sidebar-bg: #ffffff;
}

[data-bs-theme="dark"] {
    --bs-primary: #5b9bd5;
    --bs-primary-rgb: 91, 155, 213;
    --bs-body-bg: #141a21;    /* gris-bleu foncé, pas noir pur */
    --bs-body-color: #e6e9ee;
    --ingridd-primary-dark: #0f2e4a;
    --ingridd-accent: #f5b660;
    --ingridd-accent-dark: #d99a3d;
    --ingridd-link: #7fb4e8;
    --ingridd-surface: #1c232c;
    --ingridd-empty-icon: #2a323b;
    --ingridd-border: rgba(255, 255, 255, 0.08);
    --ingridd-sidebar-bg: #1c232c;
}

body {
    background-color: var(--bs-body-bg);
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    transition: background-color .2s ease, color .2s ease;
}

.ingridd-surface { background-color: var(--ingridd-surface) !important; }
a { color: var(--ingridd-link); }

h1, h2, h3, h4, h5, h6, .navbar-brand {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* Titres de page principaux : petit soulignement dégradé bleu/orange pour plus de caractère */
h1.h3 {
    position: relative;
    padding-bottom: .55rem;
    margin-bottom: 1.1rem;
}
h1.h3::after {
    content: '';
    position: absolute;
    left: 0; bottom: 0;
    width: 60px; height: 4px;
    border-radius: 4px;
    background: linear-gradient(90deg, #1c4e80, var(--ingridd-accent));
}

/* ================= NAVBAR SIMPLE (auth, étudiant, profil) ================= */
.ingridd-navbar {
    background: linear-gradient(120deg, #1c4e80 0%, #123a5e 100%);
    box-shadow: 0 2px 12px rgba(18, 58, 94, 0.25);
}
.ingridd-navbar .nav-link { transition: color .15s ease, transform .15s ease; }
.ingridd-navbar .nav-link:hover { color: var(--ingridd-accent) !important; transform: translateY(-1px); }

/* ================= APP SHELL (sidebar + topbar, espace admin) ================= */
.app-shell { display: flex; min-height: 100vh; }

.app-sidebar {
    width: 264px;
    flex-shrink: 0;
    background: var(--ingridd-sidebar-bg);
    border-right: 1px solid var(--ingridd-border);
    display: flex;
    flex-direction: column;
    transition: width .22s ease;
}
@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        overflow: hidden; /* seul .sidebar-nav défile, pas la sidebar entière */
    }
}
.app-sidebar.is-collapsed { width: 82px; }
.app-sidebar.is-collapsed .sidebar-label,
.app-sidebar.is-collapsed .sidebar-group-label,
.app-sidebar.is-collapsed .sidebar-brand-text { display: none !important; }
.app-sidebar.is-collapsed .sidebar-link { justify-content: center; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.25rem 1.1rem;
    border-bottom: 1px solid var(--ingridd-border);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--bs-primary);
}
.sidebar-brand .brand-badge {
    width: 38px; height: 38px; border-radius: 10px;
    background: linear-gradient(135deg, #1c4e80, #123a5e);
    color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: .9rem .7rem; }
.sidebar-group-label {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .06em;
    color: #98a2b3; font-weight: 700; margin: 1.1rem .6rem .4rem;
}
.sidebar-group-label:first-child { margin-top: 0; }

.sidebar-link {
    display: flex; align-items: center; gap: .75rem;
    padding: .58rem .75rem; border-radius: 10px;
    color: #45505f; font-weight: 600; font-size: .92rem;
    text-decoration: none; margin-bottom: .15rem;
    transition: background-color .15s ease, color .15s ease;
    white-space: nowrap;
}
[data-bs-theme="dark"] .sidebar-link { color: #c3ccd6; }
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link:hover { background: rgba(var(--bs-primary-rgb), 0.08); color: var(--bs-primary); }
.sidebar-link.active {
    background: linear-gradient(120deg, #1c4e80, #123a5e);
    color: #fff;
    box-shadow: 0 3px 10px rgba(28, 78, 128, .28);
}

.sidebar-footer { padding: .8rem 1rem; border-top: 1px solid var(--ingridd-border); }
.sidebar-collapse-btn {
    width: 100%; border: none; background: transparent; color: #98a2b3;
    display: flex; align-items: center; justify-content: center; gap: .5rem;
    padding: .5rem; border-radius: 8px; font-size: .85rem;
}
.sidebar-collapse-btn:hover { background: rgba(var(--bs-primary-rgb), 0.08); color: var(--bs-primary); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    background: var(--ingridd-surface);
    border-bottom: 1px solid var(--ingridd-border);
    padding: .65rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .85rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.topbar-search { flex: 1; max-width: 420px; }
.topbar-search .input-group-text { background: var(--bs-body-bg); border-color: var(--ingridd-border); }
.topbar-search input { background: var(--bs-body-bg); border-color: var(--ingridd-border); }

.topbar-icon-btn {
    width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--ingridd-border);
    background: var(--ingridd-surface); color: #45505f;
    display: inline-flex; align-items: center; justify-content: center;
    position: relative; transition: all .15s ease;
}
[data-bs-theme="dark"] .topbar-icon-btn { color: #c3ccd6; }
.topbar-icon-btn:hover { background: rgba(var(--bs-primary-rgb), 0.08); color: var(--bs-primary); }
.topbar-icon-btn .notif-dot {
    position: absolute; top: -3px; right: -3px;
    background: var(--ingridd-accent); color: #fff; font-size: .65rem; font-weight: 700;
    min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
    padding: 0 4px; border: 2px solid var(--ingridd-surface);
}

.app-content { padding: 1.5rem; flex: 1; }

/* ================= Boutons ================= */
.btn { transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(0,0,0,0.10); }
.btn:active { transform: translateY(0); }

.btn-primary { background-color: #1c4e80; border-color: #1c4e80; }
.btn-primary:hover, .btn-primary:focus { background-color: #123a5e; border-color: #123a5e; }

.btn-warning { background-color: var(--ingridd-accent); border-color: var(--ingridd-accent); color: #fff; }
.btn-warning:hover { background-color: var(--ingridd-accent-dark); border-color: var(--ingridd-accent-dark); color: #fff; }

.btn.is-loading { pointer-events: none; opacity: .85; }

/* ================= Cartes ================= */
.card {
    border: 1px solid var(--ingridd-border);
    box-shadow: 0 3px 14px rgba(18, 58, 94, 0.07);
    transition: transform .18s ease, box-shadow .18s ease;
    border-radius: .8rem;
}
[data-bs-theme="dark"] .card { box-shadow: 0 3px 14px rgba(0, 0, 0, 0.35); }
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 26px rgba(18, 58, 94, 0.15); }

.card-cover {
    height: 140px;
    background: linear-gradient(135deg, #1c4e80, #123a5e);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 2.4rem;
    border-radius: .8rem .8rem 0 0;
}
.card-cover-img {
    height: 140px;
    width: 100%;
    object-fit: cover;
    border-radius: .8rem .8rem 0 0;
}

/* Cartes statistiques premium : liseré de couleur en haut */
.stat-card { position: relative; overflow: hidden; }
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, #1c4e80, #123a5e);
}
.stat-card.accent::before { background: linear-gradient(90deg, var(--ingridd-accent), var(--ingridd-accent-dark)); }

.stat-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    background: rgba(var(--bs-primary-rgb), 0.12); color: var(--bs-primary);
}
.stat-card.accent .stat-icon { background: rgba(242, 160, 61, 0.16); color: var(--ingridd-accent-dark); }

/* ================= En-têtes de section ================= */
.section-header {
    display: flex; align-items: center; gap: .65rem;
    margin: 2.1rem 0 1.1rem;
    padding-bottom: .6rem;
    border-bottom: 2px solid rgba(var(--bs-primary-rgb), 0.13);
}
.section-header .icon-chip {
    width: 38px; height: 38px; min-width: 38px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem;
    background: rgba(var(--bs-primary-rgb), 0.14); color: var(--bs-primary);
}
.section-header .icon-chip.accent { background: rgba(242, 160, 61, 0.18); color: var(--ingridd-accent-dark); }
.section-header h2 { margin: 0; font-size: 1.15rem; }
.section-header .subtitle { font-size: .82rem; font-weight: 500; color: #6b7280; margin-left: .25rem; }

.summary-panel {
    background: var(--ingridd-surface);
    border: 1px solid var(--ingridd-border);
    border-radius: .8rem;
    padding: 1.5rem;
    box-shadow: 0 3px 14px rgba(18, 58, 94, 0.07);
    margin-bottom: 2rem;
}

/* ================= Badges ================= */
.badge.bg-livre { background-color: #e8f0f8; color: #1c4e80; }
.badge.bg-memoire { background-color: #fdf1de; color: #a5690f; }
[data-bs-theme="dark"] .badge.bg-livre { background-color: #1c3348; color: #8fc1e8; }
[data-bs-theme="dark"] .badge.bg-memoire { background-color: #3a2c14; color: #f5b660; }

/* ================= Auth (pages sans app-shell) ================= */
.auth-card { max-width: 460px; margin: 3rem auto; animation: fadeInUp .5s ease both; }

.wave { display: inline-block; animation: wave 1.6s ease-in-out 1; transform-origin: 70% 70%; }
@keyframes wave {
    0%, 100% { transform: rotate(0deg); }
    10%, 30% { transform: rotate(14deg); }
    20% { transform: rotate(-8deg); }
    40% { transform: rotate(-4deg); }
    50% { transform: rotate(10deg); }
    60% { transform: rotate(0deg); }
}

/* ================= Animations (légères) ================= */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.fade-in-up { animation: fadeInUp .4s ease both; }
.stagger > * { animation: fadeInUp .4s ease both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .05s; }
.stagger > *:nth-child(3) { animation-delay: .09s; }
.stagger > *:nth-child(4) { animation-delay: .13s; }
.stagger > *:nth-child(5) { animation-delay: .17s; }
.stagger > *:nth-child(6) { animation-delay: .21s; }

/* ================= États vides ================= */
.empty-state { text-align: center; padding: 3rem 1rem; color: #6b7280; }
.empty-state i { font-size: 2.75rem; color: var(--ingridd-empty-icon); margin-bottom: .75rem; display: block; }

/* ================= Tableaux ================= */
.table-responsive {
    border-radius: .7rem;
    overflow-x: auto;
    overflow-y: auto;
    border: 1px solid var(--ingridd-border);
    box-shadow: 0 3px 14px rgba(18, 58, 94, 0.06);
    max-height: 560px;
}

/* Scrollbars personnalisées (horizontale et verticale) */
.table-responsive::-webkit-scrollbar { width: 9px; height: 9px; }
.table-responsive::-webkit-scrollbar-track { background: transparent; }
.table-responsive::-webkit-scrollbar-thumb {
    background-color: rgba(var(--bs-primary-rgb), 0.35);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}
.table-responsive::-webkit-scrollbar-thumb:hover { background-color: rgba(var(--bs-primary-rgb), 0.55); }
.table-responsive { scrollbar-width: thin; scrollbar-color: rgba(28,78,128,0.35) transparent; }

table.table {
    font-size: .865rem;
    margin-bottom: 0;
}
table.table thead th,
table.table thead td {
    position: sticky;
    top: 0;
    z-index: 2;
    background-color: #e8f0f8 !important;
    color: #123a5e !important;
    border: none !important;
    border-bottom: 2px solid rgba(28, 78, 128, 0.15) !important;
    font-weight: 700;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    padding-top: .7rem;
    padding-bottom: .7rem;
}
[data-bs-theme="dark"] table.table thead th,
[data-bs-theme="dark"] table.table thead td {
    background-color: #23344a !important;
    color: #bcd8f2 !important;
    border-bottom-color: rgba(255, 255, 255, 0.12) !important;
}
table.table tbody td { padding-top: .55rem; padding-bottom: .55rem; vertical-align: middle; }
table.table tbody tr { transition: background-color .12s ease; }

/* ================= Bannière compacte (tableau de bord étudiant) ================= */
.banner-compact { border-radius: .8rem; overflow: hidden; box-shadow: 0 3px 14px rgba(18,58,94,0.1); min-height: 130px; }
.banner-compact-wrap { position: relative; height: 100%; }
.banner-compact-link {
    display: flex; align-items: stretch; height: 100%; min-height: 130px;
    text-decoration: none; position: relative;
    background: linear-gradient(120deg, #1c4e80, #123a5e);
}
.banner-compact-img {
    width: 40%; min-width: 100px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(255, 255, 255, 0.06);
}
.banner-compact-body { padding: 1rem 1.2rem; color: #fff; display: flex; flex-direction: column; justify-content: center; }
.banner-compact-body strong { font-size: 1.05rem; }
.banner-compact-arrow { position: absolute; top: 10px; right: 12px; color: rgba(255,255,255,0.85); font-size: 1.2rem; }
.banner-zoom-btn {
    position: absolute;
    bottom: 10px;
    right: 12px;
    z-index: 20;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease;
    text-decoration: none;
}
.banner-zoom-btn:hover { background: rgba(0,0,0,0.7); color: #fff; }

/* ================= Bannières (ancien format plein écran, conservé pour compatibilité) ================= */
.banner-frame {
    background: linear-gradient(135deg, #1c4e80, #123a5e);
    height: 320px; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.banner-frame img {
    max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
    animation: kenburns 9s ease-in-out infinite alternate;
}
@keyframes kenburns { from { transform: scale(1); } to { transform: scale(1.05); } }
.carousel-indicators [data-bs-target] { background-color: var(--ingridd-accent); }

/* ================= Fiche document : bandeau "hero" coloré ================= */
.doc-hero {
    display: flex;
    background: linear-gradient(120deg, #1c4e80 0%, #123a5e 100%);
    border-radius: .9rem;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(18, 58, 94, 0.22);
}
.doc-hero-cover {
    width: 180px;
    min-width: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    font-size: 3.2rem;
    color: rgba(255,255,255,0.85);
}
.doc-hero-cover img { width: 100%; height: 100%; object-fit: cover; }
.doc-hero-body { padding: 1.5rem; flex: 1; }

.doc-chip {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.15);
    color: #fff;
    padding: .3rem .7rem;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
}
.doc-chip-light {
    background: rgba(var(--bs-primary-rgb), 0.08);
    color: #1c4e80;
}
[data-bs-theme="dark"] .doc-chip-light { background: rgba(255,255,255,0.08); color: #e6e9ee; }

.info-pill {
    display: flex;
    align-items: center;
    gap: .7rem;
    background: var(--ingridd-surface);
    border: 1px solid var(--ingridd-border);
    border-radius: .7rem;
    padding: .8rem 1rem;
    height: 100%;
}
.info-pill i { font-size: 1.3rem; }
.info-pill .label { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: #98a2b3; }
.info-pill .value { display: block; font-weight: 700; }

@media (max-width: 575.98px) {
    .doc-hero { flex-direction: column; }
    .doc-hero-cover { width: 100%; height: 140px; }
}
@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; z-index: 1045; height: 100vh; }
}

/* ================= Autocomplétion recherche documents ================= */
.autocomplete-liste {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1030;
    background: var(--ingridd-surface);
    border: 1px solid var(--ingridd-border);
    border-radius: .6rem;
    box-shadow: 0 8px 20px rgba(18, 58, 94, 0.15);
    margin-top: .3rem;
    max-height: 320px;
    overflow-y: auto;
}
.autocomplete-item {
    display: flex;
    align-items: center;
    padding: .6rem .9rem;
    text-decoration: none;
    color: inherit;
    font-size: .9rem;
    border-bottom: 1px solid var(--ingridd-border);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: rgba(var(--bs-primary-rgb), 0.07); }

/* ================= Pied de page (pages de connexion/inscription/accueil) ================= */
footer.text-muted {
    background: linear-gradient(120deg, #1c4e80 0%, #123a5e 100%) !important;
    color: rgba(255, 255, 255, 0.85) !important;
    margin-top: auto; /* garantit qu'il reste collé en bas même si le contenu de la page est court */
}

/* ================= Cartes "Nos filières" (page d'accueil) ================= */
.filiere-card {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #1c4e80 0%, #123a5e 100%);
    border: none;
    color: #fff;
    transition: transform .25s ease, box-shadow .25s ease;
    box-shadow: 0 6px 18px rgba(18, 58, 94, 0.18);
}

/* Le cercle orange décoratif, ancré en haut à droite, qui déborde légèrement du cadre */
.filiere-card::after {
    content: '';
    position: absolute;
    top: -34px;
    right: -34px;
    width: 100px;
    height: 100px;
    background: var(--ingridd-accent);
    border-radius: 50%;
    opacity: 0.9;
    transition: transform .35s ease, opacity .35s ease;
    z-index: 1;
}

.filiere-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 16px 32px rgba(18, 58, 94, 0.32);
}
.filiere-card:hover::after {
    transform: scale(1.2) rotate(15deg);
}

/* Le contenu (icône + texte) passe au-dessus du cercle décoratif */
.filiere-card .card-body { position: relative; z-index: 2; }

.filiere-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 1.4rem;
    transition: transform .25s ease;
}
.filiere-card:hover .filiere-card-icon {
    transform: scale(1.1) rotate(-6deg);
}

/* ================= Badges de comptage dans la sidebar (Étudiants, Suggestions...) ================= */
.sidebar-badge {
    margin-left: auto;
    background: var(--ingridd-accent);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    flex-shrink: 0;
}
.sidebar-link.active .sidebar-badge {
    background: rgba(255, 255, 255, 0.9);
    color: var(--bs-primary);
}

/* Sidebar réduite (icônes seules) : le badge devient un petit point en coin plutôt qu'un chiffre en bout de ligne */
.app-sidebar.is-collapsed .sidebar-link { position: relative; }
.app-sidebar.is-collapsed .sidebar-badge {
    position: absolute;
    top: 6px;
    right: 10px;
    margin-left: 0;
    min-width: 16px;
    height: 16px;
    font-size: .62rem;
    padding: 0 4px;
}
