/* =====================================================================
   CœurInfoTech Pro — thème de l'interface (Bootstrap 5.3, clair / sombre)
   ===================================================================== */
:root {
  --cit-primary: #0d47a1;
  --cit-primary-2: #1565c0;
  --cit-accent: #00a3e0;
  --cit-sidebar-bg: #0b1f3a;
  --cit-sidebar-fg: #c9d6ea;
  --cit-sidebar-muted: #7f93b2;
  --cit-sidebar-active: #1565c0;
  --cit-sidebar-w: 264px;
  --cit-sidebar-w-collapsed: 76px;
  --cit-topbar-h: 62px;
  --cit-body-bg: #f3f6fb;
  --cit-card-bg: #ffffff;
  --cit-border: #e3e9f2;
  --cit-muted: #6b7a90;
  --cit-radius: .85rem;
  --bs-primary: #0d47a1;
  --bs-primary-rgb: 13, 71, 161;
  --bs-link-color: #0d47a1;
  --bs-link-color-rgb: 13, 71, 161;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
[data-bs-theme="dark"] {
  --cit-sidebar-bg: #0a1424;
  --cit-body-bg: #0f1724;
  --cit-card-bg: #152033;
  --cit-border: #24324a;
  --cit-muted: #93a3bb;
  --bs-body-bg: #0f1724;
  --bs-body-color: #dde5f0;
  --bs-border-color: #24324a;
  --bs-secondary-bg: #1b2840;
  --bs-tertiary-bg: #18243a;
  --bs-primary: #4f8ff7;
  --bs-primary-rgb: 79, 143, 247;
  --bs-link-color: #78a9ff;
  --bs-link-color-rgb: 120, 169, 255;
}

html, body { height: 100%; }
body { background: var(--cit-body-bg); font-size: .925rem; }

.btn-primary { --bs-btn-bg: var(--cit-primary); --bs-btn-border-color: var(--cit-primary); --bs-btn-hover-bg: var(--cit-primary-2); --bs-btn-hover-border-color: var(--cit-primary-2); --bs-btn-active-bg: #0a3880; }
[data-bs-theme="dark"] .btn-primary { --bs-btn-bg: #2f6fdc; --bs-btn-border-color: #2f6fdc; --bs-btn-hover-bg: #3b7bea; }
.btn-outline-primary { --bs-btn-color: var(--bs-primary); --bs-btn-border-color: var(--bs-primary); --bs-btn-hover-bg: var(--bs-primary); --bs-btn-hover-border-color: var(--bs-primary); }
.text-primary { color: rgb(var(--bs-primary-rgb)) !important; }
.bg-primary { background-color: rgb(var(--bs-primary-rgb)) !important; }

/* ---------- Structure ---------- */
.cit-sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--cit-sidebar-w); z-index: 1040;
  background: var(--cit-sidebar-bg); color: var(--cit-sidebar-fg);
  display: flex; flex-direction: column; transition: width .2s ease, transform .2s ease;
}
.cit-main { margin-left: var(--cit-sidebar-w); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .2s ease; }
.cit-brand { height: var(--cit-topbar-h); display: flex; align-items: center; gap: .65rem; padding: 0 1.1rem; border-bottom: 1px solid rgba(255,255,255,.07); text-decoration: none; color: #fff; flex-shrink: 0; }
.cit-brand-logo { width: 38px; height: 38px; border-radius: .6rem; background: linear-gradient(135deg, var(--cit-accent), var(--cit-primary-2)); display: grid; place-items: center; font-weight: 800; color: #fff; flex-shrink: 0; overflow: hidden; }
.cit-brand-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.cit-brand-text { line-height: 1.1; white-space: nowrap; }
.cit-brand-text strong { font-size: 1.02rem; letter-spacing: .2px; }
.cit-brand-text small { color: var(--cit-sidebar-muted); font-size: .72rem; }

.cit-nav { overflow-y: auto; padding: .75rem .6rem 1.5rem; flex: 1; scrollbar-width: thin; }
.cit-nav-module { color: var(--cit-sidebar-muted); text-transform: uppercase; font-size: .68rem; letter-spacing: .08em; font-weight: 700; padding: 1rem .75rem .35rem; display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.cit-nav a { display: flex; align-items: center; gap: .75rem; padding: .55rem .75rem; margin: 1px 0; border-radius: .55rem; color: var(--cit-sidebar-fg); text-decoration: none; white-space: nowrap; font-weight: 500; }
.cit-nav a i { font-size: 1.08rem; width: 1.3rem; text-align: center; flex-shrink: 0; }
.cit-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.cit-nav a.active { background: var(--cit-sidebar-active); color: #fff; box-shadow: 0 4px 14px rgba(21,101,192,.35); }

body.sidebar-collapsed .cit-sidebar { width: var(--cit-sidebar-w-collapsed); }
body.sidebar-collapsed .cit-main { margin-left: var(--cit-sidebar-w-collapsed); }
body.sidebar-collapsed .cit-brand-text, body.sidebar-collapsed .cit-nav a span, body.sidebar-collapsed .cit-nav-module span { display: none; }
body.sidebar-collapsed .cit-nav-module { justify-content: center; padding-left: 0; padding-right: 0; }
body.sidebar-collapsed .cit-nav a { justify-content: center; }

.cit-topbar { height: var(--cit-topbar-h); background: var(--cit-card-bg); border-bottom: 1px solid var(--cit-border); display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; position: sticky; top: 0; z-index: 1030; }
.cit-topbar .page-title { font-weight: 650; font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cit-content { padding: 1.4rem; flex: 1; }
.cit-footer { padding: .9rem 1.4rem; color: var(--cit-muted); font-size: .8rem; border-top: 1px solid var(--cit-border); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: linear-gradient(135deg, var(--cit-primary-2), var(--cit-accent)); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .85rem; }
.icon-btn { width: 38px; height: 38px; border-radius: .6rem; display: inline-grid; place-items: center; border: 1px solid var(--cit-border); background: transparent; color: inherit; position: relative; }
.icon-btn:hover { background: var(--bs-tertiary-bg); }
.notif-dot { position: absolute; top: 4px; right: 4px; min-width: 17px; height: 17px; border-radius: 9px; background: #e53935; color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.notif-menu { width: 360px; max-height: 460px; overflow-y: auto; }
.notif-item { white-space: normal; border-left: 3px solid transparent; }
.notif-item.unread { background: rgba(var(--bs-primary-rgb), .06); border-left-color: rgb(var(--bs-primary-rgb)); }

.cit-backdrop { display: none; }
@media (max-width: 991.98px) {
  .cit-sidebar { transform: translateX(-100%); width: var(--cit-sidebar-w) !important; }
  .cit-main { margin-left: 0 !important; }
  body.sidebar-open .cit-sidebar { transform: none; }
  body.sidebar-open .cit-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1035; }
  body.sidebar-collapsed .cit-brand-text, body.sidebar-collapsed .cit-nav a span, body.sidebar-collapsed .cit-nav-module span { display: initial; }
  .cit-content { padding: 1rem; }
  .notif-menu { width: 92vw; }
}

/* ---------- Cartes ---------- */
.card { border: 1px solid var(--cit-border); border-radius: var(--cit-radius); background: var(--cit-card-bg); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--cit-border); padding: .9rem 1.1rem; font-weight: 600; }
.stat-card { padding: 1.05rem 1.1rem; display: flex; gap: .9rem; align-items: center; height: 100%; }
.stat-icon { width: 48px; height: 48px; border-radius: .8rem; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-label { color: var(--cit-muted); font-size: .78rem; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.28rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-sub { font-size: .78rem; color: var(--cit-muted); }
.soft-primary { background: rgba(13,71,161,.1); color: #0d47a1; }
.soft-success { background: rgba(25,135,84,.12); color: #198754; }
.soft-danger { background: rgba(220,53,69,.12); color: #dc3545; }
.soft-warning { background: rgba(255,153,0,.15); color: #c77700; }
.soft-info { background: rgba(0,163,224,.13); color: #0088bb; }
.soft-dark { background: rgba(33,37,41,.08); color: #343a40; }
[data-bs-theme="dark"] .soft-primary { color: #78a9ff; background: rgba(79,143,247,.15); }
[data-bs-theme="dark"] .soft-dark { color: #c8d2e0; background: rgba(255,255,255,.08); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-muted-2 { color: var(--cit-muted) !important; }

/* ---------- Tableaux ---------- */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: .62rem .7rem; border-bottom-color: var(--cit-border); }
.table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--cit-muted); font-weight: 650; background: var(--bs-tertiary-bg); white-space: nowrap; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: rgba(13,71,161,.035); }
div.dt-container .dt-search input, div.dt-container .dt-length select { border-radius: .5rem; }
div.dt-container { padding: .25rem .2rem; }
div.dt-container .dt-paging .page-link { border-radius: .45rem !important; margin: 0 2px; }
.dt-actions { white-space: nowrap; text-align: right; }
.dt-actions .btn { padding: .2rem .45rem; }
.table tfoot td { font-weight: 700; background: var(--bs-tertiary-bg); }

/* ---------- Formulaires / modales ---------- */
.form-label { font-weight: 550; font-size: .83rem; margin-bottom: .3rem; }
.form-control, .form-select { border-radius: .55rem; }
.modal-content { border: 0; border-radius: 1rem; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-header { border-bottom: 1px solid var(--cit-border); }
.modal-footer { border-top: 1px solid var(--cit-border); }
.required::after { content: " *"; color: #dc3545; }
.select2-container--bootstrap-5 .select2-selection { border-radius: .55rem; min-height: calc(1.5em + .75rem + 2px); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown { background-color: var(--bs-body-bg); color: var(--bs-body-color); border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered { color: var(--bs-body-color); }
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-results__options .select2-results__option.select2-results__option--highlighted { background: #2f6fdc; }
.filters-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; }
.filters-bar .form-control, .filters-bar .form-select { min-width: 140px; }
.lines-table input { min-width: 80px; }
.lines-table td { vertical-align: middle; }
.nav-tabs .nav-link { font-weight: 550; }
.nav-pills .nav-link.active { background: var(--cit-primary); }

/* ---------- Authentification ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero { background: radial-gradient(1200px 600px at 10% 10%, #1e88e5 0%, transparent 60%), linear-gradient(135deg, #0b1f3a 0%, #0d47a1 100%); color: #fff; padding: 3.5rem; display: flex; flex-direction: column; justify-content: space-between; }
.auth-hero h1 { font-weight: 800; font-size: 2.3rem; }
.auth-feature { display: flex; gap: .8rem; align-items: start; margin-bottom: 1rem; color: #d7e5ff; }
.auth-feature i { font-size: 1.3rem; color: #7cc4ff; }
.auth-form { display: grid; place-items: center; padding: 2rem; background: var(--cit-card-bg); }
.auth-card { width: 100%; max-width: 400px; }
@media (max-width: 991.98px) { .auth-wrap { grid-template-columns: 1fr; } .auth-hero { display: none; } }

/* ---------- Divers ---------- */
.timeline { list-style: none; padding-left: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 .9rem 1.4rem; border-left: 2px solid var(--cit-border); margin-left: .4rem; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: .25rem; width: 10px; height: 10px; border-radius: 50%; background: rgb(var(--bs-primary-rgb)); }
.chart-box { position: relative; height: 300px; }
.loading-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.6); z-index: 5; border-radius: var(--cit-radius); }
[data-bs-theme="dark"] .loading-overlay { background: rgba(15,23,36,.6); }
.perm-grid .form-check { padding: .35rem .5rem .35rem 2rem; border-radius: .45rem; }
.perm-grid .form-check:hover { background: var(--bs-tertiary-bg); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--cit-muted); }
.empty-state i { font-size: 2.4rem; display: block; margin-bottom: .5rem; opacity: .6; }
.badge { font-weight: 600; letter-spacing: .01em; }
.swal2-popup { border-radius: 1rem !important; }
[data-bs-theme="dark"] .swal2-popup { background: #152033 !important; color: #dde5f0 !important; }
@media print { .cit-sidebar, .cit-topbar, .cit-footer, .no-print { display: none !important; } .cit-main { margin: 0 !important; } }
a.icon-btn { color: inherit; text-decoration: none; display: inline-grid; place-items: center; }
