/* CSS Custom Properties */
:root {
  --primary-color: #3477ef;
  --primary-hover: #496fbe;
  --primary-active: #2865d9;
  --secondary-color: #ffe066;
  --bg-dark: #1b1b1b;
  --bg-medium: #2a2a2a;
  --bg-light: #333;
  --text-light: #ececec;
  --text-medium: #a3adbc;
  --border-color: #000; /* Updated to black for enhanced contrast */
  --fret-color: #d2b790;
  --string-label-color: #bfa764;
  --correct-color: #4caf50;
  --incorrect-color: #f44336;
  --fret-width: 74px;
  --fret-height: 36px;
  --natural-note-color: #666;
  --sharp-note-color: #333;
  --control-button-color: #4caf50;
  --stop-button-color: #f44336;
  --nut-width: 25px;
}

/* Base Styles */
* { 
  box-sizing: border-box; 
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-dark);
  color: var(--text-light);
  margin: 0;
  padding: 0;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.main-layout {
  display: flex;
  flex-direction: column;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0;
}

h1 {
  font-size: 2rem;
  font-weight: 600;
  margin: 0;
}

.back-link {
  background: var(--bg-medium);
  color: var(--text-light);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.back-link:hover {
  background: var(--primary-color);
}

/* Settings Panel */
.settings-panel {
  background: var(--bg-medium);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: center;
}

.setting-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
}

.setting-group label {
  color: var(--string-label-color);
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.setting-group select {
  background: var(--bg-light);
  color: var(--text-light);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.5rem;
  font-size: 0.9rem;
  min-width: 120px;
}

.setting-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(52, 119, 239, 0.2);
}

/* Hide redundant debug info */
.debug-info {
  display: none;
}

/* Training Status - Hidden */
.training-status {
  display: none;
}

/* Updated Training Controls Layout */
.training-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0;
  gap: 1rem;
}

.stats-container {
  flex: 1;
}

.control-container {
  flex-shrink: 0;
}

/* Compact control button - 30% smaller */
.control-btn.compact {
  background: var(--control-button-color);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
}

.control-btn.compact:hover {
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.control-btn.compact.stop {
  background: var(--stop-button-color);
}

.control-btn.compact.stop:hover {
  background: #d32f2f;
}

.control-btn.compact:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* Fretboard Container */
.fretboard-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0.5rem 0;
  user-select: none;
  overflow-x: auto;
  padding: 0.5rem;
}

.fretboard-section {
  order: 2;
}

/* Base Fretboard Styles */
.fretboard {
  display: flex;
  flex-direction: column;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-light);
  padding: 0.5rem;
}

.fret-row {
  display: flex;
  align-items: center;
  margin-bottom: 2px;
}

.fret-row:last-child {
  margin-bottom: 0;
}

.string-label {
  width: 40px;
  text-align: center;
  font-size: 1rem;
  color: var(--string-label-color);
  font-weight: 600;
}

.fret {
  width: var(--fret-width);
  height: var(--fret-height);
  background: var(--bg-medium);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  font-size: 1.1em;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: default;
  border: 1px solid var(--fret-color);
  margin: 0 1px;
}

.fret.nut {
  width: var(--nut-width);
  background: var(--string-label-color);
  border: 2px solid var(--fret-color);
  border-radius: 4px;
  font-weight: bold;
  color: var(--bg-dark);
}

.fret.highlight {
  background: var(--primary-color);
  color: #fff;
  font-weight: bold;
  box-shadow: 0 0 12px rgba(52, 119, 239, 0.6);
  animation: pulse 2s infinite;
}

.fret.reveal {
  color: var(--secondary-color);
  font-weight: bold;
  background: #3a2b00;
  box-shadow: 0 0 8px rgba(255, 224, 102, 0.4);
}

/* NEW: Click-to-reveal styling */
.fret:not(.nut):not(.highlight) {
  cursor: pointer;
}

.fret:not(.nut):not(.highlight):hover {
  background: #404040; /* Subtle hover effect */
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(52, 119, 239, 0.6); }
  50% { box-shadow: 0 0 20px rgba(52, 119, 239, 0.9); }
}

/* Fret Markers - Base */
.fret-marker {
  position: absolute;
  font-size: 1.2em;
  color: var(--secondary-color);
  pointer-events: none;
  user-select: none;
  z-index: 2;
  text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.fret-marker.single {
  font-size: 1.2em;
}

/* RIGHT-HANDED DOUBLE MARKERS (12th fret) */
.fret-marker.double-1 {
  top: 30%;
  left: 30%;
  font-size: 0.8em;
}

.fret-marker.double-2 {
  top: 70%;
  left: 70%;
  font-size: 0.8em;
}

/* LEFT-HANDED DOUBLE MARKERS - MIRRORED POSITIONS */
.fretboard.left-handed .fret-marker.double-1 {
  left: 70% !important;
}

.fretboard.left-handed .fret-marker.double-2 {
  left: 30% !important;
}

/* Fret Labels - FIXED ALIGNMENT WITH 1PX SPACER SOLUTION */
.fret-labels {
  display: flex;
  margin-top: 0.5rem;
  justify-content: center;
  align-items: center;
}

/* String label spacer - 1px solution for perfect alignment */
.fret-label.nut-label {
  width: 1px;
  height: 24px;
  margin: 0;
}

/* Fret 0 label (nut position) - narrower for better alignment */
.fret-label.nut {
  width: var(--fret-width);
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--string-label-color);
  font-size: 0.85em;
  user-select: none;
  font-weight: 500;
  margin: 0 1px;
}

/* Regular fret labels */
.fret-label {
  width: var(--fret-width);
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--string-label-color);
  font-size: 0.85em;
  user-select: none;
  font-weight: 500;
  margin: 0 1px;
}

/* Tab System - Moved above fretboard */
.tab-container {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  margin: 1rem 0 0.5rem 0;
  overflow-x: auto;
}

.tabs-section {
  order: 1;
}

.tab {
  padding: 12px 24px;
  background: var(--bg-medium);
  border: 1px solid var(--border-color);
  border-bottom: none;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  font-weight: 500;
  position: relative;
  margin-right: 2px;
}

.tab:first-child { 
  border-radius: 6px 0 0 0; 
}

.tab:last-child { 
  border-radius: 0 6px 0 0; 
  margin-right: 0; 
}

.tab:hover { 
  background: var(--primary-hover); 
  color: white; 
}

.tab.active {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.tab.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-color);
}

/* Content Area */
.content-area {
  background: var(--bg-medium);
  border-radius: 0 0 8px 8px;
  padding: 1rem 1.5rem;
  min-height: 200px;
}

.content-section {
  order: 3;
}

/* Answer Buttons */
.answer-buttons {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 4px;
  margin: 1.5rem 0;
  width: 100%;
  overflow-x: auto;
}

.note-btn {
  color: var(--text-light);
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 0.95em;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
  min-width: 60px;
  flex-shrink: 0;
}

.note-btn.natural {
  background: var(--natural-note-color);
  border-color: #888;
}

.note-btn.natural:hover {
  background: var(--primary-hover);
  border-color: var(--primary-color);
  color: white;
  transform: translateY(-1px);
}

.note-btn.sharp-flat {
  background: var(--sharp-note-color);
  border-color: var(--border-color);
}

.note-btn.sharp-flat:hover {
  background: var(--primary-hover);
  border-color: var(--primary-color);
  color: white;
  transform: translateY(-1px);
}

.note-btn:active {
  background: var(--primary-active);
  transform: translateY(0);
}

.note-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Stats and Feedback */
.feedback {
  text-align: center;
  margin: 1rem 0;
  min-height: 2rem;
  font-size: 1.2em;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stats,
.stat-group {
  display: flex;
  justify-content: flex-start;
  gap: 2rem;
  margin: 0;
  font-size: 1.1em;
  font-weight: 600;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-label {
  color: var(--text-medium);
  font-size: 0.9em;
  font-weight: normal;
}

.stat-value {
  color: var(--secondary-color);
  font-size: 1.2em;
}

.timing {
  text-align: center;
  color: var(--text-medium);
  font-size: 0.95em;
  margin: 0.5rem 0;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  :root {
    --fret-width: 45px;
    --fret-height: 30px;
    --nut-width: 20px;
  }

  .settings-panel {
    flex-direction: column;
    gap: 0.75rem;
  }

  .setting-group {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
  }

  .setting-group label {
    margin-bottom: 0;
    margin-right: 0.5rem;
  }

  .note-btn {
    padding: 10px 8px;
    font-size: 0.9em;
    min-width: 50px;
  }

  .training-controls-row {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }
  
  .stats,
  .stat-group {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  .control-container {
    text-align: center;
  }
  
  .control-btn.compact {
    width: 100%;
    min-width: auto;
  }

  h1 {
    font-size: 1.5rem;
  }

  /* Mobile fret label adjustments */
  .fret-label.nut {
    width: 15px;
  }
}

@media (max-width: 480px) {
  :root {
    --fret-width: 38px;
    --fret-height: 28px;
    --nut-width: 18px;
  }

  .container {
    padding: 0 0.5rem;
  }

  .note-btn {
    min-width: 45px;
    padding: 8px 6px;
    font-size: 0.85em;
  }

  .answer-buttons {
    gap: 3px;
  }

  /* Very small screen fret label adjustments */
  .fret-label.nut {
    width: 12px;
  }
}

/* Focus styles */
.note-btn:focus,
.tab:focus,
select:focus,
.control-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}
