/* Тёмная тема и переключатель — BPMN Office */

body,
.app-shell,
.app-sidebar,
.app-main-header,
.admin-panel-body,
.folders-panel,
.diagrams-panel,
.folder-explorer-toolbar,
.editor-page .toolbar {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.15s ease;
}

.theme-switch--fixed {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 300;
  width: auto;
  max-width: none;
  box-shadow: 0 2px 12px rgba(27, 53, 91, 0.12);
}

/* В шапке — только ползунок, без дублирующих иконок солнца/луны */
.theme-switch--compact {
  padding: 4px 6px;
  min-height: 0;
  gap: 0;
}

.theme-switch--compact .theme-switch__icon {
  display: none;
}

.app-main-header .theme-switch--compact {
  flex-shrink: 0;
}

html[data-theme="dark"] .theme-switch--fixed {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.app-main > .app-main-header {
  justify-content: space-between;
  gap: 16px;
}

.app-main > .app-main-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1px solid var(--gl-border);
  border-radius: 999px;
  background: var(--panel-elevated);
  color: var(--muted);
  cursor: pointer;
  flex-shrink: 0;
  font: inherit;
  line-height: 1;
  min-height: 34px;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.theme-switch:hover {
  border-color: var(--gl-border-strong);
  color: var(--text);
}

.theme-switch:focus-visible {
  outline: 2px solid var(--highlight);
  outline-offset: 2px;
}

.theme-switch__icon {
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity 0.2s, color 0.2s;
}

.theme-switch__track {
  position: relative;
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: var(--bpmn-grey-95);
  border: 1px solid var(--gl-border);
  transition: background 0.25s, border-color 0.25s;
}

.theme-switch__knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: transform 0.25s ease;
}

.theme-switch[aria-pressed="true"] {
  border-color: rgba(59, 158, 255, 0.45);
  background: rgba(59, 158, 255, 0.1);
  color: #3b9eff;
}

.theme-switch[aria-pressed="true"] .theme-switch__track {
  background: #3b9eff;
  border-color: #3b9eff;
}

.theme-switch[aria-pressed="true"] .theme-switch__knob {
  transform: translateX(18px);
}

.theme-switch[aria-pressed="true"] .theme-switch__icon--sun { opacity: 0.35; }
.theme-switch[aria-pressed="true"] .theme-switch__icon--moon { opacity: 1; color: #93c5fd; }
.theme-switch[aria-pressed="false"] .theme-switch__icon--sun { opacity: 1; color: #f5a623; }
.theme-switch[aria-pressed="false"] .theme-switch__icon--moon { opacity: 0.35; }

html[data-theme="dark"] {
  color-scheme: dark;

  --bpmn-white: #1a2332;
  --bpmn-canvas: #ffffff;
  --bpmn-surface: #1a2332;
  --content-bg: #1a2332;
  --bg: #0f1419;
  --panel: #1a2332;
  --panel-elevated: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --muted: #8b9cb3;

  --bpmn-grey-15: #e8edf4;
  --bpmn-grey-35: #a8b8cc;
  --bpmn-grey-55: #8b9cb3;
  --bpmn-grey-75: #4a5d78;
  --bpmn-grey-95: #243044;
  --bpmn-grey-97: #1a2332;

  --sidebar-bg: #1a2332;
  --sidebar-border: #2d3a4f;
  --sidebar-text: #e8edf4;
  --sidebar-muted: #8b9cb3;
  --sidebar-hover: #243044;
  --sidebar-active-bg: rgba(59, 158, 255, 0.15);
  --sidebar-active-indicator: #3b9eff;
  --sidebar-brand-bg: #243044;

  --brand-navy: #e8edf4;
  --brand-navy-hover: #ffffff;
  --brand-sky: #3b9eff;
  --brand-sky-soft: rgba(59, 158, 255, 0.15);
  --brand-sky-soft-strong: rgba(59, 158, 255, 0.25);
  --accent-border-soft: rgba(59, 158, 255, 0.35);

  --highlight: #3b9eff;
  --highlight-hover: #5cb0ff;
  --highlight-soft: rgba(59, 158, 255, 0.2);
  --bpmn-blue-soft: rgba(59, 158, 255, 0.2);
  --bpmn-blue: #3b9eff;
  --bpmn-blue-hover: #5cb0ff;

  --accent: #3b9eff;
  --accent-hover: #5cb0ff;
  --accent-soft: rgba(59, 158, 255, 0.15);
  --accent-soft-strong: rgba(59, 158, 255, 0.22);

  --gl-border: #2d3a4f;
  --gl-border-strong: #3d4f6a;
  --gl-blue-500: #3b9eff;
  --btn-primary-bg: #3b9eff;
  --btn-primary-hover: #5cb0ff;
  --btn-secondary-bg: #3d4f6a;
  --btn-secondary-border: #5a6d88;
  --btn-secondary-hover: #4d627d;

  --ok: #34d399;
  --danger: #f87171;
}

html[data-theme="dark"] body:has(#view-login:not(.hidden)) {
  background: #0f1419;
}

html[data-theme="dark"] .app-brand .brand-logo--mark {
  filter: brightness(0) invert(1);
}

html[data-theme="dark"] .login-brand .brand-logo--full {
  filter: brightness(0) invert(1);
}

html[data-theme="dark"] .login-shell {
  border-color: #2d3a4f;
}

html[data-theme="dark"] .login-info-panel {
  color: var(--text);
}

html[data-theme="dark"] .login-auth-panel h2,
html[data-theme="dark"] .login-info-panel h2 {
  color: var(--text);
}

html[data-theme="dark"] .modal-backdrop {
  background: rgba(0, 0, 0, 0.55);
}

html[data-theme="dark"] .modal {
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] button.secondary,
html[data-theme="dark"] .btn.secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
  color: var(--text);
}

html[data-theme="dark"] button.secondary:hover,
html[data-theme="dark"] .btn.secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: #6b7d96;
  color: var(--text);
}

html[data-theme="dark"] .diagram-table .row-actions button.secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
}

html[data-theme="dark"] .diagram-table tbody tr:hover .row-actions button.secondary,
html[data-theme="dark"] .diagram-table tbody tr:focus-within .row-actions button.secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
}

html[data-theme="dark"] .archive-tabs--compact .archive-tab:not(.active) {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
}

html[data-theme="dark"] .archive-tabs--compact .archive-tab:not(.active):hover {
  background: var(--btn-secondary-hover);
  border-color: #6b7d96;
}

html[data-theme="dark"] .modal-actions button.secondary,
html[data-theme="dark"] .editor-page .toolbar button.secondary {
  background: var(--btn-secondary-bg);
  border-color: var(--btn-secondary-border);
  color: var(--text);
}

html[data-theme="dark"] .editor-page .toolbar button.secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: #6b7d96;
}

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #243044;
  border-color: #2d3a4f;
  color: #e8edf4;
}

html[data-theme="dark"] input::placeholder {
  color: #6b7d96;
}

html[data-theme="dark"] .diagram-list-wrap,
html[data-theme="dark"] .folder-explorer-body {
  background: var(--content-bg);
}

html[data-theme="dark"] .kpi__value,
html[data-theme="dark"] .diagrams-panel-header h2,
html[data-theme="dark"] .app-main-header h2 {
  color: var(--text);
}

html[data-theme="dark"] .editor-rail {
  background: #1a2332;
  border-left-color: #2d3a4f;
}

html[data-theme="dark"] .editor-page .toolbar {
  background: #1a2332;
  border-bottom-color: #2d3a4f;
}
