/* ============================================================
   FMCourse · dashboard.css
   Sidebar + topbar + layout dashboard + composants internes.

   Repose sur le design system de main.css (navy / teal / gold,
   Spectral + Mulish). main.css DOIT être chargé avant ce fichier.

   Correctif clé : dashboard.css utilisait des tokens (--c-*, --sp-*,
   --r-*, --shadow-sm) jamais déclarés. On les définit ici une fois,
   en les mappant sur les vrais tokens de main.css. Tout le reste du
   fichier devient alors valide.
   ============================================================ */

/* ------------------------------------------------------------
   0. PONT DE TOKENS  (dashboard → design system main.css)
   ------------------------------------------------------------ */
:root {
    /* Échelle d'espacement */
    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;

    /* Couleurs (alias vers main.css) */
    --c-primary:        var(--navy);
    --c-primary-dark:   var(--navy-dark);
    --c-primary-light:  #eaf3f7;          /* tint teal très clair */
    --c-accent:         var(--teal);
    --c-text:           var(--text);
    --c-text-muted:     var(--text-soft);
    --c-border:         var(--line);
    --c-border-light:   #eef1f4;
    --c-success:        var(--success);
    --c-danger:         var(--danger);
    --c-warning:        #b07a12;           /* ambre lisible (le gold est trop clair en texte) */

    /* Rayons */
    --r-sm: 6px;
    --r-md: 10px;
    --r-lg: 14px;

    /* Ombres */
    --shadow-sm: 0 1px 2px rgba(35, 68, 97, .05), 0 4px 14px rgba(35, 68, 97, .05);

    /* Gabarit */
    --dash-topbar-h: 64px;
    --dash-sidebar-w: 264px;
}

body.layout-dashboard {
    background: #eef0f2;
}

/* ------------------------------------------------------------
   1. TOPBAR
   ------------------------------------------------------------ */
.topbar {
    height: var(--dash-topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--c-border);
    padding: 0 var(--sp-5);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.brand {
    display: flex;
    align-items: center;
}
.brand img {
    height: 34px;
    width: auto;
}
.topbar-actions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
}
.topbar-icon {
    position: relative;
    width: 40px;
    height: 40px;
    color: var(--c-text-muted);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.topbar-icon:hover {
    background: var(--bg-soft);
    color: var(--navy);
}
.topbar-icon .badge {
    position: absolute;
    top: 4px;
    right: 4px;
}

/* Avatar topbar : aligné sur le style header public */
.topbar .user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--c-border);
    background: var(--navy);
    color: #fff;
    font-weight: 800;
    font-family: var(--serif);
    font-size: 16px;
    cursor: pointer;
    overflow: hidden;
    display: grid;
    place-items: center;
    transition: border-color .15s;
}
.topbar .user-avatar:hover {
    border-color: var(--teal);
}
.topbar .user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ------------------------------------------------------------
   2. LAYOUT (sidebar + contenu)
   ------------------------------------------------------------ */
.dashboard-layout {
    display: grid;
    grid-template-columns: var(--dash-sidebar-w) 1fr;
    min-height: calc(100vh - var(--dash-topbar-h));
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--c-border);
    padding: var(--sp-4) 0;
    overflow-y: auto;
}
.sidebar nav {
    display: flex;
    flex-direction: column;
}
.sidebar nav a {
    position: relative;
    padding: 11px var(--sp-5);
    color: var(--c-text);
    text-decoration: none;
    border-left: 3px solid transparent;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    transition: background .15s, color .15s, border-color .15s;
}
.sidebar nav a:hover {
    background: var(--bg-soft);
    color: var(--navy);
}
.sidebar nav a.active {
    background: var(--c-primary-light);
    border-left-color: var(--teal);
    color: var(--navy);
    font-weight: 700;
}
.sidebar nav a:focus-visible {
    outline: 2px solid var(--teal);
    outline-offset: -2px;
}
.sidebar nav hr {
    margin: var(--sp-3) var(--sp-5);
    border: none;
    border-top: 1px solid var(--c-border-light);
}

.dashboard-content {
    padding: var(--sp-6) var(--sp-6);
    max-width: 1120px;
    width: 100%;
}

@media (max-width: 900px) {
    .dashboard-layout { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    .dashboard-content { padding: var(--sp-5) var(--sp-4); }
}

/* ------------------------------------------------------------
   3. EN-TÊTE DE PAGE
   ------------------------------------------------------------ */
.page-header {
    margin-bottom: var(--sp-6);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: var(--sp-3);
}
.page-header h1 {
    margin: 0;
    font-size: 30px;
}
.page-header p {
    margin: 4px 0 0;
    color: var(--c-text-muted);
}

/* ------------------------------------------------------------
   4. STATISTIQUES
   ------------------------------------------------------------ */
.stats-row {
    display: flex;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin: var(--sp-4) 0;
}
.stat-box {
    flex: 1;
    min-width: 180px;
    padding: var(--sp-4);
    background: #fff;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-md);
    text-align: center;
}
.stat-box small {
    display: block;
    margin-bottom: var(--sp-2);
    color: var(--c-text-muted);
}
.stat-box strong {
    font-family: var(--serif);
    font-size: 24px;
    color: var(--navy);
}
.stat-box-large strong {
    font-size: 30px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-6);
}
.stat-card {
    background: #fff;
    padding: var(--sp-5);
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    transition: transform .2s, box-shadow .2s;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow);
}
.stat-card small {
    color: var(--c-text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    font-size: 11.5px;
}
.stat-card strong {
    font-family: var(--serif);
    font-size: 32px;
    color: var(--navy);
    line-height: 1.1;
}
.stat-card a {
    margin-top: auto;
    font-size: 14px;
    color: var(--teal);
    font-weight: 700;
}
.stat-card a:hover { color: var(--navy); }
.stat-card-alert strong { color: var(--c-warning); }

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-3);
}
.quick-action {
    background: #fff;
    border: 1px solid var(--c-border-light);
    padding: var(--sp-4);
    border-radius: var(--r-md);
    display: flex;
    flex-direction: column;
    color: var(--c-text);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.quick-action:hover {
    border-color: var(--teal);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}
.quick-action strong {
    display: block;
    margin-bottom: var(--sp-1);
    color: var(--navy);
}
.quick-action small { color: var(--c-text-muted); }

/* ------------------------------------------------------------
   5. ONGLETS DE PÉRIODE
   ------------------------------------------------------------ */
.period-tabs {
    display: flex;
    gap: var(--sp-2);
}
.period-tabs a {
    padding: 6px 16px;
    border-radius: var(--pill);
    font-size: 13px;
    font-weight: 700;
    color: var(--c-text-muted);
    background: transparent;
    border: 1px solid transparent;
    transition: .15s;
}
.period-tabs a:hover {
    color: var(--navy);
    border-color: var(--c-border);
}
.period-tabs a.active {
    background: var(--navy);
    color: #fff;
    border-color: var(--navy);
}

/* ------------------------------------------------------------
   6. UPLOAD AVATAR
   ------------------------------------------------------------ */
.avatar-upload {
    display: flex;
    gap: var(--sp-4);
    align-items: center;
    flex-wrap: wrap;
}
.avatar-preview {
    width: 84px;
    height: 84px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--c-border);
    background: var(--navy);
    color: #fff;
    font-family: var(--serif);
    font-weight: 800;
    font-size: 34px;
    line-height: 1;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.avatar-upload-controls {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}
.avatar-error {
    color: var(--c-danger);
    font-weight: 600;
    font-size: 12.5px;
}
.avatar-xs {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: var(--sp-2);
    object-fit: cover;
}

/* ===== Icône SVG en ligne (remplace les emojis) ===== */
.inline-icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    margin-right: 6px;
    color: var(--teal);
    flex-shrink: 0;
}

/* ------------------------------------------------------------
   7. BARRE DE PROGRESSION
   ------------------------------------------------------------ */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--c-border-light);
    border-radius: var(--pill);
    overflow: hidden;
    margin: var(--sp-2) 0;
}
.progress-fill {
    height: 100%;
    background: var(--teal);
    border-radius: var(--pill);
    transition: width .3s;
}

/* ------------------------------------------------------------
   8. NOTIFICATIONS
   ------------------------------------------------------------ */
.notifications-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.notification-item {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-4);
    background: #fff;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-md);
    margin-bottom: var(--sp-2);
    align-items: flex-start;
    transition: box-shadow .15s;
}
.notification-item:hover { box-shadow: var(--shadow-sm); }
.notification-item.is-unread {
    border-left: 3px solid var(--teal);
}
.notification-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--c-primary-light);
    flex-shrink: 0;
}
.notification-body { flex: 1; }
.notification-body h4 { margin: 0 0 var(--sp-1); font-size: 14px; }
.notification-body p { margin: 0 0 var(--sp-2); font-size: 14px; color: var(--c-text-muted); }
.notification-body time { font-size: 12px; color: var(--c-text-muted); }

/* ------------------------------------------------------------
   9. GRILLES D'INSCRIPTIONS (mes formations / mes lives)
   ------------------------------------------------------------ */
.enrollment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--sp-4);
}
.enrollment-card {
    background: #fff;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    transition: transform .2s, box-shadow .2s;
}
.enrollment-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow);
}
.enrollment-image {
    display: block;
    aspect-ratio: 16 / 9;
    background: var(--c-border-light);
    overflow: hidden;
}
.enrollment-image img { width: 100%; height: 100%; object-fit: cover; }
.enrollment-image .placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #cbd5e1, #94a3b8);
}
.enrollment-body {
    padding: var(--sp-4);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    flex: 1;
}
.enrollment-body h3 { font-size: 16px; margin: 0; }
.enrollment-instructor { color: var(--c-text-muted); font-size: 13px; margin: 0; }
.enrollment-meta { margin: var(--sp-2) 0 0; font-size: 13px; color: var(--c-text-muted); }
.enrollment-actions {
    display: flex;
    gap: var(--sp-2);
    margin-top: auto;
    padding-top: var(--sp-2);
}
.class-name { color: var(--navy); font-weight: 700; }

/* ------------------------------------------------------------
   10. PANIER
   ------------------------------------------------------------ */
.cart-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: var(--sp-5);
    align-items: flex-start;
}
.cart-items { list-style: none; padding: 0; margin: 0; }
.cart-item {
    display: grid;
    grid-template-columns: 80px 1fr auto auto;
    gap: var(--sp-3);
    align-items: center;
    padding: var(--sp-3);
    background: #fff;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-md);
    margin-bottom: var(--sp-2);
}
.cart-item-image {
    width: 80px;
    aspect-ratio: 16/9;
    overflow: hidden;
    border-radius: var(--r-sm);
}
.cart-item-image img { width: 100%; height: 100%; object-fit: cover; }
.cart-item-info h3 { font-size: 15px; margin: 0 0 var(--sp-1); }
.cart-item-price { text-align: right; }
.cart-item-price .price-original {
    display: block;
    text-decoration: line-through;
    font-size: 12px;
    color: var(--c-text-muted);
}
.cart-summary {
    background: #fff;
    border: 1px solid var(--c-border-light);
    padding: var(--sp-5);
    border-radius: var(--r-lg);
    position: sticky;
    top: calc(var(--dash-topbar-h) + var(--sp-4));
    box-shadow: var(--shadow-sm);
}
.cart-summary dl {
    display: flex;
    justify-content: space-between;
    margin: 0 0 var(--sp-2);
}
.cart-summary dl dt, .cart-summary dl dd { margin: 0; }
.cart-total {
    padding-top: var(--sp-3);
    border-top: 1px solid var(--c-border);
    font-size: 18px;
    font-weight: 700;
    color: var(--navy);
}
.cart-info { color: var(--c-text-muted); margin-top: var(--sp-3); font-size: 13px; }

@media (max-width: 768px) {
    .cart-layout { grid-template-columns: 1fr; }
    .cart-item { grid-template-columns: 60px 1fr; }
    .cart-item-price, .cart-item .btn-icon { grid-column: 2; justify-self: end; }
}

/* ------------------------------------------------------------
   11. CARTES REMBOURSEMENT / TICKET (admin)
   ------------------------------------------------------------ */
.refund-card, .ticket-card { padding: var(--sp-5); }
.refund-header, .ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--sp-3);
}
.refund-header h3, .ticket-header h3 { margin: 0; }
.refund-amount { text-align: right; }
.refund-amount strong {
    display: block;
    font-family: var(--serif);
    font-size: 20px;
    color: var(--navy);
}
.refund-body, .ticket-body { margin-bottom: var(--sp-3); color: var(--c-text-muted); }
.refund-actions {
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--c-border-light);
}
.action-buttons { display: flex; gap: var(--sp-2); }
.refund-decision { margin: 0; }
.ticket-actions { display: flex; gap: var(--sp-2); }

/* ------------------------------------------------------------
   12. SECTION FORMATION (instructor live-sessions)
   ------------------------------------------------------------ */
.course-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--sp-4);
    gap: var(--sp-3);
    flex-wrap: wrap;
}
.course-section-header h2 { margin: 0 0 var(--sp-1); }
.course-section-header small { color: var(--c-text-muted); }
.course-stats { display: flex; gap: var(--sp-3); margin: var(--sp-2) 0; }

/* ------------------------------------------------------------
   13. INDICATEUR DE DISPONIBILITÉ SERVEUR
   ------------------------------------------------------------ */
.availability-indicator {
    background: #fff;
    border: 1px solid var(--c-border-light);
    border-left: 4px solid var(--c-success);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-4);
    border-radius: var(--r-md);
    font-size: 14px;
    color: var(--c-text);
}
.availability-indicator strong { color: var(--navy); }
.availability-indicator.is-saturated { border-left-color: var(--c-danger); }
.availability-indicator.is-warning { border-left-color: var(--c-warning); }

/* ------------------------------------------------------------
   14. TAGS
   ------------------------------------------------------------ */
.tag-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
}
.tag {
    display: inline-block;
    padding: 4px 12px;
    background: var(--c-primary-light);
    color: var(--navy);
    border-radius: var(--pill);
    font-size: 13px;
    font-weight: 600;
}

/* ------------------------------------------------------------
   15. BARRE DE FILTRES
   ------------------------------------------------------------ */
.filters-bar {
    display: flex;
    gap: var(--sp-3);
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: var(--sp-4);
    padding: var(--sp-3) var(--sp-4);
    background: #fff;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-md);
}
.filters-bar input,
.filters-bar select {
    padding: 9px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--r-sm);
    font-family: var(--sans);
    font-size: 14px;
    color: var(--text);
    background: #fff;
}
.filters-bar input:focus,
.filters-bar select:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(78, 152, 180, .15);
}

/* ------------------------------------------------------------
   16. PAGE DE CONTENU (politiques, aide…)
   ------------------------------------------------------------ */
.content-page { line-height: 1.7; }
.content-page h2 { margin-top: var(--sp-5); }
.content-page h3 { margin-top: var(--sp-4); }
.content-page ul, .content-page ol { padding-left: var(--sp-5); }
.content-page li { margin-bottom: var(--sp-2); }

/* ------------------------------------------------------------
   17. ACCESSIBILITÉ : mouvement réduit
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
    .stat-card, .quick-action, .enrollment-card, .topbar-icon,
    .progress-fill, .sidebar nav a {
        transition: none;
    }
}