/*
 * Shared dark-mode palette for the public area (templates/base/base_public.html
 * and every page inheriting it: FAQ, customer portal, customer chat).
 *
 * Mirrors the proven utility overrides from templates/base/base.html so the
 * public surfaces render with the same readable dark palette as the internal
 * app shell. Loaded unconditionally; every rule is scoped to
 * [data-bs-theme="dark"] so the light theme is untouched.
 */

[data-bs-theme="dark"] {
  /* Backgrounds */
  --bs-body-bg:            #0d1117;
  --bs-body-bg-rgb:        13, 17, 23;
  --bs-card-bg:            #161b22;
  --bs-card-cap-bg:        #1c2128;
  --bs-secondary-bg:       #21262d;
  --bs-tertiary-bg:        #1c2128;

  /* Text */
  --bs-body-color:         #c9d1d9;
  --bs-body-color-rgb:     201, 209, 217;
  --bs-emphasis-color:     #f0f6fc;
  --bs-secondary-color:    rgba(201, 209, 217, .75);
  --bs-tertiary-color:     rgba(201, 209, 217, .5);
  --bs-heading-color:      #e6edf3;

  /* Borders */
  --bs-border-color:       #30363d;
  --bs-border-color-translucent: rgba(240, 246, 252, .1);

  /* Links */
  --bs-link-color:         #58a6ff;
  --bs-link-color-rgb:     88, 166, 255;
  --bs-link-hover-color:   #79c0ff;

  /* Tables */
  --bs-table-border-color: #30363d;
  --bs-table-striped-bg:   rgba(255, 255, 255, .02);
  --bs-table-hover-bg:     rgba(255, 255, 255, .04);

  /* Code */
  --bs-code-color:         #79c0ff;
}

/* ── Surfaces ─────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .bg-white  { background-color: var(--bs-card-bg) !important; }
[data-bs-theme="dark"] .bg-light  { background-color: var(--bs-secondary-bg) !important; color: var(--bs-body-color) !important; }
[data-bs-theme="dark"] .card      { background: var(--bs-card-bg); border-color: var(--bs-border-color); }
[data-bs-theme="dark"] .card-header,
[data-bs-theme="dark"] .card-footer                { background: var(--bs-card-cap-bg) !important; border-color: var(--bs-border-color) !important; }
[data-bs-theme="dark"] .card-header.bg-white,
[data-bs-theme="dark"] .card-footer.bg-white       { background-color: var(--bs-card-cap-bg) !important; }
[data-bs-theme="dark"] .shadow-sm { box-shadow: 0 1px 6px rgba(0, 0, 0, .55) !important; }

/* Text-emphasis utilities that would otherwise stay near-black on dark cards. */
[data-bs-theme="dark"] .text-dark { color: var(--bs-emphasis-color) !important; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .table-light {
  --bs-table-bg:           #1c2128;
  --bs-table-border-color: #30363d;
  --bs-table-color:        #e6edf3;
}
[data-bs-theme="dark"] .table { border-color: #30363d; }
[data-bs-theme="dark"] .table > tbody > tr > td,
[data-bs-theme="dark"] .table > tbody > tr > th { border-color: #21262d; }

/* ── Badges ───────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .badge.bg-success-subtle   { background-color: rgba(63, 185, 80, .18)  !important; color: #56d364 !important; border-color: rgba(63, 185, 80, .4)  !important; }
[data-bs-theme="dark"] .badge.bg-danger-subtle    { background-color: rgba(248, 81, 73, .18)  !important; color: #ff7b72 !important; border-color: rgba(248, 81, 73, .4)  !important; }
[data-bs-theme="dark"] .badge.bg-warning-subtle   { background-color: rgba(187, 128, 9, .22)  !important; color: #e3b341 !important; border-color: rgba(187, 128, 9, .45) !important; }
[data-bs-theme="dark"] .badge.bg-info-subtle      { background-color: rgba(88, 166, 255, .18) !important; color: #79c0ff !important; border-color: rgba(88, 166, 255, .4) !important; }
[data-bs-theme="dark"] .badge.bg-secondary-subtle { background-color: rgba(255, 255, 255, .07) !important; color: #8b949e  !important; border-color: #30363d !important; }
[data-bs-theme="dark"] .badge.bg-light            { background-color: var(--bs-secondary-bg) !important; color: var(--bs-body-color) !important; border-color: var(--bs-border-color) !important; }
[data-bs-theme="dark"] .badge.bg-success          { background-color: #1f6823 !important; color: #eafbea !important; }
[data-bs-theme="dark"] .badge.bg-secondary        { background-color: #21262d !important; color: #8b949e !important; }
[data-bs-theme="dark"] .badge.bg-danger           { background-color: #6e1c1a !important; color: #ffd9d6 !important; }
[data-bs-theme="dark"] .badge.bg-info             { background-color: #1158a8 !important; color: #dceafc !important; }
[data-bs-theme="dark"] .badge.bg-warning          { background-color: #7a5a09 !important; color: #ffe9b0 !important; }
/* Colored badges that carry the .text-dark utility must stay readable. */
[data-bs-theme="dark"] .badge.bg-info.text-dark,
[data-bs-theme="dark"] .badge.bg-warning.text-dark,
[data-bs-theme="dark"] .badge.bg-white.text-dark  { color: #f0f6fc !important; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .alert-info    { background-color: rgba(88, 166, 255, .1); border-color: rgba(88, 166, 255, .25); color: #79c0ff; }
[data-bs-theme="dark"] .alert-success { background-color: rgba(63, 185, 80, .1);  border-color: rgba(63, 185, 80, .25);  color: #56d364; }
[data-bs-theme="dark"] .alert-warning { background-color: rgba(187, 128, 9, .12); border-color: rgba(187, 128, 9, .3);   color: #e3b341; }
[data-bs-theme="dark"] .alert-danger  { background-color: rgba(248, 81, 73, .1);  border-color: rgba(248, 81, 73, .25);  color: #ff7b72; }

/* ── Lists, breadcrumbs, list-groups ──────────────────────────────────────── */
[data-bs-theme="dark"] .list-group-item { background: var(--bs-card-bg); border-color: var(--bs-border-color); color: var(--bs-body-color); }
[data-bs-theme="dark"] .list-group-item-action:hover { background: var(--bs-secondary-bg); color: var(--bs-emphasis-color); }
[data-bs-theme="dark"] .breadcrumb { --bs-breadcrumb-divider-color: var(--bs-tertiary-color); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select    { background-color: #0d1117; border-color: #30363d; color: #c9d1d9; }
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus { background-color: #0d1117; border-color: #58a6ff; color: #e6edf3; box-shadow: 0 0 0 .2rem rgba(88, 166, 255, .2); }
[data-bs-theme="dark"] .form-control::placeholder { color: #484f58; }
[data-bs-theme="dark"] .form-text     { color: #8b949e; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
[data-bs-theme="dark"] .btn-outline-secondary { border-color: #30363d; color: #8b949e; }
[data-bs-theme="dark"] .btn-outline-secondary:hover { background-color: #21262d; border-color: #8b949e; color: #c9d1d9; }
[data-bs-theme="dark"] .btn-outline-primary { border-color: #1f6feb; color: #58a6ff; }
[data-bs-theme="dark"] .btn-outline-primary:hover { background-color: #1f6feb22; }
[data-bs-theme="dark"] .btn-light { background-color: var(--bs-secondary-bg); border-color: var(--bs-border-color); color: var(--bs-body-color); }

/* ── Dropdowns / modals ───────────────────────────────────────────────────── */
[data-bs-theme="dark"] .dropdown-menu  { background-color: #161b22; border-color: #30363d; }
[data-bs-theme="dark"] .dropdown-item  { color: #c9d1d9; }
[data-bs-theme="dark"] .dropdown-item:hover { background-color: #21262d; color: #f0f6fc; }
[data-bs-theme="dark"] .dropdown-divider { border-color: #30363d; }
[data-bs-theme="dark"] .modal-content  { background-color: #161b22; border-color: #30363d; }
[data-bs-theme="dark"] .modal-header   { border-bottom-color: #30363d; }
[data-bs-theme="dark"] .modal-footer   { border-top-color: #30363d; }

/* ── Public customer chat bubbles ─────────────────────────────────────────── */
[data-bs-theme="dark"] .chat-box   { background: var(--bs-tertiary-bg) !important; }
[data-bs-theme="dark"] .msg-agent  { background: var(--bs-card-bg) !important; border-color: var(--bs-border-color) !important; color: var(--bs-body-color) !important; }
[data-bs-theme="dark"] .msg-system { color: var(--bs-secondary-color) !important; }

/* ── FAQ article rich text ────────────────────────────────────────────────── */
[data-bs-theme="dark"] .faq-content pre { background: var(--bs-tertiary-bg); }
[data-bs-theme="dark"] .faq-content th  { background: var(--bs-tertiary-bg); }
[data-bs-theme="dark"] .faq-content th,
[data-bs-theme="dark"] .faq-content td  { border-color: var(--bs-border-color); }
