/* =============================================
   Townhall Inventory — Custom Theme
   Slate / Blue-Gray palette · Light + Dark
   ============================================= */

/* ---------- Custom Properties ---------- */

:root,
[data-bs-theme="light"] {
  --th-primary: #4f6f8f;
  --th-primary-rgb: 79, 111, 143;
  --th-primary-dark: #3d5a73;

  --bs-primary: var(--th-primary);
  --bs-primary-rgb: var(--th-primary-rgb);
  --bs-link-color: var(--th-primary-dark);
  --bs-link-hover-color: var(--th-primary);

  --th-body-bg: #eef1f5;
  --th-card-bg: #ffffff;
  --th-card-cap-bg: #f6f7f9;
  --th-table-striped-bg: #f5f6f9;
  --th-table-hover-bg: #eaf0f5;
  --th-border-color: #dde1e7;
  --th-emphasis-color: #1f2a36;
  --th-secondary-color: #6c757d;

  --bs-body-bg: var(--th-body-bg);
  --bs-body-bg-rgb: 238, 241, 245;
  --bs-card-bg: var(--th-card-bg);
  --bs-card-cap-bg: var(--th-card-cap-bg);
  --bs-card-border-color: var(--th-border-color);
  --bs-table-striped-bg: var(--th-table-striped-bg);
  --bs-table-hover-bg: var(--th-table-hover-bg);
  --bs-border-color: var(--th-border-color);
  --bs-emphasis-color: var(--th-emphasis-color);
  --bs-heading-color: var(--th-emphasis-color);
  --bs-secondary-color: var(--th-secondary-color);
}

[data-bs-theme="dark"] {
  --th-primary: #7ea8cc;
  --th-primary-rgb: 126, 168, 204;
  --th-primary-dark: #98c0dd;

  --bs-primary: var(--th-primary);
  --bs-primary-rgb: var(--th-primary-rgb);
  --bs-link-color: var(--th-primary);
  --bs-link-hover-color: var(--th-primary-dark);

  --th-body-bg: #15181d;
  --th-card-bg: #1c1f25;
  --th-card-cap-bg: #22252c;
  --th-table-striped-bg: #1e2128;
  --th-table-hover-bg: #22252c;
  --th-border-color: #2a2e35;
  --th-emphasis-color: #e8eaed;
  --th-secondary-color: #8b9098;

  --bs-body-bg: var(--th-body-bg);
  --bs-body-bg-rgb: 21, 24, 29;
  --bs-body-color: #d1d5db;
  --bs-body-color-rgb: 209, 213, 219;
  --bs-card-bg: var(--th-card-bg);
  --bs-card-cap-bg: var(--th-card-cap-bg);
  --bs-card-border-color: var(--th-border-color);
  --bs-table-striped-bg: var(--th-table-striped-bg);
  --bs-table-hover-bg: var(--th-table-hover-bg);
  --bs-border-color: var(--th-border-color);
  --bs-emphasis-color: var(--th-emphasis-color);
  --bs-heading-color: var(--th-emphasis-color);
  --bs-secondary-color: var(--th-secondary-color);
}

/* ---------- Navbar ---------- */

.navbar-themed {
  background: linear-gradient(135deg, #2c3e50 0%, #3a5269 100%) !important;
}
[data-bs-theme="dark"] .navbar-themed {
  background: linear-gradient(135deg, #15181e 0%, #1e242b 100%) !important;
}

/* ---------- Cards & Tables ---------- */

.card {
  border: 1px solid var(--bs-card-border-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.card-header {
  font-weight: 600;
  font-size: 0.875rem;
}

/* ---------- Badges ---------- */

.badge {
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* ---------- Breadcrumb ---------- */

.breadcrumb {
  --bs-breadcrumb-divider: '>';
}

/* ---------- Code (SKU, symbols) ---------- */

code {
  background: var(--bs-tertiary-bg);
  color: var(--bs-emphasis-color);
  padding: 0.15em 0.4em;
  border-radius: 0.25rem;
  font-size: 0.85em;
}

/* ---------- Form Controls ---------- */

.form-control,
.form-select,
.input-group-text {
  background-color: #ffffff;
  border-color: #c7cfd8;
  color: var(--bs-emphasis-color);
}

.form-control:hover,
.form-select:hover {
  border-color: #aeb9c4;
}

.form-control::placeholder {
  color: #98a2ad;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.2);
}

.form-control[readonly],
.form-select[readonly] {
  background-color: #f1f3f6;
}

[data-bs-theme="dark"] {
  color-scheme: dark;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .input-group-text {
  background-color: #262a31;
  border-color: #3a4049;
  color: #e8eaed;
}

[data-bs-theme="dark"] .form-control:hover,
[data-bs-theme="dark"] .form-select:hover {
  border-color: #4a515c;
}

[data-bs-theme="dark"] .form-control::placeholder {
  color: #7c838e;
}

[data-bs-theme="dark"] .form-control[readonly],
[data-bs-theme="dark"] .form-select[readonly] {
  background-color: #22252c;
}

/* ---------- Theme Toggle Button ---------- */

.btn-theme-toggle {
  color: rgba(255, 255, 255, 0.75);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn-theme-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* ---------- Pagination ---------- */

.pagination {
  --bs-pagination-active-bg: var(--bs-primary);
  --bs-pagination-active-border-color: var(--bs-primary);
}

/* ---------- Nested Dropdown Submenus ---------- */

.dropdown-submenu {
  position: relative;
}

.dropdown-submenu > .dropdown-menu {
  top: 0;
  left: 100%;
  margin-top: -0.4rem;
  display: none;
}

.dropdown-submenu > .dropdown-menu.show {
  display: block;
}

.dropdown-toggle-sub::after {
  display: inline-block;
  margin-left: 0.5em;
  vertical-align: middle;
  content: "";
  border-top: 0.3em solid transparent;
  border-bottom: 0.3em solid transparent;
  border-left: 0.3em solid;
}

/* ---------- Alert debug (Django) ---------- */

.alert-debug {
  background-color: var(--bs-tertiary-bg);
  border-color: var(--bs-border-color);
  color: var(--bs-body-color);
}

/* ---------- Choices.js height fix ---------- */

.choices {
  width: 100% !important;
  margin-bottom: 0;
}

.choices__inner {
  min-height: auto !important;
  padding: 0.375rem 0.75rem !important;
  font-size: 1rem;
  border-radius: var(--bs-border-radius);
  background-color: #ffffff;
  border-color: #c7cfd8;
}

.choices__list--single {
  padding: 0;
}

.choices__list--dropdown .choices__item--selectable,
.choices__list[aria-expanded] .choices__item--selectable {
  padding: 0.25rem 0.75rem;
  font-size: 0.9rem;
}

/* ---------- Choices.js dark mode ---------- */

[data-bs-theme="dark"] .choices,
[data-bs-theme="dark"] .choices__inner,
[data-bs-theme="dark"] .choices__list--dropdown,
[data-bs-theme="dark"] .choices__list[aria-expanded] {
  background-color: #262a31;
  border-color: #3a4049;
  color: #e8eaed;
}

[data-bs-theme="dark"] .choices__input {
  background-color: #262a31;
  color: #e8eaed;
  border-color: #3a4049;
}

[data-bs-theme="dark"] .choices__list--dropdown .choices__item--selectable.is-highlighted,
[data-bs-theme="dark"] .choices__list[aria-expanded] .choices__item--selectable.is-highlighted {
  background-color: var(--bs-primary);
  color: #fff;
}

[data-bs-theme="dark"] .choices__list--dropdown .choices__list,
[data-bs-theme="dark"] .choices__list[aria-expanded] .choices__list {
  background-color: #262a31;
}

[data-bs-theme="dark"] .choices[data-type*="select-one"] .choices__input {
  background-color: #262a31;
  border-bottom-color: #3a4049;
}

/* ---------- Disabled selects in dark mode ---------- */
[data-bs-theme="dark"] select:disabled,
[data-bs-theme="dark"] select[disabled],
[data-bs-theme="dark"] input:disabled,
[data-bs-theme="dark"] textarea:disabled {
  background-color: var(--bs-tertiary-bg);
  color: var(--bs-body-color);
  opacity: 0.7;
}

/* Choices.js disabled wrapper in dark mode */
[data-bs-theme="dark"] .choices.is-disabled .choices__inner,
[data-bs-theme="dark"] .choices.is-disabled .choices__input {
  background-color: var(--bs-tertiary-bg) !important;
  color: var(--bs-body-color);
  opacity: 0.7;
}
