/* ============================================================
   JOBIZ IA ADMIN — design system (v3)
   Repris du système "Admin 3.0" de admin.joboost.org (sidebar sombre,
   IBM Plex Sans/Mono, cartes à bordure fine, chiffres tabulaires) et adapté
   à l'identité JObiz IA (accent indigo au lieu du vert JOboost). Bootstrap
   reste chargé uniquement pour ses classes utilitaires de mise en page
   (d-flex, gap-*, row/col, modal JS) — tout l'habillage visuel (cartes,
   tableaux, boutons, badges, formulaires) passe par les classes .adm-* ici.
   ============================================================ */

:root {
    /* Texte / surfaces */
    --ink: #0d1420;
    --ink-text: #1c2534;
    --muted: #667085;
    --paper: #ffffff;
    --paper-dim: #f4f5f7;
    --paper-tint: #eef0ff;
    --line: rgba(13, 20, 32, 0.10);
    --line-strong: rgba(13, 20, 32, 0.16);

    /* Accent de marque JObiz IA (indigo) + sémantique */
    --primary: #6366f1;
    --primary-dark: #4338ca;
    --accent: #2a5cad;
    --accent-dim: #eaf0fa;
    --danger: #d92d20;
    --danger-dim: #fdeceb;
    --warning: #dc6803;
    --warning-dim: #fff3e0;

    /* Typographie */
    --font-display: "IBM Plex Sans", "Segoe UI", sans-serif;
    --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
    --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

    /* Rayons / ombres */
    --radius-lg: 12px;
    --radius-md: 9px;
    --radius-sm: 7px;
    --shadow-soft: 0 20px 45px -22px rgba(13, 20, 32, 0.45);
    --shadow-card: 0 1px 2px rgba(13, 20, 32, 0.05), 0 1px 0 rgba(13, 20, 32, 0.03);

    /* Sidebar sombre */
    --sidebar-w: 264px;
    --sidebar-bg: #0d1420;
    --sidebar-bg-hover: #182231;
    --sidebar-text: #c7ccd6;
    --sidebar-text-dim: #6b7386;
    --sidebar-active-bg: rgba(99, 102, 241, 0.18);
    --sidebar-line: rgba(255, 255, 255, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-body);
    background: var(--paper-dim);
    color: var(--ink-text);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; color: var(--ink); letter-spacing: -0.01em; }
code { font-family: var(--font-mono); }
::selection { background: rgba(99, 102, 241, 0.2); }

/* ===== Shell ===== */
.adm-shell { display: flex; min-height: 100vh; }

/* ===== Sidebar (sombre) ===== */
.adm-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    z-index: 40;
}
.adm-sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 20px; border-bottom: 1px solid var(--sidebar-line);
}
.adm-sidebar-logo {
    width: 32px; height: 32px; border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.9rem;
    flex-shrink: 0;
}
.adm-sidebar-brand-text { font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; color: #f2f4f7; }
.adm-sidebar-brand-text strong { color: var(--primary); font-weight: 700; }

.adm-sidebar-nav { padding: 12px 10px 24px; flex: 1; }
.adm-nav-section {
    font-family: var(--font-mono);
    font-size: 0.64rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em;
    color: var(--sidebar-text-dim); padding: 16px 10px 6px;
}
.adm-nav-section:first-child { padding-top: 4px; }
.adm-nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    font-size: 0.86rem; font-weight: 500; color: var(--sidebar-text);
    transition: background 0.15s, color 0.15s;
    position: relative;
}
.adm-nav-link i { width: 16px; text-align: center; color: var(--sidebar-text-dim); font-size: 0.85rem; transition: color 0.15s; }
.adm-nav-link:hover { background: var(--sidebar-bg-hover); color: #f2f4f7; }
.adm-nav-link.active { background: var(--sidebar-active-bg); color: #ffffff; font-weight: 600; }
.adm-nav-link.active i { color: var(--primary); }
.adm-nav-count {
    margin-left: auto; font-family: var(--font-mono); font-size: 0.68rem; font-weight: 700;
    background: var(--danger); color: #fff; border-radius: 999px; padding: 1px 6px; min-width: 18px; text-align: center;
}

/* ===== Main / Topbar ===== */
.adm-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.adm-topbar {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 28px; background: var(--paper); border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 30;
}
.adm-topbar-title { font-size: 1.05rem; flex: 1; }
.adm-sidebar-toggle {
    display: none; width: 34px; height: 34px; border-radius: var(--radius-sm);
    border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer;
}
.adm-topbar-actions { display: flex; align-items: center; gap: 14px; }
.adm-topbar-search { position: relative; width: 340px; flex-shrink: 1; min-width: 160px; }
.adm-topbar-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.78rem; pointer-events: none; }
.adm-topbar-search input { padding: 7px 12px 7px 32px; font-size: 0.82rem; width: 100%; }
.adm-admin-chip { display: flex; align-items: center; gap: 10px; }
.adm-admin-avatar {
    width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
    background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem; font-family: var(--font-display); flex-shrink: 0;
}
.adm-admin-chip-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.15; }
.adm-admin-chip-text strong { font-size: 0.8rem; font-weight: 600; }
.adm-admin-chip-text span { font-size: 0.72rem; color: var(--muted); }
.adm-logout-btn {
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--line); color: var(--danger); transition: background 0.15s, border-color 0.15s;
}
.adm-logout-btn:hover { background: var(--danger-dim); border-color: var(--danger); }

.adm-content { padding: 24px 28px 60px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ===== Page intro ===== */
.adm-page-intro { margin-bottom: 20px; }
.adm-page-intro p { color: var(--muted); font-size: 0.88rem; margin: 5px 0 0; }

/* ===== Compteur "live" (ex: clients en temps réel) ===== */
.adm-live-hero { text-align: center; padding: 30px 20px; }
.adm-live-hero-label {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    font-family: var(--font-mono); font-size: 0.74rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 10px;
}
.adm-live-dot {
    width: 8px; height: 8px; border-radius: 50%; background: var(--primary);
    box-shadow: 0 0 0 rgba(99, 102, 241, 0.5);
    animation: admLivePulse 1.6s ease-out infinite;
}
@keyframes admLivePulse {
    0%   { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.55); }
    70%  { box-shadow: 0 0 0 9px rgba(99, 102, 241, 0); }
    100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}
.adm-live-hero-value {
    font-family: var(--font-mono); font-weight: 700; font-size: 4.2rem; line-height: 1;
    color: var(--ink); font-variant-numeric: tabular-nums;
}
@media (max-width: 600px) { .adm-live-hero-value { font-size: 3rem; } }

/* ===== Stat cards ===== */
.stats-grid, .adm-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card, .adm-stat-card {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 18px; box-shadow: var(--shadow-card);
}
.stat-card-label, .adm-stat-card .label { font-size: 0.76rem; color: var(--muted); font-weight: 500; margin-bottom: 8px; display: flex; align-items: center; gap: 7px; }
.stat-card-value, .adm-stat-card .value { font-family: var(--font-mono); font-weight: 600; font-size: 1.5rem; color: var(--ink); font-variant-numeric: tabular-nums; }
.stat-card-sub, .adm-stat-card .delta { font-size: 0.76rem; margin-top: 6px; color: var(--muted); font-family: var(--font-mono); }
.stat-card-sub.up, .delta.up { color: var(--primary-dark); }
.stat-card-sub.down, .delta.down { color: var(--danger); }

/* ===== Cards / panels ===== */
.card, .adm-card {
    background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
    padding: 20px; box-shadow: var(--shadow-card); margin-bottom: 20px;
}
.card h2, .adm-card h3 { font-size: 0.94rem; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.card h2 i, .adm-card h3 i { color: var(--muted); font-size: 0.85rem; }

/* ===== Toolbar ===== */
.adm-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.adm-search { position: relative; flex: 1; min-width: 220px; }
.adm-search i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.82rem; pointer-events: none; }
.adm-search input { padding-left: 38px; width: 100%; }

/* ===== Formulaires ===== */
.adm-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.adm-field label { font-size: 0.8rem; font-weight: 600; color: var(--ink); }
.adm-field .hint { font-size: 0.74rem; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="tel"], input[type="color"], input[type="file"],
select, textarea, .form-control, .form-select {
    font-family: var(--font-body); font-size: 0.88rem;
    padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
    background: #fff; color: var(--ink-text);
}
input:focus, select:focus, textarea:focus, .form-control:focus, .form-select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.14);
}
label { font-size: 0.85rem; }
.form-control-sm, .form-select-sm { padding: 6px 10px; font-size: 0.8rem; }

/* ===== Boutons ===== */
.btn, .adm-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 9px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer;
    font-family: var(--font-body); font-weight: 600; font-size: 0.83rem;
    transition: background 0.15s, box-shadow 0.15s, opacity 0.15s, border-color 0.15s;
}
.btn:disabled, .adm-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary, .adm-btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled), .adm-btn-primary:hover:not(:disabled) { background: var(--primary-dark); color: #fff; }
.btn-success { background: #12b76a; color: #fff; }
.btn-success:hover { background: #0d8a52; color: #fff; }
.btn-danger, .adm-btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled), .adm-btn-danger:hover:not(:disabled) { background: #b6251b; color: #fff; }
.btn-outline-primary { background: var(--paper); color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--paper-tint); }
.btn-outline-danger { background: var(--paper); color: var(--danger); border-color: rgba(217,45,32,0.4); }
.btn-outline-danger:hover { background: var(--danger-dim); }
.btn-outline-success { background: var(--paper); color: #0d8a52; border-color: rgba(18,183,106,0.4); }
.btn-outline-success:hover { background: #eafaf2; }
.btn-outline-secondary, .adm-btn-ghost { background: var(--paper); color: var(--ink-text); border-color: var(--line-strong); }
.btn-outline-secondary:hover, .adm-btn-ghost:hover:not(:disabled) { background: var(--paper-dim); border-color: var(--muted); }
.btn-sm, .adm-btn-sm { padding: 6px 12px; font-size: 0.76rem; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45408; color: #fff; }

/* ===== Badges de statut ===== */
.badge, .adm-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
    font-family: var(--font-mono);
}
.bg-success, .adm-badge-success { background: #eafaf2 !important; color: #0d8a52 !important; }
.bg-danger, .adm-badge-danger { background: var(--danger-dim) !important; color: #9c2a1f !important; }
.bg-warning, .adm-badge-warning { background: var(--warning-dim) !important; color: #8a4a0a !important; }
.bg-secondary, .adm-badge-neutral { background: var(--paper-dim) !important; color: var(--muted) !important; }
.bg-info-subtle { background: #e8f0fe !important; }
.text-info-emphasis { color: #1a56c4 !important; }
.adm-badge-info { background: #e8f0fe; color: #1a56c4; }
.bg-light { background: var(--paper-dim) !important; }
.text-dark { color: var(--ink-text) !important; }
.border { border: 1px solid var(--line) !important; }

/* ===== Tables ===== */
.table-wrap, .adm-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); }
table, .adm-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
table th, .adm-table th {
    text-align: left; padding: 10px 14px; background: var(--paper-dim);
    font-family: var(--font-mono);
    font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600;
    white-space: nowrap;
}
table td, .adm-table td { padding: 10px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
table tbody tr:hover, .adm-table tbody tr:hover { background: var(--paper-dim); }
.num { font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* ===== Pagination ===== */
.pagination, .adm-pagination { display: flex; align-items: center; gap: 6px; list-style: none; padding: 0; margin-top: 14px; }
.pagination .page-link, .adm-pagination a, .adm-pagination span {
    min-width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 600; color: var(--ink-text);
    font-family: var(--font-mono);
    border: 1px solid var(--line); padding: 0 8px;
}
.pagination .page-link:hover, .adm-pagination a:hover { background: var(--paper-dim); }
.pagination .page-item.disabled .page-link { opacity: 0.4; }
.pagination .page-item.active .page-link, .adm-pagination .current { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ===== Alerts ===== */
.alert, .adm-alert { display: flex; align-items: flex-start; gap: 10px; padding: 12px 15px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 0.86rem; margin-bottom: 16px; }
.alert-success, .adm-alert-success { background: #eafaf2; color: #0d8a52; border-color: rgba(18,183,106,0.25); }
.alert-danger, .adm-alert-error { background: var(--danger-dim); color: #8a1f1f; border-color: rgba(217,45,32,0.25); }
.alert-warning { background: var(--warning-dim); color: #8a4a0a; border-color: rgba(220,104,3,0.25); }
.alert-info, .adm-alert-info { background: var(--accent-dim); color: var(--accent); border-color: rgba(42,92,173,0.2); }

/* ===== Modal (bootstrap JS conservé, look adm-* appliqué) ===== */
.modal-content { border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: var(--shadow-soft); }
.modal-header, .modal-footer { border-color: var(--line); }
.modal-title { font-family: var(--font-display); font-size: 1rem; font-weight: 600; }

.adm-modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(13,20,32,0.55);
    z-index: 1000; align-items: center; justify-content: center; padding: 20px;
}
.adm-modal-overlay.open { display: flex; }
.adm-modal { background: #fff; border-radius: var(--radius-lg); padding: 24px; max-width: 440px; width: 100%; box-shadow: var(--shadow-soft); border: 1px solid var(--line); }
.adm-modal h3 { margin-bottom: 10px; font-size: 1rem; }
.adm-modal p { color: var(--muted); font-size: 0.88rem; margin: 0 0 18px; }
.adm-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ===== Chat bubbles (surveillance IA) ===== */
.chat-meta { font-size: 0.74rem; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chat-bubble { padding: 10px 14px; border-radius: var(--radius-md); font-size: 0.86rem; margin-bottom: 6px; max-width: 85%; white-space: pre-wrap; }
.chat-bubble.user { background: var(--paper-dim); color: var(--ink-text); }
.chat-bubble.ai { background: var(--paper-tint); color: var(--primary-dark); margin-left: auto; }

/* ===== Empty state ===== */
.adm-empty-state { text-align: center; padding: 60px 24px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); max-width: 480px; margin: 60px auto; }
.adm-empty-icon { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%; background: var(--paper-dim); color: var(--muted); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; }
.adm-empty-state h2 { font-size: 1.1rem; margin-bottom: 8px; }
.adm-empty-state p { color: var(--muted); font-size: 0.88rem; margin: 0 0 20px; }

/* ===== Toasts ===== */
#admToasts { position: fixed; bottom: 24px; right: 24px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.adm-toast {
    background: var(--ink); color: #fff; padding: 11px 16px; border-radius: var(--radius-sm);
    font-size: 0.83rem; box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: 8px;
    animation: admToastIn 0.2s ease-out;
}
.adm-toast.success { background: var(--primary-dark); }
.adm-toast.error { background: #8a1f1f; }
@keyframes admToastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ===== Login page ===== */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); padding: 20px; }
.login-card { background: #fff; border-radius: var(--radius-lg); padding: 36px 32px; max-width: 380px; width: 100%; box-shadow: var(--shadow-soft); }

/* ===== Responsive ===== */
@media (max-width: 900px) {
    .adm-sidebar {
        position: fixed; left: 0; top: 0; transform: translateX(-100%);
        transition: transform 0.2s ease; box-shadow: var(--shadow-soft);
    }
    .adm-sidebar.open { transform: translateX(0); }
    .adm-sidebar-toggle { display: flex; align-items: center; justify-content: center; }
    .adm-content { padding: 18px 16px 40px; }
    .adm-admin-chip-text { display: none; }
    .adm-topbar-search { display: none; }
}
