/* admin dark mode, colours from the ui2.css palette, scoped to [data-bs-theme="dark"] */

/* picker + dark mode bar, fixed in the corner */
.admin-prefs {
  position: fixed; bottom: 1rem; inset-inline-end: 1rem; z-index: 1040;
  display: flex; align-items: center; gap: .5rem;
  padding: .4rem .6rem; border-radius: 999px;
  background: var(--ui-navy); border: 1px solid var(--ui-gold);
  box-shadow: var(--ui-sh-2);
}
.admin-prefs #uiLangSlot { display: inline-flex; }
.admin-prefs #uiLang { width: auto; min-width: 7.5rem; }
.admin-prefs .theme-toggle { border: 1px solid var(--ui-on-navy); color: white; cursor: pointer; }
.admin-prefs .theme-toggle:hover { background: rgba(255, 255, 255, .15); color: white; }
@media (max-width: 991.98px) {
  .admin-prefs { bottom: .5rem; inset-inline-end: .5rem; gap: .25rem; padding: .25rem .35rem; }
  .admin-prefs #uiLang { min-width: 0; font-size: .8rem; padding-block: .15rem; }
  .admin-prefs .theme-label { display: none; }
  .admin-prefs .theme-toggle i { margin: 0 !important; }
  body { padding-bottom: 4rem; }
}
@media print { .admin-prefs { display: none !important; } }

[data-bs-theme="dark"] body.bg-light { background-color: var(--ui-bg) !important; color: var(--ui-ink); }
[data-bs-theme="dark"] .admin-content { color: var(--ui-ink); }

[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .card-body,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .list-group-item,
[data-bs-theme="dark"] .dropdown-menu {
  background: var(--ui-card);
  color: var(--ui-ink);
  border-color: var(--ui-line);
}
[data-bs-theme="dark"] .card-header { background: var(--ui-head); color: var(--ui-ink); border-color: var(--ui-line); }

[data-bs-theme="dark"] h1, [data-bs-theme="dark"] h2, [data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4, [data-bs-theme="dark"] h5, [data-bs-theme="dark"] h6 { color: var(--ui-ink); }
[data-bs-theme="dark"] .text-muted { color: var(--ui-muted) !important; }

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
  background-color: var(--ui-field);
  color: var(--ui-ink);
  border-color: var(--ui-line);
}
[data-bs-theme="dark"] .form-control::placeholder { color: var(--ui-muted); }
[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly],
[data-bs-theme="dark"] #imageFile:hover { background-color: var(--ui-head); }
[data-bs-theme="dark"] body:not(.can-product-edit) #productTable .form-control { background: var(--ui-head); }

[data-bs-theme="dark"] .table { --bs-table-bg: transparent; --bs-table-color: var(--ui-ink); --bs-table-border-color: var(--ui-line); color: var(--ui-ink); }
[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .table-light > th,
[data-bs-theme="dark"] .table-light > td,
[data-bs-theme="dark"] .table > :not(caption) > .table-light > * {
  --bs-table-bg: var(--ui-head);
  --bs-table-color: var(--ui-ink);
  background-color: var(--ui-head);
  color: var(--ui-ink);
}
[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-bg-type: var(--ui-sand); color: var(--ui-ink); }
[data-bs-theme="dark"] .table-hover > tbody > tr:hover > * { --bs-table-bg-state: var(--ui-sand); color: var(--ui-ink); }

/* Order detail page (invoice) */
[data-bs-theme="dark"] .invoice { background: var(--ui-card); border-color: var(--ui-line); box-shadow: var(--ui-sh-1); }
[data-bs-theme="dark"] .invoice-block h6,
[data-bs-theme="dark"] .invoice-footer { color: var(--ui-muted); }
[data-bs-theme="dark"] .invoice-footer { background: var(--ui-head); border-top-color: var(--ui-line); }

/* Light badges keep dark text so they stay readable */
[data-bs-theme="dark"] .badge.text-dark,
[data-bs-theme="dark"] .badge.bg-light { color: var(--ui-navy) !important; }
[data-bs-theme="dark"] .badge.bg-light.text-dark { background-color: var(--ui-warn-soft) !important; color: var(--ui-ink) !important; border-color: var(--ui-gold) !important; }
[data-bs-theme="dark"] .bg-light:not(body):not(.badge) { background-color: var(--ui-sand) !important; color: var(--ui-ink); }
[data-bs-theme="dark"] .gallery-editor .bg-white,
[data-bs-theme="dark"] .bg-white { background-color: var(--ui-card) !important; color: var(--ui-ink); }
[data-bs-theme="dark"] .invalid-feedback { color: var(--ui-bad); }
[data-bs-theme="dark"] .form-control.is-invalid { border-color: var(--ui-bad); }
[data-bs-theme="dark"] .alert { border-color: var(--ui-line); }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

@media print {
  [data-bs-theme="dark"] body.bg-light { background-color: white !important; color: black; }
}

/* Right-to-left (Arabic): the sidebar marker moves to the other edge. */
[dir="rtl"] .admin-sidebar .nav-link { border-left: 0; border-right: 3px solid transparent; }
[dir="rtl"] .admin-sidebar .nav-link:hover,
[dir="rtl"] .admin-sidebar .nav-link.active { border-right-color: white; }
