/* Shared contrast palette. Loaded after the legacy theme rules.
 * Text accents and filled buttons intentionally use different shades.
 * Do not invert images, logos, or user-authored content with CSS filters.
 */
html[data-bs-theme] {
  --bc-text-primary: #171717 !important;
  --bc-text-main: #171717 !important;
  --bc-text-secondary: #454545 !important;
  --bc-text-muted: #595959 !important;
  --bc-text-dim: #595959 !important;
  --bc-link: #174fc4;
  --bc-link-hover: #103a94;
  --bc-success-text: #166534;
  --bc-warning-text: #854d0e;
  --bc-danger-text: #b91c1c;
  --bc-info-text: #075985;
  --bc-purple-text: #6d28d9;
  --bc-control-border: #858585;
  --bc-button-primary: #2457d6;
  --bc-button-primary-hover: #1944b0;
  --bc-button-success: #18713a;
  --bc-button-danger: #b91c1c;
  --bc-primary: #2457d6 !important;
  --bc-primary-hover: #1944b0 !important;
  --bc-primary-active: #163a94 !important;
  --theme-text-primary: var(--bc-text-primary);
  --theme-text-muted: var(--bc-text-muted);
  color-scheme: light;
}

html[data-bs-theme="dark"] {
  color-scheme: dark;
  --bc-background: #000000 !important;
  --bc-bg-app: #000000 !important;
  --bc-bg-page: #000000 !important;
  --bc-surface: #141414 !important;
  --bc-card-bg: #141414 !important;
  --bc-surface-raised: #1c1c1c !important;
  --bc-surface-muted: #242424 !important;
  --bc-surface-subtle: #1c1c1c !important;
  --bc-card-hover: #242424 !important;
  --bc-border: #444444 !important;
  --bc-border-subtle: #363636 !important;
  --bc-border-hover: #737373 !important;
  --bc-border-strong: #858585 !important;
  --bc-text-primary: #f5f5f5 !important;
  --bc-text-main: #f5f5f5 !important;
  --bc-text-secondary: #d4d4d4 !important;
  --bc-text-muted: #b8b8b8 !important;
  --bc-text-dim: #b8b8b8 !important;
  --bc-link: #93c5fd;
  --bc-link-hover: #bfdbfe;
  --bc-success-text: #86efac;
  --bc-warning-text: #fde047;
  --bc-danger-text: #fca5a5;
  --bc-info-text: #7dd3fc;
  --bc-purple-text: #c4b5fd;
  --theme-card-bg: var(--bc-surface);
  --theme-card-border: var(--bc-border);
  --theme-icon-color: #d4d4d4;
  --theme-icon-hover: var(--bc-link);
  --pe-app-sidebar-bg: #141414 !important;
  --pe-app-sidebar-border-color: #444444 !important;
  --pe-app-sidebar-menu-item-color: #d4d4d4 !important;
  --pe-app-sidebar-text-muted: #b8b8b8 !important;
  --pe-app-sidebar-caption-color: #93c5fd !important;
  --pe-app-sidebar-menu-item-hover-color: #93c5fd !important;
  --pe-app-sidebar-menu-item-active-color: #93c5fd !important;
  --pe-primary: #93c5fd !important;
  --pe-primary-rgb: 147, 197, 253 !important;
  --bs-primary: #93c5fd !important;
  --bs-primary-rgb: 147, 197, 253 !important;
}

/* Bootstrap is compiled with the pe prefix; some custom pages use bs. */
html[data-bs-theme] {
  --pe-body-color: var(--bc-text-primary) !important;
  --bs-body-color: var(--bc-text-primary) !important;
  --pe-secondary-color: var(--bc-text-muted) !important;
  --bs-secondary-color: var(--bc-text-muted) !important;
  --pe-tertiary-color: var(--bc-text-muted) !important;
  --bs-tertiary-color: var(--bc-text-muted) !important;
  --pe-heading-color: var(--bc-text-primary) !important;
  --bs-heading-color: var(--bc-text-primary) !important;
  --pe-link-color: var(--bc-link) !important;
  --bs-link-color: var(--bc-link) !important;
  --pe-link-hover-color: var(--bc-link-hover) !important;
  --bs-link-hover-color: var(--bc-link-hover) !important;
}

html[data-bs-theme="dark"] {
  --pe-body-bg: #000000 !important;
  --bs-body-bg: #000000 !important;
  --pe-body-bg-rgb: 0, 0, 0;
  --bs-body-bg-rgb: 0, 0, 0;
  --pe-body-color-rgb: 245, 245, 245;
  --bs-body-color-rgb: 245, 245, 245;
  --pe-secondary-bg: #141414 !important;
  --bs-secondary-bg: #141414 !important;
  --pe-secondary-bg-rgb: 20, 20, 20;
  --bs-secondary-bg-rgb: 20, 20, 20;
  --pe-tertiary-bg: #242424 !important;
  --bs-tertiary-bg: #242424 !important;
  --pe-tertiary-bg-rgb: 36, 36, 36;
  --bs-tertiary-bg-rgb: 36, 36, 36;
  --pe-border-color: #444444 !important;
  --bs-border-color: #444444 !important;
  --pe-link-color-rgb: 147, 197, 253;
  --bs-link-color-rgb: 147, 197, 253;
  --pe-link-hover-color-rgb: 191, 219, 254;
  --bs-link-hover-color-rgb: 191, 219, 254;
}

html[data-bs-theme] :is(.text-muted, .text-body-secondary, .text-body-tertiary, .form-text) {
  color: var(--bc-text-muted) !important;
}
html[data-bs-theme] :is(.form-control, .form-select, .form-control-saas, .form-select-saas) {
  background-color: var(--bc-surface) !important;
  color: var(--bc-text-primary) !important;
  border-color: var(--bc-control-border) !important;
}
html[data-bs-theme] :is(.form-control, .form-control-saas, input, textarea)::placeholder {
  color: var(--bc-text-muted) !important;
  opacity: 1;
}
html[data-bs-theme] :is(.form-control, .form-select):focus {
  background-color: var(--bc-surface) !important;
  color: var(--bc-text-primary) !important;
  border-color: var(--bc-link) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bc-link) 30%, transparent) !important;
}
html[data-bs-theme] :is(.form-control, .form-select):disabled {
  background-color: var(--bc-surface-muted) !important;
  color: var(--bc-text-muted) !important;
  cursor: not-allowed;
}
html[data-bs-theme] .text-primary { color: var(--bc-link) !important; }
html[data-bs-theme] .text-success { color: var(--bc-success-text) !important; }
html[data-bs-theme] .text-warning { color: var(--bc-warning-text) !important; }
html[data-bs-theme] .text-danger { color: var(--bc-danger-text) !important; }
html[data-bs-theme] .text-info { color: var(--bc-info-text) !important; }

html[data-bs-theme] :is(.btn-primary, .btn-bc-primary) {
  background-color: var(--bc-button-primary) !important;
  border-color: var(--bc-button-primary) !important;
  color: #ffffff !important;
}
html[data-bs-theme] :is(.btn-primary, .btn-bc-primary):is(:hover, :focus-visible, :active) {
  background-color: var(--bc-button-primary-hover) !important;
  border-color: var(--bc-button-primary-hover) !important;
}
html[data-bs-theme] .btn-success {
  --pe-btn-hover-bg: #12592d;
  --bs-btn-hover-bg: #12592d;
  background-color: var(--bc-button-success);
  border-color: var(--bc-button-success);
  color: #ffffff;
}
html[data-bs-theme] .btn-danger {
  background-color: var(--bc-button-danger);
  border-color: var(--bc-button-danger);
  color: #ffffff;
}
html[data-bs-theme] .btn-outline-primary {
  color: var(--bc-link) !important;
}
html[data-bs-theme] :is(.btn-secondary, .btn-light, .btn-bc-secondary):hover {
  color: var(--bc-link) !important;
}

html[data-bs-theme="dark"] :is(body, #layout-wrapper, .app-wrapper) {
  background-color: #000000 !important;
  color: var(--bc-text-primary) !important;
}
html[data-bs-theme="dark"] :is(.card, .card-header, .card-footer, .settings-sidebar,
  .settings-content-card, .saas-card, .card-premium, .stat-box, .bg-white,
  .modal-content, .offcanvas, .dropdown-menu, .app-header, .bc-global-footer,
  .team-task-composer, .team-task-composer-footer, .team-task-type-menu,
  .team-task-title-input, .team-task-description-input, .bc-editor-menubar) {
  background-color: var(--bc-surface) !important;
  border-color: var(--bc-border) !important;
  color: var(--bc-text-primary) !important;
}
html[data-bs-theme="dark"] :is(.bg-light, .bg-light-light, .bg-light-subtle,
  .btn-light, .btn-light-light, .input-group-text, .team-task-chip,
  .team-task-status-badge) {
  background-color: var(--bc-surface-muted) !important;
  border-color: var(--bc-border) !important;
  color: var(--bc-text-primary) !important;
}
html[data-bs-theme="dark"] :is(.text-dark, .text-body) {
  color: var(--bc-text-primary) !important;
}
html[data-bs-theme="dark"] .text-secondary { color: var(--bc-text-secondary) !important; }
html[data-bs-theme="dark"] .dropdown-item { color: var(--bc-text-primary) !important; }
html[data-bs-theme="dark"] .dropdown-item:is(:hover, :focus) {
  background-color: var(--bc-surface-muted) !important;
  color: var(--bc-link) !important;
}
html[data-bs-theme="dark"] .table > :not(caption) > * > * {
  color: var(--bc-text-primary) !important;
  border-color: var(--bc-border) !important;
}
html[data-bs-theme="dark"] :is(.table thead, thead.bg-light) > tr > th {
  background-color: var(--bc-surface-muted) !important;
  color: var(--bc-text-secondary) !important;
}
html[data-bs-theme="dark"] .nav-tabs .nav-link.active {
  background-color: var(--bc-surface) !important;
  color: var(--bc-link) !important;
  border-color: var(--bc-border) var(--bc-border) transparent !important;
}

/* Feature-owned palettes still share the same readable neutral surfaces. */
html[data-bs-theme] .an-dashboard {
  --an-ink: var(--bc-text-primary);
  --an-muted: var(--bc-text-muted);
  --an-line: var(--bc-border);
  --an-surface: var(--bc-surface);
  --an-soft: var(--bc-surface-muted);
}
html[data-bs-theme] .ds-store {
  --ds-ink: var(--bc-text-primary);
  --ds-muted: var(--bc-text-muted);
  --ds-line: var(--bc-border);
  --ds-surface: var(--bc-surface);
  --ds-soft: var(--bc-surface-muted);
}
html[data-bs-theme] .ps-store {
  --ps-ink: var(--bc-text-primary);
  --ps-muted: var(--bc-text-muted);
  --ps-line: var(--bc-border);
  --ps-surface: var(--bc-surface);
  --ps-soft: var(--bc-surface-muted);
}
html[data-bs-theme] .mi {
  --mi-ink: var(--bc-text-primary);
  --mi-muted: var(--bc-text-muted);
  --mi-border: var(--bc-border);
  --mi-card: var(--bc-surface);
  --mi-soft: var(--bc-surface-muted);
}
html[data-bs-theme="dark"] {
  --bc-dash-card-bg: var(--bc-surface);
  --bc-dash-card-border: var(--bc-border);
}
html[data-bs-theme="dark"] :is(.kpi-card, .quick-action-tile,
  .team-metric-card, .kanban-card, .gantt-chart, .chat-container,
  .achievement-card, .bc-command-dialog, .bc-command-input) {
  background-color: var(--bc-surface) !important;
  color: var(--bc-text-primary) !important;
  border-color: var(--bc-border) !important;
}
html[data-bs-theme="dark"] :is(.info-tile, .chat-bubble-saas,
  .team-task-table th, .calendar-day-header) {
  background-color: var(--bc-surface-muted) !important;
  color: var(--bc-text-secondary) !important;
  border-color: var(--bc-border) !important;
}
html[data-bs-theme="dark"] .card[style*="linear-gradient(180deg, #ffffff"] {
  background-image: none !important;
}
html[data-bs-theme="dark"] .quick-action-tile:hover {
  color: var(--bc-link) !important;
}
