/* Switch flotante claro/oscuro. Clases con prefijo bw-theme-. */

.bw-theme {
  --bw-theme-left: 5px;
  --bw-theme-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  --bw-theme-track: #e9ecef;
  --bw-theme-track-border: rgba(0, 0, 0, 0.12);
  --bw-theme-thumb: #fff;
  --bw-theme-sun: #f5a524;
  --bw-theme-moon: #6c7a91;
  position: fixed;
  left: calc(var(--bw-theme-left) + env(safe-area-inset-left, 0px));
  right: auto;
  bottom: var(--bw-theme-bottom);
  z-index: 99950;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.bw-theme *,
.bw-theme *::before,
.bw-theme *::after {
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .bw-theme {
    --bw-theme-bottom: 65px;
  }
}

.bw-theme-switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  width: 58px;
  height: 32px;
  padding: 0 7px;
  border: 1px solid var(--bw-theme-track-border);
  border-radius: 999px;
  background: var(--bw-theme-track);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  color: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  transform: rotate(90deg);
}

.bw-theme-switch:hover {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
}

.bw-theme-switch:focus-visible {
  outline: 2px solid var(--primary-color, #1abc9c);
  outline-offset: 3px;
}

.bw-theme .bw-theme-icon {
  position: relative;
  z-index: 1;
  display: block;
  width: 14px;
  height: 14px;
  color: var(--bw-theme-moon);
  opacity: 0.55;
  transition: color 0.2s ease, opacity 0.2s ease;
}

.bw-theme .bw-theme-sun {
  color: var(--bw-theme-sun);
  opacity: 1;
}

.bw-theme-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bw-theme-thumb);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
  pointer-events: none;
  transition: transform 0.2s ease;
}

.bw-theme-is-dark {
  --bw-theme-track: #2b2b2b;
  --bw-theme-track-border: rgba(255, 255, 255, 0.16);
  --bw-theme-thumb: #1a1a1a;
  --bw-theme-moon: #c5d0e0;
}

.bw-theme-is-dark .bw-theme-sun {
  opacity: 0.45;
  color: #c9a227;
}

.bw-theme-is-dark .bw-theme-moon {
  opacity: 1;
  color: var(--bw-theme-moon);
}

.bw-theme-is-dark .bw-theme-thumb {
  transform: translateX(26px);
}

@media (max-width: 480px) {
  .bw-theme {
    --bw-theme-left: 0px;
    --bw-theme-bottom: calc(25px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .bw-theme-switch,
  .bw-theme-icon,
  .bw-theme-thumb {
    transition: none;
  }
}

@media print {
  .bw-theme {
    display: none;
  }
}
