/* ═══════════════════════════════════════════════════════════════
   THEME PANEL UI
   ═══════════════════════════════════════════════════════════════ */

/* Wrapper */
.theme-settings-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* Toggle Button - Neumorphic 3D Design */
#theme-settings-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-faint);
  color: var(--text-secondary);
  border-radius: var(--r-full);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  padding: 0;
  /* Neumorphic 3D extrusion */
  box-shadow: 
    4px 4px 8px rgba(0, 0, 0, 0.1),
    -4px -4px 8px rgba(255, 255, 255, 0.05),
    inset 1px 1px 1px rgba(255, 255, 255, 0.1),
    inset -1px -1px 1px rgba(0, 0, 0, 0.05);
}

#theme-settings-btn:hover {
  color: var(--text-primary);
  transform: translateY(-1px);
  box-shadow: 
    6px 6px 12px rgba(0, 0, 0, 0.12),
    -6px -6px 12px rgba(255, 255, 255, 0.06),
    inset 1px 1px 2px rgba(255, 255, 255, 0.15),
    inset -1px -1px 2px rgba(0, 0, 0, 0.05);
}

.theme-settings-wrapper:has(.theme-settings-panel.active) #theme-settings-btn,
#theme-settings-btn:active {
  /* Pressed state */
  transform: translateY(1px);
  background: var(--bg-root);
  box-shadow: 
    inset 4px 4px 8px rgba(0, 0, 0, 0.1),
    inset -4px -4px 8px rgba(255, 255, 255, 0.04);
}

#theme-settings-btn svg {
  transition: transform var(--t-normal);
}

#theme-settings-btn:hover svg {
  transform: rotate(15deg);
}

/* Panel */
.theme-settings-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 12px;
  width: 290px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: 
    10px 10px 20px rgba(0, 0, 0, 0.15),
    -10px -10px 20px rgba(255, 255, 255, 0.05),
    inset 1px 1px 1px rgba(255, 255, 255, 0.1);
  padding: 16px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.95);
  transform-origin: top right;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s;
  z-index: var(--z-modal);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.theme-settings-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Panel Header */
.ts-header {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-faint);
}

.ts-header h4 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0;
  font-family: var(--font-body);
}

/* Panel Sections */
.ts-section {
  margin-bottom: 16px;
}

.ts-section:last-child {
  margin-bottom: 0;
}

.ts-label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}

/* Mode Selector (Segmented Control) */
.ts-mode-selector {
  display: flex;
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  padding: 6px;
  gap: 6px;
  box-shadow: 
    inset 4px 4px 8px rgba(0, 0, 0, 0.15),
    inset -4px -4px 8px rgba(255, 255, 255, 0.05);
}

.ts-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--r-md);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--t-fast);
}

.ts-mode-btn svg {
  flex-shrink: 0;
}

.ts-mode-btn:hover {
  color: var(--text-primary);
}

.ts-mode-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: 
    4px 4px 8px rgba(0, 0, 0, 0.2),
    -4px -4px 8px rgba(255, 255, 255, 0.08);
}

/* Theme Swatches */
.ts-theme-selector {
  display: flex;
  justify-content: space-between;
}

.ts-theme-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: var(--swatch-color);
  cursor: pointer;
  transition: var(--t-fast);
  padding: 0;
  position: relative;
  box-shadow: 
    3px 3px 6px rgba(0, 0, 0, 0.2),
    -2px -2px 5px rgba(255, 255, 255, 0.08);
}

.ts-theme-swatch:hover {
  transform: scale(1.15);
  box-shadow: 
    4px 4px 8px rgba(0, 0, 0, 0.25),
    -3px -3px 6px rgba(255, 255, 255, 0.1);
}

.ts-theme-swatch.active {
  transform: scale(0.95);
  box-shadow: 
    inset 3px 3px 6px rgba(0, 0, 0, 0.4),
    inset -2px -2px 5px rgba(255, 255, 255, 0.1),
    0 0 0 2px var(--bg-card), 
    0 0 0 4px var(--swatch-color);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
  .theme-settings-panel {
    right: -16px; /* align with screen edge */
    width: 300px;
    margin-top: 16px;
  }
}
