/**
 * Perfex Theme — dark mode token remapping
 * Activated via html[data-theme="dark"] (set by early boot script / prefers-color-scheme)
 */

html[data-theme="dark"],
html.pt-dark {
  color-scheme: dark;
}

html[data-theme="dark"] {
  --pt-sidebar-bg: #0f172a;
  --pt-sidebar-text: #94a3b8;
  --pt-header-bg: #111827;
  --pt-content-bg: #0b1220;
  --pt-card-bg: #111827;
  --pt-text: #e2e8f0;
  --pt-muted: #94a3b8;
  --pt-border: #1e293b;
  --pt-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --pt-primary-soft: rgba(51, 153, 255, 0.18);
}

/* PurplePro preset dark tweak */
html[data-theme="dark"][data-pt-preset="purplepro"] {
  --pt-sidebar-bg: #1a1325;
  --pt-content-bg: #120e1a;
  --pt-card-bg: #1a1325;
  --pt-border: #2e2440;
  --pt-primary-soft: rgba(167, 139, 250, 0.2);
}

/* Coach preset dark tweak */
html[data-theme="dark"][data-pt-preset="coach"] {
  --pt-sidebar-bg: #1c1917;
  --pt-content-bg: #0c0a09;
  --pt-card-bg: #1c1917;
  --pt-header-bg: #1c1917;
  --pt-border: #44403c;
  --pt-primary-soft: rgba(249, 115, 22, 0.2);
}

/* Consulting stays dark-surface; refine when OS/dark mode also on */
html[data-theme="dark"][data-pt-preset="consulting"] {
  --pt-sidebar-bg: #0b0f14;
  --pt-content-bg: #0a0d11;
  --pt-card-bg: #1a1f26;
  --pt-header-bg: #111827;
  --pt-border: #2a3340;
  --pt-primary-soft: rgba(201, 162, 39, 0.22);
}

html[data-theme="dark"] body.admin.pt-theme,
html[data-theme="dark"] body.pt-theme,
html.pt-dark body.admin.pt-theme {
  background-color: var(--pt-content-bg) !important;
  color: var(--pt-text);
}

html[data-theme="dark"] body.admin.pt-theme #wrapper,
html[data-theme="dark"] body.admin.pt-theme .content {
  background-color: var(--pt-content-bg);
  color: var(--pt-text);
}

html[data-theme="dark"] body.admin.pt-theme #header {
  background: var(--pt-header-bg) !important;
  border-bottom-color: var(--pt-border);
}

html[data-theme="dark"] body.admin.pt-theme #menu.sidebar,
html[data-theme="dark"] body.admin.pt-theme aside#menu,
html[data-theme="dark"] body.admin.pt-theme #setup-menu-wrapper {
  background: var(--pt-sidebar-bg) !important;
  border-right-color: var(--pt-border);
}

html[data-theme="dark"] body.pt-theme .panel_s,
html[data-theme="dark"] body.pt-theme .modal-content,
html[data-theme="dark"] body.pt-theme .dropdown-menu {
  background: var(--pt-card-bg);
  border-color: var(--pt-border);
  color: var(--pt-text);
}

html[data-theme="dark"] body.pt-theme .panel_s > .panel-heading,
html[data-theme="dark"] body.pt-theme .panel_s > .panel-body,
html[data-theme="dark"] body.pt-theme .panel_s > .panel-footer,
html[data-theme="dark"] body.pt-theme .modal-header,
html[data-theme="dark"] body.pt-theme .modal-footer {
  background: var(--pt-card-bg);
  border-color: var(--pt-border);
  color: var(--pt-text);
}

html[data-theme="dark"] body.pt-theme .form-control,
html[data-theme="dark"] body.pt-theme .input-group-addon,
html[data-theme="dark"] body.pt-theme .bootstrap-select > .dropdown-toggle,
html[data-theme="dark"] body.pt-theme .select2-container--default .select2-selection--single,
html[data-theme="dark"] body.pt-theme .select2-container--default .select2-selection--multiple {
  background-color: #0f172a !important;
  border-color: var(--pt-border) !important;
  color: var(--pt-text) !important;
}

html[data-theme="dark"] body.pt-theme .btn-default {
  background: #1e293b;
  border-color: var(--pt-border);
  color: var(--pt-text);
}

html[data-theme="dark"] body.pt-theme .btn-default:hover {
  background: #334155;
  color: #fff;
}

html[data-theme="dark"] body.pt-theme .table > thead > tr > th,
html[data-theme="dark"] body.pt-theme .table > tbody > tr > td,
html[data-theme="dark"] body.pt-theme table.dataTable thead > tr > th {
  border-color: var(--pt-border) !important;
  color: var(--pt-text);
}

html[data-theme="dark"] body.pt-theme .table-striped > tbody > tr:nth-of-type(odd) {
  background-color: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] body.pt-theme .nav-tabs > li.active > a {
  background: var(--pt-card-bg);
  border-color: var(--pt-border) var(--pt-border) transparent;
  color: var(--pt-primary);
}

html[data-theme="dark"] body.pt-theme .nav-tabs {
  border-bottom-color: var(--pt-border);
}

html[data-theme="dark"] body.pt-theme .tw-text-neutral-700,
html[data-theme="dark"] body.pt-theme .tw-text-neutral-800,
html[data-theme="dark"] body.pt-theme .tw-text-neutral-900,
html[data-theme="dark"] body.pt-theme .tw-text-gray-700,
html[data-theme="dark"] body.pt-theme .tw-text-gray-800 {
  color: var(--pt-text) !important;
}

html[data-theme="dark"] body.pt-theme .tw-text-neutral-500,
html[data-theme="dark"] body.pt-theme .tw-text-neutral-400,
html[data-theme="dark"] body.pt-theme .tw-text-gray-500 {
  color: var(--pt-muted) !important;
}

html[data-theme="dark"] body.pt-theme .tw-bg-white,
html[data-theme="dark"] body.pt-theme .tw-bg-neutral-50,
html[data-theme="dark"] body.pt-theme .tw-bg-neutral-100 {
  background-color: var(--pt-card-bg) !important;
}

html[data-theme="dark"] body.pt-theme .tw-border-neutral-200,
html[data-theme="dark"] body.pt-theme .tw-border-neutral-300,
html[data-theme="dark"] body.pt-theme .tw-border-solid {
  border-color: var(--pt-border) !important;
}

html[data-theme="dark"] body.pt-theme #top_search input,
html[data-theme="dark"] body.pt-theme .top-search-input {
  background: #0f172a !important;
  color: var(--pt-text);
  border-color: var(--pt-border) !important;
}

html[data-theme="dark"] body.login_admin,
html[data-theme="dark"] body.authentication {
  background: var(--pt-content-bg) !important;
  color: var(--pt-text);
}

html[data-theme="dark"] .authentication .form-control,
html[data-theme="dark"] body.login_admin .form-control {
  background: #0f172a;
  border-color: var(--pt-border);
  color: var(--pt-text);
}

/* DataTables dark */
html[data-theme="dark"] body.pt-theme .dataTables_wrapper .dataTables_filter input,
html[data-theme="dark"] body.pt-theme .dataTables_wrapper .dataTables_length select {
  background: #0f172a;
  border-color: var(--pt-border);
  color: var(--pt-text);
}

html[data-theme="dark"] body.pt-theme .pagination > li > a,
html[data-theme="dark"] body.pt-theme .pagination > li > span {
  background: var(--pt-card-bg);
  border-color: var(--pt-border);
  color: var(--pt-text);
}

/* Design page swatches stay readable */
html[data-theme="dark"] .pt-preset-card {
  background: var(--pt-card-bg);
}

html[data-theme="dark"] body.pt-theme nav.customer-tabs,
html[data-theme="dark"] body.pt-theme .md\:tw-max-w-64:has(nav.customer-tabs) {
  background: var(--pt-card-bg);
  border-color: var(--pt-border);
}

html[data-theme="dark"] body.pt-theme .ccp-card {
  background: var(--pt-card-bg) !important;
  border-color: var(--pt-border) !important;
  color: var(--pt-text);
}
