/* ============================================================
   QTPL GLOBAL THEME SYSTEM
   Dark (default) + Light mode for all pages
   ============================================================ */

/* ---------- DARK THEME (DEFAULT) ---------- */
:root,
html[data-theme="dark"] {
  --bg-1: #0a0f1e;
  --bg-2: #0f172a;
  --bg-3: #1e293b;
  --bg-hero: radial-gradient(ellipse at top left, #103421 0%, #0a0f1e 60%);
  --bg-gradient: linear-gradient(180deg, #0a0f1e 0%, #0f172a 50%, #0a0f1e 100%);
  --bg-gradient-soft: linear-gradient(135deg, #0a0f1e, #0f172a);
  --card-bg: linear-gradient(145deg, rgba(30, 41, 59, 0.85), rgba(15, 23, 42, 0.95));
  --card-bg-solid: #1e293b;
  --card-bg-hover: rgba(30, 41, 59, 0.95);
  --card-border: rgba(255, 255, 255, 0.06);
  --card-border-strong: rgba(255, 255, 255, 0.12);
  --text-primary: #ffffff;
  --text-secondary: #b8c4d9;
  --text-muted: #8b9bb4;
  --text-inverse: #0a0f1e;
  --heading-color: #ffffff;
  --grid-line: rgba(27, 189, 54, 0.06);
  --orb-opacity: 0.28;
  --shadow: rgba(0, 0, 0, 0.4);
  --shadow-light: rgba(0, 0, 0, 0.2);
  --glow: rgba(27, 189, 54, 0.25);
  --glow-strong: rgba(27, 189, 54, 0.4);
  --accent-bg: rgba(27, 189, 54, 0.12);
  --accent-bg-hover: rgba(27, 189, 54, 0.2);
  --accent-border: rgba(94, 226, 122, 0.35);
  --accent-border-strong: rgba(94, 226, 122, 0.5);
  --accent-text: #5ee27a;
  --accent-solid: #1bbd36;
  --logo-filter: grayscale(60%) brightness(1.05);
  --logo-opacity: 0.85;
  --input-bg: rgba(255, 255, 255, 0.05);
  --input-border: rgba(255, 255, 255, 0.1);
  --divider: rgba(255, 255, 255, 0.08);
}

/* ---------- LIGHT THEME ---------- */
html[data-theme="light"] {
  --bg-1: #f8fafc;
  --bg-2: #f1f5f9;
  --bg-3: #ffffff;
  --bg-hero: radial-gradient(ellipse at top left, #e8f5eb 0%, #f8fafc 60%);
  --bg-gradient: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 50%, #f8fafc 100%);
  --bg-gradient-soft: linear-gradient(135deg, #f8fafc, #f1f5f9);
  --card-bg: linear-gradient(145deg, #ffffff, #f8fafc);
  --card-bg-solid: #ffffff;
  --card-bg-hover: #f1f5f9;
  --card-border: rgba(15, 23, 42, 0.08);
  --card-border-strong: rgba(15, 23, 42, 0.15);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;
  --heading-color: #0f172a;
  --grid-line: rgba(27, 189, 54, 0.12);
  --orb-opacity: 0.12;
  --shadow: rgba(15, 23, 42, 0.1);
  --shadow-light: rgba(15, 23, 42, 0.05);
  --glow: rgba(27, 189, 54, 0.15);
  --glow-strong: rgba(27, 189, 54, 0.25);
  --accent-bg: rgba(27, 189, 54, 0.1);
  --accent-bg-hover: rgba(27, 189, 54, 0.18);
  --accent-border: rgba(27, 189, 54, 0.3);
  --accent-border-strong: rgba(27, 189, 54, 0.45);
  --accent-text: #14972a;
  --accent-solid: #1bbd36;
  --logo-filter: grayscale(100%) brightness(0.95);
  --logo-opacity: 1;
  --input-bg: #ffffff;
  --input-border: rgba(15, 23, 42, 0.12);
  --divider: rgba(15, 23, 42, 0.08);
}

/* ---------- BASE TRANSITIONS ---------- */
html,
body {
  transition: background-color 0.4s ease, color 0.4s ease;
}

body {
  background-color: var(--bg-1);
  color: var(--text-primary);
}

section,
div,
header,
footer,
nav,
article,
aside,
h1, h2, h3, h4, h5, h6,
p, a, span, li,
button {
  transition-property: background-color, color, border-color, box-shadow;
  transition-duration: 0.4s;
  transition-timing-function: ease;
}

/* ---------- THEME TOGGLE BUTTON ---------- */
.theme-toggle-btn {
  position: fixed;
  top: 90px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--card-border-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: var(--text-primary);
  box-shadow: 0 10px 30px var(--shadow);
  z-index: 99998;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  padding: 0;
}

.theme-toggle-btn::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, #1bbd36, #5ee27a, #00f2fe, #a78bfa, #1bbd36);
  opacity: 0;
  transition: opacity 0.3s;
  animation: themeRotate 4s linear infinite;
  z-index: -1;
}

.theme-toggle-btn:hover::before { opacity: 0.2; }

@keyframes themeRotate {
  to { transform: rotate(360deg); }
}

.theme-toggle-btn:hover {
  transform: scale(1.1) rotate(15deg);
  box-shadow: 0 15px 40px var(--shadow), 0 0 0 1px var(--accent-border-strong);
}

.theme-toggle-btn .icon-sun,
.theme-toggle-btn .icon-moon {
  position: absolute;
  transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  line-height: 1;
}

html[data-theme="dark"] .theme-toggle-btn .icon-sun,
html:not([data-theme]) .theme-toggle-btn .icon-sun {
  opacity: 1;
  transform: rotate(0) scale(1);
  color: #fbbf24;
}

html[data-theme="dark"] .theme-toggle-btn .icon-moon,
html:not([data-theme]) .theme-toggle-btn .icon-moon {
  opacity: 0;
  transform: rotate(-180deg) scale(0.3);
}

html[data-theme="light"] .theme-toggle-btn .icon-sun {
  opacity: 0;
  transform: rotate(180deg) scale(0.3);
}

html[data-theme="light"] .theme-toggle-btn .icon-moon {
  opacity: 1;
  transform: rotate(0) scale(1);
  color: #1e293b;
}

@media (max-width: 768px) {
  .theme-toggle-btn {
    top: 80px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .theme-toggle-btn {
    top: 70px;
    right: 12px;
    width: 40px;
    height: 40px;
    font-size: 16px;
  }
}