/* =================================================================
   LMS ISIM - Stylesheet Principal
   ================================================================= */

/* --- VARIABLES CSS (Inspiré Zendenta) --- */
:root {
    --primary-color: #3b5de7;
    --primary-dark: #2948c6;
    --primary-light: #6c8aef;
    --secondary-color: #6c757d;
    --success-color: #1ecab8;
    --danger-color: #f1556c;
    --warning-color: #f7b924;
    --info-color: #4fc6e1;

    --text-primary: #323a46;
    --text-secondary: #8a92a6;
    --text-muted: #adb5bd;

    --bg-light: #fafbfe;
    --bg-white: #ffffff;
    --bg-gray: #f8f9fa;
    --border-color: #eef2f7;
    --border-light: #f1f5fa;

    --sidebar-width: 260px;
    --topbar-height: 64px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- RESET & BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-light);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* --- LAYOUT --- */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
}

.sidebar-nav {
    padding: 20px 0;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-section-title {
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 4px;
    color: var(--text-secondary);
    transition: var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(102,126,234,0.1) 0%, transparent 100%);
    color: var(--primary-color);
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-color);
}

.nav-icon {
    width: 20px;
    margin-right: 12px;
    font-size: 16px;
}

.nav-badge {
    margin-left: auto;
    background: var(--danger-color);
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.user-info {
    text-align: right;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 12px 20px;
    color: var(--text-primary);
    transition: var(--transition);
}

.dropdown-item:hover {
    background: var(--bg-light);
}

.content-wrapper {
    padding: 30px;
    flex: 1;
}

/* --- FLASH MESSAGES --- */
.flash-messages {
    margin-bottom: 20px;
}

.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 12px;
    border-left: 4px solid;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-color: var(--success-color);
}

.alert-error,
.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border-color: var(--danger-color);
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border-color: var(--warning-color);
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border-color: var(--info-color);
}

/* --- PAGE HEADER --- */
.page-header {
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.breadcrumb {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 15px;
}

.breadcrumb a {
    color: var(--text-secondary);
}

/* --- CARDS (Metrica Style) --- */
.card, .dashboard-card {
    background: white;
    border: 1px solid #f1f3f7;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.card-header {
    padding: 20px 24px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 16px 24px;
    background: var(--bg-gray);
    border-top: 1px solid var(--border-light);
}

/* --- STATS CARDS --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stats-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stats-grid-4 {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    color: var(--primary-color);
    border-radius: var(--radius-lg);
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.stat-detail {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

/* --- DASHBOARD GRID --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
}

/* --- BUTTONS (Metrica Style Ultra-Fin) --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 3px;
    font-weight: 400;
    font-size: 13px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    line-height: 1.4;
    letter-spacing: 0.02em;
}

.btn-primary {
    background: linear-gradient(135deg, #3b5de7 0%, #5a7bef 100%);
    color: white;
    border: none;
    box-shadow: 0 1px 3px rgba(59, 93, 231, 0.15);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2948c6 0%, #3b5de7 100%);
    box-shadow: 0 3px 8px rgba(59, 93, 231, 0.25);
    transform: translateY(-1px);
}

.btn-success {
    background: linear-gradient(135deg, #1ecab8 0%, #36d9c7 100%);
    color: white;
    border: none;
    box-shadow: 0 1px 3px rgba(30, 202, 184, 0.15);
}

.btn-success:hover {
    background: linear-gradient(135deg, #19b3a3 0%, #1ecab8 100%);
    box-shadow: 0 3px 8px rgba(30, 202, 184, 0.25);
    transform: translateY(-1px);
}

.btn-danger {
    background: linear-gradient(135deg, #f1556c 0%, #f76a7e 100%);
    color: white;
    border: none;
    box-shadow: 0 1px 3px rgba(241, 85, 108, 0.15);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #ee395b 0%, #f1556c 100%);
    box-shadow: 0 3px 8px rgba(241, 85, 108, 0.25);
    transform: translateY(-1px);
}

.btn-warning {
    background: linear-gradient(135deg, #f7b924 0%, #fac546 100%);
    color: white;
    border: none;
    box-shadow: 0 1px 3px rgba(247, 185, 36, 0.15);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #e5a812 0%, #f7b924 100%);
    box-shadow: 0 3px 8px rgba(247, 185, 36, 0.25);
    transform: translateY(-1px);
}

.btn-outline,
.btn-outline-primary {
    background: white;
    border: 1px solid #e3e8ef;
    color: #6c757d;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-outline:hover,
.btn-outline-primary:hover {
    background: #f8f9fa;
    border-color: #3b5de7;
    color: #3b5de7;
    box-shadow: 0 2px 4px rgba(59, 93, 231, 0.1);
}

.btn-outline-danger {
    background: white;
    border: 1px solid #e3e8ef;
    color: #6c757d;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-outline-danger:hover {
    background: #fff5f7;
    border-color: #f1556c;
    color: #f1556c;
    box-shadow: 0 2px 4px rgba(241, 85, 108, 0.1);
}

.btn-light {
    background: white;
    border: 1px solid #e3e8ef;
    color: #495057;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.btn-light:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #212529;
}

.btn-sm {
    padding: 3px 8px;
    font-size: 12px;
}

.btn-lg {
    padding: 8px 18px;
    font-size: 14px;
}

.btn-block {
    width: 100%;
    display: block;
}

.btn-icon {
    padding: 5px;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
}

/* --- FORMS (Metrica Style) --- */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 400;
    color: #6c757d;
    font-size: 13px;
}

.form-control, .form-select {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid #e3e8ef;
    border-radius: 3px;
    font-size: 13px;
    font-family: inherit;
    transition: all 0.15s ease;
    background: white;
    color: #495057;
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: #3b5de7;
    box-shadow: 0 0 0 3px rgba(59, 93, 231, 0.08);
}

.form-control-sm, .form-select-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 3px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

.form-text {
    font-size: 11px;
    color: #8a92a6;
    margin-top: 4px;
    display: block;
}

/* --- TABLES (Metrica Style - Header fixe) --- */
.table-container {
    max-height: 600px;
    overflow-y: auto;
    border: 1px solid var(--border-light);
    border-radius: 6px;
}

.data-table, .table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--bg-white);
    margin-bottom: 0;
}

.data-table thead, .table thead {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 2px rgba(0,0,0,0.03);
}

.data-table th, .table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid var(--border-color);
    background: #f8f9fa;
}

.data-table td, .table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    font-size: 13px;
}

.data-table tbody tr:hover, .table tbody tr:hover {
    background: rgba(59, 93, 231, 0.03);
}

.data-table tr:last-child td, .table tbody tr:last-child td {
    border-bottom: 1px solid var(--border-light);
}

/* --- BADGES (Metrica Style Ultra-Moderne) --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 2px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0.02em;
    border: 1px solid transparent;
}

.badge-primary, .bg-primary {
    background: linear-gradient(135deg, rgba(59, 93, 231, 0.1) 0%, rgba(90, 123, 239, 0.1) 100%);
    color: #3b5de7;
    border-color: rgba(59, 93, 231, 0.2);
}

.badge-success, .bg-success {
    background: linear-gradient(135deg, rgba(30, 202, 184, 0.1) 0%, rgba(54, 217, 199, 0.1) 100%);
    color: #1ecab8;
    border-color: rgba(30, 202, 184, 0.2);
}

.badge-danger, .bg-danger {
    background: linear-gradient(135deg, rgba(241, 85, 108, 0.1) 0%, rgba(247, 106, 126, 0.1) 100%);
    color: #f1556c;
    border-color: rgba(241, 85, 108, 0.2);
}

.badge-warning, .bg-warning {
    background: linear-gradient(135deg, rgba(247, 185, 36, 0.1) 0%, rgba(250, 197, 70, 0.1) 100%);
    color: #e5a812;
    border-color: rgba(247, 185, 36, 0.2);
}

.badge-info, .bg-info {
    background: linear-gradient(135deg, rgba(79, 198, 225, 0.1) 0%, rgba(103, 210, 233, 0.1) 100%);
    color: #4fc6e1;
    border-color: rgba(79, 198, 225, 0.2);
}

.badge-secondary {
    background: #f8f9fa;
    color: #6c757d;
    border-color: #e9ecef;
}

.bg-light {
    background: #fafbfc;
    color: #6c757d;
    border-color: #f1f3f7;
}

.badge-beginner {
    background: rgba(30, 202, 184, 0.12);
    color: #1ecab8;
}

.badge-intermediate {
    background: rgba(247, 185, 36, 0.12);
    color: #f7b924;
}

.badge-advanced {
    background: rgba(241, 85, 108, 0.12);
    color: #f1556c;
}

/* --- PROGRESS BAR --- */
.progress {
    width: 100%;
    height: 8px;
    background: #E5E7EB;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-light) 100%);
    border-radius: 10px;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-bar.bg-success {
    background: linear-gradient(90deg, var(--success-color) 0%, #34D399 100%);
}

.progress-bar.bg-warning {
    background: linear-gradient(90deg, var(--warning-color) 0%, #FBBF24 100%);
}

.progress-bar.bg-danger {
    background: linear-gradient(90deg, var(--danger-color) 0%, #F87171 100%);
}

.progress-bar-large {
    height: 12px;
}

.progress-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* --- PAGINATION --- */
.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 24px;
}

.page-link {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    transition: var(--transition);
}

.page-link:hover {
    background: var(--bg-light);
}

.page-link.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* --- EMPTY STATE --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 20px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* --- ONGLETS ADMIN --- */
.admin-tabs-container {
    background: var(--bg-white);
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.admin-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    gap: 0;
}

.admin-tabs .nav-tabs {
    border: none;
    margin: 0;
    flex: 1;
    display: flex;
    flex-wrap: nowrap;
    gap: 0;
}

.admin-tabs .nav-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    border-right: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 16px 24px;
    margin: 0;
    font-weight: 500;
    transition: all 0.2s ease;
    border-radius: 0;
    background: transparent;
    white-space: nowrap;
}

.admin-tabs .nav-tabs .nav-link:last-child {
    border-right: none;
}

.admin-tabs .nav-tabs .nav-link:hover {
    border-bottom-color: var(--primary-light);
    background: var(--bg-light);
    color: var(--text-primary);
}

.admin-tabs .nav-tabs .nav-link.active {
    border-bottom-color: var(--primary-color);
    background: white;
    color: var(--primary-color);
    font-weight: 600;
}

.admin-tabs .nav-tabs .nav-link i {
    margin-right: 8px;
    font-size: 14px;
}

.admin-tabs .tab-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-left: 1px solid var(--border-color);
}

.btn-reload-tab {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: var(--transition);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-reload-tab:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.btn-reload-tab i {
    font-size: 13px;
}

/* Page header Metrica - ultra-épuré */
.admin-page-header,
.page-header {
    margin-bottom: 20px;
    padding: 0;
    background: white;
    border-bottom: 1px solid #f1f3f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-page-header .header-title,
.page-header > div:first-child {
    flex: 1;
}

.admin-page-header h2,
.page-header h2 {
    font-size: 16px;
    font-weight: 500;
    color: #495057;
    margin: 0;
    padding: 12px 0;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.02em;
}

.admin-page-header p,
.page-header p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 12px;
    display: none;
}

.admin-page-header .header-actions,
.page-header > div:last-child {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 12px 0;
}

/* --- BOUTON RELOAD --- */
.btn-reload-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
}

.btn-reload-tab:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-reload-tab i {
    font-size: 13px;
    transition: transform 0.6s ease;
}

.btn-reload-tab:active i,
.btn-reload-tab.spinning i {
    animation: spin-reload 0.6s linear;
}

@keyframes spin-reload {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- UTILITY CLASSES --- */
.text-muted {
    color: var(--text-muted);
}

.text-success {
    color: var(--success-color);
}

.text-danger {
    color: var(--danger-color);
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .content-wrapper {
        padding: 20px 15px;
    }

    .page-header {
        flex-direction: column;
        gap: 15px;
    }
}
