:root,
:root[data-bs-theme="light"] {
  color-scheme: light;
}

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

/* Text selection colors for dark theme */
:root[data-bs-theme="dark"] ::selection {
  background-color: rgba(59, 130, 246, 0.5);
  color: #fff;
}

:root[data-bs-theme="dark"] ::-moz-selection {
  background-color: rgba(59, 130, 246, 0.5);
  color: #fff;
}

body.theme-dark ::selection {
  background-color: rgba(59, 130, 246, 0.5);
  color: #fff;
}

body.theme-dark ::-moz-selection {
  background-color: rgba(59, 130, 246, 0.5);
  color: #fff;
}

body.compact-ui {
  background-color: var(--tblr-body-bg);
  font-size: 0.9375rem;
  color: var(--tblr-body-color);
}

body.compact-ui.theme-dark {
  background-color: var(--tblr-body-bg);
}

body.compact-ui .page-wrapper {
  padding-top: 0;
}

body.compact-ui .page-header {
  padding: 0;
  margin-bottom: 0.25rem;
}

body.compact-ui .navbar {
  min-height: 3.25rem;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
}

body.compact-ui .navbar-brand img {
  height: 32px;
  width: 32px;
}

body.compact-ui .navbar-nav .nav-link {
  padding: 0.45rem 0.75rem;
  font-weight: 500;
}

body.compact-ui .navbar .navbar-nav .btn {
  padding: 0.375rem 0.75rem;
}

body.compact-ui .page-body {
  padding: 0.5rem 0 1.5rem;
}

body.compact-ui .card {
  border-radius: 0.5rem;
  background-color: var(--tblr-card-bg);
  color: inherit;
}

body.compact-ui .page-header > .container-fluid:empty {
  display: none;
}

body.compact-ui .card.card-sm .card-body {
  padding: 0.9rem 1rem;
}

body.compact-ui .card + .card {
  margin-top: 0.75rem;
}

body.compact-ui .form-control,
body.compact-ui .form-select,
body.compact-ui .input-group-text {
  min-height: 2.25rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.875rem;
  line-height: 1.25;
}

body.compact-ui .input-group-sm > .form-control,
body.compact-ui .input-group-sm > .form-select,
body.compact-ui .input-group-sm > .input-group-text {
  min-height: 2rem;
}

body.compact-ui .btn {
  font-size: 0.875rem;
  padding: 0.35rem 0.75rem;
  line-height: 1.25;
}

body.compact-ui .btn.btn-icon {
  padding: 0.35rem;
}

body.compact-ui .table {
  font-size: 0.82rem;
}

body.compact-ui .nav-tabs .nav-link {
  padding: 0.5rem 0.75rem;
}

body.compact-ui #content > .row {
  margin-bottom: 0.75rem;
}

body.compact-ui fieldset {
  border: 1px solid var(--tblr-border-color) !important;
  border-radius: 0.5rem;
  padding: 0.75rem 0.9rem !important;
  margin-bottom: 0.75rem;
  background-color: var(--tblr-card-bg);
}

body.compact-ui fieldset legend {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0 0.5rem;
  width: auto;
  margin-bottom: 0.5rem;
}

body.compact-ui fieldset fieldset {
  background-color: var(--tblr-bg-surface);
}

.min-w-16rem {
  min-width: 16rem !important;
}

.min-w-18rem {
  min-width: 18rem !important;
}

.min-w-20rem {
  min-width: 20rem !important;
}

.max-w-5rem {
  max-width: 5rem !important;
}

.max-w-6rem {
  max-width: 6rem !important;
}

.max-w-7rem {
  max-width: 7rem !important;
}

.max-w-8rem {
  max-width: 8rem !important;
}

.legend-fixed {
  min-width: 12.5rem;
}

.form-check-compact {
  font-size: 0.85rem;
}

.form-check-compact .form-check-input {
  width: 1rem;
  height: 1rem;
}

.average-time-info {
  max-width: 12rem;
  font-size: 0.7rem;
}

.ts--small .ts-control {
  min-height: 2.25rem;
  padding: 0.25rem 0.5rem;
}

.card-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-grid {
  display: grid;
  gap: 0.75rem 1rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.filter-grid .btn-group {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.bootstrap-table .fixed-table-toolbar .dropdown-menu,
.bootstrap-table .fixed-table-pagination .dropdown-menu,
.bootstrap-table .page-list .dropdown-menu {
  z-index: 1055;
  background-color: var(--tblr-bg-surface);
  border-color: var(--tblr-border-color);
  color: var(--tblr-body-color);
}

/* Fix page-list dropdown in pagination */
.bootstrap-table .page-list .dropdown-toggle {
  cursor: pointer;
}

.bootstrap-table .page-list .dropdown {
  position: relative;
}

.bootstrap-table .page-list .dropdown-menu a,
.bootstrap-table .fixed-table-pagination .dropdown-menu a {
  color: var(--tblr-body-color);
}

.bootstrap-table .page-list .dropdown-menu a:hover,
.bootstrap-table .fixed-table-pagination .dropdown-menu a:hover {
  background-color: var(--tblr-primary);
  color: #fff;
}

.bootstrap-table .fixed-table-toolbar .keep-open {
  position: relative;
  display: inline-flex;
}

.ts-theme-light .ts-control,
.ts-theme-light .ts-control input,
.ts-theme-dark .ts-control,
.ts-theme-dark .ts-control input {
  background-color: var(--tblr-bg-surface) !important;
  color: var(--tblr-body-color) !important;
  border-color: var(--tblr-border-color) !important;
}

.ts-theme-light .ts-control .item,
.ts-theme-dark .ts-control .item {
  background-color: var(--tblr-primary) !important;
  color: #fff !important;
  border: none !important;
}

.ts-theme-light .ts-control .item .remove,
.ts-theme-dark .ts-control .item .remove {
  color: rgba(255, 255, 255, 0.85) !important;
}

.ts-theme-light .ts-dropdown,
.ts-theme-dark .ts-dropdown {
  background-color: var(--tblr-bg-surface) !important;
  color: var(--tblr-body-color) !important;
  border-color: var(--tblr-border-color) !important;
}

.ts-theme-light .ts-dropdown .option,
.ts-theme-dark .ts-dropdown .option {
  color: var(--tblr-body-color) !important;
}

.ts-theme-light .ts-dropdown .option.active,
.ts-theme-dark .ts-dropdown .option.active {
  background-color: var(--tblr-primary) !important;
  color: #fff !important;
}

/* Clickable card widgets */
.card.card-link {
  cursor: pointer;
  transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.card.card-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.theme-dark .card.card-link:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Confirmation modal - assets list container */
#confirmAssetsList {
  background-color: #f8f9fa !important;
  border: 1px solid #dee2e6;
}

#confirmAssetsList .badge,
#confirmAssetsList .badge.bg-primary {
  color: #fff !important;
  font-weight: 500;
  background-color: #206bc4 !important;
}

/* Confirmation modal dark theme support */
body.theme-dark #confirmAssetsList,
:root[data-bs-theme="dark"] #confirmAssetsList {
  background-color: #2d3748 !important;
  border-color: #4a5568 !important;
}

body.theme-dark #confirmAssetsList .badge,
:root[data-bs-theme="dark"] #confirmAssetsList .badge {
  background-color: #4299e1 !important;
  color: #fff !important;
}

body.theme-dark #modalConfirmBacktesting .table,
:root[data-bs-theme="dark"] #modalConfirmBacktesting .table {
  color: var(--tblr-body-color);
}

body.theme-dark #modalConfirmBacktesting .modal-content,
:root[data-bs-theme="dark"] #modalConfirmBacktesting .modal-content {
  background-color: #1e293b !important;
  color: var(--tblr-body-color);
}

body.theme-dark #modalConfirmBacktesting .modal-body,
:root[data-bs-theme="dark"] #modalConfirmBacktesting .modal-body {
  background-color: #1e293b !important;
}

#modalConfirmBacktesting .modal-body {
  padding: 1rem 1.5rem;
}

body.theme-dark #modalConfirmBacktesting .modal-footer,
:root[data-bs-theme="dark"] #modalConfirmBacktesting .modal-footer {
  background-color: #1e293b !important;
  border-top-color: #334155 !important;
}

body.theme-dark #modalConfirmBacktesting hr,
:root[data-bs-theme="dark"] #modalConfirmBacktesting hr {
  border-color: #334155 !important;
}

body.theme-dark #modalConfirmBacktesting .alert-info,
:root[data-bs-theme="dark"] #modalConfirmBacktesting .alert-info {
  background-color: rgba(59, 130, 246, 0.15);
  border-color: rgba(59, 130, 246, 0.3);
  color: var(--tblr-body-color);
}

@media (max-width: 768px) {
  body.compact-ui .navbar-nav .nav-link {
    padding: 0.5rem 1rem;
  }

  .min-w-16rem,
  .min-w-18rem,
  .min-w-20rem {
    min-width: 100% !important;
  }
}
