/* ===== RESET & BASE ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

\:root {
  --primary: #2c3e50;
  --secondary: #34495e;
  --accent: #3498db;
  --background: #f8f9fa;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --light-gray: #ecf0f1;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --border-radius: 8px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  --focus-outline: 3px solid #3498db;
}

/* MI-005: WCAG AA Color Contrast */
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--background);
  padding: 20px;
}

/* MI-002: Loading Spinner */
.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent);
  animation: spin 1s ease-in-out infinite;
}

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

.spinner-inline {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent);
  animation: spin 1s ease-in-out infinite;
}

/* MI-004: Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .spinner, .spinner-inline {
    animation: none !important;
  }
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

header {
  text-align: center;
  margin-bottom: 30px;
}

header h1 {
  color: var(--secondary);
  margin-bottom: 10px;
}

header p {
  color: var(--text-light);
  font-size: 1.1rem;
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 30px;
  padding: 20px;
  background: var(--light-gray);
  border-radius: var(--border-radius);
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 15px;
}

.control-group label {
  font-weight: 600;
  color: var(--text);
}

/* MI-003: Focus Styles */
.btn:focus, input:focus, select:focus {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

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

.btn-primary\:hover {
  background-color: var(--secondary);
}

.btn-secondary {
  background-color: #6c757d;
  color: white;
}

.btn-secondary\:hover {
  background-color: #5a6268;
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger\:hover {
  background-color: #c0392b;
}

.btn-small {
  padding: 8px 15px;
  font-size: 0.9rem;
}

input[type="range"] {
  flex: 1;
  min-width: 150px;
}

input[type="file"] {
  display: none;
}

select, input[type="text"] {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: var(--border-radius);
  font-size: 1rem;
}

/* ===== VISUALIZERS ===== */
.visualizers {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 30px;
}

.visualizer {
  background: var(--light-gray);
  padding: 15px;
  border-radius: var(--border-radius);
}

.visualizer h3 {
  margin-bottom: 10px;
  color: var(--secondary);
}

canvas {
  width: 100%;
  height: 150px;
  background: #222;
  border-radius: var(--border-radius);
}

/* ===== PRESETS ===== */
.presets {
  margin-bottom: 30px;
  padding: 20px;
  background: var(--light-gray);
  border-radius: var(--border-radius);
}

.preset-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* ===== STATUS ===== */
.status {
  text-align: center;
  padding: 15px;
  background: var(--light-gray);
  border-radius: var(--border-radius);
  margin-bottom: 20px;
}

#statusMessage {
  font-weight: 600;
  color: var(--secondary);
}

/* MI-006: Unsupported Browser Banner */
.error-banner {
  background: var(--danger);
  color: white;
  padding: 15px;
  text-align: center;
  border-radius: var(--border-radius);
  margin-bottom: 20px;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 15px 25px;
  background: var(--danger);
  color: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 1000;
}

.toast.success {
  background: var(--success);
}

#closeToast {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .container {
    padding: 10px;
  }

  .controls, .presets {
    padding: 15px;
  }

  .control-group {
    flex-direction: column;
    align-items: stretch;
  }

  input[type="range"] {
    width: 100%;
  }

  canvas {
    height: 120px;
  }
}
