/* Tema da Central: alterna superfícies e contraste sem trocar a identidade.
   Roxo estrutura, laranja assina e os estados semânticos mantêm significado. */
.theme-toggle {
  display: inline-flex;
  min-width: 96px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--ct-line-strong, var(--border-default));
  border-radius: 8px;
  background: var(--ct-surface, var(--background-surface));
  color: var(--ct-purple, var(--brand-primary));
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  white-space: nowrap;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.theme-toggle:hover {
  border-color: var(--ct-purple, var(--brand-primary));
  background: var(--ct-purple-soft, var(--brand-primary-soft));
  color: var(--ct-purple-dark, var(--brand-primary-hover));
}
.theme-toggle:active { transform: translateY(1px); }
.theme-toggle:focus-visible { outline: 3px solid color-mix(in srgb, var(--ct-purple, #6b02a8), transparent 66%); outline-offset: 2px; }
.theme-toggle-icon { display: grid; place-items: center; }
.theme-toggle-icon .ui-icon { width: 17px; height: 17px; }
.theme-toggle-moon { display: none; }

html[data-theme="dark"] {
  --brand-primary: #bd6be0;
  --brand-primary-hover: #d08aef;
  --brand-primary-soft: #382641;
  --brand-primary-subtle: #271d2b;
  --brand-accent: #f0ad32;
  --brand-accent-hover: #f5bd53;
  --brand-accent-soft: #3a2a19;
  --brand-lilac: #ca98ed;
  --background-app: #18131b;
  --background-surface: #211a24;
  --background-muted: #2a222e;
  --text-primary: #f2eaf4;
  --text-secondary: #d5c9d9;
  --text-muted: #aa9daf;
  --border-default: #4b3d50;
  --border-subtle: #382e3c;
  --success: #72c99c;
  --success-soft: #173529;
  --warning: #f0b552;
  --warning-soft: #3b2b18;
  --danger: #ef8994;
  --danger-soft: #3c2027;
  --info: #8fb7e7;
  --info-soft: #202f42;
  --shadow-sm: 0 1px 2px rgba(5, 2, 7, .28);
  --shadow-md: 0 12px 34px rgba(5, 2, 7, .35);

  --ct-canvas: #18131b;
  --ct-canvas-warm: #1d171f;
  --ct-surface: #211a24;
  --ct-surface-raised: #29202d;
  --ct-surface-lilac: #2f2236;
  --ct-surface-lilac-strong: #3a2943;
  --ct-ink: #f2eaf4;
  --ct-text: #d5c9d9;
  --ct-muted: #aa9daf;
  --ct-line: #3e3343;
  --ct-line-strong: #5b4a61;
  --ct-purple: #bd6be0;
  --ct-purple-dark: #d493ef;
  --ct-purple-soft: #382641;
  --ct-orange: #f0ad32;
  --ct-orange-dark: #f4bd58;
  --ct-orange-soft: #3a2a19;
  --ct-green: #72c99c;
  --ct-green-soft: #173529;
  --ct-blue: #8fb7e7;
  --ct-blue-soft: #202f42;
  --ct-red: #ef8994;
  --ct-red-soft: #3c2027;
  --ct-shadow: 0 12px 34px rgba(5, 2, 7, .38);
}

html[data-theme="dark"] body:has(.app-shell),
html[data-theme="dark"] body:has(.app-shell) .app-shell,
html[data-theme="dark"] body:has(.app-shell) .main,
html[data-theme="dark"] body:has(.app-shell) .content {
  background: var(--ct-canvas);
  color: var(--ct-text);
  color-scheme: dark;
}
html[data-theme="dark"] body:has(.app-shell) .sidebar { background: #1d171f; border-color: var(--ct-line); }
html[data-theme="dark"] body:has(.app-shell) .topbar { background: rgba(33, 26, 36, .96); border-color: var(--ct-line); }
html[data-theme="dark"] body:has(.app-shell) .org-card { background: #2a1e30; border-color: var(--ct-line); }
html[data-theme="dark"] body:has(.app-shell) .sidebar-footer,
html[data-theme="dark"] body:has(.app-shell) .sidebar-brand { border-color: var(--ct-line); }
html[data-theme="dark"] body:has(.app-shell) .user-summary,
html[data-theme="dark"] body:has(.app-shell) .sidebar-toggle,
html[data-theme="dark"] body:has(.app-shell) .mobile-menu { color: var(--ct-text); }
html[data-theme="dark"] body:has(.app-shell) .session-logout-button,
html[data-theme="dark"] body:has(.app-shell) .logout-button {
  border-color: var(--ct-line-strong);
  background: var(--ct-surface);
  color: var(--ct-ink);
}
html[data-theme="dark"] .theme-toggle { border-color: var(--ct-line-strong); background: var(--ct-surface-raised); color: var(--ct-orange); }
html[data-theme="dark"] .theme-toggle:hover { border-color: var(--ct-orange); background: var(--ct-orange-soft); color: var(--ct-orange-dark); }
html[data-theme="dark"] .theme-toggle-sun { display: none; }
html[data-theme="dark"] .theme-toggle-moon { display: grid; }

html[data-theme="dark"] :is(.operational-board-workspace,.post-sales-workspace,.reputation-workspace,.experience-workspace,#board-record-panel,#reputation-panel,#xp-panel,.op-panel,.op-create-dialog,.op-view-panel,.op-selection-dialog) { color-scheme: dark; }
html[data-theme="dark"] :is(.operational-board-workspace,.post-sales-workspace,.reputation-workspace,.experience-workspace) :is(input,select,textarea) { color-scheme: dark; }
html[data-theme="dark"] :is(.op-group-head,.op-table th,.op-subitem-container th,.monday-grid :is(thead,.board-group-columns) th,.reputation-table-wrap th,.xp-table-wrap th,.admin-user-table th) {
  background: var(--ct-surface-lilac-strong);
  color: var(--ct-text);
}
html[data-theme="dark"] :is(.op-table-wrap,.op-table th,.op-table td,.op-add-row td,.op-subitem-container table,.op-subitem-container th,.op-subitem-container td,.monday-grid-scroll,.monday-grid th,.monday-grid td,.monday-grid [data-col=name]) {
  background: var(--ct-surface);
  border-color: var(--ct-line);
  color: var(--ct-ink);
}
html[data-theme="dark"] .op-table tbody tr:not(.op-add-row):hover td,
html[data-theme="dark"] .reputation-table-wrap tbody tr:hover,
html[data-theme="dark"] .xp-table-wrap tbody tr:hover,
html[data-theme="dark"] .admin-user-table tr:hover td { background: #2b2130; }
html[data-theme="dark"] .op-subitem-container > td { background: var(--ct-surface-lilac) !important; }
html[data-theme="dark"] :is(.op-cell-input,.op-subitem-container input,.monday-grid input,.monday-grid textarea):focus {
  background: var(--ct-surface-raised);
  color: var(--ct-ink);
  caret-color: var(--ct-purple);
}
html[data-theme="dark"] :is(.op-cell-select,.op-cell-person) { color: var(--ct-ink); }
html[data-theme="dark"] :is(.op-cell-select,.op-cell-person,.monday-grid) option { background: var(--ct-surface-raised); color: var(--ct-ink); }
html[data-theme="dark"] .op-cell-select { background-color: color-mix(in srgb, var(--cell-color, transparent) 22%, var(--ct-surface)); }
html[data-theme="dark"] :is(.op-panel,.op-create-dialog,.op-view-panel,.op-selection-dialog,.board-columns > div,.board-column-popup,.board-status-popup,.board-tool-popup,.board-group-dialog,.cell-emoji-popup,.mention-picker,#board-record-panel,#reputation-panel,#xp-panel) {
  background: var(--ct-surface);
  border-color: var(--ct-line-strong);
  color: var(--ct-text);
}
html[data-theme="dark"] :is(.op-panel,.op-create-dialog,.board-tool-popup,.board-group-dialog,.board-status-popup,.cell-emoji-popup,.mention-picker,#board-record-panel,#reputation-panel,#xp-panel) :is(input:not([type=checkbox]):not([type=radio]),select,textarea),
html[data-theme="dark"] :is(.result-choice label > span,.evidence-drop,.history-entry,.xp-diagnostic,.xp-event,[data-panel-content] article,[data-panel-content] .board-composer,#board-record-panel .panel-empty,#board-record-panel footer) {
  background: var(--ct-surface-raised);
  border-color: var(--ct-line);
  color: var(--ct-ink);
}
html[data-theme="dark"] :is(.quick-filter-values button,.owner-chip,.xp-score.none,.result-tag.without_attempt,.result-tag.operational_pending,.admin-status,.admin-settings .status-pill) {
  background: var(--ct-surface-lilac);
  color: var(--ct-text);
}
html[data-theme="dark"] .monday-grid td.status-cell,
html[data-theme="dark"] .monday-grid .board-extra-pinned.status-cell { background: color-mix(in srgb, var(--cell-color, #8f8793) 32%, var(--ct-surface)); color: var(--ct-ink); }

html[data-theme="dark"] body.admin-settings { color-scheme: dark; }
html[data-theme="dark"] .admin-nav { background: #241a29; border-color: var(--ct-line); }
html[data-theme="dark"] .admin-heading { background: #211a24; border-color: var(--ct-line); }
html[data-theme="dark"] .admin-nav-group a:hover { background: var(--ct-surface-lilac); }
html[data-theme="dark"] :is(.admin-settings .create-panel,.admin-settings .create-strip,.admin-table-scroll,.admin-board-access > summary,.admin-board-access fieldset,.brand-upload-card,.profile-photo-editor) {
  background: var(--ct-surface);
  border-color: var(--ct-line);
  color: var(--ct-text);
}
html[data-theme="dark"] .admin-settings .topbar { background: #2c1933; border-color: #51345b; }
html[data-theme="dark"] .admin-settings .theme-toggle { border-color: rgba(255,255,255,.42); background: rgba(255,255,255,.08); color: #f0ad32; }
html[data-theme="dark"] .admin-settings .session-logout-button { background: transparent; color: #fff; border-color: rgba(255,255,255,.45); }

@media (max-width: 760px) {
  .theme-toggle { min-width: 44px; width: 44px; min-height: 44px; padding: 0; }
  .theme-toggle-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle { transition-duration: .01ms; }
}
