/**
 * SfThemeSwitcher — M4-A UI layer (calls SfThemeManager only)
 */
.sf-theme-switcher {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  border: 1px solid var(--color-border-subtle, rgba(145, 174, 210, 0.16));
  background: var(--color-bg-control, rgba(255, 255, 255, 0.06));
  box-shadow: none;
}

.sf-theme-switcher__btn {
  appearance: none;
  border: 0;
  margin: 0;
  padding: 5px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  color: var(--color-text-muted, #9fb0c5);
  background: transparent;
  transition: color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.sf-theme-switcher__btn:hover {
  color: var(--color-text-primary, #e8f1ff);
  background: var(--color-bg-control-hover, rgba(255, 255, 255, 0.12));
}

.sf-theme-switcher__btn:focus {
  outline: none;
}

.sf-theme-switcher__btn:focus-visible {
  outline: 2px solid var(--color-interactive-primary, #5aa8ff);
  outline-offset: 2px;
}

.sf-theme-switcher__btn.is-active,
.sf-theme-switcher__btn[aria-pressed="true"] {
  color: var(--color-text-on-selected, #f3f8ff);
  background: var(--color-bg-selected-soft, rgba(90, 150, 220, 0.14));
  box-shadow: var(--shadow-selected-inset, 0 0 0 1px rgba(80, 140, 210, 0.18) inset);
}

html[data-theme="light"] .sf-theme-switcher__btn {
  color: var(--color-text-muted, #748899);
}
html[data-theme="light"] .sf-theme-switcher__btn:hover {
  color: var(--color-text-primary, #263b4a);
  background: var(--color-bg-control-hover, rgba(37, 99, 235, 0.08));
}
html[data-theme="light"] .sf-theme-switcher__btn.is-active,
html[data-theme="light"] .sf-theme-switcher__btn[aria-pressed="true"] {
  color: var(--color-interactive-primary, #2563eb);
  background: rgba(37, 99, 235, 0.12);
}

/* Desktop sidebar placement */
.sf-theme-switcher-host--sidebar {
  display: none;
}

@media (min-width: 768px) {
  body.has-desktop-shell .desktop-sidebar .sf-theme-switcher-host--sidebar {
    display: block;
    margin-top: auto;
    padding: 0 6px 10px;
  }

  body.has-desktop-shell .sf-theme-switcher-host--floating {
    display: none !important;
  }
}

/* Mobile / peripheral floating placement */
.sf-theme-switcher-host--floating {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
  z-index: 85;
  pointer-events: none;
}

.sf-theme-switcher-host--floating .sf-theme-switcher {
  pointer-events: auto;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-panel, 0 10px 28px rgba(0, 0, 0, 0.18));
}

@media (max-width: 767px) {
  body.has-desktop-shell .sf-theme-switcher-host--floating {
    display: block !important;
  }

  /* Avoid overlapping mobile back button on chart family */
  body.has-desktop-shell .v2-mobile-back ~ .sf-theme-switcher-host--floating,
  body.has-desktop-shell:has(.v2-mobile-back) .sf-theme-switcher-host--floating {
    top: calc(48px + env(safe-area-inset-top, 0px));
  }
}

body:not(.has-desktop-shell) .sf-theme-switcher-host--sidebar {
  display: none !important;
}

body:not(.has-desktop-shell) .sf-theme-switcher-host--floating {
  display: block;
}
