/* ==============================
   Reset & base
   ============================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
    --bg: #f5f6f8;
    --bg-card: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --primary: #1e3a8a;
    --primary-dark: #1e2a5e;
    --primary-light: #dbeafe;
    --accent: #b45309;
    --success: #047857;
    --success-bg: #d1fae5;
    --warning: #b45309;
    --warning-bg: #fef3c7;
    --danger: #b91c1c;
    --danger-bg: #fee2e2;
    --info: #1e40af;
    --info-bg: #dbeafe;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --radius: 8px;
    --radius-sm: 4px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--text); margin-top: 0; }
h1 { font-size: 1.75rem; margin-bottom: 1rem; }
h2 { font-size: 1.35rem; margin-bottom: .8rem; }
h3 { font-size: 1.1rem; margin-bottom: .6rem; }

/* Navbar */
.navbar { background: var(--primary); color: #fff; box-shadow: var(--shadow-md); }
.nav-container {
    max-width: 1200px; margin: 0 auto; padding: 0 1rem;
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.nav-brand { color: #fff; font-weight: 600; font-size: 1.15rem; padding: 1rem 0; }
.nav-brand:hover { text-decoration: none; opacity: .9; }
.nav-links { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; }
.nav-links a {
    color: #fff; padding: .6rem 1rem; border-radius: var(--radius-sm);
    display: block; font-size: .95rem; transition: background .15s;
}
.nav-links a:hover { background: rgba(255,255,255,0.12); text-decoration: none; }
.nav-logout { background: rgba(255,255,255,0.1); }
.nav-toggle {
    display: none; background: transparent; border: 0; color: #fff;
    font-size: 1.5rem; cursor: pointer;
}

/* Container */
.container {
    max-width: 1200px; width: 100%; margin: 0 auto;
    padding: 1.5rem 1rem; flex: 1;
}
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
}
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem;
    box-shadow: var(--shadow); margin-bottom: 1.25rem;
}
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Stats */
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
    box-shadow: var(--shadow); border-left: 4px solid var(--primary);
}
.stat-card .stat-value {
    font-size: 2rem; font-weight: 700; color: var(--primary);
    line-height: 1; margin: .25rem 0;
}
.stat-card .stat-label {
    color: var(--text-muted); font-size: .85rem;
    text-transform: uppercase; letter-spacing: .03em;
}
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card.danger .stat-value { color: var(--danger); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.success .stat-value { color: var(--success); }

/* Boutons */
.btn {
    display: inline-block; padding: .55rem 1.1rem; background: var(--primary);
    color: #fff; border: 0; border-radius: var(--radius-sm); cursor: pointer;
    font-size: .95rem; text-decoration: none;
    transition: background .15s, transform .05s; font-family: inherit;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .35rem .75rem; font-size: .85rem; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #991b1b; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #065f46; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-block { width: 100%; }

/* Formulaires */
.form-group { margin-bottom: 1rem; }
.form-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}
label {
    display: block; margin-bottom: .35rem;
    font-weight: 500; font-size: .9rem; color: var(--text);
}
input[type="text"], input[type="password"], input[type="email"],
input[type="tel"], input[type="date"], input[type="datetime-local"],
input[type="number"], input[type="file"], select, textarea {
    width: 100%; padding: .55rem .75rem; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: .95rem; font-family: inherit;
    background: #fff; color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1);
}
textarea { resize: vertical; min-height: 80px; }

/* Tables */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--bg-card); }
th, td { text-align: left; padding: .75rem 1rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
th {
    background: #f9fafb; font-weight: 600; color: var(--text-muted);
    font-size: .8rem; text-transform: uppercase; letter-spacing: .03em;
}
tbody tr:hover { background: #fafbfc; }

/* Badges */
.badge {
    display: inline-block; padding: .2rem .55rem;
    border-radius: 999px; font-size: .75rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .02em;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-muted { background: #f3f4f6; color: var(--text-muted); }

/* Flash */
.flash {
    padding: .9rem 1.2rem; border-radius: var(--radius);
    margin-bottom: 1.25rem; border: 1px solid transparent; font-size: .95rem;
}
.flash-success { background: var(--success-bg); border-color: #6ee7b7; color: var(--success); }
.flash-error, .flash-danger { background: var(--danger-bg); border-color: #fca5a5; color: var(--danger); }
.flash-info { background: var(--info-bg); border-color: #93c5fd; color: var(--info); }

/* Login */
.login-wrapper {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 1rem;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e2a5e 100%);
}
.login-card {
    background: #fff; padding: 2.5rem; border-radius: var(--radius);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    width: 100%; max-width: 400px;
}
.login-card h1 { text-align: center; margin-bottom: .25rem; color: var(--primary); }
.login-subtitle {
    text-align: center; color: var(--text-muted);
    margin-bottom: 2rem; font-size: .9rem;
}

/* Timeline */
.timeline { position: relative; padding-left: 2rem; margin: 1rem 0; }
.timeline::before {
    content: ''; position: absolute; left: .65rem;
    top: 0; bottom: 0; width: 2px; background: var(--border);
}
.timeline-item {
    position: relative; margin-bottom: 1.5rem;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.25rem;
}
.timeline-item::before {
    content: ''; position: absolute; left: -1.7rem; top: 1.2rem;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--bg-card); border: 3px solid var(--text-muted);
}
.timeline-item.statut-termine::before { border-color: var(--success); background: var(--success); }
.timeline-item.statut-en_cours::before { border-color: var(--warning); }
.timeline-item.statut-a_faire::before { border-color: var(--text-muted); }
.timeline-item h4 { margin: 0 0 .25rem 0; }
.timeline-item .timeline-date { font-size: .85rem; color: var(--text-muted); margin-bottom: .5rem; }
.timeline-item .timeline-actions { display: flex; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }

/* Tabs */
.tabs {
    display: flex; border-bottom: 2px solid var(--border);
    margin-bottom: 1.5rem; overflow-x: auto; gap: 0;
}
.tab {
    padding: .75rem 1.25rem; cursor: pointer; border: 0;
    background: transparent; font-size: .95rem; font-family: inherit;
    color: var(--text-muted); border-bottom: 2px solid transparent;
    margin-bottom: -2px; white-space: nowrap; text-decoration: none;
    transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--primary); text-decoration: none; }
.tab.active {
    color: var(--primary); border-bottom-color: var(--primary); font-weight: 600;
}

/* Utils */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; } .mb-3 { margin-bottom: 1.5rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }

.footer {
    text-align: center; padding: 1.5rem 1rem; color: var(--text-muted);
    font-size: .85rem; border-top: 1px solid var(--border); background: #fff;
}

@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .nav-links {
        display: none; width: 100%;
        flex-direction: column; padding-bottom: .5rem;
    }
    .nav-links.open { display: flex; }
    .nav-links a { padding: .75rem 1rem; }
    h1 { font-size: 1.4rem; }
    .card { padding: 1rem; }
    .login-card { padding: 1.75rem; }
}
