/* =====================================================
   Panneau d'administration sécurisé — Feuille de styles
   Design moderne, responsive et professionnel
   ===================================================== */

* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #4f46e5;
    --radius: 10px;
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
    padding: 24px 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    display: flex; align-items: center; gap: 10px;
}
.sidebar-brand i { color: var(--primary); }
.sidebar-nav { display: flex; flex-direction: column; padding: 16px 8px; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; border-radius: 8px;
    color: var(--sidebar-text); font-size: 14px; font-weight: 500;
    transition: all .2s;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-nav a.active { background: var(--sidebar-active); color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
    background: var(--surface); padding: 14px 24px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: var(--shadow); position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-user { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.topbar-user i { font-size: 22px; color: var(--primary); }
.content { padding: 24px; flex: 1; }
.footer { padding: 16px 24px; color: var(--muted); font-size: 13px; text-align: center; border-top: 1px solid var(--border); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-header h2, .card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* ---------- Page header ---------- */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
}
.page-header h2 { font-size: 22px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.page-header h2 i { color: var(--primary); }

/* ---------- Stats grid ---------- */
.stats-grid {
    display: grid; gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.stat-card {
    background: var(--surface); padding: 20px; border-radius: var(--radius);
    box-shadow: var(--shadow); display: flex; align-items: center; gap: 16px;
    border-left: 4px solid var(--primary);
}
.stat-card i { font-size: 32px; opacity: .8; }
.stat-card h3 { font-size: 26px; font-weight: 700; }
.stat-card p { color: var(--muted); font-size: 13px; }
.stat-blue   { border-color: #3b82f6; } .stat-blue i   { color: #3b82f6; }
.stat-green  { border-color: #10b981; } .stat-green i  { color: #10b981; }
.stat-purple { border-color: #8b5cf6; } .stat-purple i { color: #8b5cf6; }
.stat-orange { border-color: #f59e0b; } .stat-orange i { color: #f59e0b; }
.stat-red    { border-color: #ef4444; } .stat-red i    { color: #ef4444; }
.stat-teal   { border-color: #14b8a6; } .stat-teal i   { color: #14b8a6; }
.stat-pink   { border-color: #ec4899; } .stat-pink i   { color: #ec4899; }

/* ---------- Forms ---------- */
form label { display: block; margin-bottom: 14px; }
form label > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #334155; }
form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form select,
form textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 14px; background: #f8fafc;
    transition: border-color .2s, box-shadow .2s;
}
form input:focus, form select:focus, form textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15); background: #fff;
}
form fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin: 16px 0; }
form fieldset legend { font-weight: 600; padding: 0 8px; color: #334155; }
.checkbox { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.checkbox-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.perm-module { font-size: 14px; color: var(--primary); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .5px; }

.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
.mt-4 { margin-top: 16px; }
.mb-3 { margin-bottom: 12px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 16px; border-radius: 8px;
    font-size: 14px; font-weight: 600;
    border: none; cursor: pointer; transition: all .2s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-secondary { background: #e2e8f0; color: #334155; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-ghost   { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead {
    background: #f8fafc; text-align: left; font-size: 12px;
    text-transform: uppercase; color: var(--muted); letter-spacing: .5px;
}
.data-table th, .data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table .actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }
.data-table thead th:last-child { text-align: right; }
.data-table td.actions { justify-content: flex-end; }
.data-table .empty { text-align: center; color: var(--muted); padding: 24px; }
.inline { display: inline; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block; padding: 3px 10px; border-radius: 999px;
    font-size: 11px; font-weight: 600; margin: 2px;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* ---------- Flash messages ---------- */
.flash {
    padding: 12px 16px; border-radius: 8px; margin-bottom: 16px;
    display: flex; align-items: center; gap: 10px; font-size: 14px;
}
.flash-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.flash-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }

/* ---------- Auth pages ---------- */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%); padding: 20px;
}
.auth-card {
    background: #fff; border-radius: 16px; padding: 36px;
    width: 100%; max-width: 440px; box-shadow: 0 20px 50px rgba(0,0,0,.2);
}
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand i { font-size: 40px; color: var(--primary); }
.auth-brand h1 { font-size: 22px; font-weight: 700; margin-top: 8px; }
.auth-brand p { color: var(--muted); font-size: 14px; }
.auth-link { text-align: center; margin-top: 16px; font-size: 14px; color: var(--muted); }
.error-card { text-align: center; }
.error-card h1 { font-size: 64px; color: var(--danger); margin-bottom: 8px; }
.error-card p { color: var(--muted); margin-bottom: 16px; }

/* ---------- Demo credentials (login page) ---------- */
.demo-creds {
    margin-top: 16px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; overflow: hidden;
}
.demo-creds summary {
    padding: 10px 14px; cursor: pointer; background: #f8fafc;
    color: var(--muted); font-weight: 600;
    list-style: none; display: flex; align-items: center; gap: 6px;
}
.demo-creds summary::-webkit-details-marker { display: none; }
.demo-creds-table { width: 100%; border-collapse: collapse; }
.demo-creds-table th {
    background: #f1f5f9; padding: 6px 10px; text-align: left;
    font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .3px;
}
.demo-creds-table td { padding: 6px 10px; border-top: 1px solid #f1f5f9; font-size: 12px; }
.demo-creds-table code {
    font-family: monospace; background: #f1f5f9;
    padding: 2px 5px; border-radius: 4px; font-size: 11px;
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .sidebar { width: 70px; }
    .sidebar-brand span, .sidebar-nav a span { display: none; }
    .sidebar-nav a { justify-content: center; }
    .sidebar-brand { justify-content: center; padding: 20px 0; }
}
