/* Estilos generales */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body {
  font-family: "Orbitron", sans-serif;
  background-color: #f0f0f0;
  color: #333;
  transition: background-color 0.3s, color 0.3s;
  overscroll-behavior: none;
}

.dark-theme {
  background-color: #222;
  color: #f0f0f0;
}

.synth-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
  background-color: #fff;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  position: relative;
  transition: background-color 0.3s;
}

.dark-theme .synth-container {
  background-color: #333;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

/* Overlay de inicio */
#start-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  z-index: 100;
  color: #fff;
  border-radius: 10px;
  padding: 100px 20px 20px 20px;
}

#start-overlay h1 {
  font-size: 3rem;
  margin-bottom: 20px;
  color: #ffcc00;
  text-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

#start-overlay p {
  font-size: 1.2rem;
  margin-bottom: 30px;
}

#start-button {
  padding: 15px 30px;
  font-size: 1.2rem;
  background-color: #ffcc00;
  color: #000;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: "Orbitron", sans-serif;
  transition: background-color 0.3s, transform 0.1s;
}

#start-button:hover {
  background-color: #ffdd33;
  transform: scale(1.05);
}

#start-button:active {
  transform: scale(0.98);
}

/* Encabezado */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 2px solid #eee;
}

.dark-theme header {
  border-bottom-color: #444;
}

.logo-container {
  display: flex;
  align-items: center;
}

#miguelo-logo {
  width: 60px;
  height: 60px;
  margin-right: 15px;
}

header h1 {
  font-size: 1.8rem;
  color: #ffcc00;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

.dark-theme header h1 {
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.header-buttons {
  display: flex;
  gap: 10px;
}

#theme-button,
#language-button {
  padding: 8px 15px;
  background-color: #333;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: "Orbitron", sans-serif;
  font-size: 0.8rem;
  transition: background-color 0.3s;
}

#language-button {
  background-color: #43e8d8;
  color: #000;
}

.dark-theme #theme-button {
  background-color: #ffcc00;
  color: #000;
}

.dark-theme #language-button {
  background-color: #43e8d8;
  color: #000;
}

/* Controles */
.controls-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.control-group {
  display: flex;
  flex-direction: column;
  background-color: #f9f9f9;
  padding: 15px;
  border-radius: 5px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.dark-theme .control-group {
  background-color: #444;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.control-group label {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: #666;
}

.dark-theme .control-group label {
  color: #ccc;
}

.control-group input[type="range"] {
  width: 100%;
  margin-bottom: 8px;
  -webkit-appearance: none;
  height: 8px;
  background: #ddd;
  border-radius: 4px;
  outline: none;
}

.control-group input[type="range"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dark-theme .control-group input[type="range"] {
  background: #555;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #ffcc00;
  border-radius: 50%;
  cursor: pointer;
}

.control-group input[type="range"]:disabled::-webkit-slider-thumb {
  cursor: not-allowed;
}

.control-group select {
  padding: 8px;
  background-color: #eee;
  border: none;
  border-radius: 4px;
  font-family: "Orbitron", sans-serif;
  font-size: 0.9rem;
  color: #333;
}

.dark-theme .control-group select {
  background-color: #555;
  color: #fff;
}

.control-group span {
  font-size: 0.8rem;
  color: #999;
  text-align: right;
}

.dark-theme .control-group span {
  color: #aaa;
}

/* Sección LFO */
.lfo-container {
  background-color: #f0f0f0;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border: 2px solid #43e8d8;
}

.dark-theme .lfo-container {
  background-color: #2a2a2a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.lfo-container h2 {
  font-size: 1.3rem;
  color: #43e8d8;
  margin-bottom: 15px;
  text-align: center;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.lfo-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 15px;
}

.lfo-control-group {
  display: flex;
  flex-direction: column;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 12px;
  border-radius: 5px;
}

.dark-theme .lfo-control-group {
  background-color: rgba(255, 255, 255, 0.05);
}

.lfo-control-group label {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: #555;
}

.dark-theme .lfo-control-group label {
  color: #ccc;
}

.lfo-control-group input[type="range"] {
  width: 100%;
  margin-bottom: 8px;
  -webkit-appearance: none;
  height: 8px;
  background: #ddd;
  border-radius: 4px;
  outline: none;
}

.dark-theme .lfo-control-group input[type="range"] {
  background: #555;
}

.lfo-control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #43e8d8;
  border-radius: 50%;
  cursor: pointer;
}

.lfo-control-group span {
  font-size: 0.8rem;
  color: #777;
  text-align: right;
}

.dark-theme .lfo-control-group span {
  color: #aaa;
}

/* Ajustes responsivos para LFO */
@media (max-width: 768px) {
  .lfo-controls {
    grid-template-columns: 1fr;
  }
}

/* Botón de modo de frecuencia */
.mode-toggle {
  padding: 6px 10px;
  margin-bottom: 10px;
  background-color: #43e8d8;
  color: #000;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: "Orbitron", sans-serif;
  font-size: 0.75rem;
  transition: background-color 0.3s;
  align-self: flex-start;
}

.mode-toggle.manual-mode {
  background-color: #ffcc00;
}

/* Arpegiador */
.arpeggiator-container {
  background-color: #f0f0f0;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border: 2px solid #ffcc00;
}

.dark-theme .arpeggiator-container {
  background-color: #2a2a2a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.arpeggiator-container h2 {
  font-size: 1.3rem;
  color: #ffcc00;
  margin-bottom: 15px;
  text-align: center;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.arpeggiator-controls {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

.arp-control-group {
  display: flex;
  flex-direction: column;
  background-color: rgba(0, 0, 0, 0.05);
  padding: 12px;
  border-radius: 5px;
}

.dark-theme .arp-control-group {
  background-color: rgba(255, 255, 255, 0.05);
}

.arp-control-group label {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: #555;
}

.dark-theme .arp-control-group label {
  color: #ccc;
}

.arp-control-group input[type="range"] {
  width: 100%;
  margin-bottom: 8px;
  -webkit-appearance: none;
  height: 8px;
  background: #ddd;
  border-radius: 4px;
  outline: none;
}

.dark-theme .arp-control-group input[type="range"] {
  background: #555;
}

.arp-control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  background: #43e8d8;
  border-radius: 50%;
  cursor: pointer;
}

.arp-control-group select {
  padding: 8px;
  background-color: #eee;
  border: none;
  border-radius: 4px;
  font-family: "Orbitron", sans-serif;
  font-size: 0.85rem;
  color: #333;
}

.dark-theme .arp-control-group select {
  background-color: #555;
  color: #fff;
}

.arp-control-group span {
  font-size: 0.8rem;
  color: #777;
  text-align: right;
}

.dark-theme .arp-control-group span {
  color: #aaa;
}

.arp-button {
  padding: 10px;
  background-color: #666;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: "Orbitron", sans-serif;
  font-size: 0.9rem;
  transition: background-color 0.3s;
  width: 100%;
}

.arp-button.active {
  background-color: #43e8d8;
  color: #000;
}

.arp-notes-display {
  grid-column: 1 / -1;
  background-color: rgba(0, 0, 0, 0.1);
  padding: 10px;
  border-radius: 5px;
  font-size: 0.85rem;
  color: #555;
  text-align: center;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dark-theme .arp-notes-display {
  background-color: rgba(255, 255, 255, 0.1);
  color: #ccc;
}

/* Visualizador */
.visualizer-container {
  background-color: #f0f0f0;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  border: 2px solid #ffcc00;
}

.dark-theme .visualizer-container {
  background-color: #2a2a2a;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.visualizer-container h2 {
  font-size: 1.3rem;
  color: #ffcc00;
  margin-bottom: 15px;
  text-align: center;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

#waveform-visualizer {
  width: 100%;
  height: 120px;
  background-color: rgba(0, 0, 0, 0.1);
  border-radius: 5px;
}

.dark-theme #waveform-visualizer {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Presets */
.presets-container {
  margin-bottom: 20px;
}

.presets-container h2 {
  font-size: 1.3rem;
  margin-bottom: 15px;
  color: #333;
  text-align: center;
}

.dark-theme .presets-container h2 {
  color: #fff;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.preset-btn {
  padding: 10px 15px;
  background-color: #eee;
  color: #333;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-family: "Orbitron", sans-serif;
  font-size: 0.8rem;
  transition: background-color 0.3s, transform 0.1s;
}

.dark-theme .preset-btn {
  background-color: #555;
  color: #fff;
}

.preset-btn:hover {
  background-color: #ddd;
  transform: scale(1.05);
}

.dark-theme .preset-btn:hover {
  background-color: #666;
}

.preset-btn:active {
  transform: scale(0.98);
}

/* Teclado corregido */
.keyboard-container {
  margin-bottom: 20px;
  position: relative;
}

#touch-keyboard {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 10px;
  background-color: #222;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.piano-row {
  display: flex;
  position: relative;
  height: 150px;
}

.piano-key {
  position: relative;
  border: none;
  outline: none;
  cursor: pointer;
  font-family: "Orbitron", sans-serif;
  font-weight: bold;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
  transition: background-color 0.1s;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.white-key {
  flex: 1;
  height: 100%;
  background-color: #fff;
  border-radius: 0 0 5px 5px;
  border-right: 1px solid #ccc;
  color: #333;
  z-index: 1;
}

.white-key:last-child {
  border-right: none;
}

.black-key {
  position: absolute;
  width: 8%;
  height: 60%;
  background-color: #222;
  border-radius: 0 0 3px 3px;
  color: #fff;
  z-index: 2;
}

/* Posicionamiento corregido de las teclas negras */
.black-key:nth-of-type(9) {
  left: 6.5%; /* C# */
}
.black-key:nth-of-type(10) {
  left: 18.5%; /* D# */
}
.black-key:nth-of-type(11) {
  left: 43.5%; /* F# */
}
.black-key:nth-of-type(12) {
  left: 56.5%; /* G# */
}
.black-key:nth-of-type(13) {
  left: 68.5%; /* A# */
}

/* CORREGIDO: Estilo para teclas activas */
.piano-key.active {
  background-color: #ffcc00;
  color: #000;
}

.octave-display {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 15px;
  gap: 20px;
}

#current-octave {
  font-size: 1rem;
  font-weight: bold;
  color: #ffcc00;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 8px 15px;
  border-radius: 5px;
}

.octave-buttons {
  display: flex;
  gap: 10px;
}

.octave-btn {
  width: 40px;
  height: 40px;
  background-color: #ffcc00;
  color: #000;
  border: none;
  border-radius: 5px;
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

.stop-btn {
  width: 80px;
  height: 40px;
  background-color: #ff3333;
  color: #fff;
  border: none;
  border-radius: 5px;
  font-family: "Orbitron", sans-serif;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-left: 20px;
  transition: background-color 0.2s, transform 0.1s;
}

.stop-btn:hover {
  background-color: #ff0000;
  transform: scale(1.05);
}

.stop-btn:active {
  transform: scale(0.98);
}

/* Debug */
#debug-container {
  margin-top: 20px;
  padding: 15px;
  background-color: #f5f5f5;
  border-radius: 5px;
  font-family: monospace;
  font-size: 0.8rem;
  color: #666;
  max-height: 200px;
  overflow-y: auto;
}

.dark-theme #debug-container {
  background-color: #444;
  color: #ccc;
}

#debug-container h3 {
  margin-bottom: 10px;
  color: #333;
}

.dark-theme #debug-container h3 {
  color: #fff;
}

#debug {
  white-space: pre-wrap;
  line-height: 1.4;
}

/* Responsive */
@media (max-width: 768px) {
  .controls-container {
    grid-template-columns: 1fr;
  }

  .arpeggiator-controls {
    grid-template-columns: 1fr;
  }

  .piano-row {
    height: 120px;
  }

  .preset-buttons {
    flex-direction: column;
    align-items: center;
  }

  .preset-btn {
    width: 100%;
    max-width: 300px;
  }

  .black-key {
    width: 10%;
  }

  /* Ajustar posicionamiento de teclas negras en móvil */
  .black-key:nth-of-type(9) {
    left: 6%; /* C# */
  }
  .black-key:nth-of-type(10) {
    left: 18%; /* D# */
  }
  .black-key:nth-of-type(11) {
    left: 43%; /* F# */
  }
  .black-key:nth-of-type(12) {
    left: 56%; /* G# */
  }
  .black-key:nth-of-type(13) {
    left: 68%; /* A# */
  }
}

/* Ajustes responsivos para el visualizador */
@media (max-width: 768px) {
  #waveform-visualizer {
    height: 100px;
  }
}

/* Ajustes para dispositivos móviles */
@media (max-width: 768px) {
  #start-overlay {
    padding-top: 100px;
  }

  #start-overlay h1 {
    font-size: 2.2rem;
    margin-bottom: 15px;
  }

  #start-overlay p {
    font-size: 1rem;
    margin-bottom: 20px;
  }
}

/* Añadir estilos para el footer */
.footer {
  text-align: center;
  margin-top: 30px;
  padding: 15px 0;
  border-top: 1px solid #eee;
  font-size: 0.9rem;
  color: #666;
}

.dark-theme .footer {
  border-top-color: #444;
  color: #aaa;
}

.footer a {
  color: #ffcc00;
  text-decoration: none;
  font-weight: bold;
  transition: color 0.3s;
}

.footer a:hover {
  color: #ff9900;
  text-decoration: underline;
}

.dark-theme .footer a {
  color: #ffcc00;
}

.dark-theme .footer a:hover {
  color: #ffdd33;
}

/* Ajustar el layout para dispositivos móviles */
@media (max-width: 768px) {
  .octave-display {
    flex-wrap: wrap;
    gap: 10px;
  }

  .stop-btn {
    margin-left: 0;
    margin-top: 10px;
    width: 100%;
    max-width: 200px;
  }
}
