/* Minimal dark theme overrides for AskosTours app */
body.theme-dark {
  --bg: #0b0f14;
  --panel: #0f1720;
  --fg: #e6eef6;
  --muted: #9aa6b2;
  --accent: #3aa0ff;
  background-color: var(--bg);
  color: var(--fg);
}

/* Main container and content */
body.theme-dark .s-main,
body.theme-dark .content,
body.theme-dark .page-container-common {
  background-color: var(--bg) !important;
  color: var(--fg) !important;
}

/* Sidebar */
body.theme-dark .s-sidebar,
body.theme-dark .s-sidebar-pane,
body.theme-dark .s-sidebar-header,
body.theme-dark .s-sidebar-item,
body.theme-dark .s-sidebar-menu,
body.theme-dark .s-sidebar-link,
body.theme-dark .s-sidebar-header-actions {
  background-color: var(--panel) !important;
  color: var(--fg) !important;
}

body.theme-dark .s-sidebar-link-text,
body.theme-dark .s-sidebar-search-input,
body.theme-dark .s-user-info,
body.theme-dark .s-user-card,
body.theme-dark .s-user-avatar {
  color: var(--fg) !important;
}

/* Navbar / header / cards */
body.theme-dark header,
body.theme-dark .navbar,
body.theme-dark .card,
body.theme-dark .panel,
body.theme-dark .dropdown-menu,
body.theme-dark .modal-content {
  background-color: var(--panel) !important;
  color: var(--fg) !important;
  border-color: rgba(255,255,255,0.06) !important;
}

/* Links and accents */
body.theme-dark a,
body.theme-dark .s-sidebar-link,
body.theme-dark .dropdown-item {
  color: var(--accent) !important;
}

/* Muted text */
body.theme-dark .text-muted,
body.theme-dark .s-muted {
  color: var(--muted) !important;
}

/* Form controls */
body.theme-dark input,
body.theme-dark select,
body.theme-dark textarea,
body.theme-dark .form-control {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

/* Stronger rules for editors, password fields and validation states */
body.theme-dark input[type="password"],
body.theme-dark input.editor,
body.theme-dark input[class*="Serenity-PasswordEditor"],
body.theme-dark input[class*="PasswordEditor"],
body.theme-dark input.required,
body.theme-dark input.valid,
body.theme-dark .editor,
body.theme-dark .s-Serenity-StringEditor,
body.theme-dark .s-Serenity-PasswordEditor,
body.theme-dark .s-PasswordEditor {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
  box-shadow: none !important;
}

/* Placeholder and autofill adjustments */
body.theme-dark input::placeholder,
body.theme-dark textarea::placeholder {
  color: rgba(230,238,246,0.5) !important;
}

body.theme-dark input:-webkit-autofill,
body.theme-dark input:-webkit-autofill:hover,
body.theme-dark input:-webkit-autofill:focus,
body.theme-dark textarea:-webkit-autofill,
body.theme-dark textarea:-webkit-autofill:hover,
body.theme-dark textarea:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--fg) !important;
  -webkit-box-shadow: 0 0 0px 1000px #0b0f14 inset !important;
}

/* Buttons */
body.theme-dark .btn,
body.theme-dark .btn-primary {
  background-color: #183349 !important;
  color: var(--fg) !important;
  border-color: rgba(255,255,255,0.06) !important;
}

/* Ensure icons remain visible */
body.theme-dark .fa {
  color: var(--fg) !important;
}

/* Ensure theme toggle icon is always white in both themes and hide its text */
.theme-toggle-item .theme-toggle-icon,
.theme-toggle-item .fa {
  color: #ffffff !important;
}

.s-sidebar-header-actions .s-sidebar-link .s-sidebar-link-text {
  display: none !important;
}

/* Apply dark theme styles to content section and all its children */
body.theme-dark .content,
body.theme-dark .content * {
  color: var(--fg) !important;
}

/* Give common content containers a dark background */
body.theme-dark .content .card,
body.theme-dark .content .panel,
body.theme-dark .content .table,
body.theme-dark .content .table tbody tr,
body.theme-dark .content .list-group,
body.theme-dark .content .dropdown-menu,
body.theme-dark .content .modal-content,
body.theme-dark .content .box {
  background-color: var(--panel) !important;
  color: var(--fg) !important;
  border-color: rgba(255,255,255,0.06) !important;
}

/* Form controls inside content */
body.theme-dark .content input,
body.theme-dark .content select,
body.theme-dark .content textarea,
body.theme-dark .content .form-control {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

/* Links and accents inside content */
body.theme-dark .content a,
body.theme-dark .content .btn-link {
  color: var(--accent) !important;
}

/* Tables */
body.theme-dark .content table,
body.theme-dark .content thead,
body.theme-dark .content tbody,
body.theme-dark .content th,
body.theme-dark .content td {
  color: var(--fg) !important;
}

/* Specific rules for #GridDiv and common grid widgets */
body.theme-dark #GridDiv,
body.theme-dark #GridDiv * {
  color: var(--fg) !important;
}

/* Grid containers and tables inside GridDiv */
body.theme-dark #GridDiv .grid,
body.theme-dark #GridDiv .s-DataGrid,
body.theme-dark #GridDiv .k-grid,
body.theme-dark #GridDiv .dataTables_wrapper,
body.theme-dark #GridDiv table,
body.theme-dark #GridDiv thead,
body.theme-dark #GridDiv tbody,
body.theme-dark #GridDiv th,
body.theme-dark #GridDiv td {
  background-color: var(--panel) !important;
  color: var(--fg) !important;
  border-color: rgba(255,255,255,0.06) !important;
}

/* Header cells and rows */
body.theme-dark #GridDiv thead th,
body.theme-dark #GridDiv thead tr {
  background-color: rgba(255,255,255,0.02) !important;
  color: var(--fg) !important;
}

/* Row hover / selected */
body.theme-dark #GridDiv tbody tr:hover,
body.theme-dark #GridDiv .grid-row:hover {
  background-color: rgba(255,255,255,0.03) !important;
}

/* Form controls inside grid */
body.theme-dark #GridDiv input,
body.theme-dark #GridDiv select,
body.theme-dark #GridDiv textarea,
body.theme-dark #GridDiv .form-control {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

/* Links and action buttons inside grid */
body.theme-dark #GridDiv a,
body.theme-dark #GridDiv .btn,
body.theme-dark #GridDiv .btn-link {
  color: var(--accent) !important;
}

/* Ensure virtualized/grid cells (slickgrid, kendo) are visible */
body.theme-dark #GridDiv .slick-header-columns,
body.theme-dark #GridDiv .slick-cell,
body.theme-dark #GridDiv .k-grid-header,
body.theme-dark #GridDiv .k-grid-content {
  background-color: transparent !important;
  color: var(--fg) !important;
}

/* Stronger overrides for grid container and cells to handle inline/third-party backgrounds */
body.theme-dark #GridDiv,
body.theme-dark #GridDiv .grid-container,
body.theme-dark #GridDiv .grid-container.slick-container,
body.theme-dark #GridDiv .slick-viewport,
body.theme-dark #GridDiv .grid-canvas {
  background-color: var(--panel) !important;
  color: var(--fg) !important;
}

body.theme-dark #GridDiv .slick-row,
body.theme-dark #GridDiv .slick-cell,
body.theme-dark #GridDiv .slick-row .slick-cell,
body.theme-dark #GridDiv .grid-canvas .slick-row {
  background-color: transparent !important;
  color: var(--fg) !important;
}

/* Toolbar / buttons */
body.theme-dark #GridDiv .grid-toolbar,
body.theme-dark #GridDiv .grid-title,
body.theme-dark #GridDiv .tool-group,
body.theme-dark #GridDiv .tool-button,
body.theme-dark #GridDiv .button-inner {
  background-color: transparent !important;
  color: var(--fg) !important;
}

/* Select2 specific overrides */
body.theme-dark #GridDiv .select2-container .select2-choice,
body.theme-dark #GridDiv .select2-container.select2-with-searchbox .select2-choice,
body.theme-dark #GridDiv .select2-choice.select2-default,
body.theme-dark #GridDiv .select2-drop,
body.theme-dark #GridDiv .select2-results,
body.theme-dark #GridDiv .select2-search .select2-input,
body.theme-dark #GridDiv .select2-container .select2-choice .select2-chosen {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

/* Global select2 overrides (covers select2 elements outside grids) */
body.theme-dark .select2-container .select2-choice,
body.theme-dark .select2-container.select2-with-searchbox .select2-choice,
body.theme-dark .select2-choice.select2-default,
body.theme-dark a.select2-choice,
body.theme-dark .select2-container .select2-choice .select2-chosen,
body.theme-dark .select2-container .select2-choice .select2-arrow {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

body.theme-dark .select2-drop,
body.theme-dark .select2-drop .select2-search,
body.theme-dark .select2-drop .select2-results {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

body.theme-dark .select2-container .select2-choice .select2-chosen {
  color: var(--fg) !important;
}

/* Select2 multi-choice tokens and choices (the pills) */
body.theme-dark .select2-container-multi .select2-choices,
body.theme-dark .select2-container-multi .select2-choices li.select2-search-choice,
body.theme-dark .select2-container-multi .select2-choices li.select2-search-choice div,
body.theme-dark .select2-container-multi .select2-choices li.select2-search-choice .select2-search-choice-close {
  background-color: rgba(255,255,255,0.03) !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.04) !important;
}

body.theme-dark .select2-container-multi .select2-choices li.select2-search-choice a.select2-search-choice-close {
  color: var(--fg) !important;
}

/* The search field inside multi select */
body.theme-dark .select2-container-multi .select2-choices li.select2-search-field input.select2-input,
body.theme-dark .select2-container-multi .select2-choices li.select2-search-field input.select2-default {
  background-color: transparent !important;
  color: var(--fg) !important;
}

/* Ensure dropdown list also dark */
body.theme-dark .select2-container-multi .select2-drop,
body.theme-dark .select2-container-multi .select2-drop .select2-results {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
}

/* Ensure focus/inputs in select2 are dark */
body.theme-dark .select2-container .select2-focusser,
body.theme-dark .select2-container .select2-input,
body.theme-dark .select2-search .select2-input {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
}

/* Fallback for inline white backgrounds in select2 containers */
body.theme-dark .select2-container[style*="background"],
body.theme-dark .select2-container[style*="background:"] {
  background-color: transparent !important;
}

/* Links and source text inside grid */
body.theme-dark #GridDiv a.source-text {
  color: var(--accent) !important;
}

/* Inputs and placeholders */
body.theme-dark #GridDiv input.custom-text,
body.theme-dark #GridDiv input[type="text"],
body.theme-dark #GridDiv input.custom-text::placeholder,
body.theme-dark #GridDiv input::placeholder {
  color: rgba(230,238,246,0.6) !important;
}

/* Fallback for inline background declarations */
body.theme-dark #GridDiv [style*="background:#fff"],
body.theme-dark #GridDiv [style*="background: #fff"],
body.theme-dark #GridDiv [style*="background:white"],
body.theme-dark #GridDiv [style*="background: white"] {
  background-color: transparent !important;
}

/* Panels (Serenity s-Panel) */
body.theme-dark .s-Panel,
body.theme-dark .s-Panel .panel-body,
body.theme-dark .s-Panel .panel-titlebar,
body.theme-dark .s-Panel .panel-footer,
body.theme-dark .s-Panel .panel-titlebar-text,
body.theme-dark .s-Panel .panel-titlebar-close,
body.theme-dark .s-Panel .s-Form,
body.theme-dark .s-Panel .s-PropertyGrid,
body.theme-dark .s-Panel .categories,
body.theme-dark .s-Panel .category,
body.theme-dark .s-Panel .field {
  background-color: var(--panel) !important;
  color: var(--fg) !important;
  border-color: rgba(255,255,255,0.06) !important;
}

body.theme-dark .s-Panel .panel-titlebar {
  background-color: rgba(255,255,255,0.02) !important;
  color: var(--fg) !important;
}

body.theme-dark .s-Panel .panel-titlebar-text {
  color: var(--fg) !important;
}

body.theme-dark .s-Panel .panel-footer {
  background-color: transparent !important;
}

/* Toolbar buttons inside panels */
body.theme-dark .s-Panel .tool-button,
body.theme-dark .s-Panel .tool-group,
body.theme-dark .s-Panel .button-inner,
body.theme-dark .s-Panel .icon-tool-button {
  background-color: transparent !important;
  color: var(--fg) !important;
  border-color: rgba(255,255,255,0.03) !important;
}

/* Icons and colored text inside panels */
body.theme-dark .s-Panel .fa,
body.theme-dark .s-Panel .text-purple,
body.theme-dark .s-Panel .text-danger {
  color: var(--fg) !important;
}

/* Inputs, labels and editors inside panel */
body.theme-dark .s-Panel label.caption,
body.theme-dark .s-Panel .editor,
body.theme-dark .s-Panel input,
body.theme-dark .s-Panel textarea,
body.theme-dark .s-Panel select,
body.theme-dark .s-Panel .form-control {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

/* Placeholder color */
body.theme-dark .s-Panel input::placeholder,
body.theme-dark .s-Panel textarea::placeholder {
  color: rgba(230,238,246,0.6) !important;
}

/* Fallback for inline white backgrounds in panels */
body.theme-dark .s-Panel [style*="background:#fff"],
body.theme-dark .s-Panel [style*="background: #fff"],
body.theme-dark .s-Panel [style*="background:white"],
body.theme-dark .s-Panel [style*="background: white"] {
  background-color: transparent !important;
}

/* Tabs, panes and form property grid */
body.theme-dark .tab-content,
body.theme-dark .tab-pane,
body.theme-dark .tab-pane .s-Form,
body.theme-dark .tab-pane .s-PropertyGrid,
body.theme-dark .tab-pane .categories,
body.theme-dark .tab-pane .category,
body.theme-dark .tab-pane .category-title,
body.theme-dark .tab-pane .field,
body.theme-dark .tab-pane .s-DialogToolbar,
body.theme-dark .tab-pane .s-Toolbar,
body.theme-dark .tab-pane .tool-group,
body.theme-dark .tab-pane .tool-button,
body.theme-dark .tab-pane .button-inner,
body.theme-dark .tab-content * {
  background-color: transparent !important;
  color: var(--fg) !important;
}

/* Ensure editors and inputs inside tab panes are dark */
body.theme-dark .tab-pane input,
body.theme-dark .tab-pane textarea,
body.theme-dark .tab-pane select,
body.theme-dark .tab-pane .editor,
body.theme-dark .tab-pane .form-control {
  background-color: #0b0f14 !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

/* Slick grid containers inside tabs */
body.theme-dark .tab-pane .slick-container,
body.theme-dark .tab-pane .grid-container,
body.theme-dark .tab-pane .slick-viewport,
body.theme-dark .tab-pane .grid-canvas {
  background-color: var(--panel) !important;
  color: var(--fg) !important;
}

body.theme-dark .tab-pane .slick-row,
body.theme-dark .tab-pane .slick-cell {
  background-color: transparent !important;
  color: var(--fg) !important;
}

/* Make quick-filter labels and controls dark */
body.theme-dark .tab-pane .quick-filter-item,
body.theme-dark .tab-pane .quick-filter-label,
body.theme-dark .tab-pane .quick-filters-bar {
  color: var(--fg) !important;
  background-color: transparent !important;
}

/* Fallback for inline white backgrounds inside tabs */
body.theme-dark .tab-pane [style*="background:#fff"],
body.theme-dark .tab-pane [style*="background: #fff"],
body.theme-dark .tab-pane [style*="background:white"],
body.theme-dark .tab-pane [style*="background: white"] {
  background-color: transparent !important;
}

/* Reports page */
body.theme-dark .s-ReportPage,
body.theme-dark .s-DataGrid.s-ReportPage,
body.theme-dark #ReportPage,
body.theme-dark .report-list,
body.theme-dark .report-list ul,
body.theme-dark .report-item,
body.theme-dark .report-category,
body.theme-dark .report-link,
body.theme-dark .grid-title,
body.theme-dark .grid-toolbar {
  background-color: transparent !important;
  color: var(--fg) !important;
}

body.theme-dark .s-ReportPage .grid-title .title-text,
body.theme-dark .s-ReportPage .report-link,
body.theme-dark #ReportPage .report-link {
  color: var(--fg) !important;
}

body.theme-dark .report-list .report-item,
body.theme-dark .report-list .report-category {
  background-color: transparent !important;
  color: var(--fg) !important;
  border-color: rgba(255,255,255,0.03) !important;
}

body.theme-dark .report-list .report-item i,
body.theme-dark .report-list .report-category i {
  color: var(--fg) !important;
}

body.theme-dark .report-list .report-link {
  color: var(--accent) !important;
}

/* Buttons inside report categories */
body.theme-dark .report-category button.btn {
  background-color: transparent !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.03) !important;
}

/* Ensure collapse/show sections inherit dark bg */
body.theme-dark .collapse.show,
body.theme-dark .list-unstyled.ps-0,
body.theme-dark .list-unstyled.ps-5 {
  background-color: transparent !important;
}

/* Alerts / sample info boxes */
body.theme-dark .alert,
body.theme-dark .s-sample-info,
body.theme-dark .alert-dismissible {
  background-color: var(--panel) !important;
  color: var(--fg) !important;
  border: 1px solid rgba(255,255,255,0.06) !important;
}

body.theme-dark .alert.alert-info,
body.theme-dark .s-sample-info.alert-info,
body.theme-dark .s-sample-info {
  background-color: rgba(255,255,255,0.02) !important;
  color: var(--fg) !important;
}

body.theme-dark .alert p,
body.theme-dark .s-sample-info p {
  color: var(--fg) !important;
}

/* Close button visible on dark background */
body.theme-dark .alert .btn-close,
body.theme-dark .btn-close {
  filter: invert(1) brightness(1.6) !important;
}

/* Sample source links */
body.theme-dark .s-sample-source-link,
body.theme-dark .s-sample-info a,
body.theme-dark .alert a {
  color: var(--accent) !important;
}

/* Fallback for inline white backgrounds inside alerts */
body.theme-dark .alert [style*="background:#fff"],
body.theme-dark .s-sample-info [style*="background:#fff"],
body.theme-dark .alert [style*="background:white"] {
  background-color: transparent !important;
}

/* Modal dialog header/footer styling */
body.theme-dark .modal-content {
  background-color: var(--panel) !important;
  color: var(--fg) !important;
  border-color: rgba(255,255,255,0.06) !important;
}

body.theme-dark .modal-header {
  background-color: rgba(255,255,255,0.02) !important;
  color: var(--fg) !important;
  border-bottom: 1px solid rgba(255,255,255,0.06) !important;
}

body.theme-dark .modal-title {
  color: var(--fg) !important;
}

/* Ensure close button is visible on dark background */
body.theme-dark .modal-header .btn-close {
  filter: invert(1) brightness(2) !important;
}

body.theme-dark .modal-footer {
  background-color: transparent !important;
  border-top: 1px solid rgba(255,255,255,0.03) !important;
}

/* Tabs: ensure active tab is readable in dark theme */
body.theme-dark .nav-tabs .nav-link {
  color: rgba(230,238,246,0.9) !important;
  background-color: transparent !important;
  border-color: transparent !important;
}

body.theme-dark .nav-tabs .nav-link.active,
body.theme-dark .nav-tabs .nav-item.show .nav-link {
  color: var(--fg) !important;
  background-color: rgba(255,255,255,0.03) !important;
  border-color: rgba(255,255,255,0.06) rgba(255,255,255,0.06) transparent !important;
}

/* Ensure tab text (span inside link) is visible */
body.theme-dark .nav-tabs .nav-link span {
  color: inherit !important;
}

/* Active tab hover/focus */
body.theme-dark .nav-tabs .nav-link.active:hover,
body.theme-dark .nav-tabs .nav-link.active:focus {
  background-color: rgba(255,255,255,0.04) !important;
}
