/* ═══════════════════════════════════════════════════════════════
   Know Yourself Better — Multi-Theme Engine Stylesheet
   Themes: Default Dark, Light, Warm Paper (Sepia), Midnight OLED, Cyberpunk Neon
   ═══════════════════════════════════════════════════════════════ */

/* ─── 1. Warm Paper / Sepia Theme ─── */
[data-theme="sepia"] {
  --bg: #f6f1e8;
  --surface: #ede5d8;
  --border: #dfd4c0;
  --text: #2c2419;
  --text-muted: #6e604f;
  --text-dim: #948472;
  --blue: #8a5a2b;
  --blue-light: #b07840;
  --green: #3d7a54;
  --red: #ba3f32;
  --yellow: #cb8220;
  --orange: #c86326;
  --purple: #7b507d;
  --pink: #b84a6e;
  --glow-blue: rgba(138, 90, 43, 0.12);
  --glow-purple: rgba(123, 80, 125, 0.10);
}

[data-theme="sepia"] .nav-bar {
  background: rgba(246, 241, 232, 0.94);
  border-bottom-color: var(--border);
}

[data-theme="sepia"] .scale-num {
  background: #e4dacf;
  color: #6e604f;
}

[data-theme="sepia"] .results-card {
  background: linear-gradient(135deg, #ede5d8 0%, #dfd3bf 100%);
  border-color: var(--border);
}

[data-theme="sepia"] .breakdown-item,
[data-theme="sepia"] .rec-item {
  background: rgba(44, 36, 25, 0.03);
  border-color: rgba(44, 36, 25, 0.08);
}

[data-theme="sepia"] .breakdown-bar {
  background: rgba(44, 36, 25, 0.08);
}

[data-theme="sepia"] .toast {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: 0 8px 28px rgba(44, 36, 25, 0.15);
}

[data-theme="sepia"] .rating-btn[data-tooltip]::before {
  background: #ede5d8;
  color: #8a5a2b;
  border-color: #dfd4c0;
  box-shadow: 0 4px 14px rgba(138, 90, 43, 0.15);
}

[data-theme="sepia"] .rating-btn[data-tooltip]::after {
  border-bottom-color: #ede5d8;
}

[data-theme="sepia"] .rating-btn.selected-1 { background: rgba(186, 63, 50, 0.18); border-color: var(--red); color: var(--red); }
[data-theme="sepia"] .rating-btn.selected-2 { background: rgba(200, 99, 38, 0.18); border-color: var(--orange); color: var(--orange); }
[data-theme="sepia"] .rating-btn.selected-3 { background: rgba(203, 130, 32, 0.18); border-color: var(--yellow); color: var(--yellow); }
[data-theme="sepia"] .rating-btn.selected-4 { background: rgba(61, 122, 84, 0.18); border-color: var(--green); color: var(--green); }
[data-theme="sepia"] .rating-btn.selected-5 { background: rgba(138, 90, 43, 0.22); border-color: var(--blue); color: var(--blue); }

[data-theme="sepia"] .prob-badge {
  color: var(--blue);
  background: rgba(138, 90, 43, 0.10);
  border-color: rgba(138, 90, 43, 0.25);
}

[data-theme="sepia"] .neural-network-wrapper {
  background: #f6f1e8;
  border-color: var(--border);
}

[data-theme="sepia"] .neural-header {
  background: rgba(246, 241, 232, 0.94);
}

[data-theme="sepia"] .neural-spotlight-card {
  background: rgba(237, 229, 216, 0.96);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="sepia"] .neural-tooltip {
  background: rgba(237, 229, 216, 0.96);
  border-color: var(--border);
  color: var(--text);
}

/* ─── 2. Midnight OLED Theme ─── */
[data-theme="oled"] {
  --bg: #000000;
  --surface: #0a0a0c;
  --border: #1e1e24;
  --text: #f4f4f6;
  --text-muted: #a1a1aa;
  --text-dim: #52525b;
  --blue: #38bdf8;
  --blue-light: #7dd3fc;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --purple: #c084fc;
  --pink: #f472b6;
  --glow-blue: rgba(56, 189, 248, 0.08);
  --glow-purple: rgba(192, 132, 252, 0.08);
}

[data-theme="oled"] .nav-bar {
  background: rgba(0, 0, 0, 0.92);
  border-bottom-color: #1a1a20;
}

[data-theme="oled"] .scale-num {
  background: #121216;
  color: #71717a;
}

[data-theme="oled"] .results-card {
  background: linear-gradient(135deg, #09090c 0%, #13131a 100%);
  border-color: #24242e;
}

[data-theme="oled"] .breakdown-item,
[data-theme="oled"] .rec-item {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="oled"] .toast {
  background: #09090c;
  border-color: #24242e;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.8);
}

[data-theme="oled"] .neural-network-wrapper {
  background: #000000;
  border-color: #1e1e24;
}

[data-theme="oled"] .neural-header {
  background: rgba(0, 0, 0, 0.92);
}

[data-theme="oled"] .neural-spotlight-card {
  background: rgba(10, 10, 12, 0.96);
  border-color: #24242e;
}

/* ─── 3. Cyberpunk Neon Theme ─── */
[data-theme="cyberpunk"] {
  --bg: #090514;
  --surface: #120924;
  --border: #2c144d;
  --text: #f5f3ff;
  --text-muted: #a78bfa;
  --text-dim: #6d52a8;
  --blue: #00f0ff;
  --blue-light: #46f7ff;
  --green: #00ff9d;
  --red: #ff0055;
  --yellow: #ffe600;
  --orange: #ff6b00;
  --purple: #d946ef;
  --pink: #ff2a85;
  --glow-blue: rgba(0, 240, 255, 0.22);
  --glow-purple: rgba(217, 70, 239, 0.24);
}

[data-theme="cyberpunk"] .nav-bar {
  background: rgba(9, 5, 20, 0.90);
  border-bottom: 1px solid rgba(0, 240, 255, 0.25);
  box-shadow: 0 4px 20px rgba(0, 240, 255, 0.08);
}

[data-theme="cyberpunk"] .scale-num {
  background: #1b0e33;
  color: #a78bfa;
  border-color: #3b1d66;
}

[data-theme="cyberpunk"] .results-card {
  background: linear-gradient(135deg, #130a27 0%, #200d3d 100%);
  border: 1px solid rgba(217, 70, 239, 0.4);
  box-shadow: 0 0 30px rgba(217, 70, 239, 0.15), 0 0 15px rgba(0, 240, 255, 0.1);
}

[data-theme="cyberpunk"] .breakdown-item,
[data-theme="cyberpunk"] .rec-item {
  background: rgba(19, 10, 39, 0.7);
  border-color: rgba(217, 70, 239, 0.2);
}

[data-theme="cyberpunk"] .breakdown-bar {
  background: rgba(217, 70, 239, 0.15);
}

[data-theme="cyberpunk"] .toast {
  background: #150b29;
  border-color: rgba(0, 240, 255, 0.4);
  box-shadow: 0 8px 32px rgba(0, 240, 255, 0.2);
  color: #f5f3ff;
}

[data-theme="cyberpunk"] .rating-btn[data-tooltip]::before {
  background: #120924;
  color: #00f0ff;
  border-color: rgba(0, 240, 255, 0.5);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.25);
}

[data-theme="cyberpunk"] .rating-btn[data-tooltip]::after {
  border-bottom-color: #120924;
}

[data-theme="cyberpunk"] .rating-btn.selected-1 { background: rgba(255, 0, 85, 0.2); border-color: #ff0055; color: #ff0055; box-shadow: 0 0 10px rgba(255, 0, 85, 0.3); }
[data-theme="cyberpunk"] .rating-btn.selected-2 { background: rgba(255, 107, 0, 0.2); border-color: #ff6b00; color: #ff6b00; box-shadow: 0 0 10px rgba(255, 107, 0, 0.3); }
[data-theme="cyberpunk"] .rating-btn.selected-3 { background: rgba(255, 230, 0, 0.2); border-color: #ffe600; color: #ffe600; box-shadow: 0 0 10px rgba(255, 230, 0, 0.3); }
[data-theme="cyberpunk"] .rating-btn.selected-4 { background: rgba(0, 255, 157, 0.2); border-color: #00ff9d; color: #00ff9d; box-shadow: 0 0 10px rgba(0, 255, 157, 0.3); }
[data-theme="cyberpunk"] .rating-btn.selected-5 { background: rgba(0, 240, 255, 0.2); border-color: #00f0ff; color: #00f0ff; box-shadow: 0 0 12px rgba(0, 240, 255, 0.35); }

[data-theme="cyberpunk"] .prob-badge {
  color: #00f0ff;
  background: rgba(0, 240, 255, 0.12);
  border-color: rgba(0, 240, 255, 0.35);
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
}

[data-theme="cyberpunk"] .neural-network-wrapper {
  background: #090514;
  border-color: rgba(217, 70, 239, 0.3);
}

[data-theme="cyberpunk"] .neural-header {
  background: rgba(9, 5, 20, 0.92);
}

[data-theme="cyberpunk"] .neural-spotlight-card {
  background: rgba(18, 9, 36, 0.96);
  border-color: rgba(0, 240, 255, 0.4);
  box-shadow: 0 8px 32px rgba(0, 240, 255, 0.15);
}

/* ─── 4. Theme Popover & Switcher UI ─── */
.theme-picker-wrapper {
  position: relative;
  display: inline-block;
}

.theme-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 0 1px rgba(255, 255, 255, 0.1);
  padding: 8px;
  z-index: 1000;
  display: none;
  flex-direction: column;
  gap: 4px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: themePopIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transform-origin: top right;
}

.theme-popover.open {
  display: flex;
}

@keyframes themePopIn {
  0% { opacity: 0; transform: scale(0.94) translateY(-6px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.theme-popover-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  padding: 6px 10px 4px;
  user-select: none;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: all 0.15s ease;
  user-select: none;
  box-sizing: border-box;
}

.theme-option:hover,
.theme-option:focus-visible {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  outline: none;
}

[data-theme="light"] .theme-option:hover,
[data-theme="light"] .theme-option:focus-visible,
[data-theme="sepia"] .theme-option:hover,
[data-theme="sepia"] .theme-option:focus-visible {
  background: rgba(0, 0, 0, 0.04);
}

.theme-option.active {
  background: var(--glow-blue);
  border-color: var(--blue);
  color: var(--text);
  font-weight: 600;
}

.theme-option-icon {
  font-size: 15px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
}

.theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
  display: inline-block;
  box-sizing: border-box;
}

.theme-swatch.swatch-system {
  background: linear-gradient(135deg, #0c0f1a 50%, #f8fafc 50%);
  border-color: #64748b;
}

.theme-swatch.swatch-dark {
  background: #0c0f1a;
  border-color: #3b82f6;
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.4);
}

.theme-swatch.swatch-light {
  background: #f8fafc;
  border-color: #2563eb;
  box-shadow: 0 0 6px rgba(37, 99, 235, 0.2);
}

.theme-swatch.swatch-sepia {
  background: #f6f1e8;
  border-color: #8a5a2b;
  box-shadow: 0 0 6px rgba(138, 90, 43, 0.3);
}

.theme-swatch.swatch-oled {
  background: #000000;
  border-color: #ffffff;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
}

.theme-swatch.swatch-cyberpunk {
  background: #090514;
  border-color: #00f0ff;
  box-shadow: 0 0 6px rgba(0, 240, 255, 0.5);
}

.theme-option-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-option-check {
  font-size: 13px;
  color: var(--blue-light);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.theme-option.active .theme-option-check {
  opacity: 1;
}

.theme-popover-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
  padding: 4px 6px 2px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.theme-popover-hint kbd {
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
}
