/* ==========================================================================
   MuseScore 4.7.6 Inspired Web Score Studio — "Todo lo que respira"
   Fuentes Oficiales SMuFL (Leland, Bravura) y Editorial (Edwin)
   ========================================================================== */

@font-face {
  font-family: 'Leland';
  src: url('../fonts/Leland.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'LelandText';
  src: url('../fonts/LelandText.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Bravura';
  src: url('../fonts/Bravura.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
  font-display: block;
}

@font-face {
  font-family: 'Edwin';
  src: url('../fonts/Edwin-Roman.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Edwin';
  src: url('../fonts/Edwin-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Edwin';
  src: url('../fonts/Edwin-Italic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}

/* ==========================================================================
   Layout Principal del Estudio Musical (Inspirado en NotationFrame.qml de MuseScore 4.7.6)
   ========================================================================== */

.studio-workspace {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 118px);
  min-height: 680px;
  background: #0b111e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

.studio-workspace.is-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2500;
  border-radius: 0;
  border: none;
}

/* --- Barra Superior 1: Proyecto, Canto Vinculado y Guardado en Servidor --- */
.studio-top-project-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: linear-gradient(180deg, #152036 0%, #0f1829 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  flex-wrap: wrap;
}

.studio-project-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.studio-brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(197, 160, 89, 0.16);
  border: 1px solid rgba(197, 160, 89, 0.35);
  border-radius: 6px;
  color: #e2be78;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.studio-song-selector {
  min-width: 280px;
  max-width: 390px;
  background: #090e1a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12.5px;
  font-weight: 500;
}

.studio-song-mode-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.studio-song-mode-tag.mode-xml {
  background: rgba(16, 185, 129, 0.14);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.studio-song-mode-tag.mode-img {
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.studio-project-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Barra Superior 2: NoteInputBar (Idéntica a MuseScore 4.7.6) --- */
.studio-note-input-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: #131d31;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  scrollbar-width: thin;
}

.studio-tool-group {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding-right: 8px;
  margin-right: 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.09);
}

.studio-tool-group:last-child {
  border-right: none;
}

.studio-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 32px;
  height: 30px;
  padding: 0 7px;
  background: rgba(255, 255, 255, 0.03);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  user-select: none;
}

.studio-tool-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.18);
}

.studio-tool-btn.active {
  background: #2563eb;
  color: #ffffff;
  border-color: #60a5fa;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.45);
}

.studio-tool-btn.mode-n-btn.active {
  background: #c5a059;
  color: #090d16;
  border-color: #f3d088;
  box-shadow: 0 0 12px rgba(197, 160, 89, 0.5);
}

.studio-tool-btn .smufl-glyph {
  font-family: 'Leland', 'Bravura', serif;
  font-size: 18px;
  line-height: 1;
  font-weight: normal;
}

.studio-tool-btn kbd {
  font-family: var(--font-mono);
  font-size: 9.5px;
  opacity: 0.65;
  margin-left: 2px;
}

/* Selector de Voces 1-4 (Colores de MuseScore 4) */
.voice-btn-1.active { background: #2563eb !important; border-color: #60a5fa !important; }
.voice-btn-2.active { background: #059669 !important; border-color: #34d399 !important; }
.voice-btn-3.active { background: #d97706 !important; border-color: #fbbf24 !important; }
.voice-btn-4.active { background: #9333ea !important; border-color: #c084fc !important; }

/* --- Cuerpo Central: Panel Izquierdo (Paletas/Inspector) + Lienzo Central --- */
.studio-main-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Panel Izquierdo (300px como en NotationFrame.qml) */
.studio-left-dock {
  width: 300px;
  min-width: 280px;
  background: #0e1626;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease;
}

.studio-left-dock.collapsed {
  width: 0;
  min-width: 0;
  border-right: none;
}

.studio-dock-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 10px;
  background: #131e33;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.studio-dock-tab {
  padding: 6px 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: #94a3b8;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.studio-dock-tab:hover {
  color: #f8fafc;
  background: rgba(255, 255, 255, 0.04);
}

.studio-dock-tab.active {
  color: #e2be78;
  background: rgba(197, 160, 89, 0.14);
  border-color: rgba(197, 160, 89, 0.32);
}

.studio-dock-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.studio-dock-pane {
  display: none;
}

.studio-dock-pane.active {
  display: block;
}

/* Acordeones de Paletas Musicales */
.palette-box {
  margin-bottom: 10px;
  background: #131e33;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  overflow: hidden;
}

.palette-box-header {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: none;
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.palette-box-header:hover {
  background: rgba(255, 255, 255, 0.05);
}

.palette-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.palette-item-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 4px;
  background: #0c1322;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #f1f5f9;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.palette-item-btn:hover {
  background: #1d2d4d;
  border-color: #c5a059;
  transform: translateY(-1px);
}

.palette-item-symbol {
  font-family: 'Leland', 'Bravura', 'Edwin', serif;
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
}

.palette-item-label {
  font-size: 10px;
  color: #94a3b8;
}

/* --- Área Central Dividida: Imagen de Referencia + Lienzo de Partitura --- */
.studio-center-stage {
  flex: 1;
  display: flex;
  min-width: 0;
  background: #070b14;
  position: relative;
}

/* Panel de Imagen Escaneada (Para transcripción en Pantalla Dividida) */
.studio-reference-panel {
  width: 44%;
  min-width: 280px;
  max-width: 65%;
  background: #0a0f1c;
  border-right: 2px solid rgba(197, 160, 89, 0.35);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.studio-reference-panel.visible {
  display: flex;
}

.studio-ref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  background: #111a2e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  font-weight: 600;
  color: #e2be78;
}

.studio-ref-viewport {
  flex: 1;
  overflow: auto;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: radial-gradient(circle at center, #111827 0%, #060911 100%);
}

.studio-ref-viewport img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.65);
  transform-origin: top center;
  transition: transform 0.15s ease;
}

/* Lienzo de Partitura Musical (Hoja Editorial Interactiva) */
.studio-canvas-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Barra rápida de Nota/Compás Seleccionado y Entrada de Letra/Acorde */
.studio-quick-edit-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
  background: #10192b;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  flex-wrap: wrap;
}

.studio-quick-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #cbd5e1;
}

.studio-quick-field input,
.studio-quick-field select {
  background: #090e1a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 12px;
}

/* Viewport del Papel Musical */
.studio-paper-scroll {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(37, 99, 235, 0.06), transparent 65%),
    #182030;
}

.studio-score-page {
  width: 940px;
  min-height: 1180px;
  background: #ffffff;
  color: #000000;
  border-radius: 4px;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(0, 0, 0, 0.15);
  padding: 44px 48px 56px 48px;
  position: relative;
  transform-origin: top center;
  transition: width 0.15s ease;
}

/* Encabezado Editorial dentro de la Hoja del Estudio (Estilo Himnario Hebrón / Belén) */
.studio-page-editorial-header {
  border-bottom: 1.5px solid #1e293b;
  padding-bottom: 12px;
  margin-bottom: 18px;
  font-family: 'Edwin', 'Sylfaen', Georgia, serif;
  color: #0f172a;
}

.studio-page-top-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: #334155;
  margin-bottom: 4px;
}

.studio-page-title {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #000000;
  margin: 0;
}

.studio-page-subtitle {
  text-align: center;
  font-size: 13.5px;
  font-style: italic;
  color: #334155;
  margin-top: 2px;
}

.studio-page-submeta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
}

/* Rejilla Interactiva de Compases y Notas (Click-to-Edit + Visualización OSMD) */
.studio-interactive-grid {
  margin-bottom: 18px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f8fafc;
  padding: 10px 12px;
}

.studio-grid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 11.5px;
  font-weight: 700;
  color: #1e293b;
  font-family: var(--font-body);
}

.studio-measures-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.studio-measure-card {
  flex: 1 1 calc(25% - 8px);
  min-width: 195px;
  background: #ffffff;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.studio-measure-card:hover {
  border-color: #64748b;
}

.studio-measure-card.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
  background: #eff6ff;
}

.studio-measure-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 5px;
  border-bottom: 1px dashed #e2e8f0;
  padding-bottom: 3px;
}

.studio-notes-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 34px;
  align-items: center;
}

.studio-note-Token {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 3px 6px;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.15;
  transition: all 0.12s ease;
}

.studio-note-Token:hover {
  background: #e2e8f0;
  border-color: #64748b;
}

.studio-note-Token.selected {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
  transform: scale(1.05);
}

.studio-note-Token.is-rest {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
}

.studio-note-Token .token-chord {
  font-size: 9.5px;
  color: #b45309;
  font-weight: 800;
}

.studio-note-Token.selected .token-chord {
  color: #fde68a;
}

.studio-note-Token .token-lyric {
  font-size: 9.5px;
  color: #475569;
  font-weight: 500;
  font-style: italic;
}

.studio-note-Token.selected .token-lyric {
  color: #e0f2fe;
}

/* Superficie OSMD Vectorial en Vivo dentro del Estudio */
.studio-osmd-canvas {
  width: 100%;
  min-height: 550px;
  user-select: none;
}

.studio-sheet-direct-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
  border-radius: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e3a8a;
  font-size: 11.5px;
  font-family: var(--font-body);
}

/* Interacción directa sobre las notas SVG en el pentagrama (Estilo MuseScore) */
.studio-svg-note-interactive {
  cursor: ns-resize;
  transition: filter 0.1s ease;
}

.studio-svg-note-interactive:hover path,
.studio-svg-note-interactive:hover rect {
  fill: #3b82f6 !important;
  stroke: #3b82f6 !important;
}

.studio-svg-note-selected path,
.studio-svg-note-selected rect,
.studio-svg-note-selected text {
  fill: #2563eb !important;
  stroke: #2563eb !important;
}

.studio-svg-note-selected {
  filter: drop-shadow(0 0 4px rgba(37, 99, 235, 0.55));
}

/* HUD Flotante sobre la Nota Seleccionada en el Pentagrama */
.studio-floating-note-hud {
  position: absolute;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 7px;
  background: #0f172a;
  color: #f8fafc;
  border: 1.5px solid #3b82f6;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.45);
  transform: translate(-50%, -100%);
  pointer-events: auto;
  white-space: nowrap;
}

.studio-floating-note-hud .hud-pitch-badge {
  background: #2563eb;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 5px;
  margin-right: 2px;
  font-family: var(--font-body);
}

.studio-floating-note-hud .hud-btn {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
}

.studio-floating-note-hud .hud-btn:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #60a5fa;
}

.studio-floating-note-hud .hud-btn-add {
  color: #34d399;
}

.studio-floating-note-hud .hud-btn-del {
  color: #f87171;
}

.studio-floating-note-hud .hud-sep {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.18);
  margin: 0 2px;
}

/* Editor de Código Fuente MusicXML (Pestaña Conmutable) */
.studio-xml-code-drawer {
  display: none;
  flex-direction: column;
  height: 240px;
  background: #090d16;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.studio-xml-code-drawer.open {
  display: flex;
}

.studio-xml-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #111827;
  font-size: 11.5px;
  font-weight: 600;
  color: #94a3b8;
}

.studio-xml-textarea {
  flex: 1;
  width: 100%;
  background: #060911;
  color: #38bdf8;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.45;
  padding: 10px 14px;
  border: none;
  resize: none;
  outline: none;
}

/* --- Barra de Estado Inferior (Igual a NotationStatusBar de MuseScore 4.7.6) --- */
.studio-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px;
  background: #0b1220;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 11.5px;
  color: #94a3b8;
}

.studio-status-left,
.studio-status-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.studio-kbd-hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #cbd5e1;
}

.studio-kbd-hint kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: var(--font-mono);
}
