/**
 * SoundForge AI - Operation Panel Styles
 * Generate, Modify, Transform, Analyze panels
 */

/* ===== OPERATION TABS ENHANCEMENTS ===== */
.operation-tabs {
  position: relative;
}

.operation-tabs::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--bg-tertiary);
}

.op-tab {
  position: relative;
  z-index: 1;
}

.op-tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--brand-primary);
}

/* ===== GENERATE PANEL ===== */
#panelGenerate .btn-primary {
  margin-top: var(--space-4);
  padding: var(--space-4) var(--space-5);
  font-size: 1rem;
}

.generate-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.generate-options .param-group:last-child {
  grid-column: span 2;
}

/* Preset buttons */
.presets-row {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.preset-btn {
  padding: var(--space-1) var(--space-3);
  font-size: 0.75rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.preset-btn:hover {
  background: var(--bg-hover);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.preset-btn.active {
  background: rgba(0, 212, 255, 0.15);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

/* ===== MODIFY PANEL ===== */
.modify-operations {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.btn-op {
  position: relative;
  overflow: hidden;
}

.btn-op::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(0, 212, 255, 0.1));
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn-op:hover::before {
  opacity: 1;
}

/* Selected operation state */
.btn-op.selected {
  background: rgba(0, 212, 255, 0.15);
  border-color: var(--brand-primary);
  box-shadow: 0 0 20px rgba(0, 212, 255, 0.15);
}

.btn-op.selected .op-icon {
  transform: scale(1.2);
}

/* Modify params panel */
.modify-params {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-3);
  animation: slideDown 0.2s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modify-params h4 {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--text-primary);
}

/* Operation-specific param styles */
.param-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.param-row > label {
  min-width: 100px;
  margin-bottom: 0;
}

.param-row .param-input,
.param-row .param-select {
  flex: 1;
}

/* Range slider styling for params */
input[type="range"].param-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  cursor: pointer;
}

input[type="range"].param-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--brand-primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-glow-primary);
}

/* ===== TRANSFORM PANEL ===== */
.effect-item {
  transition: all var(--transition-fast);
}

.effect-item:hover {
  background: var(--bg-hover);
}

.effect-item.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.effect-toggle input[type="checkbox"]:disabled + span {
  color: var(--text-muted);
}

.effect-params {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
  opacity: 0;
  padding: 0 var(--space-6);
}

.effect-toggle input[type="checkbox"]:checked ~ .effect-params {
  max-height: 200px;
  opacity: 1;
  padding: var(--space-3) 0 var(--space-3) var(--space-6);
}

/* Effect value displays */
.effect-value {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--brand-primary);
  min-width: 45px;
  text-align: right;
}

/* Master button */
#btnMaster {
  margin-top: var(--space-4);
  position: relative;
  overflow: hidden;
}

#btnMaster::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: transform 0.5s ease;
}

#btnMaster:hover::after {
  transform: translateX(100%);
}

/* ===== ANALYZE PANEL ===== */
.analysis-results {
  min-height: 100px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.analysis-item {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}

.analysis-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.analysis-value {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--brand-primary);
  font-family: var(--font-mono);
}

.analysis-unit {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Spectrum analyzer container */
.analyzer-container {
  position: relative;
}

.spectrum-canvas {
  width: 100%;
  height: 150px;
  background: linear-gradient(
    to top,
    var(--bg-primary) 0%,
    rgba(0, 212, 255, 0.05) 50%,
    rgba(123, 47, 247, 0.05) 100%
  );
}

/* Meter enhancements */
.meters-container {
  margin-top: var(--space-4);
}

.stereo-meter {
  gap: var(--space-6);
}

.meter-channel {
  flex: 1;
}

.meter-bar {
  height: 24px;
  background: var(--meter-bg);
}

.meter-db {
  min-width: 45px;
  font-family: var(--font-mono);
}

/* Analysis status */
.analysis-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  color: var(--text-muted);
}

.analysis-empty {
  text-align: center;
  padding: var(--space-8);
  color: var(--text-muted);
}

.analysis-empty-icon {
  font-size: 3rem;
  margin-bottom: var(--space-3);
  opacity: 0.5;
}

/* ===== REVISION HISTORY ===== */
.revision-list {
  max-height: 200px;
  overflow-y: auto;
  margin-top: var(--space-3);
}

.revision-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-2);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.revision-item:hover {
  background: var(--bg-hover);
}

.revision-item.current {
  border-left: 2px solid var(--brand-primary);
}

.revision-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.revision-name {
  font-size: 0.85rem;
  font-weight: 500;
}

.revision-time {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.revision-actions {
  display: flex;
  gap: var(--space-2);
}

.btn-revision {
  padding: var(--space-1) var(--space-2);
  font-size: 0.75rem;
  background: transparent;
  color: var(--text-secondary);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-revision:hover {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

/* ===== UNDO/REDO CONTROLS ===== */
.undo-controls {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 2px solid rgba(255, 255, 255, 0.08);
}

/* ===== FILE IMPORT/EXPORT ===== */
.file-controls {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.file-drop-zone {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: var(--space-4);
}

.file-drop-zone:hover,
.file-drop-zone.drag-over {
  border-color: var(--brand-primary);
  background: rgba(0, 212, 255, 0.05);
}

.file-drop-icon {
  font-size: 2rem;
  margin-bottom: var(--space-2);
  opacity: 0.6;
}

.file-drop-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.file-drop-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.export-options {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
  align-items: center;
}

.export-options label {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ===== RESPONSIVE FOR OPERATIONS PANEL ===== */

/* Tablet (641px - 1024px) */
@media (max-width: 1024px) and (min-width: 641px) {
  .generate-options {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
  }
  
  .modify-operations {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile Landscape & Small Tablet (640px - 768px) */
@media (max-width: 768px) and (min-width: 641px) {
  .analysis-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .param-row > label {
    min-width: 80px;
  }
}

/* Mobile Portrait (<640px) */
@media (max-width: 640px) {
  .modify-operations {
    grid-template-columns: 1fr;
  }
  
  .generate-options {
    grid-template-columns: 1fr;
  }
  
  .generate-options .param-group:last-child {
    grid-column: span 1;
  }
  
  .analysis-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Parameter row - stack on small screens */
  .param-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }
  
  .param-row > label {
    min-width: auto;
  }
  
  .param-row .param-input,
  .param-row .param-select {
    width: 100%;
  }
  
  /* Range sliders - touch friendly */
  input[type="range"].param-range {
    height: 8px;
    min-height: 44px;
    padding: 18px 0;
  }
  
  input[type="range"].param-range::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
  }
  
  /* Effect items - full width */
  .effect-item {
    padding: var(--space-3);
  }
  
  /* File controls - wrap */
  .file-controls {
    flex-wrap: wrap;
  }
  
  /* Export options - stack */
  .export-options {
    flex-direction: column;
    align-items: flex-start;
  }
  
  /* Revision list items - adjust padding */
  .revision-item {
    padding: var(--space-2);
  }
  
  .revision-info {
    overflow: hidden;
  }
  
  .revision-name {
    font-size: 0.8rem;
  }
}

/* Very Small Screens (<380px) */
@media (max-width: 380px) {
  .analysis-grid {
    grid-template-columns: 1fr;
  }
  
  .analysis-value {
    font-size: 1.1rem;
  }
  
  .preset-btn {
    padding: var(--space-1) var(--space-2);
    font-size: 0.7rem;
  }
  
  .btn-op {
    padding: var(--space-2) var(--space-3);
  }
  
  .op-icon {
    font-size: 1.1rem;
  }
}

/* Ultrawide Screens (>1440px) */
@media (min-width: 1440px) {
  .modify-operations {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .analysis-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

/* ============================================
   INDUSTRY-LEADING MUSIC FEATURES STYLES
   Duration Presets, Lyrics, Structure, Mood, Cover Art
   ============================================ */

/* ===== DURATION PRESET BUTTONS ===== */
.duration-presets-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.duration-preset-btn {
  padding: 4px 10px;
  font-size: 0.7rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.duration-preset-btn:hover {
  background: var(--bg-hover);
  color: var(--brand-primary);
  border-color: rgba(0, 212, 255, 0.3);
}

.duration-preset-btn.active {
  background: rgba(0, 212, 255, 0.15);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

/* ===== LYRICS SECTION (Suno/Udio Style) ===== */
.vocals-toggle-row {
  display: flex;
  gap: 8px;
}

.vocals-toggle-btn {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.8rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.vocals-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: rgba(0, 212, 255, 0.3);
}

.vocals-toggle-btn.active {
  background: rgba(0, 212, 255, 0.15);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.lyrics-textarea {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  min-height: 120px;
}

.vocal-style-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.vocal-style-btn {
  padding: 4px 10px;
  font-size: 0.72rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.vocal-style-btn:hover {
  background: var(--bg-hover);
  color: var(--brand-primary);
  border-color: rgba(0, 212, 255, 0.3);
}

.vocal-style-btn.active {
  background: rgba(0, 212, 255, 0.15);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-generate-lyrics {
  width: 100%;
  padding: 10px 16px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== SONG STRUCTURE CONTROLS ===== */
.collapsible-section .collapsible-header {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
}

.collapsible-section .collapsible-icon {
  transition: transform var(--transition-normal);
}

.collapsible-section.collapsed .collapsible-icon {
  transform: rotate(-90deg);
}

.collapsible-content {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  max-height: 500px;
  opacity: 1;
}

.collapsible-section.collapsed .collapsible-content {
  max-height: 0;
  opacity: 0;
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.structure-presets-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.structure-preset-btn {
  padding: 6px 12px;
  font-size: 0.75rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.structure-preset-btn:hover {
  background: var(--bg-hover);
  color: var(--brand-primary);
  border-color: rgba(0, 212, 255, 0.3);
}

.structure-preset-btn.active {
  background: rgba(0, 212, 255, 0.15);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

/* ===== MOOD TAGS ===== */
.mood-tags-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mood-tag-btn {
  padding: 5px 10px;
  font-size: 0.78rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 4px;
}

.mood-tag-btn:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}

.mood-tag-btn.active {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(147, 51, 234, 0.2));
  color: #fff;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px rgba(0, 212, 255, 0.2);
}

/* ===== COVER ART GENERATION ===== */
.cover-art-container {
  text-align: center;
}

.cover-art-preview {
  width: 140px;
  height: 140px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-tertiary);
  border: 2px dashed rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cover-art-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.cover-art-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.btn-cover-art {
  padding: 10px 16px;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Responsive additions for new features */
@media (max-width: 640px) {
  .duration-presets-row {
    gap: 4px;
  }
  
  .duration-preset-btn {
    font-size: 0.65rem;
    padding: 3px 8px;
  }
  
  .vocal-style-grid {
    gap: 4px;
  }
  
  .vocal-style-btn {
    font-size: 0.68rem;
    padding: 3px 8px;
  }
  
  .mood-tags-grid {
    gap: 4px;
  }
  
  .mood-tag-btn {
    font-size: 0.7rem;
    padding: 4px 8px;
  }
  
  .cover-art-preview {
    width: 120px;
    height: 120px;
  }
}

/* ============================================
   NEW SOUNDFORGE AI FEATURES - PART 2
   Collapsible Sections, Prompt Chains, Download,
   Toggles Grid, Section Selection, Universal Prompts,
   Editable Value Inputs
   ============================================ */

/* ===== 1. COLLAPSIBLE SECTIONS WITH TOGGLES ===== */
.collapsible-section {
  margin-bottom: 12px;
}

.collapsible-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  transition: background var(--transition-fast);
  user-select: none;
}

.collapsible-header:hover {
  background: var(--bg-hover);
}

.collapsible-header span {
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

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

/* Section toggle switch */
.section-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.section-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 24px;
  transition: var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition-fast);
}

.section-toggle input:checked + .toggle-slider {
  background: var(--brand-primary);
}

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

/* Chevron animation */
.chevron-icon {
  transition: transform 0.3s ease;
  display: inline-block;
}

.chevron-icon.rotated {
  transform: rotate(-90deg);
}

.collapsible-content {
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
  max-height: 1000px;
  opacity: 1;
}

.collapsible-content.collapsed {
  max-height: 0 !important;
  opacity: 0;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

/* Disabled section styling */
.collapsible-section.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.auto-defaults-badge {
  background: var(--brand-success);
  color: #000;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ===== 2. POSITIVE/NEGATIVE PROMPT CHAINS ===== */
.prompt-chain-container {
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 12px 0;
}

.prompt-chains {
  padding: 12px;
}

.prompt-chains.negative {
  background: rgba(255, 107, 107, 0.05);
  border-top: 2px solid var(--bg-elevated);
}

.prompt-chain-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.prompt-chains.negative .prompt-chain-header {
  color: var(--brand-accent);
}

.btn-add-prompt {
  background: var(--bg-tertiary);
  border: 2px dashed var(--bg-hover);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-add-prompt:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: rgba(0, 212, 255, 0.08);
}

.prompt-chain-item {
  position: relative;
  background: var(--bg-secondary);
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-bottom: 8px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.prompt-chain-item:hover {
  border-color: rgba(0, 212, 255, 0.3);
}

.prompt-chain-item:last-child {
  margin-bottom: 0;
}

.prompt-input {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  margin-bottom: 8px;
  background: var(--bg-primary);
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 10px;
  color: var(--text-primary);
  font-size: 0.85rem;
  line-height: 1.5;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.prompt-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.prompt-input.sm {
  min-height: 40px;
}

.prompt-input::placeholder {
  color: var(--text-muted);
}

.prompt-weight-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.prompt-weight-row.compact {
  gap: 4px;
}

.weight-slider {
  flex: 1;
  accent-color: var(--brand-primary);
  height: 4px;
  cursor: pointer;
}

.weight-slider.xs {
  width: 60px;
  flex: none;
}

.weight-value {
  min-width: 36px;
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--brand-primary);
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-remove-prompt {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.btn-remove-prompt:hover {
  background: var(--brand-accent);
  color: white;
}

/* Compact variant for non-generate panels */
.prompt-chain-container.compact {
  font-size: 0.9rem;
}

.prompt-chain-container.compact .prompt-chains {
  padding: 8px;
}

.prompt-chain-container.compact .prompt-input {
  min-height: 36px;
  font-size: 0.85rem;
  padding: 8px;
}

.prompt-chain-container.compact .prompt-weight-row {
  font-size: 0.75rem;
}

/* ===== 3. DOWNLOAD SECTION ===== */
.download-section {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(123, 47, 247, 0.1));
  border: 2px solid var(--brand-primary);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.download-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(0, 212, 255, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.download-header {
  font-weight: 700;
  font-size: 1rem;
  color: var(--brand-primary);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.download-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.btn-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}

.btn-download::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.btn-download:hover::after {
  opacity: 1;
}

.btn-download[data-format="wav"] {
  background: rgba(0, 255, 136, 0.15);
  color: var(--brand-success);
  border-color: var(--brand-success);
}

.btn-download[data-format="mp3"] {
  background: rgba(0, 212, 255, 0.15);
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-download[data-format="flac"] {
  background: rgba(123, 47, 247, 0.15);
  color: var(--brand-secondary);
  border-color: var(--brand-secondary);
}

.btn-download:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

.btn-download:active {
  transform: translateY(0);
}

.filename-display {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  position: relative;
  z-index: 1;
}

.filename-display span {
  color: var(--brand-primary);
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  word-break: break-all;
}

/* ===== 4. ENHANCED TOGGLES GRID (for Remix) ===== */
.toggles-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-md);
}

.toggle-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
}

.toggle-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.switch-toggle {
  position: relative;
  width: 48px;
  height: 26px;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider-round {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 26px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.slider-round::before {
  content: '';
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition-fast);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch-toggle input:checked + .slider-round {
  background: var(--brand-primary);
}

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

.switch-toggle input:focus + .slider-round {
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.2);
}

.form-select.sm {
  padding: 6px 10px;
  font-size: 0.85rem;
  background: var(--bg-secondary);
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.form-select.sm:focus {
  outline: none;
  border-color: var(--brand-primary);
}

/* ===== 5. VISUAL SECTION SELECTION ===== */
.selection-info {
  display: flex;
  justify-content: space-around;
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.selection-info strong {
  color: var(--brand-primary);
  font-family: 'JetBrains Mono', monospace;
}

.section-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.section-preset-btn {
  padding: 8px 16px;
  background: var(--bg-secondary);
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.section-preset-btn:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  background: rgba(0, 212, 255, 0.08);
}

.section-preset-btn.active {
  background: var(--brand-primary);
  color: #000;
  border-color: var(--brand-primary);
  font-weight: 600;
}

.help-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-style: italic;
  line-height: 1.4;
}

.auto-label {
  font-size: 0.75rem;
  color: var(--brand-success);
  font-weight: normal;
  margin-left: 6px;
}

/* ===== 6. UNIVERSAL PROMPTS (for other tools) ===== */
.universal-prompts {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 16px;
  border: 2px solid var(--bg-elevated);
}

.prompts-details {
  margin-top: 8px;
}

.prompts-details summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  list-style: none;
}

.prompts-details summary::-webkit-details-marker {
  display: none;
}

.prompts-details summary::before {
  content: '▶';
  font-size: 0.65rem;
  transition: transform var(--transition-fast);
}

.prompts-details[open] summary::before {
  transform: rotate(90deg);
}

.prompts-details summary:hover {
  color: var(--brand-primary);
  background: rgba(0, 212, 255, 0.05);
}

.prompts-details[open] summary {
  margin-bottom: 8px;
  color: var(--text-primary);
}

.prompts-details .prompt-content {
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  border-left: 3px solid var(--brand-primary);
}

/* ===== 7. EDITABLE VALUE INPUTS ===== */
.range-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.range-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  color: var(--brand-primary);
  background: var(--bg-secondary);
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 60px;
  text-align: center;
  cursor: text;
  border: 2px solid transparent;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
}

.range-value:hover {
  border-color: rgba(0, 212, 255, 0.4);
  background: var(--bg-tertiary);
}

.range-value:focus {
  outline: none;
  border-color: var(--brand-primary);
  background: var(--bg-primary);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

.range-value[contenteditable="true"]:empty:before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

/* ============================================
   RESPONSIVE STYLES FOR NEW FEATURES
   Mobile (<768px)
   ============================================ */

@media (max-width: 768px) {
  /* Collapsible sections - reduce padding */
  .collapsible-header {
    padding: 10px 12px;
  }
  
  .collapsible-header span {
    font-size: 0.85rem;
  }
  
  /* Toggle switch - touch friendly */
  .section-toggle {
    width: 48px;
    height: 26px;
  }
  
  .toggle-slider::before {
    height: 20px;
    width: 20px;
  }
  
  .section-toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
  }
  
  /* Prompt chains - compact on mobile */
  .prompt-chain-container {
    margin: 8px 0;
  }
  
  .prompt-chains {
    padding: 10px;
  }
  
  .prompt-input {
    min-height: 50px;
    font-size: 0.82rem;
    padding: 8px;
  }
  
  .prompt-input.sm {
    min-height: 36px;
  }
  
  .btn-remove-prompt {
    top: 6px;
    right: 6px;
    padding: 2px 6px;
    font-size: 16px;
  }
  
  .prompt-weight-row {
    flex-wrap: wrap;
    gap: 6px;
  }
  
  /* Download section - stack buttons */
  .download-section {
    padding: 16px 12px;
  }
  
  .download-header {
    font-size: 0.9rem;
    margin-bottom: 12px;
  }
  
  .download-buttons {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  
  .btn-download {
    padding: 12px 16px;
    font-size: 0.85rem;
  }
  
  .filename-display {
    font-size: 0.8rem;
  }
  
  /* Toggles grid - single column on small screens */
  .toggles-grid {
    grid-template-columns: 1fr;
    padding: 12px;
    gap: 8px;
  }
  
  .toggle-item {
    padding: 6px 0;
  }
  
  .switch-toggle {
    width: 44px;
    height: 24px;
  }
  
  .slider-round::before {
    height: 18px;
    width: 18px;
  }
  
  .switch-toggle input:checked + .slider-round::before {
    transform: translateX(20px);
  }
  
  /* Selection info - wrap on mobile */
  .selection-info {
    flex-direction: column;
    gap: 8px;
    text-align: center;
    font-size: 0.8rem;
  }
  
  .section-presets {
    justify-content: center;
  }
  
  .section-preset-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  
  /* Universal prompts - compact */
  .universal-prompts {
    padding: 10px;
    margin-bottom: 12px;
  }
  
  .prompts-details summary {
    font-size: 0.8rem;
    padding: 6px;
  }
  
  .prompts-details .prompt-content {
    padding: 10px;
    font-size: 0.78rem;
  }
  
  /* Range value inputs - slightly larger touch target */
  .range-value {
    min-width: 55px;
    padding: 4px 6px;
    font-size: 0.82rem;
  }
  
  /* Auto defaults badge - smaller */
  .auto-defaults-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
  }
}

/* Extra small screens (<480px) */
@media (max-width: 480px) {
  .collapsible-header {
    padding: 8px 10px;
  }
  
  .collapsible-header span {
    font-size: 0.8rem;
    gap: 6px;
  }
  
  .toggle-row {
    gap: 8px;
  }
  
  .prompt-chain-header {
    font-size: 0.8rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  
  .btn-add-prompt {
    font-size: 0.75rem;
    padding: 3px 10px;
  }
  
  .prompt-input {
    min-height: 44px;
    font-size: 0.8rem;
  }
  
  .weight-slider.xs {
    width: 50px;
  }
  
  .weight-value {
    min-width: 32px;
    font-size: 0.7rem;
  }
  
  .download-section {
    padding: 12px 10px;
    border-radius: var(--radius-md);
  }
  
  .btn-download {
    padding: 10px 14px;
    font-size: 0.82rem;
    gap: 6px;
  }
  
  .section-preset-btn {
    padding: 5px 10px;
    font-size: 0.72rem;
  }
  
  .help-text {
    font-size: 0.75rem;
  }
}

/* ============================================
   CRITICAL FIX: 800px - 900px Visual Break Zone
   Target the problematic viewport range
   ============================================ */
@media (min-width: 801px) and (max-width: 900px) {
  /* Collapsible sections - compact */
  .collapsible-header {
    padding: 10px 12px !important;
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .collapsible-header span {
    font-size: 0.82rem;
  }
  
  .toggle-row {
    gap: 8px;
  }
  
  /* Toggle switch - slightly smaller */
  .section-toggle {
    width: 40px;
    height: 22px;
  }
  
  .toggle-slider::before {
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
  }
  
  .section-toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
  }
  
  /* Prompt chains - more compact */
  .prompt-chain-container {
    margin: 6px 0 !important;
  }
  
  .prompt-chains {
    padding: 8px !important;
  }
  
  .prompt-chain-header {
    font-size: 0.8rem;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .btn-add-prompt {
    font-size: 0.75rem;
    padding: 4px 10px;
  }
  
  .prompt-input {
    min-height: 44px !important;
    font-size: 0.82rem;
    padding: 8px;
  }
  
  .prompt-input.sm {
    min-height: 36px !important;
    font-size: 0.78rem;
  }
  
  .prompt-weight-row {
    gap: 6px;
    font-size: 0.75rem;
  }
  
  .weight-slider {
    height: 4px;
  }
  
  .weight-value {
    min-width: 32px;
    font-size: 0.72rem;
  }
  
  .btn-remove-prompt {
    font-size: 14px;
    padding: 2px 6px;
  }
  
  /* Download section - compact */
  .download-section {
    padding: 14px 12px !important;
  }
  
  .download-header {
    font-size: 0.9rem;
    margin-bottom: 12px;
  }
  
  .download-buttons {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  
  .btn-download {
    padding: 12px 14px;
    font-size: 0.82rem;
    gap: 6px;
  }
  
  .filename-display {
    font-size: 0.78rem;
  }
  
  /* Toggles grid - compact */
  .toggles-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    padding: 12px !important;
  }
  
  .toggle-item {
    flex-wrap: wrap;
    gap: 4px;
  }
  
  .toggle-label {
    font-size: 0.78rem;
  }
  
  .switch-toggle {
    width: 42px;
    height: 24px;
  }
  
  .slider-round::before {
    height: 18px;
    width: 18px;
  }
  
  .form-select.sm {
    padding: 5px 8px;
    font-size: 0.8rem;
  }
  
  /* Section selection - compact */
  .selection-info {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px;
    font-size: 0.8rem;
  }
  
  .section-presets {
    gap: 6px;
  }
  
  .section-preset-btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
  
  .help-text {
    font-size: 0.75rem;
  }
  
  /* Universal prompts - compact */
  .universal-prompts {
    padding: 10px !important;
  }
  
  .prompts-details summary {
    font-size: 0.8rem;
    padding: 6px;
  }
  
  /* Auto defaults badge - smaller */
  .auto-defaults-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
  }
  
  /* Nested options - compact */
  .nested-options {
    margin-top: 10px !important;
    padding: 10px !important;
  }
  
  .nested-options-title {
    font-size: 0.8rem;
    gap: 6px;
  }
}

/* ============================================
   SIMPLE / ADVANCED MODE TOGGLE SYSTEM
   ============================================ */

/* Mode Toggle Container */
.mode-toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.08), rgba(123, 47, 247, 0.08));
  border: 2px solid rgba(0, 212, 255, 0.2);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 20px;
}

/* Mode Indicator Badge (shown in header) */
.mode-indicator {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.15), rgba(0, 212, 255, 0.15));
  color: var(--brand-primary);
  border: 1px solid rgba(0, 212, 255, 0.3);
}

.mode-toggle {
  display: flex;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.mode-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-muted);
  background: transparent;
}

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

.mode-btn.active {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #000;
  box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

.mode-btn svg {
  width: 16px;
  height: 16px;
}

.mode-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Mode Views */
.mode-view {
  display: none;
  animation: fadeIn 0.25s ease;
}

.mode-view.active {
  display: block;
}

/* ===== SIMPLE MODE STYLES ===== */

/* Main Prompt in Simple Mode */
#simpleModeView .form-textarea {
  min-height: 100px;
  font-size: 1rem;
  line-height: 1.5;
}

/* Simple Toggle Row */
.simple-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin: 16px 0;
}

.simple-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.simple-toggle-label svg {
  width: 18px;
  height: 18px;
  color: var(--brand-primary);
}

/* Simple Options (Details/Summary) */
.simple-options {
  margin-top: 16px;
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.simple-options summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.simple-options summary:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.simple-options summary svg {
  width: 16px;
  height: 16px;
}

.simple-options[open] summary {
  border-bottom: 2px solid var(--bg-elevated);
  color: var(--brand-primary);
}

.simple-prompts-inner {
  padding: 16px;
}

/* Reference Upload Section */
.reference-upload-section {
  padding: 16px;
}

.upload-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  border: 2px dashed var(--bg-hover);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.upload-drop-zone:hover {
  border-color: var(--brand-primary);
  background: rgba(0, 212, 255, 0.05);
}

.upload-drop-zone svg {
  width: 40px;
  height: 40px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.upload-drop-zone p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.upload-drop-zone small {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.ref-audio-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(0, 255, 136, 0.1);
  border: 2px solid var(--brand-success);
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.ref-name {
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.ref-duration {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.btn-remove-ref {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: var(--brand-accent);
  color: white;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: all var(--transition-fast);
}

.btn-remove-ref:hover {
  transform: scale(1.1);
}

/* Smart Defaults Banner */
.smart-defaults-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(0, 255, 136, 0.08), rgba(0, 212, 255, 0.08));
  border: 2px solid rgba(0, 255, 136, 0.2);
  border-radius: var(--radius-md);
  margin: 16px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.smart-defaults-banner svg {
  width: 20px;
  height: 20px;
  color: var(--brand-success);
  flex-shrink: 0;
  margin-top: 2px;
}

.smart-defaults-banner strong {
  color: var(--brand-success);
}

/* Generate Button (Main) */
.btn-generate-main {
  width: 100%;
  padding: 18px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #000;
  border: none;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 8px 30px rgba(0, 212, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-generate-main:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(0, 212, 255, 0.4);
}

.btn-generate-main:active {
  transform: translateY(0);
}

.btn-generate-main svg {
  width: 22px;
  height: 22px;
}

/* ===== ADVANCED MODE ENHANCEMENTS ===== */

/* Better visual hierarchy for sections */
#advancedModeView .collapsible-section {
  margin-bottom: 12px;
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all var(--transition-fast);
}

#advancedModeView .collapsible-section:hover {
  border-color: rgba(0, 212, 255, 0.3);
}

#advancedModeView .collapsible-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.2));
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-fast);
}

#advancedModeView .collapsible-header:hover {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(123, 47, 247, 0.05));
}

#advancedModeView .collapsible-header span {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text-primary);
}

#advancedModeView .collapsible-header span svg {
  width: 18px;
  height: 18px;
  color: var(--brand-primary);
}

/* Priority indicators */
.collapsible-header .priority-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  text-transform: uppercase;
}

.priority-high { background: rgba(0, 255, 136, 0.15); color: var(--brand-success); }
.priority-medium { background: rgba(255, 170, 0, 0.15); color: var(--brand-warning); }
.priority-low { background: rgba(160, 160, 184, 0.15); color: var(--text-muted); }

/* Toggle Row in Header */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Section Toggle Switch */
.section-toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
}

.section-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-elevated);
  border-radius: 24px;
  transition: var(--transition-fast);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: var(--transition-fast);
}

.section-toggle input:checked + .toggle-slider {
  background: var(--brand-primary);
}

.section-toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}

/* Chevron Icon */
.chevron-icon {
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.chevron-icon.rotated {
  transform: rotate(-90deg);
  color: var(--brand-primary);
}

/* Collapsible Content */
.collapsible-content {
  overflow: hidden;
  transition: max-height 0.35s ease, padding 0.35s ease;
  max-height: 2000px; /* Allow expansion */
}

.collapsible-content.collapsed {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.collapsible-content > * {
  padding: 16px;
}

/* Disabled State */
.collapsible-section.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.collapsible-section.disabled .collapsible-header {
  background: var(--bg-tertiary);
}

/* Smart Defaults Indicator (shown when section disabled) */
.smart-defaults-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  margin: 8px 16px;
  background: rgba(0, 255, 136, 0.1);
  border: 2px dashed var(--brand-success);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--brand-success);
  font-weight: 500;
}

.smart-defaults-indicator svg {
  width: 14px;
  height: 14px;
}

/* Responsive */
@media (max-width: 768px) {
  .mode-toggle-container {
    flex-direction: column;
    gap: 10px;
    text-align: center;
  }
  
  .mode-toggle {
    width: 100%;
  }
  
  .mode-btn {
    flex: 1;
    justify-content: center;
    padding: 10px 16px;
    font-size: 0.85rem;
  }
  
  .mode-hint {
    font-size: 0.75rem;
  }
  
  .simple-toggle-row {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  
  .btn-generate-main {
    padding: 16px 24px;
    font-size: 1rem;
  }
}

/* ============================================
   AI SETTINGS PANEL & MODAL
   ============================================ */

/* Settings Button with Badge */
.btn-settings-trigger {
  position: relative;
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(123, 47, 247, 0.1));
  border-color: rgba(0, 212, 255, 0.3);
}

.btn-settings-trigger:hover {
  border-color: var(--brand-primary);
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.2), rgba(123, 47, 247, 0.2));
}

.settings-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  padding: 2px 6px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: white;
  border-radius: 10px;
  animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

/* AI Status Panel */
.ai-status-panel {
  background: linear-gradient(135deg, rgba(0, 212, 255, 0.05), rgba(123, 47, 247, 0.05));
  border: 2px solid rgba(0, 212, 255, 0.15);
}

.ai-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.ai-status-indicator .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.ai-status-indicator .status-dot.ready {
  background: var(--brand-success);
  box-shadow: 0 0 8px var(--brand-success);
}

.ai-status-indicator .status-dot.error {
  background: var(--brand-accent);
  box-shadow: 0 0 8px var(--brand-accent);
}

.ai-status-indicator .status-dot.generating {
  background: var(--brand-warning);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.ai-current-model,
.ai-provider-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.8rem;
}

.model-label,
.provider-label {
  color: var(--text-muted);
}

.model-value,
.provider-value {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

/* Generation Progress */
.generation-progress {
  margin-top: 12px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.75rem;
  color: var(--brand-primary);
  font-family: 'JetBrains Mono', monospace;
}

.generation-status {
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  min-height: 20px;
}

/* Settings Modal */
.settings-modal {
  max-width: 650px;
  max-height: 90vh;
  overflow-y: auto;
}

.settings-body {
  padding: 20px 24px;
}

.settings-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.settings-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.settings-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.settings-section-title svg {
  width: 18px;
  height: 18px;
  color: var(--brand-primary);
}

/* API Key Input Wrapper */
.api-key-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.api-key-input-wrapper .form-input {
  padding-right: 48px;
}

.btn-toggle-visibility {
  position: absolute;
  right: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast);
}

.btn-toggle-visibility:hover {
  color: var(--brand-primary);
}

.btn-toggle-visibility svg {
  width: 18px;
  height: 18px;
}

/* Test Connection Button & Result */
.btn-test-connection {
  width: 100%;
  margin-top: 12px;
  justify-content: center;
  gap: 8px;
}

.connection-result {
  display: block;
  margin-top: 8px;
  font-size: 0.8rem;
  text-align: center;
  min-height: 20px;
}

.connection-result.success {
  color: var(--brand-success);
}

.connection-result.error {
  color: var(--brand-accent);
}

/* Model Info Card */
.model-info-card {
  margin-top: 12px;
  padding: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.model-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 0.82rem;
}

.model-info-row:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.info-label {
  color: var(--text-muted);
}

.info-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* Parameter Grid for Settings */
.param-grid-settings {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.param-grid-settings .form-group {
  margin-bottom: 0;
}

/* Toggle Option Row */
.toggle-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.toggle-option:last-child {
  border-bottom: none;
}

/* Modal Footer */
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary {
  padding: 10px 20px;
}

/* Help Text Links */
.help-text a {
  color: var(--brand-primary);
  text-decoration: none;
}

.help-text a:hover {
  text-decoration: underline;
}

/* Responsive Settings */
@media (max-width: 768px) {
  .settings-modal {
    max-width: 95vw;
    margin: 10px;
  }
  
  .param-grid-settings {
    grid-template-columns: 1fr;
  }
  
  .settings-body {
    padding: 16px;
  }
}

/* ============================================
   ENHANCED SETTINGS STYLES v2.0
   Additional styles for enterprise features
   ============================================ */

/* Provider Select with OptGroups */
.form-select optgroup {
  font-weight: 600;
  color: var(--brand-primary);
  background: var(--bg-primary);
}

.form-select option {
  padding: 8px 12px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

/* API Key Input Validation States */
.form-input.valid {
  border-color: var(--brand-success) !important;
  box-shadow: 0 0 0 3px rgba(0, 255, 136, 0.1);
}

.form-input.invalid {
  border-color: var(--brand-accent) !important;
  box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.1);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* Connection Result States */
.connection-result.testing {
  color: var(--brand-warning);
  animation: pulse-text 1s infinite;
}

@keyframes pulse-text {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Quality Indicators in Model Info */
.info-value.quality-best {
  color: var(--brand-success);
  font-weight: 600;
}

.info-value.quality-high {
  color: var(--brand-primary);
}

.info-value.quality-good {
  color: var(--brand-warning);
}

.info-value.quality-medium,
.info-value.quality-varies,
.info-value.quality-custom {
  color: var(--text-secondary);
}

/* Settings Badge Configured State */
.settings-badge.configured {
  background: linear-gradient(135deg, var(--brand-success), #00cc6a);
  animation: none;
}

/* Provider Feature Tags */
.provider-features {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.feature-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 0.7rem;
  font-weight: 500;
  border-radius: 20px;
  background: rgba(0, 212, 255, 0.1);
  color: var(--brand-primary);
  border: 1px solid rgba(0, 212, 255, 0.2);
}

.feature-tag.free {
  background: rgba(0, 255, 136, 0.1);
  color: var(--brand-success);
  border-color: rgba(0, 255, 136, 0.2);
}

.feature-tag.fast {
  background: rgba(255, 170, 0, 0.1);
  color: var(--brand-warning);
  border-color: rgba(255, 170, 0, 0.2);
}

.feature-tag.enterprise {
  background: rgba(123, 47, 247, 0.1);
  color: var(--brand-secondary);
  border-color: rgba(123, 47, 247, 0.2);
}

/* Model Description */
.model-description {
  margin-top: 8px;
  padding: 10px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  line-height: 1.5;
  border-left: 2px solid var(--brand-primary);
}

/* Advanced Parameters Toggle */
.advanced-params-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: color var(--transition-fast);
}

.advanced-params-toggle:hover {
  color: var(--brand-primary);
}

.advanced-params-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  opacity: 0;
}

.advanced-params-content.expanded {
  max-height: 500px;
  opacity: 1;
  margin-top: 12px;
}

/* Generation Queue Display */
.queue-status {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
}

.queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.queue-item:last-child {
  border-bottom: none;
}

.queue-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--brand-primary);
  color: var(--bg-primary);
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
}

/* Colab/NGROK Setup Guide */
.setup-guide {
  margin-top: 12px;
  padding: 14px;
  background: linear-gradient(135deg, rgba(123, 47, 247, 0.08), rgba(0, 212, 255, 0.08));
  border-radius: var(--radius-md);
  border: 1px dashed rgba(123, 47, 247, 0.3);
}

.setup-guide h5 {
  font-size: 0.82rem;
  color: var(--brand-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.setup-guide ol {
  margin-left: 18px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.setup-guide ol li::marker {
  color: var(--brand-primary);
}

.setup-guide code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--brand-success);
}

/* Pricing Comparison Table (hidden by default) */
.pricing-info {
  margin-top: 10px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
}

.pricing-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  color: var(--text-secondary);
}

.pricing-row .price {
  color: var(--brand-success);
  font-weight: 500;
}

/* Modal Animation */
.modal-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-content {
  transform: translateY(-20px) scale(0.95);
  transition: transform 0.25s ease;
}

.modal-content.visible {
  transform: translateY(0) scale(1);
}

/* Loading Spinner for Test Button */
.btn-test-connection.loading {
  position: relative;
  pointer-events: none;
}

.btn-test-connection.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Tooltip for settings fields */
.field-tooltip {
  position: relative;
  cursor: help;
}

.field-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 0.72rem;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  z-index: 100;
}

.field-tooltip:hover::after {
  opacity: 1;
  visibility: visible;
  bottom: calc(100% + 6px);
}
