/* ==========================================================================
   DECAL TẤN KIỆT - CÔNG TẮC SÁNG / TỐI (mặt trời - mặt trăng)
   Dựa trên mẫu của andrew-demchenk0 (Uiverse.io), chỉnh màu theo web.
   Giao diện sáng: nền trời xanh nhạt, mặt trời bên phải.
   Giao diện tối:  nền xám than, mặt trăng cyan bên trái.
   ========================================================================== */
.theme-switch {
  --ts-w: 60px;
  --ts-h: 32px;
  --ts-knob: 26px;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  width: var(--ts-w);
  height: var(--ts-h);
  cursor: pointer;
}

.theme-switch-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.theme-switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #8fd0ff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.18);
  transition: background-color 0.4s, border-color 0.4s;
}

.theme-switch-slider::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 3px;
  width: var(--ts-knob);
  height: var(--ts-knob);
  border-radius: 50%;
  background: #f5f5f5;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transform: translateY(-50%);
  transition: transform 0.4s, background-color 0.4s;
}

.theme-switch-sun svg,
.theme-switch-moon svg {
  position: absolute;
  z-index: 1;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
}

.theme-switch-sun svg {
  right: 6px;
  animation: themeSwitchRotate 15s linear infinite;
}

.theme-switch-moon svg {
  left: 6px;
  fill: #3b82c4;
  animation: themeSwitchTilt 5s linear infinite;
}

/* Bật = giao diện tối */
.theme-switch-input:checked + .theme-switch-slider {
  background: #1b1d20;
  border-color: rgba(var(--rgb-gold), 0.45);
}

.theme-switch-input:checked + .theme-switch-slider::before {
  transform: translate(calc(var(--ts-w) - var(--ts-knob) - 8px), -50%);
  background: #e8e8e8;
}

:root[data-theme="dark"] .theme-switch-moon svg {
  fill: rgb(var(--rgb-gold));
}

.theme-switch-input:focus-visible + .theme-switch-slider {
  outline: 2px solid var(--accent-gold);
  outline-offset: 2px;
}

.theme-switch:hover .theme-switch-slider {
  border-color: var(--accent-gold);
}

@keyframes themeSwitchRotate {
  from { transform: rotate(0); }
  to { transform: rotate(360deg); }
}

@keyframes themeSwitchTilt {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

/* Điện thoại: thu nhỏ để vừa thanh menu */
@media (max-width: 480px) {
  .theme-switch {
    --ts-w: 52px;
    --ts-h: 28px;
    --ts-knob: 22px;
  }
  .theme-switch-sun svg,
  .theme-switch-moon svg {
    width: 17px;
    height: 17px;
    margin-top: -8.5px;
  }
  .theme-switch-sun svg { right: 5px; }
  .theme-switch-moon svg { left: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch-sun svg,
  .theme-switch-moon svg { animation: none; }
  .theme-switch-slider,
  .theme-switch-slider::before { transition: none; }
}

/* Chuyển màu mượt khi đổi giao diện */
body {
  transition: background-color 0.25s ease, color 0.25s ease;
}
