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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Dark theme (par défaut) */
body.theme-dark {
    background: #0f172a;
    color: #e5e7eb;
}

body.theme-dark a {
    color: #38bdf8;
}

/* Light theme */
body.theme-light {
    background: #f3f4f6;
    color: #111827;
}

body.theme-light a {
    color: #2563eb;
}

a {
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    padding: 1.5rem;
}

body.theme-dark .sidebar {
    background: #020617;
}

body.theme-light .sidebar {
    background: #e5e7eb;
}

.sidebar h1 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.sidebar .role-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
}

body.theme-dark .sidebar .role-badge {
    background: #1d4ed8;
    color: #e5e7eb;
}

body.theme-light .sidebar .role-badge {
    background: #1e3a8a;
    color: #e5e7eb;
}

.nav-section {
    margin-top: 1.5rem;
}

.nav-section h2 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 0.5rem;
}

body.theme-dark .nav-section h2 {
    color: #64748b;
}

body.theme-light .nav-section h2 {
    color: #6b7280;
}

.nav-link {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
}

body.theme-dark .nav-link {
    color: #e5e7eb;
}

body.theme-light .nav-link {
    color: #111827;
}

body.theme-dark .nav-link:hover {
    background: #0f172a;
}

body.theme-light .nav-link:hover {
    background: #d1d5db;
}

/* Main */
.main {
    flex: 1;
    padding: 1.5rem;
}

/* Card */
.card {
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}

body.theme-dark .card {
    background: #020617;
}

body.theme-light .card {
    background: #ffffff;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table th, .table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #1e293b;
}

body.theme-light .table th, 
body.theme-light .table td {
    border-bottom: 1px solid #e5e7eb;
}

.table th {
    text-align: left;
    font-weight: 500;
}

body.theme-dark .table th {
    color: #9ca3af;
}

body.theme-light .table th {
    color: #6b7280;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.4rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: #2563eb;
    color: white;
}

.btn-danger {
    background: #b91c1c;
    color: white;
}

.btn-secondary {
    background: #334155;
    color: white;
}

/* Theme toggle button */
.btn-toggle-theme {
    font-size: 0.8rem;
    padding: 0.3rem 0.7rem;
    border-radius: 9999px;
    border: 1px solid rgba(148,163,184,0.6);
    background: transparent;
    cursor: pointer;
}

body.theme-dark .btn-toggle-theme {
    color: #e5e7eb;
}

body.theme-light .btn-toggle-theme {
    color: #111827;
}

/* Form */
.form-group {
    margin-bottom: 0.75rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

body.theme-dark .form-group label {
    color: #9ca3af;
}

body.theme-light .form-group label {
    color: #4b5563;
}

.form-control {
    width: 100%;
    padding: 0.45rem 0.6rem;
    border-radius: 0.5rem;
    border: 1px solid #1e293b;
    font-size: 0.9rem;
}

body.theme-dark .form-control {
    background: #020617;
    color: #e5e7eb;
}

body.theme-light .form-control {
    background: #ffffff;
    color: #111827;
    border-color: #d1d5db;
}

/* Alerts */
.alert {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.alert-error {
    background: #7f1d1d;
    color: #fecaca;
}

/* Topbar */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.topbar-right {
    font-size: 0.85rem;
}

body.theme-dark .topbar-right {
    color: #9ca3af;
}

body.theme-light .topbar-right {
    color: #4b5563;
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.filters .form-group {
    min-width: 140px;
    margin-bottom: 0;
}

/* Mobile */
@media (max-width: 768px) {
    .layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    .nav-section {
        display: none;
    }
}

.global-banner {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    text-align: center;
    font-weight: 500;
}

body.theme-dark .global-banner {
    background: rgba(56, 189, 248, 0.15);
    color: #e0f2fe;
}

body.theme-light .global-banner {
    background: #e0f2fe;
    color: #0f172a;
}

/* ===== Fix contraste formulaire de connexion (mode sombre) ===== */

body.theme-dark .card {
    color: #e5e7eb; /* texte clair dans les cartes (dont login) */
}

body.theme-dark label {
    color: #e5e7eb; /* labels "Identifiant", "Mot de passe" lisibles */
}

/* Inputs dans le login (et ailleurs) en mode sombre */
body.theme-dark .form-control {
    background: #020617;          /* bleu très sombre */
    border: 1px solid #1f2937;    /* léger contour */
    color: #e5e7eb;               /* texte clair */
}

body.theme-dark .form-control::placeholder {
    color: #64748b;               /* gris moyen pour placeholder */
}

/* Bouton principal bien visible */
body.theme-dark .btn-primary {
    background: #2563eb;
    border: none;
    color: #f9fafb;
}

body.theme-dark .btn-primary:hover {
    background: #1d4ed8;
}

