/* Reset and base styles */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  background-color: #1e1e1e;
  color: #d4d4d4;
  text-align: center;
  margin: 0;
  padding: 2rem 1rem;
  line-height: 1.5;
}

/* Main wrapper for everything */
.container {
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* Typography */
h1 {
  color: #569cd6;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

h3 {
  color: #569cd6;
  font-size: 1.25rem;
  margin: 1.5rem 0 1rem;
}

p {
  margin: 1rem 0;
  font-size: 1rem;
}

/* Backend selection links */
.backend-links {
  background-color: #2d2d2d;
  padding: 1rem;
  border-radius: 8px;
  margin: 1.5rem 0;
  border: 1px solid #404040;
}

.backend-links strong {
  color: #569cd6;
  margin-right: 1rem;
}

.backend-links a {
  color: #d4d4d4;
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: inline-block;
  margin: 0 0.25rem;
}

.backend-links a:hover {
  background-color: #404040;
  color: #ffffff;
}

.backend-links a.active {
  font-weight: 600;
  background-color: #ff6f00;
  color: #ffffff;
}

/* Controls section */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0;
  flex-wrap: wrap;
  background-color: #2d2d2d;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #404040;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1rem 0;
  justify-content: center;
  background-color: #2d2d2d;
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid #404040;
}

.control-group label {
  color: #d4d4d4;
  font-weight: 500;
  min-width: 90px;
  text-align: right;
}

/* Form elements */
#mic-select,
.controls button {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  border-radius: 6px;
  border: 1px solid #555;
  transition: all 0.2s ease;
}

#mic-select {
  background-color: #333;
  color: #d4d4d4;
  min-width: 200px;
}

#mic-select:focus {
  outline: none;
  border-color: #569cd6;
  box-shadow: 0 0 0 2px rgba(86, 156, 214, 0.2);
}

.controls button {
  cursor: pointer;
  background-color: #0e639c;
  color: white;
  font-weight: 500;
  min-width: 120px;
  transition: background-color 0.2s ease;
}

.controls button:hover:not(:disabled) {
  background-color: #1177bb;
}

.controls button:disabled {
  background-color: #555;
  cursor: not-allowed;
  opacity: 0.6;
}

/* Fixed gain slider */
#gain-slider {
  width: 200px;
  height: 6px;
  background-color: #404040;
  border: none;
  border-radius: 3px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
}

#gain-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background-color: #569cd6;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

#gain-slider::-webkit-slider-thumb:hover {
  background-color: #6ba6d6;
  transform: scale(1.1);
}

#gain-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background-color: #569cd6;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

#gain-slider::-moz-range-track {
  height: 6px;
  background-color: #404040;
  border-radius: 3px;
}

#gain-value {
  color: #4ec9b0;
  font-weight: 500;
  min-width: 50px;
}

/* Status indicators */
#vad-status {
  color: #555;
  font-size: 1.2rem;
  transition: color 0.2s ease;
}

#vad-status.active {
  color: #28a745;
  text-shadow: 0 0 5px rgba(40, 167, 69, 0.5);
}

#status-text {
  font-weight: 500;
}

/* Detection result */
#detection-result {
  min-height: 3rem;
  font-size: 1.3rem;
  color: #4ec9b0;
  margin: 2rem 0;
  padding: 1rem;
  background-color: #2d2d2d;
  border-radius: 8px;
  border: 1px solid #404040;
}

#detection-text {
  font-weight: 500;
  margin: 0;
}

/* Chart container */
.chart-container {
  margin: 2rem 0;
  background-color: #2d2d2d;
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid #404040;
}

/* Debug section */
#debug-audio-container {
  margin: 2rem 0;
  padding: 1.5rem;
  background-color: #2d2d2d;
  border-radius: 8px;
  border: 1px solid #404040;
}

#debug-audio-container h3 {
  color: #569cd6;
  margin-bottom: 1.5rem;
}

.audio-clip {
  margin: 1rem 0;
  padding: 1rem;
  background-color: #1e1e1e;
  border-radius: 6px;
  border: 1px solid #404040;
}

.audio-clip-label {
  color: #d4d4d4;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  text-align: left;
}

.audio-clip audio {
  width: 100%;
  height: 40px;
}

#debug-output {
  width: 100%;
  height: 200px;
  background-color: #1e1e1e;
  color: #00ff00;
  font-family: "Consolas", "Monaco", "Courier New", monospace;
  font-size: 0.9rem;
  border: 1px solid #444;
  border-radius: 4px;
  padding: 1rem;
  resize: vertical;
  line-height: 1.4;
}

#debug-output:focus {
  outline: none;
  border-color: #569cd6;
  box-shadow: 0 0 0 2px rgba(86, 156, 214, 0.2);
}

/* Model info table */
#model-info table {
  margin: 2rem 0;
  border-collapse: collapse;
  width: 100%;
  background-color: #2d2d2d;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #404040;
}

#model-info th,
#model-info td {
  border: 1px solid #404040;
  padding: 0.75rem;
  text-align: left;
}

#model-info th {
  background-color: #333;
  color: #569cd6;
  font-weight: 600;
}

#model-info td {
  background-color: #2d2d2d;
}

#model-info tr:nth-child(even) td {
  background-color: #262626;
}

/* Responsive design */
@media (max-width: 768px) {
  body {
    padding: 1rem 0.5rem;
  }
  
  .container {
    width: 95%;
  }
  
  h1 {
    font-size: 2rem;
  }
  
  .controls {
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem;
  }
  
  .control-group {
    flex-direction: column;
    gap: 0.5rem;
    text-align: center;
  }
  
  .control-group label {
    text-align: center;
    min-width: auto;
  }
  
  #mic-select {
    min-width: 250px;
  }
  
  #gain-slider {
    width: 250px;
  }
  
  .backend-links {
    padding: 0.75rem;
  }
  
  .backend-links strong {
    display: block;
    margin-bottom: 0.5rem;
  }
  
  .chart-container {
    padding: 1rem;
  }
}