/* ============================================
   SUNO EXPLORER - Settings Page
   ============================================ */

:root {
  --bg-base: #09090b;
  --bg-surface: #111113;
  --bg-elevated: #18181b;
  --bg-hover: #232328;
  
  --text-primary: #fafafa;
  --text-secondary: #e6e6e6;
  --text-muted: #52525b;
  
  --accent: #a855f7;
  --accent-bright: #c084fc;
  --accent-dim: rgba(168, 85, 247, 0.15);
  
  --success: #22c55e;
  --warning: #eab308;
  --error: #ef4444;
  
  --border: #27272a;
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  
  --font-sans: 'Space Grotesk', -apple-system, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.back-btn {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.back-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 28px;
}

.logo-text {
  font-size: 20px;
  font-weight: 600;
}

.save-status {
  font-size: 13px;
  color: var(--success);
}

/* Main */
.main {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px;
}

/* Sections */
.section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.section-header {
  margin-bottom: 20px;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.section-desc {
  font-size: 14px;
  color: var(--text-secondary);
}

/* Privacy Tiers */
.privacy-tiers {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.privacy-tier {
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  transition: all 0.2s;
  cursor: pointer;
}

.privacy-tier:hover {
  border-color: var(--text-muted);
}

.privacy-tier:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.tier-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tier-radio {
  display: flex;
  align-items: center;
}

.tier-radio input[type="radio"] {
  display: none;
}

.tier-label {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.tier-icon {
  font-size: 24px;
}

.tier-name {
  font-size: 16px;
  font-weight: 600;
}

.tier-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tier-badge.minimal {
  background: var(--bg-surface);
  color: var(--text-muted);
}

.tier-badge.recommended {
  background: var(--accent-dim);
  color: var(--accent-bright);
}

.tier-badge.full {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.tier-badge.community {
  background: rgba(234, 179, 8, 0.15);
  color: var(--warning);
}

.tier-details {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.tier-details p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.tier-includes {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.tier-includes li {
  font-size: 12px;
  color: var(--text-secondary);
}

.tier-includes li.included {
  color: var(--success);
}

.tier-includes li.excluded {
  color: var(--text-muted);
}

.tier-note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.tier-note strong {
  color: var(--text-secondary);
}

/* Data Actions */
.data-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.data-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
}

.action-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.action-info p {
  font-size: 12px;
  color: var(--text-muted);
  padding-right: 6px;
}

/* Buttons */
.btn {
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--error);
  border: 1px solid var(--error);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

/* Toggle */
.toggle-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
}

.toggle-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.toggle-info p {
  font-size: 12px;
  color: var(--text-muted);
}

/* Feature Preview */
.feature-preview {
  margin-top: 24px;
  padding: 20px;
  background: rgba(168, 85, 247, 0.05);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 12px;
}

.feature-preview h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--accent);
}

.feature-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feature-list li {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.feature-list li strong {
  color: var(--text-primary);
}

.toggle {
  display: flex;
  position: relative;
  width: 48px;
  height: 26px;
}

.toggle input {
  display: none;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated, #2a2a3a);
  border: 1px solid var(--border, #3a3a4a);
  border-radius: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  background: var(--text-secondary, #888);
  border-radius: 50%;
  transition: all 0.2s;
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(22px);
  background: white;
}

/* Error Log */
.error-log {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
}

.error-log h4 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.error-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.error-item {
  padding: 8px 10px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 12px;
}

.error-item-time {
  color: var(--text-muted);
  margin-right: 8px;
}

.error-item-msg {
  color: var(--error);
}

.empty-state {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}

/* About */
.about-info {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.about-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.about-row:last-child {
  border-bottom: none;
}

.about-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.about-value {
  font-size: 13px;
  font-weight: 500;
}

.about-links {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.about-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.about-link:hover {
  background: var(--bg-elevated);
  color: var(--accent-bright);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s;
  z-index: 1000;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  border-color: var(--success);
}

.toast.error {
  border-color: var(--error);
}

/* Analytics Submit */
.analytics-submit {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  margin-top: 20px;
  border: 1px solid var(--border);
}

.submit-info p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.submit-info .muted {
  font-size: 12px;
  color: var(--text-muted);
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
}

.btn-primary:hover {
  background: var(--accent-bright);
}

.btn-primary:disabled {
  background: var(--text-muted);
  cursor: not-allowed;
}

/* Global Insights */
.global-insights {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 24px;
  border: 1px solid var(--border);
}

.insights-placeholder {
  text-align: center;
  padding: 24px;
}

.insights-placeholder p {
  font-size: 14px;
  color: var(--text-secondary);
}

.insights-placeholder .muted {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.global-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.global-stat {
  text-align: center;
  padding: 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
}

.global-stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--accent-bright);
}

.global-stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Percentile Badges */
.percentile-badge {
  background: linear-gradient(135deg, var(--bg-surface), var(--bg-elevated));
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

.percentile-badge.legendary {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.1), rgba(239, 68, 68, 0.1));
  border-color: #eab308;
}

.percentile-badge.diamond {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(59, 130, 246, 0.1));
  border-color: #a855f7;
}

.percentile-badge.gold {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.1), rgba(251, 191, 36, 0.1));
  border-color: #eab308;
}

.percentile-badge.silver {
  background: linear-gradient(135deg, rgba(156, 163, 175, 0.1), rgba(209, 213, 219, 0.1));
  border-color: #9ca3af;
}

.badge-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 16px;
}

.badge-emoji {
  font-size: 32px;
}

.badge-title {
  font-size: 20px;
  font-weight: 700;
  background: linear-gradient(90deg, var(--accent-bright), var(--warning));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.badge-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
}

.badge-stat {
  text-align: center;
}

.badge-stat .stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.badge-stat .stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Comparison Sections */
.comparison-section {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.comparison-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}

.comparison-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.comparison-label {
  width: 100px;
  font-size: 12px;
  color: var(--text-secondary);
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.comparison-track {
  flex: 1;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: hidden;
}

.comparison-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-bright));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.comparison-fill.model {
  background: linear-gradient(90deg, #22c55e, #4ade80);
}

.comparison-value {
  width: 50px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.insights-timestamp {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

/* Responsive */
@media (max-width: 640px) {
  .main {
    padding: 16px;
  }
  
  .tier-includes {
    grid-template-columns: 1fr;
  }
  
  .data-action {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .analytics-submit {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .global-stats-grid {
    grid-template-columns: 1fr;
  }
}

/* Public Export Section */
.export-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.export-stats .stat {
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.export-stats .stat strong {
  color: var(--accent);
}

.export-stats .stat.error {
  color: var(--error);
}

.export-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Preview Modal */
.preview-modal {
  max-width: 600px;
  width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.preview-modal .modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.preview-modal .modal-header h2 {
  margin: 0 0 4px 0;
  font-size: 18px;
}

.preview-modal .modal-header p {
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

.preview-modal .modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.preview-modal .modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.preview-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-song {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.preview-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg-elevated);
}

.preview-info {
  flex: 1;
  min-width: 0;
}

.preview-title {
  font-weight: 500;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.preview-modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

