/* ============================================================
   app.css — CourseHub Design System
   ============================================================ */

/* --- Reset & Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* Colors */
    --c-indigo-50:  #eef2ff; --c-indigo-100: #e0e7ff;
    --c-indigo-500: #6366f1; --c-indigo-600: #4f46e5;
    --c-indigo-700: #4338ca; --c-indigo-900: #1e1b4b;

    --c-slate-50:  #f8fafc; --c-slate-100: #f1f5f9;
    --c-slate-200: #e2e8f0; --c-slate-300: #cbd5e1;
    --c-slate-400: #94a3b8; --c-slate-500: #64748b;
    --c-slate-600: #475569; --c-slate-700: #334155;
    --c-slate-800: #1e293b; --c-slate-900: #0f172a;

    --c-green-50:  #f0fdf4; --c-green-500: #22c55e; --c-green-700: #15803d;
    --c-red-50:    #fef2f2; --c-red-500:   #ef4444; --c-red-700:   #b91c1c;
    --c-amber-50:  #fffbeb; --c-amber-400: #fbbf24; --c-amber-700: #b45309;
    --c-teal-50:   #f0fdfa; --c-teal-500:  #14b8a6; --c-teal-700:  #0f766e;
    --c-purple-50: #faf5ff; --c-purple-500:#a855f7; --c-purple-700:#7e22ce;

    /* Semantic */
    --bg:         #f8fafc;
    --surface:    #ffffff;
    --surface-2:  #f1f5f9;
    --surface-3:  #f598d2;
    --border:     #e2e8f0;
    --border-2:   #cbd5e1;
    --text:       #0f172a;
    --text-2:     #475569;
    --text-3:     #94a3b8;
    --primary:    #4f46e5;
    --primary-h:  #4338ca;
    --primary-fg: #ffffff;

    /* Layout */
    --sidebar-w:  240px;
    --header-h:   60px;
    --radius:     8px;
    --radius-lg:  12px;
    --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
    --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);

    /* Typography */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

html { font-size: 16px; }
body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; }
button { font-family: inherit; cursor: pointer; }
ul, ol { list-style: none; }

/* --- Layout Auth ------------------------------------------ */
.layout-auth {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--c-indigo-50) 0%, var(--c-slate-100) 100%);
    padding: 1.5rem;
}

.auth-wrapper {
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: .5rem;
}

.auth-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: 2rem;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: .25rem;
}
.auth-subtitle { color: var(--text-2); margin-bottom: 1.75rem; font-size: .9rem; }

.auth-form { display: flex; flex-direction: column; gap: 1.1rem; }

/* --- Layout Main ------------------------------------------ */
.layout-main { display: flex; flex-direction: column; min-height: 100vh; }

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    height: 100%;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.logo {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
}
.logo:hover { text-decoration: none; }

.header-search {
    flex: 1;
    max-width: 500px;
    display: flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 99px;
    overflow: hidden;
    transition: border-color .15s, box-shadow .15s;
}
.header-search:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.header-search input {
    flex: 1;
    border: none;
    background: transparent;
    padding: .45rem 1rem;
    font-size: .9rem;
    color: var(--text);
    outline: none;
}
.header-search button {
    background: none;
    border: none;
    padding: .45rem .9rem;
    color: var(--text-3);
    display: flex;
    align-items: center;
}
.header-search button:hover { color: var(--primary); }

.header-actions { display: flex; align-items: center; gap: .75rem; margin-left: auto; }

.notif-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    color: var(--text-2);
    transition: background .15s, color .15s;
}
.notif-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.notif-btn .badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--c-red-500);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    border-radius: 99px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.balance-pill {
    background: var(--c-indigo-50);
    color: var(--c-indigo-700);
    border: 1px solid var(--c-indigo-100);
    border-radius: 99px;
    padding: .25rem .75rem;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}

/* User menu dropdown */
.user-menu { position: relative; }
.user-btn {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .35rem .6rem;
    font-size: .875rem;
    color: var(--text);
    transition: background .15s, border-color .15s;
}
.user-btn:hover { background: var(--surface-2); border-color: var(--border-2); }
.avatar {
    width: 28px;
    height: 28px;
    border-radius: 99px;
    background: var(--primary);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    z-index: 200;
    overflow: hidden;
}
.dropdown.open { display: block; }
.dropdown li a,
.dropdown li button.dropdown-logout {
    display: block;
    width: 100%;
    padding: .55rem 1rem;
    font-size: .875rem;
    color: var(--text-2);
    background: none;
    border: none;
    text-align: left;
    transition: background .1s, color .1s;
}
.dropdown li a:hover,
.dropdown li button.dropdown-logout:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.dropdown-header {
    padding: .75rem 1rem .5rem;
    border-bottom: 1px solid var(--border);
}
.dropdown-header strong { display: block; font-size: .875rem; }
.dropdown-header small { color: var(--text-3); font-size: .78rem; }
.dropdown-sep { height: 1px; background: var(--border); margin: .25rem 0; }

/* Page wrapper */
.page-wrapper {
    display: flex;
    flex: 1;
    max-width: 1700px;
    margin: 0 auto;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    overflow-y: auto;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
}
.sidebar-nav { padding: 0 .75rem; }
.nav-section { display: flex; flex-direction: column; gap: 2px; margin-bottom: .5rem; }
.nav-label {
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    padding: .75rem .75rem .25rem;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .5rem .75rem;
    border-radius: var(--radius);
    font-size: .875rem;
    color: var(--text-2);
    transition: background .12s, color .12s;
    text-decoration: none;
}
.nav-link svg { flex-shrink: 0; opacity: .7; }
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link:hover svg { opacity: 1; }
.nav-link.active {
    background: var(--c-indigo-50);
    color: var(--c-indigo-600);
    font-weight: 500;
}
.nav-link.active svg { opacity: 1; }

/* Main content */
.main-content {
    flex: 1;
    padding: 1.75rem 2rem;
    min-width: 0;    
    background-image: url("./hand-drawn-1000x667.jpg");
}

/* --- Components ------------------------------------------- */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 3px solid rgba(79,70,229,.4); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }

.btn-outline { background: transparent; border-color: var(--border-2); color: var(--text-2); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--border-2); color: var(--text); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--c-red-500); color: #fff; border-color: var(--c-red-500); }
.btn-danger:hover { background: var(--c-red-700); }

.btn-success { background: var(--c-green-500); color: #fff; border-color: var(--c-green-500); }
.btn-success:hover { background: var(--c-green-700); }

.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* Forms */
.form-group { display: flex; flex-direction: column; gap: .4rem; }
.form-group label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--text);
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: .6rem .85rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-group input::placeholder { color: var(--text-3); }
.form-group textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: .78rem; color: var(--text-3); margin-top: .2rem; }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 2.5rem; }
.toggle-password {
    position: absolute;
    right: .65rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-3);
    padding: 0;
    display: flex;
    align-items: center;
}
.toggle-password:hover { color: var(--text-2); }

.panel {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .85rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}


/* Alerts */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .85rem 1rem;
    border-radius: var(--radius);
    font-size: .875rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
}
.alert-success { background: var(--c-green-50); color: var(--c-green-700); border-color: #bbf7d0; }
.alert-error   { background: var(--c-red-50);   color: var(--c-red-700);   border-color: #fecaca; }
.alert-info    { background: var(--c-indigo-50); color: var(--c-indigo-700); border-color: var(--c-indigo-100); }
.alert-warning { background: var(--c-amber-50); color: var(--c-amber-700); border-color: #fde68a; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* Page header */
.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.6rem; font-weight: 700; margin-bottom: .25rem; }
.text-muted { color: var(--text-2); font-size: .9rem; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}
.stat-card--wide { grid-column: span 2; }
.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon--indigo { background: var(--c-indigo-50); color: var(--c-indigo-600); }
.stat-icon--teal   { background: var(--c-teal-50);   color: var(--c-teal-700); }
.stat-icon--green  { background: var(--c-green-50);  color: var(--c-green-700); }
.stat-icon--amber  { background: var(--c-amber-50);  color: var(--c-amber-700); }
.stat-icon--purple { background: var(--c-purple-50); color: var(--c-purple-700); }
.stat-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: .78rem; color: var(--text-2); margin-top: .15rem; }

/* Dash grid */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }

/* Notifications list */
.notif-list { display: flex; flex-direction: column; gap: .75rem; }
.notif-item { display: flex; gap: .75rem; align-items: flex-start; }
.notif-dot {
    width: 8px; height: 8px;
    border-radius: 99px;
    background: var(--border-2);
    flex-shrink: 0;
    margin-top: .45rem;
}
.notif-unread .notif-dot { background: var(--primary); }
.notif-text p { font-size: .875rem; color: var(--text); margin-bottom: .15rem; }
.notif-text time { font-size: .75rem; color: var(--text-3); }

/* Transactions list */
.tx-list { display: flex; flex-direction: column; gap: .65rem; }
.tx-item { display: flex; align-items: center; gap: .75rem; }
.tx-type {
    width: 32px; height: 32px;
    border-radius: 99px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .9rem;
    flex-shrink: 0;
}
.tx-type--credit { background: var(--c-green-50); color: var(--c-green-700); }
.tx-type--debit  { background: var(--c-red-50);   color: var(--c-red-700); }
.tx-body { flex: 1; min-width: 0; }
.tx-body p { font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-body time { font-size: .75rem; color: var(--text-3); }
.tx-amount { font-size: .875rem; font-weight: 600; white-space: nowrap; }
.tx-amount--credit { color: var(--c-green-700); }
.tx-amount--debit  { color: var(--c-red-700); }

/* Quick links */
.quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}
.quick-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .75rem;
    color: var(--text-2);
    font-size: .875rem;
    font-weight: 500;
    transition: border-color .15s, box-shadow .15s, color .15s;
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}
.quick-card svg { color: var(--primary); }
.quick-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    color: var(--text);
    text-decoration: none;
}

/* Tables */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}
th {
    text-align: left;
    font-weight: 600;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--text-2);
    padding: .6rem 1rem;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}
td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

.badge {
    display: block;
    width:100%;
    padding: .25rem .6rem;
    border-radius: var(--radius);
    font-size: .75rem;
    font-weight: 600;
}

.badge-primary {
    background: var(--surface);
    color: var(--text);
}
.badge-secondary {
    background: var(--surface-2);
    color: var(--text-2);
}

.badge-teriary {
    background: var(--surface-3);
    color: var(--text-2);
}

/* Badges / Pills */
.badge-pill {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 99px;
    font-size: .75rem;
    font-weight: 600;
}
.badge-pending  { background: var(--c-amber-50); color: var(--c-amber-700); }
.badge-approved { background: var(--c-green-50); color: var(--c-green-700); }
.badge-rejected { background: var(--c-red-50);   color: var(--c-red-700); }
.badge-admin    { background: var(--c-purple-50); color: var(--c-purple-700); }
.badge-manager  { background: var(--c-indigo-50); color: var(--c-indigo-700); }
.badge-teacher  { background: var(--c-teal-50);   color: var(--c-teal-700); }
.badge-student  { background: var(--c-slate-100); color: var(--c-slate-700); }

/* Grades utilisateurs (assignation automatique + Ambassadeur manuel) */
.badge-grade-nouveau_membre        { background: var(--c-slate-100); color: var(--c-slate-700); }
.badge-grade-contributeur          { background: var(--c-teal-50);   color: var(--c-teal-700); }
.badge-grade-contributeur_actif    { background: var(--c-indigo-50); color: var(--c-indigo-700); }
.badge-grade-meilleur_contributeur { background: var(--c-amber-50);  color: var(--c-amber-700); }
.badge-grade-ambassadeur_univgate  { background: var(--c-purple-50); color: var(--c-purple-700); font-weight: 700; }

/* Pagination */
.pagination ul { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: 1.25rem; }
.pagination a {
    display: flex; align-items: center; justify-content: center;
    min-width: 36px; height: 36px;
    padding: 0 .5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .85rem;
    color: var(--text-2);
    transition: background .12s, border-color .12s;
    text-decoration: none;
}
.pagination a:hover { background: var(--surface-2); border-color: var(--border-2); }
.pagination a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}
.pagination span { display: flex; align-items: center; padding: 0 .3rem; color: var(--text-3); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-3);
    font-size: .9rem;
}

/* Skeleton loader */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: skeleton-wave 1.4s infinite;
    border-radius: var(--radius);
}
@keyframes skeleton-wave {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   Bouton hamburger (visible sur mobile + tablette)
   ============================================================ */
.sidebar-toggle {
    display: none;                  /* caché sur desktop */
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.sidebar-toggle:hover {
    background: var(--surface-2);
    color: var(--text);
}
.sidebar-toggle[aria-expanded="true"] {
    background: var(--c-indigo-50);
    color: var(--primary);
}

/* Overlay sombre derrière le menu (mobile/tablette) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    z-index: 199;
    opacity: 0;
    transition: opacity .25s;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ============================================================
   Responsive — Tablette (≤ 1024px) + Mobile (≤ 768px)
   ============================================================ */
@media (max-width: 1024px) {

    /* Affiche le bouton hamburger */
    .sidebar-toggle { display: flex; }

    /* Sidebar en drawer (hors écran à gauche par défaut) */
    .sidebar {
        position: fixed;
        top: var(--header-h);
        left: 0;
        height: calc(100vh - var(--header-h));
        z-index: 200;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(.4, 0, .2, 1),
                    box-shadow .28s;
        box-shadow: none;
        /* Garde la largeur desktop */
        width: var(--sidebar-w);
    }

    /* Sidebar ouverte */
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, .18);
    }

    /* Le contenu principal prend toute la largeur */
    .page-wrapper {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    .main-content  { padding: 1rem; }
    .stat-card--wide { grid-column: span 1; }
    /*.header-search { display: none; }*/
    .user-name     { display: none; }
    .balance-pill  { font-size: .78rem; padding: .2rem .5rem; }
}

/* ============================================================
   Admin-specific styles (Phase 6)
   ============================================================ */

/* Admin badge sur le header si rôle=admin */
.role-badge-admin {
    background: var(--c-purple-50);
    color: var(--c-purple-700);
    border: 1px solid var(--c-purple-100);
    border-radius: 99px;
    padding: .15rem .55rem;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* Progress bar pour les stats (top cours) */
.progress-bar-wrap {
    height: 6px;
    background: var(--surface-2);
    border-radius: 99px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: var(--c-indigo-500);
    border-radius: 99px;
    transition: width .4s ease;
}

/* Settings form groups */
.settings-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.settings-group .form-group input {
    max-width: 380px;
}

/* Type cards (course types) */
.type-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}
.type-card:hover {
    border-color: var(--border-2);
    box-shadow: var(--shadow);
}

/* Section type list */
.section-type-item {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1.25rem;
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}
.section-type-item:last-child { border-bottom: none; }
.section-type-item:hover { background: var(--surface-2); }

/* Checkbox toggle group (sections par défaut) */
.checkbox-tag {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .35rem .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: .85rem;
    transition: background .1s, border-color .1s, color .1s;
    user-select: none;
}
.checkbox-tag:hover {
    border-color: var(--c-indigo-300);
    background: var(--c-indigo-50);
}
.checkbox-tag input { width: 14px; height: 14px; }
.checkbox-tag.checked {
    background: var(--c-indigo-50);
    border-color: var(--c-indigo-300);
    color: var(--c-indigo-700);
    font-weight: 500;
}

/* Activity chart placeholder */
.activity-bar {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 60px;
}
.activity-bar__col {
    flex: 1;
    background: var(--c-indigo-100);
    border-radius: 3px 3px 0 0;
    transition: background .2s;
    min-height: 4px;
}
.activity-bar__col:hover { background: var(--c-indigo-400); }

/* Info tooltip */
.info-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 99px;
    background: var(--surface-2);
    color: var(--text-3);
    font-size: .72rem;
    font-weight: 700;
    cursor: help;
    border: 1px solid var(--border);
}

/* Admin nav highlight */
.nav-label-admin {
    color: var(--c-purple-600);
    font-weight: 700;
}

/* Table actions column */
td .btn + form, td form + .btn, td form + form {
    margin-left: .3rem;
}

/* Modal overlay scroll fix */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
}
.modal-box {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,.2);
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Danger zone card */
.danger-zone {
    border: 1px solid var(--c-red-500);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    background: var(--c-red-50);
}
.danger-zone h3 {
    color: var(--c-red-700);
    font-size: .95rem;
    margin-bottom: .5rem;
}
.danger-zone p {
    font-size: .875rem;
    color: var(--c-red-700);
    margin-bottom: .75rem;
}

/* ---- Bouton favori dans l'arbre de catégories ---- */
.cat-tree__fav-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    margin-left: auto;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: var(--radius);
    opacity: .4;
    transition: opacity .15s, background .15s;
    flex-shrink: 0;
}
/* Affiche le bouton au survol de la ligne ou s'il est déjà favori */
.cat-tree__row:hover .cat-tree__fav-btn,
.cat-tree__fav-btn.is-fav {
    display: flex;
    opacity: 1;
}
.cat-tree__fav-btn:hover {
    background: var(--c-red-50);
    opacity: 1;
}
.cat-tree__fav-btn.is-fav {
    opacity: 1;
}

/* ============================================================
   Avis (aimer / éviter) et signalement d'une ressource
   ============================================================ */
.res-feedback {
    display: inline-flex;
    align-items: center;
    gap: .15rem;
    margin-left: .5rem;
    flex-shrink: 0;
}
.res-feedback__btn {
    display: inline-flex;
    align-items: center;
    gap: .2rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: .3rem .4rem;
    border-radius: var(--radius);
    color: var(--text-3);
    font-size: .78rem;
    line-height: 1;
    transition: background .15s, color .15s, transform .1s;
}
.res-feedback__btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.res-feedback__btn:hover { background: var(--surface-2); color: var(--text); }
.res-feedback__btn:active { transform: scale(.92); }
.res-feedback__btn[disabled] { opacity: .5; cursor: not-allowed; }

.res-feedback__btn--like.is-active {
    color: var(--c-green-700);
    background: var(--c-green-50);
}
.res-feedback__btn--avoid.is-active {
    color: var(--c-red-700);
    background: var(--c-red-50);
}
.res-feedback__btn--report {
    color: var(--text-3);
}
.res-feedback__btn--report:hover {
    color: var(--c-amber-700);
    background: var(--c-amber-50);
}
.res-feedback__btn--report.is-reported {
    color: var(--c-amber-700);
}
.res-feedback__count {
    min-width: 1ch;
    font-variant-numeric: tabular-nums;
}

/* Modal de signalement */
.report-modal .modal-box {
    max-width: 440px;
    width: 92vw;
    padding: 1.25rem 1.4rem 1.4rem;
}
.report-modal h3 {
    margin: 0 0 .25rem;
    font-size: 1.05rem;
}
.report-modal p.muted {
    margin: 0 0 1rem;
    color: var(--text-3);
    font-size: .85rem;
}
.report-modal .reason-option {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    padding: .55rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: .45rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.report-modal .reason-option:hover {
    border-color: #f5c56b;
    background: var(--c-amber-50);
}
.report-modal .reason-option input[type="radio"] {
    margin-top: .2rem;
}
.report-modal .reason-option span {
    font-size: .88rem;
}
.report-modal textarea {
    width: 100%;
    min-height: 70px;
    resize: vertical;
    margin-top: .5rem;
    padding: .5rem .6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: .85rem;
}
.report-modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: .5rem;
    margin-top: 1rem;
}

/* Grade — barre de progression (profil) */
.grade-progress {
    background: var(--surface-2);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin: .4rem 0;
}
.grade-progress__bar {
    height: 100%;
    background: linear-gradient(90deg, var(--c-teal-500, #14b8a6), var(--c-indigo-500, #6366f1));
    border-radius: inherit;
    transition: width .3s ease;
}

/* ============================================================
   Menu d'actions manager sur une ressource (⋮) — visibilité par
   section / toutes sections, retrait / suppression définitive.
   ============================================================ */
.resource-actions-menu {
    position: relative;
    flex-shrink: 0;
}
.resource-actions-toggle {
    font-weight: 700;
    line-height: 1;
    padding: .3rem .55rem;
}
.resource-actions-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 210;
    min-width: 260px;
    background: var(--surface, #fff);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,.12);
    padding: .3rem;
}
.resource-actions-dropdown.open {
    display: block;
}
.resource-action-item {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    padding: .5rem .6rem;
    border-radius: calc(var(--radius) - 2px);
    font-size: .82rem;
    color: var(--text);
    white-space: normal;
}
.resource-action-item:hover {
    background: var(--surface-2);
}
.resource-action-item--danger {
    color: var(--c-red-700, #b91c1c);
}
.resource-action-item--danger:hover {
    background: var(--c-red-50);
}


/* ============================================================
 * Pages AJAX : invitations + pages Manager (ressources, universités,
 * ambassadeurs, analytiques) — js/ug-ajax.js
 * ============================================================ */
.ug-toolbar { display:flex; flex-wrap:wrap; gap:.6rem; align-items:center; margin-bottom:1rem; }
.ug-toolbar .grow { flex:1 1 220px; }
.ug-input, .ug-select {
    padding:.5rem .75rem; border:1px solid var(--border-2); border-radius:var(--radius);
    background:var(--surface); color:var(--text); font:inherit; font-size:.875rem; min-width:0;
}
.ug-input:focus, .ug-select:focus { outline:2px solid var(--c-indigo-500); outline-offset:-1px; }
.ug-tabs { display:flex; gap:.25rem; border-bottom:1px solid var(--border); margin-bottom:1rem; flex-wrap:wrap; }
.ug-tab { padding:.55rem 1rem; border:0; background:none; font:inherit; font-size:.9rem; cursor:pointer;
          color:var(--text-2); border-bottom:2px solid transparent; margin-bottom:-1px; }
.ug-tab.active { color:var(--c-indigo-600); border-bottom-color:var(--c-indigo-600); font-weight:600; }
.ug-chips { display:flex; gap:.4rem; flex-wrap:wrap; }
.ug-chip { padding:.3rem .75rem; border:1px solid var(--border-2); border-radius:999px; background:var(--surface);
           font-size:.8rem; cursor:pointer; color:var(--text-2); }
.ug-chip.active { background:var(--c-indigo-50); border-color:var(--c-indigo-500); color:var(--c-indigo-700); font-weight:600; }
.ug-loading { opacity:.55; pointer-events:none; transition:opacity .15s; }
.ug-muted { color:var(--text-3); font-size:.8rem; }
.ug-nowrap { white-space:nowrap; }
.ug-actions { display:flex; gap:.35rem; flex-wrap:wrap; }
.ug-result { display:flex; gap:.5rem; align-items:flex-start; padding:.45rem .6rem; border-radius:var(--radius); font-size:.85rem; margin-top:.35rem; }
.ug-result.ok  { background:var(--c-green-50); color:var(--c-green-700); }
.ug-result.err { background:var(--c-red-50);   color:var(--c-red-700); }
.ug-result.warn{ background:var(--c-amber-50); color:var(--c-amber-700); }
.ug-result code { word-break:break-all; font-size:.78rem; }
.ug-copy { cursor:pointer; text-decoration:underline; }

/* Modale */
.ug-modal-back { position:fixed; inset:0; background:rgba(15,23,42,.45); display:flex; align-items:center; justify-content:center; z-index:1000; padding:1rem; }
.ug-modal { background:var(--surface); border-radius:var(--radius-lg, 12px); width:100%; max-width:480px; box-shadow:0 20px 50px rgba(0,0,0,.25); max-height:90vh; overflow:auto; }
.ug-modal-head { display:flex; justify-content:space-between; align-items:center; padding:1rem 1.25rem; border-bottom:1px solid var(--border); }
.ug-modal-head h3 { font-size:1rem; margin:0; }
.ug-modal-x { border:0; background:none; font-size:1.5rem; line-height:1; cursor:pointer; color:var(--text-2); }
.ug-modal-body { padding:1.25rem; display:flex; flex-direction:column; gap:.9rem; }
.ug-modal-body .form-group input, .ug-modal-body .form-group select { width:100%; }
.ug-modal-foot { display:flex; justify-content:flex-end; gap:.5rem; margin-top:.25rem; }

/* Analytiques */
.an-section { margin-bottom:1.5rem; }
.an-section h2 { font-size:1rem; font-weight:700; margin-bottom:.6rem; display:flex; align-items:center; gap:.5rem; }
.an-grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:.75rem; }
.an-metric { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:.9rem 1rem; display:flex; flex-direction:column; gap:.2rem; }
.an-metric .v { font-size:1.6rem; font-weight:700; line-height:1.15; font-variant-numeric:tabular-nums; }
.an-metric .l { font-size:.82rem; color:var(--text-2); }
.an-metric .h { font-size:.72rem; color:var(--text-3); }
.an-metric .bar { height:5px; border-radius:3px; background:var(--c-slate-100); overflow:hidden; margin-top:.35rem; }
.an-metric .bar > i { display:block; height:100%; background:var(--c-indigo-500); }
.an-metric.warn .v { color:var(--c-amber-700); }
.an-two { display:grid; grid-template-columns:repeat(auto-fit, minmax(300px, 1fr)); gap:1rem; }
.an-list { list-style:none; margin:0; padding:0; font-size:.86rem; }
.an-list li { display:flex; justify-content:space-between; gap:.75rem; padding:.45rem 0; border-bottom:1px solid var(--border); }
.an-list li:last-child { border-bottom:0; }
.an-list li span:first-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.dash-lastlogin { display:inline-block; font-size:.82rem; color:var(--text-2); margin:.15rem 0 .35rem; padding:.15rem .6rem; background:rgba(255,255,255,.9); border-radius:999px; }
.ug-head { background:rgba(255,255,255,.92); padding:.9rem 1.1rem; border-radius:var(--radius-lg); border:1px solid var(--border); }
.ug-head p { margin-bottom:0; }
.an-section h2 { display:inline-flex; background:rgba(255,255,255,.92); padding:.25rem .8rem; border-radius:999px; border:1px solid var(--border); }
.ug-chips, .ug-tabs { background:rgba(255,255,255,.92); padding:.4rem .5rem; border-radius:var(--radius); }
#aHint, #rTotal, #uTotal { display:inline-block; background:rgba(255,255,255,.92); padding:.15rem .6rem; border-radius:999px; }
.resource-dl { white-space:nowrap; }
