﻿:root {
  --bg-dark: #121418;
  --card-bg: #1e222a;
  --accent-orange: #ff9f43;
  --accent-blue: #54a0ff;
  --accent-green: #1dd1a1;
  --text-main: #f5f6fa;
  --border-color: #2f3640;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --header-height: 56px;
  --toolbar-height: 60px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  min-height: 100%;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  position: fixed;
  inset: 0;
  min-height: 100dvh; /* altura dinámica: se ajusta cuando la barra del navegador se muestra/oculta */
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  overflow: hidden;
}

/* HEADER */
.header {
  height: var(--header-height);
  min-height: var(--header-height);
  padding: 10px 12px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 100;
}

select.song-select {
  background: #14171c;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  flex: 1;
  outline: none;
  min-width: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23ff9f43' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

select.song-select:focus {
  border-color: var(--accent-orange);
}

/* CONTENT AREA */
.content-area {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* SONG VIEW - Chord Chart Style */
.linea {
  display: flex;
  flex-wrap: wrap; /* Evita que el texto se deforme en pantallas de celular */
  align-items: flex-end;
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.bloque {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  margin-right: 0px;
}

.acorde {
  font-family: 'Fira Code', 'SF Mono', 'Consolas', monospace;
  font-weight: 700;
  color: var(--accent-orange);
  font-size: 0.84rem;
  height: 1.4em;
  line-height: 1.2;
  white-space: nowrap;
}

.texto {
  font-size: 0.97rem; /* 10% más grande que 0.88rem */
  color: var(--text-main);
  white-space: pre; /* Mantiene la fidelidad de los espacios exactos */
}

/* EDITOR */
input[type="text"] {
  width: 100%;
  background: #14171c;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus {
  border-color: var(--accent-orange);
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 120px;
  background: #14171c;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  font-family: 'Fira Code', 'SF Mono', 'Consolas', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

textarea:focus {
  border-color: var(--accent-orange);
}

.label-editor {
  font-size: 0.85rem;
  color: var(--accent-orange);
  font-weight: 600;
  margin-top: 4px;
}

.editor-actions {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 8px;
}

.editor-actions-right {
  display: flex;
  gap: 10px;
}

/* TOOLBAR */
.toolbar {
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);
  padding: 10px 12px;
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  z-index: 100;
}

.transpose-box {
  display: flex;
  align-items: center;
  background: #14171c;
  border-radius: 12px;
  padding: 4px 8px;
  gap: 2px;
}

.btn-transpose {
  width: 44px;
  height: 44px;
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.transpose-val {
  font-family: 'Fira Code', monospace;
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0 12px;
  min-width: 36px;
  text-align: center;
}

/* BUTTONS */
.btn {
  background: #2f3640;
  color: var(--text-main);
  border: none;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s, opacity 0.2s;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.95);
  opacity: 0.8;
}

.btn-full {
  width: 100%;
}

.btn-accent { background: var(--accent-orange); color: #000; }
.btn-blue { background: var(--accent-blue); color: #fff; }
.btn-green { background: var(--accent-green); color: #000; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-secondary { background: #3a4250; color: var(--text-main); }
.btn-reset { 
  background: transparent; 
  color: var(--accent-orange);
  padding: 8px 10px;
  font-size: 1.3rem;
}

.btn-list {
  background: transparent;
  color: var(--accent-green);
  padding: 8px 10px;
  font-size: 1.3rem;
}

.btn-fullscreen {
  background: transparent;
  color: #fff;
  padding: 8px 10px;
  font-size: 1.3rem;
  display: none; /* solo se muestra en dispositivos táctiles */
}

@media (hover: none), (pointer: coarse) {
  .btn-fullscreen {
    display: flex;
  }
}
.btn-sync {
  background: transparent;
  color: var(--accent-blue);
  padding: 8px 10px;
  font-size: 1.3rem;
}

.btn-sync.syncing {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.btn-config {
  background: transparent;
  color: #888;
  padding: 8px 10px;
  font-size: 1.2rem;
}

.btn-config:hover {
  color: var(--text-main);
}

.btn-sm {
  background: #2f3640;
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.1s;
}

.btn-sm:active {
  transform: scale(0.92);
}

/* UTILITIES */
.hidden {
  display: none !important;
}

/* SCROLLBAR */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

/* LARGE SCREENS (tablets, landscape) */
@media (min-width: 768px) {
  .content-area {
    padding: 24px 32px;
  }
  
  .acorde {
    font-size: 0.92rem;
  }
  
  .texto {
    font-size: 1.06rem; /* 10% más grande que 0.96rem */
  }
}

/* MODAL SYSTEM */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  transform: scale(0.9);
  transition: transform 0.2s;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.modal-message {
  font-size: 0.95rem;
  color: #a0a4ab;
  line-height: 1.5;
  margin-bottom: 24px;
}

.modal-input {
  width: 100%;
  background: #14171c;
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 14px;
  font-size: 1rem;
  outline: none;
  margin-bottom: 20px;
}

.modal-input:focus {
  border-color: var(--accent-orange);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-actions .btn {
  flex: 1;
  min-height: 48px;
}

.modal .btn-cancel {
  background: #2f3640;
  color: var(--text-main);
}

.modal .btn-confirm {
  background: var(--accent-orange);
  color: #000;
}

.modal .btn-danger {
  background: #e74c3c;
  color: #fff;
}

/* DROP ZONE PDF */
.import-row {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch; /* ambas tarjetas con la misma altura */
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: 16px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 159, 67, 0.05);
  flex: 1;
  min-width: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.drop-zone.visible {
  display: flex;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent-orange);
  background: rgba(255, 159, 67, 0.1);
}

.drop-zone.processing {
  border-color: var(--accent-green);
  pointer-events: none;
}

.drop-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

.drop-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
}

.drop-hint {
  font-size: 0.8rem;
  color: #888;
  margin-top: 4px;
}

/* En pantallas muy angostas (móviles chicos) apilamos verticalmente para no romper el layout */
@media (max-width: 420px) {
  .import-row {
    flex-direction: column;
    align-items: stretch;
  }
}

/* LISTAS DE REUNIÓN */
.lista-vacia {
  background: var(--card-bg);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  color: #a0a4ab;
  font-size: 0.9rem;
  line-height: 1.6;
}

.lista-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.lista-card:active {
  border-color: var(--accent-orange);
}

.lista-card-info {
  flex: 1;
  min-width: 0;
}

.lista-card-nombre {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lista-card-sub {
  font-size: 0.8rem;
  color: #888;
  margin-top: 2px;
}

.btn-play { color: var(--accent-green); font-size: 1.1rem; padding: 8px 12px; }
.btn-del { color: #e74c3c; font-size: 1rem; padding: 8px 12px; }

.lista-canciones {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lista-row {
  background: #14171c;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lista-num {
  background: var(--accent-orange);
  color: #000;
  font-weight: 700;
  font-size: 0.85rem;
  min-width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lista-titulo {
  flex: 1;
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-main);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lista-eliminada {
  color: #e74c3c;
  font-style: italic;
}

select.lista-select {
  flex: none;
  width: 100%;
  min-height: 48px;
}

.btn-sm:disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* MODO VISUAL: ARRASTRAR ACORDES */
.zona-arrastre {
  background: #14171c;
  border: 2px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 10px;
  overflow-y: auto;
  max-height: 45vh;
  user-select: none;
  -webkit-user-select: none;
}

/* En modo visual la zona ocupa TODA la pantalla y el botón queda fijo arriba */
body.modo-visual .zona-arrastre {
  position: fixed;
  inset: 0;
  z-index: 600;
  max-height: none;
  border: none;
  border-radius: 0;
  background: var(--bg-dark);
  padding: calc(var(--safe-top) + 64px) 14px calc(var(--safe-bottom) + 16px);
}

body.modo-visual #btnModoArrastre {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: 12px;
  right: 12px;
  z-index: 601;
  margin: 0;
}

/* Letra y acordes un poco más grandes para apuntar mejor con el dedo */
body.modo-visual .zona-arrastre .texto {
  font-size: 1.1rem;
}

body.modo-visual .zona-arrastre .acorde {
  font-size: 1rem;
  height: 1.6em;
}

body.modo-visual .zona-arrastre .acorde-chip {
  height: 1.7em;
  padding: 0 8px;
}

.zona-arrastre.lv-activa {
  border-color: var(--accent-green);
}

.zona-arrastre .lv-vacia {
  color: #555;
  font-size: 0.8rem;
}

.acorde-chip {
  background: rgba(255, 159, 67, 0.15);
  border: 1px solid var(--accent-orange);
  border-radius: 6px;
  padding: 0 5px;
  height: 1.5em;
  line-height: 1.3;
  cursor: grab;
  touch-action: none; /* el dedo arrastra el acorde, no hace scroll */
}

.acorde-chip.lv-arrastrando {
  opacity: 0.9;
  pointer-events: none; /* deja ver el objetivo debajo del dedo */
  cursor: grabbing;
  position: relative;
  z-index: 20;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Acorde seleccionado por tap (listo para colocarlo tocando la letra) */
.acorde-chip.lv-sel {
  background: var(--accent-green);
  color: #000;
  animation: latido 1.2s ease-in-out infinite;
}

@keyframes latido {
  50% { box-shadow: 0 0 0 5px rgba(46, 204, 113, 0.35); }
}

/* Barra de ayuda del modo "tocar para colocar" */
.lv-pista {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 12px);
  left: 12px;
  right: 12px;
  background: var(--accent-green);
  color: #000;
  text-align: center;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.95rem;
  z-index: 601;
  pointer-events: none;
}

.lv-ch.lv-cursor {
  box-shadow: -2px 0 0 0 var(--accent-green);
}

#btnModoArrastre.activo {
  background: var(--accent-green);
  color: #000;
}

/* BOTÓN VOLVER A LA LISTA (barra inferior): visible solo al repasar una canción abierta desde una lista */
.btn-volver-lista {
  background: var(--accent-orange);
  color: #000;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.95rem;
  padding: 10px 14px;
}

/* ZONA DE EXTRACCIÓN DE IMAGEN: misma tarjeta que la drop-zone del PDF, siempre visible (móvil y desktop) */
.ocr-container {
  border: 2px dashed var(--border-color);
  border-radius: 16px;
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: rgba(255, 159, 67, 0.05);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.ocr-container:hover,
.ocr-container:active {
  border-color: var(--accent-orange);
  background: rgba(255, 159, 67, 0.1);
}

.ocr-container.processing {
  border-color: var(--accent-green);
  pointer-events: none;
}

.estado-ocr {
  display: block;
  font-size: 0.8rem;
  color: var(--accent-green);
  margin-top: 4px;
}

.estado-ocr:empty {
  display: none; /* sin mensaje no aporta altura extra */
}
/* ============ LOGIN ============ */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #121418;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-overlay.hidden { display: none; }
.login-box {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: center;
}
.login-logo img { width: 88px; height: 88px; display: block; margin: 0 auto; }
.login-title { font-size: 22px; font-weight: 700; color: #e8eaed; }
.login-sub { font-size: 13px; color: #8a8f98; margin-top: -8px; }
.login-box input[type="password"] {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #2a2e36;
  background: #1b1e24;
  color: #e8eaed;
  font-size: 15px;
  outline: none;
}
.login-box input[type="password"]:focus { border-color: #4a7dff; }
.login-error { min-height: 18px; font-size: 13px; color: #ff6b6b; }
