/* Mode sombre — administration & espace connecté (actif avec body.theme-dark) */

html[data-bs-theme="dark"] {
  color-scheme: dark;
}

html[data-bs-theme="dark"],
body.admin-body.theme-dark,
body.page-app.theme-dark {
  --tblr-body-bg: #0d1117;
  --tblr-bg-surface: #161b22;
  --tblr-bg-surface-secondary: #21262d;
  --tblr-body-color: #e6edf3;
  --tblr-secondary-color: #9da7b3;
  --tblr-tertiary-color: #7d8590;
  --tblr-border-color: #30363d;
  --tblr-border-color-translucent: rgba(240, 246, 252, 0.1);
  --tblr-emphasis-color: #f0f6fc;
  --tblr-link-color: #7ee787;
  --tblr-link-hover-color: #aff5b4;
  --tblr-card-bg: #161b22;
  --tblr-card-color: #e6edf3;

  --uk-navy: #e6edf3;

  --color-bg: #0d1117;
  --color-bg-alt: #161b22;
  --color-bg-soft: #21262d;
  --color-surface: #161b22;
  --color-border: #30363d;
  --color-border-strong: #484f58;
  --color-text: #e6edf3;
  --color-text-muted: #9da7b3;
  --color-navy: #e6edf3;
  --color-navy-dark: #c9d1d9;
  --color-secondary: #8b949e;
  --color-primary-tint: #1a3d2e;
  --color-accent-tint: #3d3010;
  --color-warning-tint: #3d2218;
  --color-error-tint: #3d1820;
  --color-info-tint: #163634;
}

body.admin-body.theme-dark,
body.page-app.theme-dark {
  background: var(--tblr-body-bg);
  color: var(--tblr-body-color);
}

body.admin-body.theme-dark .page-wrapper,
body.page-app.theme-dark .page-wrapper {
  background: var(--tblr-body-bg);
}

/* ---------- Sidebar ---------- */
body.theme-dark .uk-sidebar {
  --tblr-navbar-bg: #010409;
  background-color: #010409;
  border-right: 1px solid #30363d;
  color: rgba(230, 237, 243, 0.82);
}

body.theme-dark .uk-sidebar__logo {
  background: #21262d;
  box-shadow: inset 0 0 0 1px rgba(217, 162, 27, 0.35);
}

body.theme-dark .uk-sidebar .nav-section-title {
  color: rgba(230, 237, 243, 0.45);
}

body.theme-dark .uk-sidebar .navbar-nav .nav-link {
  color: rgba(230, 237, 243, 0.82);
}

body.theme-dark .uk-sidebar .navbar-nav .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

body.theme-dark .uk-sidebar .nav-item.active > .nav-link {
  color: #fff;
  background: rgba(217, 162, 27, 0.22);
}

body.theme-dark .uk-sidebar .nav-link .badge {
  background: #e3b341 !important;
  color: #0d1117 !important;
  border-color: #010409;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

body.theme-dark .uk-sidebar .nav-link .badge {
  box-shadow: 0 0 0 2px #010409;
  background: #f0c14d !important;
  color: #0a0f16 !important;
}

body.theme-dark .uk-sidebar__footer {
  border-top-color: rgba(255, 255, 255, 0.1);
}

/* ---------- Barre supérieure ---------- */
body.theme-dark .uk-topbar {
  background: #161b22;
  border-bottom-color: #30363d;
}

body.theme-dark .uk-topbar__kicker {
  color: #7ee787;
}

body.theme-dark .uk-topbar__title,
body.theme-dark .uk-topbar__crumb .uk-topbar__title::before {
  color: #e6edf3;
}

body.theme-dark .uk-topbar__date,
body.theme-dark .uk-topbar__profile,
body.theme-dark .uk-topbar__profile-text strong {
  color: #e6edf3;
}

body.theme-dark .uk-topbar__profile-text small {
  color: #9da7b3;
}

body.theme-dark .uk-topbar__profile:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

body.theme-dark .uk-topbar__logout {
  color: #7ee787;
}

body.theme-dark .uk-topbar__logout:hover {
  color: #aff5b4;
  background: rgba(126, 231, 135, 0.12);
}

body.theme-dark .uk-topbar__date,
body.theme-dark .uk-topbar__account {
  border-left-color: #30363d;
}

/* ---------- Titres & stats ---------- */
body.theme-dark .uk-page-head__title,
body.theme-dark .uk-page-head__desc,
body.theme-dark .uk-stat__value,
body.theme-dark .card-title,
body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3,
body.theme-dark h4,
body.theme-dark h5,
body.theme-dark h6 {
  color: #e6edf3;
}

body.theme-dark .uk-page-head__desc,
body.theme-dark .text-secondary,
body.theme-dark .text-muted {
  color: #9da7b3 !important;
}

body.theme-dark .text-dark {
  color: #e6edf3 !important;
}

body.theme-dark .uk-stat__icon--primary,
body.theme-dark .uk-stat__icon--success {
  background: #1a3d2e;
  color: #7ee787;
}

body.theme-dark .uk-stat__icon--warning {
  background: #3d3010;
  color: #f0c14d;
}

body.theme-dark .uk-stat__icon--info {
  background: #163634;
  color: #6ee7df;
}

body.theme-dark .uk-stat__icon--danger {
  background: #3d1820;
  color: #ff8ba7;
}

body.theme-dark .uk-stat__icon--secondary {
  background: #21262d;
  color: #c9d1d9;
}

body.theme-dark .uk-empty__icon {
  background: #1a3d2e;
  color: #7ee787;
}

body.theme-dark .uk-empty p {
  color: #9da7b3;
}

/* ---------- Cartes, listes, modales ---------- */
body.theme-dark .card {
  background: var(--tblr-card-bg);
  border-color: #30363d;
  color: #e6edf3;
}

body.theme-dark .card-header,
body.theme-dark .card-footer {
  background: transparent;
  border-color: #30363d;
  color: #e6edf3;
}

body.theme-dark .list-group-item {
  background: #161b22;
  border-color: #30363d;
  color: #e6edf3;
}

body.theme-dark .list-group-item-action:hover,
body.theme-dark .list-group-item-action:focus {
  background: #21262d;
  color: #fff;
}

body.theme-dark .list-group-item.active {
  background: #1a3d2e;
  border-color: #30363d;
  color: #aff5b4;
}

body.theme-dark .dropdown-menu {
  background: #161b22;
  border-color: #30363d;
  color: #e6edf3;
}

body.theme-dark .dropdown-item {
  color: #e6edf3;
}

body.theme-dark .dropdown-item:hover,
body.theme-dark .dropdown-item:focus {
  background: #21262d;
  color: #fff;
}

body.theme-dark .modal-content {
  background: #161b22;
  border-color: #30363d;
  color: #e6edf3;
}

body.theme-dark .modal-header,
body.theme-dark .modal-footer {
  border-color: #30363d;
}

body.theme-dark .btn-close {
  filter: invert(1) grayscale(1);
  opacity: 0.75;
}

/* ---------- Tableaux ---------- */
body.theme-dark .table {
  --tblr-table-color: #e6edf3;
  --tblr-table-bg: transparent;
  --tblr-table-border-color: #30363d;
  color: #e6edf3;
}

body.theme-dark .table > :not(caption) > * > * {
  border-bottom-color: #30363d;
  color: #e6edf3;
  background-color: transparent;
}

body.theme-dark .table-light,
body.theme-dark .table thead.table-light th {
  --tblr-table-bg: #21262d;
  --tblr-table-color: #e6edf3;
  background: #21262d !important;
  color: #e6edf3 !important;
  border-color: #30363d !important;
}

body.theme-dark .table-hover > tbody > tr:hover > * {
  background: #21262d;
  color: #fff;
}

body.theme-dark .table-active,
body.theme-dark .table-active > *,
body.theme-dark tr.table-active > td {
  background: #1f2937 !important;
  color: #fff !important;
}

body.theme-dark .table td code,
body.theme-dark code {
  background: #21262d;
  color: #ff9bce;
  border: 1px solid #30363d;
}

/* ---------- Formulaires ---------- */
body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark .form-check-input,
body.theme-dark .input-group-text,
body.theme-dark .page-app .form-group input,
body.theme-dark .page-app .form-group select,
body.theme-dark .page-app .form-group textarea {
  background: #0d1117;
  border-color: #484f58;
  color: #e6edf3;
}

body.theme-dark .form-control:focus,
body.theme-dark .form-select:focus,
body.theme-dark .page-app .form-group input:focus,
body.theme-dark .page-app .form-group select:focus,
body.theme-dark .page-app .form-group textarea:focus {
  background: #0d1117;
  border-color: #7ee787;
  color: #e6edf3;
  box-shadow: 0 0 0 0.2rem rgba(126, 231, 135, 0.15);
}

body.theme-dark .form-control::placeholder {
  color: #7d8590;
}

body.theme-dark .form-label,
body.theme-dark label {
  color: #c9d1d9;
}

body.theme-dark .form-text {
  color: #9da7b3;
}

/* ---------- Boutons outline ---------- */
body.theme-dark .btn-outline-secondary {
  color: #e6edf3;
  border-color: #484f58;
}

body.theme-dark .btn-outline-secondary:hover {
  background: #21262d;
  color: #fff;
  border-color: #7d8590;
}

body.theme-dark .btn-outline-primary {
  color: #7ee787;
  border-color: #3d8f58;
}

body.theme-dark .btn-outline-primary:hover {
  background: #1a3d2e;
  color: #aff5b4;
}

body.theme-dark .btn-link {
  color: #7ee787;
}

/* ---------- Alertes (contraste lisible) ---------- */
body.theme-dark .alert {
  border-width: 1px;
}

body.theme-dark .alert-success {
  background: #1a3d2e;
  border-color: #3d8f58;
  color: #aff5b4;
}

body.theme-dark .alert-danger,
body.theme-dark .alert-error {
  background: #3d1820;
  border-color: #9c2a3a;
  color: #ffb4c0;
}

body.theme-dark .alert-warning {
  background: #3d3010;
  border-color: #a16207;
  color: #fde68a;
}

body.theme-dark .alert-info {
  background: #163634;
  border-color: #0f766e;
  color: #99f6e4;
}

body.theme-dark .alert .btn-close {
  filter: invert(1) grayscale(1);
}

/* ---------- Badges & utilitaires Bootstrap ---------- */
body.theme-dark .badge.text-bg-secondary,
body.theme-dark .bg-secondary-lt {
  background: #21262d !important;
  color: #e6edf3 !important;
}

body.theme-dark .bg-body-tertiary,
body.theme-dark .bg-light {
  background: #21262d !important;
  color: #e6edf3 !important;
}

body.theme-dark .bg-white {
  background: #161b22 !important;
  color: #e6edf3 !important;
}

body.theme-dark .border,
body.theme-dark .border-top,
body.theme-dark .border-bottom {
  border-color: #30363d !important;
}

body.theme-dark .text-bg-primary {
  background: #1a3d2e !important;
  color: #aff5b4 !important;
}

body.theme-dark a:not(.btn):not(.nav-link):not(.dropdown-item) {
  color: #7ee787;
}

body.theme-dark a:not(.btn):not(.nav-link):not(.dropdown-item):hover {
  color: #aff5b4;
}

/* ---------- Navigation admin (onglets, paramètres) ---------- */
body.theme-dark .uk-section-nav .nav-link {
  color: #e6edf3;
  background: #161b22;
  border-color: #30363d;
}

body.theme-dark .uk-section-nav .nav-link:hover {
  background: #21262d;
  color: #aff5b4;
}

body.theme-dark .uk-section-nav .nav-link.active {
  background: #1a3d2e;
  border-color: #3d8f58;
  color: #aff5b4;
}

body.theme-dark .settings-nav {
  border-color: #30363d;
  box-shadow: none;
}

body.theme-dark .settings-nav__section {
  color: #8b949e;
  border-top-color: #30363d;
}

body.theme-dark .settings-nav .nav-link {
  color: #e6edf3;
}

body.theme-dark .settings-nav .nav-link:hover {
  background: #21262d;
  color: #aff5b4;
}

body.theme-dark .settings-nav .nav-link .settings-nav__count {
  background: rgba(255, 255, 255, 0.1);
  color: #c9d1d9;
}

body.theme-dark .settings-nav .nav-link.active {
  background: #1a3d2e;
  color: #aff5b4;
}

body.theme-dark .settings-nav .nav-link.active .settings-nav__count {
  background: rgba(175, 245, 180, 0.2);
  color: #aff5b4;
}

body.theme-dark .files-sidebar .list-group-item.active {
  background: #1a3d2e;
  color: #aff5b4;
}

body.theme-dark .folder-item:hover {
  background: #21262d;
}

body.theme-dark .uk-perm--yes {
  background: #1a3d2e;
  color: #aff5b4;
}

body.theme-dark .uk-perm--no {
  background: #21262d;
  color: #9da7b3;
}

body.theme-dark .save-block__step {
  color: #7ee787;
}

/* ---------- Page certificats émis ---------- */
body.theme-dark.page-certificates {
  background: #0d1117;
}

body.theme-dark.page-certificates .uk-page-head__title,
body.theme-dark.page-certificates .form-label {
  color: #e6edf3;
}

body.theme-dark.page-certificates .card {
  border-color: #30363d;
  box-shadow: none;
}

body.theme-dark.page-certificates .card-header {
  background: #21262d;
  border-bottom: 1px solid #30363d;
}

body.theme-dark.page-certificates .card-header .card-title {
  color: #e6edf3;
}

body.theme-dark.page-certificates .table tbody td {
  background: #161b22;
  color: #e6edf3;
}

body.theme-dark.page-certificates .table tbody tr:nth-child(even) td {
  background: #0d1117;
}

body.theme-dark.page-certificates .table.table-hover tbody tr:hover td {
  background: #21262d;
}

body.theme-dark.page-certificates .table thead.table-light th {
  background: #21262d !important;
  color: #e6edf3 !important;
  border-bottom-color: #484f58 !important;
}

body.theme-dark.page-certificates code {
  background: #21262d;
  color: #ff9bce;
}

/* ---------- Demandes (variables --color-*) ---------- */
body.theme-dark .demande-detail,
body.theme-dark .demande-file-card,
body.theme-dark .demande-inbox-row {
  color: var(--color-text);
}

body.theme-dark .demande-detail__comment-inline,
body.theme-dark .demande-file-card__meta {
  color: var(--color-text-muted);
}

body.theme-dark .demande-status-pill {
  border: 1px solid #484f58;
}

/* ---------- Pied de page ---------- */
body.theme-dark .footer.footer-transparent {
  background: transparent;
  color: #9da7b3;
}

body.theme-dark .footer.footer-transparent .text-secondary {
  color: #9da7b3 !important;
}

/* ---------- Notifications dropdown ---------- */
body.theme-dark .app-notifications__menu .list-group-item {
  background: #161b22;
  color: #e6edf3;
}

body.theme-dark .app-notifications__menu .border-bottom {
  border-color: #30363d !important;
}

/* ---------- Demandes (surcharges ciblées) ---------- */
body.theme-dark .demande-inbox-search.search-form,
body.theme-dark .demande-list-panel,
body.theme-dark .demande-detail {
  background: var(--color-bg-soft);
  border-color: var(--color-border);
  box-shadow: none;
}

body.theme-dark .demande-list-panel__head {
  background: var(--color-bg-alt);
  border-bottom-color: var(--color-border);
}

body.theme-dark .demande-inbox-search .search-group input[type="search"] {
  background: #0d1117;
  border-color: #484f58;
  color: #e6edf3;
}

body.theme-dark .demande-inbox-table thead th {
  background: #21262d;
  color: #e6edf3;
  border-color: #30363d;
}

body.theme-dark .demande-inbox-table tbody td {
  background: #161b22;
  color: #e6edf3;
  border-color: #30363d;
}

body.theme-dark .demande-inbox-table tbody tr:hover td {
  background: #21262d;
}

body.theme-dark .demande-file-card {
  background: var(--color-bg-soft);
  border-color: var(--color-border);
}

body.theme-dark .demande-detail__top h2,
body.theme-dark .demande-detail__ref {
  color: #e6edf3;
}

body.theme-dark .demande-btn--ghost {
  color: #c9d1d9;
  border-color: #484f58;
}

body.theme-dark .demande-btn--ghost:hover {
  background: #21262d;
  color: #fff;
}

body.theme-dark .pagination .page-link {
  background: #161b22;
  border-color: #30363d;
  color: #e6edf3;
}

body.theme-dark .pagination .page-link:hover {
  background: #21262d;
  color: #fff;
}

body.theme-dark .pagination .page-item.active .page-link {
  background: #1a3d2e;
  border-color: #3d8f58;
  color: #aff5b4;
}

body.theme-dark .pagination .page-item.disabled .page-link {
  background: #0d1117;
  color: #7d8590;
}
