/* Melody Trainer Styles - Sunset Boulevard */

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

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* App Header */
.app-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--glass-bg);
  border-bottom: 1px solid var(--glass-border);
}

.home-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 1.5rem;
  transition: color 0.3s ease;
}

.home-link:hover {
  color: var(--accent-secondary);
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

/* Main Layout */
.main-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Settings Panel */
.settings-panel {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--bg-tertiary);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, margin-left 0.3s ease;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  border-bottom: 1px solid var(--bg-tertiary);
}

.settings-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

/* Setting Groups */
.setting-group {
  padding: 1rem;
  border-bottom: 1px solid var(--bg-tertiary);
}

.setting-group.hidden {
  display: none;
}

.setting-group h3 {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.75rem;
}

/* Mode Grid */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.mode-btn {
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--bg-tertiary);
  background: transparent;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s ease;
}

.mode-btn:hover {
  border-color: var(--accent-primary);
  background: rgba(255, 107, 53, 0.2);
}

.mode-btn.active {
  background: var(--accent-gradient);
  border-color: var(--accent-primary);
  color: #0d0015;
}

/* Scale/Melody Grid */
.scale-grid, .melody-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.4rem;
}

.scale-btn, .melody-btn {
  padding: 0.5rem 0.25rem;
  border: 2px solid var(--bg-tertiary);
  background: transparent;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.2s ease;
  text-align: center;
}

.scale-btn:hover, .melody-btn:hover {
  border-color: var(--accent-primary);
}

.scale-btn.active, .melody-btn.active {
  background: var(--accent-gradient);
  border-color: var(--accent-primary);
  color: #0d0015;
}

/* Note Grid */
.note-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.4rem;
}

.note-btn {
  padding: 0.4rem;
  border: 2px solid var(--bg-tertiary);
  background: transparent;
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s ease;
  text-align: center;
}

.note-btn:hover {
  border-color: var(--accent-primary);
}

.note-btn.active {
  background: var(--accent-gradient);
  border-color: var(--accent-primary);
  color: #0d0015;
}

/* Selection Controls */
.selection-controls {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.text-btn {
  background: transparent;
  border: none;
  color: var(--accent-primary);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.25rem;
}

.text-btn:hover {
  text-decoration: underline;
}

/* Setting Row */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-row label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stepper-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
}

.stepper-btn:hover {
  background: rgba(255, 107, 53, 0.3);
  border: 1px solid var(--accent-primary);
}

#notes-count {
  min-width: 20px;
  text-align: center;
  font-weight: bold;
}

/* View Toggle */
.view-toggle {
  display: flex;
  gap: 0.25rem;
}

.view-btn {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--bg-tertiary);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.7rem;
}

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

/* Mini Stats */
.stats-group {
  margin-top: auto;
}

.mini-stats {
  display: flex;
  justify-content: space-around;
}

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

.mini-stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--accent-primary);
}

.mini-stat-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Practice Area */
.practice-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Start Overlay */
.start-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.start-overlay.hidden {
  display: none;
}

.start-content {
  text-align: center;
  padding: 2rem;
}

.start-content h2 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.start-content p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.start-btn {
  padding: 1rem 3rem;
  background: var(--accent-gradient);
  border: none;
  color: #0d0015;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

/* Practice Content */
.practice-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.practice-content.hidden {
  display: none;
}

/* Pattern Header */
.pattern-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.pattern-info {
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--accent-primary);
}

.position-info {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

#current-position {
  color: var(--text-primary);
  font-weight: bold;
}

/* Melody Display */
.melody-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: auto;
  min-height: 200px;
}

/* Staff View */
.staff-view {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem;
  overflow-x: auto;
}

.staff-container {
  position: relative;
  height: 160px;
  min-width: 400px;
}

.staff-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--text-secondary);
  opacity: 0.5;
}

.staff-note {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--note-pending);
  position: absolute;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  cursor: pointer;
  font-size: 0.65rem;
  font-weight: bold;
  color: var(--text-primary);
}

.staff-note.current {
  background: var(--note-current);
  box-shadow: 0 0 12px var(--note-current);
}

.staff-note.completed {
  background: var(--note-completed);
}

.staff-note.wrong {
  background: var(--wrong-color);
}

.ledger-line {
  position: absolute;
  width: 40px;
  height: 2px;
  background: var(--text-secondary);
  opacity: 0.5;
  left: 50%;
  transform: translateX(-50%);
}

/* Line View */
.line-view {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem;
}

.line-note {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--note-pending);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.85rem;
  cursor: pointer;
}

.line-note.current {
  background: var(--note-current);
  box-shadow: 0 0 12px var(--note-current);
}

.line-note.completed {
  background: var(--note-completed);
}

.line-note.wrong {
  background: var(--wrong-color);
}

.line-note.rest {
  background: transparent;
  border: 2px dashed var(--text-secondary);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: default;
}

/* Fretboard View */
.fretboard-view {
  width: 100%;
  padding: 1rem;
  overflow-x: auto;
}

.fretboard {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 100%;
}

.fret-row {
  display: flex;
  height: 28px;
  position: relative;
}

.fret-marker {
  width: 35px;
  min-width: 35px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 6px;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: bold;
}

.fret {
  flex: 1;
  min-width: 35px;
  max-width: 50px;
  border-right: 2px solid #555;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fret::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(to right, #888, #aaa, #888);
  transform: translateY(-50%);
}

.fret:first-child {
  border-left: 4px solid #333;
}

.fret.open-fret {
  background: rgba(255,255,255,0.02);
}

.fret.open-fret::before {
  left: 4px;
}

/* Fret markers row */
.fret-markers-row {
  display: flex;
  height: 16px;
}

.fret-marker-cell {
  flex: 1;
  min-width: 35px;
  max-width: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fret-marker-dot {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  opacity: 0.5;
}

.fret-marker-dot.double {
  width: 8px;
  height: 8px;
  background: var(--text-secondary);
  border-radius: 50%;
  opacity: 0.5;
  box-shadow: 16px 0 0 var(--text-secondary);
  margin-left: -8px;
}

.fret-note {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--note-pending);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: bold;
  position: absolute;
  z-index: 2;
  cursor: pointer;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.fret-note.current {
  background: var(--note-current);
  box-shadow: 0 0 12px var(--note-current);
}

.fret-note.completed {
  background: var(--note-completed);
}

.fret-note.scale-overlay {
  background: transparent;
  border: 2px solid rgba(150, 150, 150, 0.5);
  width: 18px;
  height: 18px;
  cursor: default;
}

.fret-note.scale-overlay.scale-root {
  border-color: var(--accent-primary);
  border-width: 2px;
}

.fret-note.wrong {
  background: var(--wrong-color);
}

.line-note.playing,
.staff-note.playing,
.fret-note.playing,
.sequence-note.playing {
  background: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-primary);
}

.fret-note.wrong-played {
  background: var(--wrong-color);
  animation: wrong-flash 0.8s ease-out forwards;
}

@keyframes wrong-flash {
  0% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(0.8); opacity: 0; }
}

.fret-numbers {
  display: flex;
  padding-left: 35px;
  margin-top: 12px;
}

.fret-number {
  flex: 1;
  min-width: 35px;
  max-width: 50px;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Note Sequence */
.note-sequence {
  display: flex;
  gap: 6px;
  margin-top: 16px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.2);
  border-radius: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.sequence-note {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--note-pending);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: bold;
  cursor: pointer;
}

.sequence-note.current {
  background: var(--note-current);
  box-shadow: 0 0 10px var(--note-current);
}

.sequence-note.completed {
  background: var(--note-completed);
}

.sequence-note.rest {
  background: transparent;
  border: 2px dashed var(--text-secondary);
  color: var(--text-secondary);
  font-size: 0.7rem;
  cursor: default;
}

/* Detection Area */
.detection-area {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 1rem;
  margin: 1rem 0;
}

.detected-note-box,
.expected-note-box {
  text-align: center;
  padding: 0.75rem 1.5rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  min-width: 100px;
}

.detected-label,
.expected-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.detected-note,
.expected-note {
  font-size: 1.5rem;
  font-weight: bold;
  font-family: 'Courier New', monospace;
}

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

.expected-note {
  color: var(--note-current);
}

/* Feedback */
.feedback {
  text-align: center;
  font-size: 1.1rem;
  font-weight: bold;
  min-height: 1.5rem;
}

.feedback.success {
  color: var(--correct-color);
}

.feedback.error {
  color: var(--wrong-color);
}

.feedback.info {
  color: var(--note-pending);
}

/* Practice Controls */
.practice-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
}

.control-btn {
  padding: 0.75rem 1.5rem;
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.control-btn:hover {
  background: rgba(255, 107, 53, 0.3);
}

.control-btn.primary {
  background: var(--accent-gradient);
  color: #0d0015;
}

.control-btn.primary:hover {
  opacity: 0.9;
}

.control-btn.hidden {
  display: none;
}

/* Responsive */
@media (max-width: 768px) {
  .main-layout {
    flex-direction: column;
  }

  .settings-panel {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--bg-tertiary);
  }

  .settings-panel.collapsed {
    max-height: 0;
    margin-left: 0;
    margin-top: -40vh;
  }

  .note-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .detection-area {
    flex-direction: column;
    gap: 0.5rem;
  }
}
