/* Custom variables for premium dark-ambient theme */
:root {
  --bg-primary: #0a0b10;
  --bg-secondary: #12131c;
  --card-bg: rgba(20, 21, 30, 0.7);
  --border-color: rgba(255, 255, 255, 0.06);
  --text-main: #f5f6fa;
  --text-muted: #8f92a1;
  
  /* Accent colors */
  --accent-cyan: #00f2fe;
  --accent-purple: #9b51e0;
  --accent-pink: #ff007f;
  --accent-glow-cyan: rgba(0, 242, 254, 0.35);
  --accent-glow-purple: rgba(155, 81, 224, 0.35);
  
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 20% 20%, rgba(155, 81, 224, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(0, 242, 254, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(10, 11, 16, 1) 0%, rgba(5, 5, 8, 1) 100%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* OVERLAY DE INICIALIZACION */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 6, 10, 0.95);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.overlay-content {
  text-align: center;
  max-width: 500px;
  padding: 40px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.glowing-logo {
  font-size: 4rem;
  color: var(--accent-cyan);
  text-shadow: 0 0 20px var(--accent-glow-cyan);
  margin-bottom: 20px;
  animation: float 4s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.overlay-content h1 {
  font-family: var(--font-title);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 2px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #fff 30%, var(--accent-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.overlay-content p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.6;
  margin-bottom: 30px;
}

.btn-primary-large {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
  padding: 14px 36px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 242, 254, 0.25);
  transition: var(--transition-smooth);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.btn-primary-large:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 242, 254, 0.4);
}

.btn-primary-large:active {
  transform: translateY(1px);
}

/* APP CONTAINER */
.app-container {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 24px;
}

/* HEADER */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo-icon {
  font-size: 2.2rem;
  color: var(--accent-cyan);
  text-shadow: 0 0 10px var(--accent-glow-cyan);
}

.logo-area h1 {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.logo-area h1 span {
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--accent-cyan);
  margin-left: 8px;
  vertical-align: middle;
}

.logo-area p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.btn-panic {
  background: rgba(255, 59, 48, 0.15);
  border: 1px solid rgba(255, 59, 48, 0.3);
  color: #ff3b30;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-panic:hover {
  background: #ff3b30;
  color: white;
  box-shadow: 0 0 15px rgba(255, 59, 48, 0.4);
}

/* CARDS */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255, 255, 255, 0.01);
}

.card-header h2, .card-header h3 {
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.card-header h2 i, .card-header h3 i {
  color: var(--accent-cyan);
}

.card-body {
  padding: 20px;
}

/* APP GRID LAYOUT */
.app-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  flex: 1;
}

@media (min-width: 1024px) {
  .app-grid {
    grid-template-columns: 1fr 380px;
  }
}

.control-sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* DIAPASON (FRETBOARD) */
.fretboard-section {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.fretboard-legend {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.fretboard-scroll-wrapper {
  overflow-x: auto;
  padding: 15px 10px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid var(--border-color);
}

/* Contenedor del Diapasón */
.fretboard-container {
  display: grid;
  grid-template-rows: 24px repeat(7, 36px); /* 1 Fila de números + 7 Cuerdas */
  /* El número de columnas será 25 (traste 0 a 24). Se definirá por JS */
  position: relative;
  width: 100%;
  min-width: 700px;
  background: #14151b;
  border-radius: 4px;
  padding-left: 0;
}

/* Líneas de las Cuerdas (Dibujadas con pseudo-elementos o divs) */
.string-line {
  position: absolute;
  left: 0;
  right: 0;
  background: linear-gradient(180deg, #7f8c8d 0%, #bdc3c7 50%, #7f8c8d 100%);
  pointer-events: none;
  z-index: 1;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* La Cejuela (Nut) */
.fretboard-nut {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  background: linear-gradient(90deg, #e3d9c6, #c2b296);
  z-index: 4;
  box-shadow: 2px 0 5px rgba(0,0,0,0.5);
  border-radius: 2px;
}

/* Trastes metálicos (Verticales) */
.fret-wire {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(90deg, #7f8c8d, #d5dbdb, #7f8c8d);
  z-index: 3;
  pointer-events: none;
}

/* Marcadores del Diapasón (Inlay dots) */
.fret-marker {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.5);
  z-index: 2;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.fret-marker.double {
  /* Se colocan dos marcadores en el traste 12 y 24 */
}

/* Celdas del Traste (Interactivos) */
.fret-cell {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

/* Fila de números de trastes arriba */
.fret-number-row {
  display: flex;
  justify-content: space-around;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-family: var(--font-title);
  font-weight: 500;
  font-size: 0.85rem;
}

/* Fila de números de trastes arriba */
.fret-number {
  grid-row: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--font-title);
  font-size: 0.72rem;
  font-weight: 500;
  padding-bottom: 6px;
  user-select: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.fret-number.marked {
  color: var(--accent-cyan);
  text-shadow: 0 0 5px var(--accent-glow-cyan);
  font-weight: 700;
  font-size: 0.82rem;
}

.fret-number.subtle-dot {
  opacity: 0.12;
  font-size: 0.45rem;
  padding-bottom: 8px;
}

/* Nota visual del traste (Boton interactivo) */
.note-anchor {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.48); /* Aumentar contraste de forma discreta */
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 6;
}

/* Hover en trastes */
.fret-cell:hover .note-anchor {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--text-main);
  transform: scale(1.15);
}

/* Nota activa (Sonando) */
.fret-cell.active .note-anchor {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  color: white;
  border-color: transparent;
  box-shadow: 
    0 0 15px var(--accent-glow-cyan),
    0 0 5px var(--accent-cyan);
  transform: scale(1.2);
}

/* Traste 0 (Cuerda al aire) */
.fret-cell[data-fret="0"] {
  border-right: none;
}
.fret-cell[data-fret="0"] .note-anchor {
  border-radius: 6px;
  width: 28px;
  height: 20px;
  font-size: 0.65rem;
  border: 1px solid rgba(0, 242, 254, 0.2);
  background: rgba(0, 242, 254, 0.03);
  color: rgba(255, 255, 255, 0.35);
}
.fret-cell[data-fret="0"]:hover .note-anchor {
  background: rgba(0, 242, 254, 0.15);
  color: var(--text-main);
}
.fret-cell[data-fret="0"].active .note-anchor {
  background: linear-gradient(135deg, var(--accent-pink), var(--accent-purple));
  border-color: transparent;
  box-shadow: 0 0 12px rgba(255, 0, 127, 0.5);
  color: white;
}

/* FRETBOARD FOOTER */
.fretboard-footer {
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

@media (min-width: 640px) {
  .fretboard-footer {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.tuning-info {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tuning-tag {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-title);
  color: var(--text-muted);
}

.fretboard-instructions {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* SIDEBAR: CONTROLES */
.setting-group {
  margin-bottom: 20px;
}

.setting-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.toggle-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

.toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition-smooth);
}

.toggle-btn.active {
  background: rgba(255, 255, 255, 0.07);
  color: var(--accent-cyan);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.toggle-btn:hover:not(.active) {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.02);
}

/* MONITOR DE NOTAS */
.active-notes-monitor {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 10px;
  margin-top: 15px;
}

.monitor-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.notes-badge-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  align-items: center;
}

.empty-badge {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.25);
  font-style: italic;
}

.note-badge {
  background: rgba(0, 242, 254, 0.1);
  border: 1px solid rgba(0, 242, 254, 0.3);
  color: var(--accent-cyan);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* SLIDERS */
.slider-control {
  margin-bottom: 18px;
}

.slider-control:last-child {
  margin-bottom: 0;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.slider-header span:first-child {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85);
}

.slider-header span:last-child {
  font-family: var(--font-title);
  color: var(--accent-cyan);
  font-weight: 600;
}

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  outline: none;
  transition: var(--transition-smooth);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-main);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0,0,0,0.5);
  transition: var(--transition-smooth);
  border: 2px solid var(--bg-secondary);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-glow-cyan);
  transform: scale(1.15);
}

/* SECUENCIADOR */
.sequencer-controls-top {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin-bottom: 15px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-family: var(--font-title);
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-outline-danger {
  background: transparent;
  border: 1px solid rgba(255, 59, 48, 0.3);
  color: #ff3b30;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-outline-danger:hover {
  background: rgba(255, 59, 48, 0.1);
  border-color: rgba(255, 59, 48, 0.5);
}

.chord-list-container {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 15px;
}

.chord-list {
  list-style: none;
}

.empty-chord-msg {
  padding: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

.chord-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  transition: var(--transition-smooth);
}

.chord-item:last-child {
  border-bottom: none;
}

.chord-item.active {
  background: rgba(155, 81, 224, 0.12);
  border-left: 3px solid var(--accent-purple);
}

.chord-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.chord-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.chord-notes {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.chord-duration-input {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 12px;
}

.chord-duration-input input {
  width: 45px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
}

.chord-duration-input span {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-delete-chord {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: var(--transition-smooth);
}

.btn-delete-chord:hover {
  color: #ff3b30;
}

.sequencer-transport {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.btn-seq-control {
  font-family: var(--font-title);
  font-weight: 600;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-smooth);
}

.btn-play {
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-cyan));
  color: white;
  box-shadow: 0 4px 12px rgba(155, 81, 224, 0.2);
}

.btn-play:hover {
  box-shadow: 0 6px 18px rgba(155, 81, 224, 0.35);
  transform: translateY(-1px);
}

.btn-play.playing {
  background: linear-gradient(135deg, #e67e22, #f1c40f);
}

.btn-stop {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-stop:hover {
  background: rgba(255, 255, 255, 0.1);
}

.transition-control {
  border-top: 1px solid var(--border-color);
  padding-top: 15px;
  margin-top: 10px;
}

/* VISUALIZADOR */
.visualizer-body {
  padding: 10px;
  height: 120px;
}

#audio-visualizer {
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  display: block;
}

/* FOOTER CREDIT */
.app-footer-credit {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 10px;
  padding: 10px 0;
}

/* AUTH & LOGIN STYLES */
.auth-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  max-width: 320px;
  margin: 20px auto 0 auto;
}

.input-field-group {
  position: relative;
  width: 100%;
}

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.95rem;
  pointer-events: none;
  transition: var(--transition-smooth);
}

.auth-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition-smooth);
}

.auth-input:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.15);
}

.auth-input:focus ~ .input-icon {
  color: var(--accent-cyan);
}

.error-msg {
  font-size: 0.85rem;
  min-height: 18px;
  text-align: center;
  font-weight: 500;
}
