/* Theme Toggle Button Styles - Pill-shaped Switch */
.theme-toggle {
  position: absolute;
  top: 40px;
  right: 140px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 100;
  transition: transform 0.2s ease;
}

.theme-toggle:hover {
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

/* Toggle Track (Pill-shaped container) */
.theme-toggle__track {
  position: relative;
  width: 80px;
  height: 38px;
  background: #e8e8e8;
  border-radius: 22px;
  display: flex;
  align-items: center;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: background-color 0.3s ease;
}

/* Toggle Thumb (Sliding circle with shadow - only knob.svg) - Behind icons */
.theme-toggle__thumb {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1;
  /* Use knob.svg as background */
  background-image: url("/assets/img/service/green-ai/knob.svg");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Sun Icon (Centered on knob when in light mode) - Always visible */
.theme-toggle__sun {
  position: absolute;
  left: 12.5px; /* knob 중앙에 맞춤: (44/2) - (19/2) = 22 - 9.5 = 12.5px */
  width: 19px;
  height: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition:
    opacity 0.3s ease,
    left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.theme-toggle__sun img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  /* Default: dark color when not under knob */
  filter: brightness(0);
  transition: filter 0.3s ease;
}

/* Sun icon becomes white when under knob (light mode) */
.theme-toggle__sun.icon-under-knob img,
body[data-theme="light"] .theme-toggle__sun img,
html.light-mode .theme-toggle__sun img {
  filter: brightness(0) invert(1);
}

.theme-toggle__moon {
  position: absolute;
  left: 55px;
  top: 11.5px;
  width: 15px;
  height: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  opacity: 0.6;
  transition:
    opacity 0.3s ease,
    left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.theme-toggle__moon img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  /* Default: dark color */
  filter: brightness(0);
  transition: filter 0.3s ease;
}

/* Moon icon becomes white when under knob (dark mode) */
.theme-toggle__moon.icon-under-knob img,
body[data-theme="dark"] .theme-toggle__moon img,
html.dark-mode .theme-toggle__moon img {
  filter: brightness(0) invert(1);
}

/* Dark Mode State - Thumb moves to right */
body[data-theme="dark"] .theme-toggle__thumb,
html.dark-mode .theme-toggle__thumb {
  transform: translateX(40px);
}

/* Moon centered on knob in dark mode */
body[data-theme="dark"] .theme-toggle__moon,
html.dark-mode .theme-toggle__moon {
  opacity: 1;
  left: 55px;
  top: 11.5px;
}

/* Sun hidden/moved away in dark mode */
body[data-theme="dark"] .theme-toggle__sun,
html.dark-mode .theme-toggle__sun {
  opacity: 0.3;
  left: 12.5px;
  top: 10.5px;
}

/* Light Mode State - Thumb stays on left (default) */
body[data-theme="light"] .theme-toggle__thumb,
html.light-mode .theme-toggle__thumb {
  transform: translateX(0);
}

/* Sun centered on knob in light mode */
body[data-theme="light"] .theme-toggle__sun,
html.light-mode .theme-toggle__sun {
  opacity: 1;
  top: 9.5px;
  left: 12.5px;
}

/* Moon hidden/moved away in light mode */
body[data-theme="light"] .theme-toggle__moon,
html.light-mode .theme-toggle__moon {
  opacity: 0.6;
  left: 55px;
  top: 11.5px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .theme-toggle {
    top: 15px;
    right: 15px;
  }
}
