/* Theme Toggle Styles */

.theme-toggle {
  position: relative;
  display: flex;
  align-items: center;
  margin-left: auto;
  margin-right: 0px;
}

.theme-toggle__label {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 24px;
  cursor: pointer;
}

.theme-toggle__input {
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-toggle__slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to right, var(--color-gradient-start), var(--color-gradient-end));
  border-radius: 24px;
  transition: 0.4s;
  overflow: hidden; /* Add overflow hidden to hide icons when they go behind the slider */
}

.theme-toggle__slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.4s;
  z-index: 2; /* Ensure the slider button is above the icons */
}

.theme-toggle__input:checked + .theme-toggle__slider {
  background: linear-gradient(to right, #00b4d8, #90e0ef);
}

.theme-toggle__input:checked + .theme-toggle__slider:before {
  transform: translateX(26px);
}

.theme-toggle__icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  color: var(--color-text);
  z-index: 1;
  transition: opacity 0.3s ease;
}

.theme-toggle__icon--sun {
  left: 6px;
  opacity: 0; /* Hide sun icon by default (dark mode) */
}

.theme-toggle__icon--moon {
  right: 6px;
  opacity: 1; /* Show moon icon by default (dark mode) */
}

/* Show sun icon and hide moon icon when in light mode */
.theme-toggle__input:checked ~ .theme-toggle__slider .theme-toggle__icon--sun,
.light-mode .theme-toggle__icon--sun {
  opacity: 1;
}

.theme-toggle__input:checked ~ .theme-toggle__slider .theme-toggle__icon--moon,
.light-mode .theme-toggle__icon--moon {
  opacity: 0;
}

/* Mobile Responsive */
@media screen and (max-width: 960px) {
  .theme-toggle {
    position: absolute;
    top: 20px;
    right: 70px;
  }
  
  .theme-toggle__label {
    width: 40px;
    height: 20px;
  }
  
  .theme-toggle__slider:before {
    height: 14px;
    width: 14px;
  }
  
  .theme-toggle__input:checked + .theme-toggle__slider:before {
    transform: translateX(20px);
  }
}
