/* ========================================================
   STAGE CHARTS — ATRIL DIGITAL DE ACORDES Y LETRAS (MICRO APP)
   Diseño ultra-ligero de alta visibilidad para smartphones y tablets
   ======================================================== */

:root {
  --bg-main: #090d16;
  --bg-card: rgba(18, 24, 38, 0.7);
  --bg-card-hover: rgba(26, 34, 52, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(34, 211, 238, 0.3);
  
  --cyan: #22d3ee;
  --cyan-glow: rgba(34, 211, 238, 0.25);
  --purple: #a855f7;
  --yellow: #facc15;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-chord: #38bdf8;
  
  --font-base-size: 16px;
  --header-height: 64px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  font-size: var(--font-base-size);
}

/* ─── APP HEADER ─── */
.charts-header {
  height: var(--header-height);
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-badge {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 1rem;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--cyan);
  color: var(--cyan);
}

/* ─── APP SWITCHER / WAFFLE MODAL ─── */
.app-switcher-menu {
  position: absolute;
  top: 70px;
  right: 1rem;
  width: 290px;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

.app-switcher-menu.active {
  display: flex;
}

.switcher-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 700;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
}

.switcher-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.switcher-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.75rem 0.5rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid transparent;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s;
  text-align: center;
}

.switcher-item:hover, .switcher-item.current {
  background: rgba(34, 211, 238, 0.1);
  border-color: var(--border-accent);
  color: var(--cyan);
}

.switcher-item i {
  font-size: 1.35rem;
}

/* ─── CATALOG VIEW ─── */
.view-container {
  flex: 1;
  padding: 1rem;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.search-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-input-wrapper i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px var(--cyan-glow);
}

.key-filter-select {
  padding: 0 0.85rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
  cursor: pointer;
}

/* ─── CATALOG LIST ─── */
.catalog-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.song-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 0.9rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.song-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-2px);
}

.song-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.song-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #fff;
}

.song-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.badge-key {
  background: rgba(34, 211, 238, 0.15);
  color: var(--cyan);
  font-weight: 800;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  border: 1px solid rgba(34, 211, 238, 0.25);
}

.badge-bpm {
  font-weight: 600;
}

/* ─── STICKY HEADER PERSISTENTE (TOOLBAR + PILLS DE SECCIÓN) ─── */
.chart-sticky-header {
  position: sticky;
  top: var(--header-height);
  z-index: 95;
  background: rgba(9, 13, 22, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding-top: 0.5rem;
  padding-bottom: 0.4rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chart-view-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  backdrop-filter: blur(12px);
}

.chart-title-box {
  display: flex;
  flex-direction: column;
}

.chart-main-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
}

.chart-sub-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.transpose-panel {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.25rem;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
}

.btn-transpose {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-transpose:hover {
  background: var(--cyan);
  color: #000;
}

.active-key-pill {
  font-weight: 800;
  color: var(--cyan);
  font-size: 1rem;
  padding: 0 0.5rem;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* ─── SECTION PILLS BAR (STICKY & INTERACTIVA) ─── */
.section-nav-pills {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.2rem 0.25rem 0.35rem 0.25rem;
  margin-bottom: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.section-nav-pills::-webkit-scrollbar {
  display: none;
}

.section-pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #94a3b8;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.section-pill-btn:hover {
  background: rgba(34, 211, 238, 0.15);
  color: #fff;
  border-color: rgba(34, 211, 238, 0.4);
}

.section-pill-btn.active {
  background: var(--cyan);
  color: #020617;
  border-color: var(--cyan);
  box-shadow: 0 0 14px var(--cyan-glow);
}

/* ─── CHART CONTENT (CHORDS & LYRICS) ─── */
.chart-content-area {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  padding-bottom: 5rem;
}

.chart-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 1.15rem 1.35rem;
  scroll-margin-top: calc(var(--header-height) + 145px);
}

.section-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.6rem;
  margin-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.section-name {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--cyan);
  text-transform: uppercase;
}

.section-chords-summary {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--yellow);
  background: rgba(250, 204, 21, 0.08);
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(250, 204, 21, 0.2);
}

/* Acordes sobre letra */
.lyrics-lines {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.chart-line {
  display: flex;
  flex-direction: column;
  line-height: 1.4;
}

.chord-line {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: calc(var(--font-base-size) * 1.05);
  font-weight: 800;
  color: var(--text-chord);
  letter-spacing: 0.02em;
  min-height: 1.2em;
  white-space: pre-wrap;
}

.lyric-text {
  font-size: var(--font-base-size);
  color: var(--text-main);
  white-space: pre-wrap;
}

/* ─── PRINT MODE ─── */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 13pt;
  }
  .charts-header, .chart-view-toolbar, .section-nav-pills, .btn-icon, .app-switcher-menu {
    display: none !important;
  }
  .chart-section-card {
    background: transparent !important;
    border: none !important;
    border-bottom: 1px solid #ccc !important;
    page-break-inside: avoid;
    padding: 0.5rem 0 !important;
  }
  .section-name {
    color: #000 !important;
  }
  .chord-line {
    color: #0284c7 !important;
  }
  .lyric-text {
    color: #111 !important;
  }
}

/* ─── MODAL EDITOR DE CHART & LETRAS ─── */
.chart-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.chart-modal-dialog {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.chart-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: #1e293b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.editor-meta-bar {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-wrap: wrap;
}

.editor-meta-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.editor-meta-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.editor-meta-field select,
.editor-meta-field input {
  background: #1e293b;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.9rem;
}

.editor-tab-switch {
  margin-left: auto;
  display: flex;
  background: #1e293b;
  padding: 3px;
  border-radius: 8px;
  gap: 2px;
}

.editor-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.editor-tab-btn.active {
  background: var(--cyan);
  color: #000;
}

.editor-quick-toolbar {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  background: rgba(30, 41, 59, 0.5);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-wrap: wrap;
}

.btn-tool {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.btn-tool:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--cyan);
}

.editor-body-visual,
.editor-body-chordpro {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.sections-editor-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.section-edit-card {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.section-edit-head {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.section-edit-title-input {
  background: #0f172a;
  color: var(--cyan);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-weight: 700;
  font-size: 0.95rem;
  flex: 1;
}

.section-edit-chords-input {
  background: #0f172a;
  color: var(--text-chord);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-family: monospace;
  font-weight: 600;
  font-size: 0.9rem;
  flex: 1;
}

.section-edit-textarea {
  background: #0b1120;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  min-height: 120px;
  width: 100%;
  white-space: pre;
  tab-size: 4;
}

.section-edit-textarea:focus {
  border-color: var(--cyan);
  outline: none;
  box-shadow: 0 0 0 2px var(--cyan-glow);
}

.chordpro-editor-textarea {
  width: 100%;
  height: 480px;
  background: #020617;
  color: #38bdf8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  resize: vertical;
  white-space: pre;
}

.chart-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: #1e293b;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-primary {
  background: var(--cyan);
  color: #000;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1.2rem;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
}
