@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f0f4f8; --bg-gradient: linear-gradient(135deg, #e2e8f0 0%, #f8fafc 100%);
  --panel: rgba(255, 255, 255, 0.85); --panel-solid: #ffffff; --border: #cbd5e1;
  --text: #0f172a; --text-muted: #64748b; --primary: #4f46e5; --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.3); --danger: #ef4444; --input-bg: #ffffff;
}
[data-theme="dark"] {
  --bg: #0b132b; --bg-gradient: radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.15), transparent 40%), radial-gradient(circle at 85% 30%, rgba(14, 165, 233, 0.15), transparent 40%);
  --panel: rgba(28, 37, 65, 0.85); --panel-solid: #1c2541; --border: rgba(255, 255, 255, 0.1);
  --text: #f8fafc; --text-muted: #94a3b8; --primary: #6366f1; --primary-hover: #818cf8;
  --primary-glow: rgba(99, 102, 241, 0.4); --input-bg: #0f172a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background-color: var(--bg); background-image: var(--bg-gradient); color: var(--text); font-size: 14px; line-height: 1.6; min-height: 100vh; transition: background 0.3s, color 0.3s; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; transition: all 0.2s; }
a:hover { filter: brightness(1.2); text-decoration: none; }
.text-muted { color: var(--text-muted); font-size: 13px; }
h1, h2, h3 { font-weight: 800; margin-bottom: 8px; letter-spacing: -0.5px; }

/* LOGIN */
.login-body { display: flex; align-items: center; justify-content: center; padding: 24px; min-height: 100vh; }
.login-card { background: var(--panel); backdrop-filter: blur(20px); border: 1px solid var(--border); border-radius: 24px; padding: 40px; width: 100%; max-width: 440px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); text-align: center; }
.logo-login { font-size: 48px; margin-bottom: 16px; display: inline-block; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.login-card h1 { font-size: 28px; margin-bottom: 4px; background: linear-gradient(to right, var(--text), var(--primary)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.paso { text-align: left; margin-bottom: 24px; }
.paso.oculto { display: none; }
.paso-label { display: block; margin-bottom: 12px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.opciones-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opcion-card { position: relative; cursor: pointer; padding: 16px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 16px; display: flex; flex-direction: column; align-items: center; gap: 8px; transition: all 0.2s; }
.opcion-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.opcion-card input[type="radio"] { position: absolute; opacity: 0; }
.opcion-card:has(input:checked) { border-color: var(--primary); background: rgba(99, 102, 241, 0.1); box-shadow: 0 0 0 2px var(--primary-glow); }
.opcion-icon { font-size: 24px; }
.opcion-text { font-weight: 700; font-size: 14px; }
.select-moderno { width: 100%; padding: 14px 16px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 12px; color: var(--text); font-size: 15px; font-family: inherit; transition: all 0.2s; outline: none; }
.select-moderno:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.btn-login { width: 100%; padding: 16px; background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: #fff; border: none; border-radius: 14px; font-size: 16px; font-weight: 700; cursor: pointer; transition: all 0.2s; opacity: 0.5; pointer-events: none; margin-top: 10px; }
.btn-login.visible { opacity: 1; pointer-events: auto; }
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 8px 25px var(--primary-glow); }

/* TOPBAR & LAYOUT */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--panel); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; flex-wrap: wrap; gap: 12px; width: 100%; box-sizing: border-box; }
.topbar .logo { font-weight: 800; font-size: 20px; background: linear-gradient(to right, var(--primary), #0ea5e9); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.topbar nav { display: flex; gap: 8px; background: rgba(0,0,0,0.05); padding: 4px; border-radius: 12px; }
[data-theme="dark"] .topbar nav { background: rgba(255,255,255,0.05); }
.topbar nav a { color: var(--text-muted); font-weight: 700; padding: 8px 16px; border-radius: 8px; font-size: 14px; }
.topbar nav a.active, .topbar nav a:hover { background: var(--panel-solid); color: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.topbar .user { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.badge-equipo { padding: 4px 12px; background: rgba(14, 165, 233, 0.15); color: #0284c7; border-radius: 20px; font-size: 12px; border: 1px solid rgba(14, 165, 233, 0.3); }
[data-theme="dark"] .badge-equipo { color: #38bdf8; }
.badge-rol { padding: 4px 12px; background: rgba(234, 179, 8, 0.15); color: #ca8a04; border-radius: 20px; font-size: 12px; border: 1px solid rgba(234, 179, 8, 0.3); }
[data-theme="dark"] .badge-rol { color: #fde047; }
.btn-theme { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: 16px; transition: 0.2s; }
.btn-theme:hover { background: var(--panel-solid); }
.btn-logout { color: var(--text-muted); font-size: 20px; padding: 6px; border-radius: 8px; }
.btn-logout:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* CONTENIDO A TODO EL ANCHO */
.contenido { width: 100%; max-width: 100%; margin: 0; padding: 24px 32px; box-sizing: border-box; }
.panel { background: var(--panel); backdrop-filter: blur(12px); border: 1px solid var(--border); border-radius: 20px; padding: 32px; margin-bottom: 24px; box-shadow: 0 8px 30px rgba(0,0,0,0.05); }
.fila-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }

/* BOTONES GLOBALES */
.btn-primary, .btn-sec, .btn-danger { padding: 10px 20px; border-radius: 12px; border: none; font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 15px var(--primary-glow); }
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); }
.btn-sec { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); }
.btn-sec:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-mini { background: transparent; border: 1px dashed var(--border); color: var(--text-muted); padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; cursor: pointer; transition: 0.2s; }
.btn-mini:hover { border-color: var(--primary); color: var(--primary); background: rgba(99, 102, 241, 0.05); }
.x-mini { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; padding: 4px; border-radius: 6px; }
.x-mini:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); }

/* TARJETAS Y LISTAS */
.tarjeta-culto { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 16px; margin-bottom: 12px; color: var(--text); transition: all 0.2s; cursor: pointer; }
.tarjeta-culto:hover { border-color: var(--primary); transform: translateX(5px); box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.badge-canciones { font-size: 12px; font-weight: 700; color: var(--primary); background: rgba(99, 102, 241, 0.1); padding: 6px 14px; border-radius: 20px; }
.buscador { display: flex; gap: 10px; margin-bottom: 24px; }
.buscador input { flex: 1; padding: 12px 18px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 14px; color: var(--text); font-size: 14px; outline: none; }
.buscador input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.tabla-wrapper { width: 100%; overflow-x: auto; margin-top: 16px; border-radius: 12px; border: 1px solid var(--border); background: var(--input-bg); }
.tabla-canciones { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; min-width: 600px; }
.tabla-canciones th { background: var(--bg); padding: 12px 16px; font-weight: 800; font-size: 12px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1; }
.tabla-canciones td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabla-canciones tr:last-child td { border-bottom: none; }
.tabla-canciones tbody tr { transition: background 0.2s; cursor: pointer; }
.tabla-canciones tbody tr:hover { background: rgba(99, 102, 241, 0.05); }

/* --- LAYOUT DE CANCIÓN --- */
.layout-cancion { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
.col-letra { background: var(--input-bg); border-radius: 16px; padding: 24px; border: 1px solid var(--border); position: relative; }
.col-sidebar { background: var(--panel-solid); border-radius: 16px; padding: 20px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 20px; position: sticky; top: 90px; }

.youtube-wrap { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; border-radius: 12px; background: #000; }
.youtube-wrap iframe { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; }

.barra-vista { display: flex; gap: 8px; margin-bottom: 20px; padding: 6px; background: var(--input-bg); border-radius: 14px; border: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.btn-modo { flex: 1; padding: 10px; background: transparent; border: none; color: var(--text-muted); border-radius: 10px; font-size: 13px; font-weight: 700; cursor: pointer; transition: 0.2s; white-space: nowrap; }
.btn-modo.activo { background: var(--primary); color: #fff; box-shadow: 0 2px 10px var(--primary-glow); }

/* Encabezado de la Sección */
.seccion-bloque { margin-bottom: 24px; }
.seccion-titulo { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    align-items: center; 
    background: rgba(99, 102, 241, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.seccion-titulo > div:first-child { font-weight: 800; color: var(--primary); font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }
.seccion-chips { flex: 1; justify-content: flex-start; }

/* ==========================================
   FILAS DE LA CANCIÓN (LÍNEA Y CHIPS AL LADO)
   ========================================== */
.linea { 
    padding: 6px 12px; 
    border-radius: 8px; 
    margin-bottom: 4px; 
    display: flex; 
    flex-direction: row; /* Siempre en fila */
    align-items: center; 
    justify-content: space-between;
    gap: 12px;
    border-left: 3px solid transparent; 
    transition: 0.2s; 
    cursor: pointer; 
    user-select: none; 
    line-height: 1.3;
}
.linea:hover { background: rgba(99, 102, 241, 0.08); border-left-color: var(--primary); }
.texto-col { 
    flex: 1; 
    display: flex; 
    align-items: center; 
    min-width: 0; /* Permite que el texto se ajuste sin empujar los chips */
}
.texto-linea { font-size: 15px; font-weight: 600; }
.chips-voz { 
    display: flex; 
    gap: 6px; 
    flex-wrap: wrap; /* Por si hay muchos chips */
    justify-content: flex-end; 
    align-items: center; 
    flex-shrink: 0; /* Evita que los chips se aplasten */
}
.linea.selected-linea { background: rgba(99, 102, 241, 0.15); border-left-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); }

/* Estados de resaltado */
.linea.hl-3 { background: rgba(99, 102, 241, 0.15); border-left-color: var(--primary); }
.linea.hl-2 { background: rgba(59, 130, 246, 0.1); border-left-color: #3b82f6; }
.linea.hl-1 { background: transparent; border-left-color: transparent; }
.linea.hl-0 { background: transparent; border-left-color: transparent; opacity: 1; }

/* BARRA FLOTANTE SELECCIÓN */
#barra-seleccion { 
    display: none; 
    position: fixed; 
    background: var(--panel-solid); 
    border: 2px solid var(--primary); 
    padding: 8px 16px; 
    border-radius: 30px; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.2); 
    z-index: 99999 !important;
    align-items: center;
    gap: 12px; 
    width: max-content;
    animation: popIn 0.2s ease-out;
}
@keyframes popIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
#barra-seleccion button { padding: 8px 16px; border-radius: 20px; font-size: 13px; }
#barra-seleccion span { font-weight: 800; color: var(--primary); font-size: 13px; white-space: nowrap; }

/* CHIPS DE VOZ COMPACTOS */
.chip-voz { 
    position: relative; display: inline-flex; flex-direction: column; padding: 4px 28px 4px 10px; 
    border-radius: 8px; font-size: 11px; border: 1px solid; line-height: 1.2; min-width: max-content;
    cursor: pointer; transition: transform 0.1s; animation: popIn 0.2s ease-out;
    background: var(--panel-solid);
}
.chip-top { font-weight: 800; display: flex; align-items: center; gap: 4px; color: #000 !important; }
.chip-bottom { font-weight: 800; opacity: 1; font-size: 10px; margin-top: 2px; color: #000 !important; }
[data-theme="dark"] .chip-top, [data-theme="dark"] .chip-bottom { color: #fff !important; }

.chip-voz .x-mini {
    position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
    padding: 4px 6px; font-size: 14px; color: inherit; background: transparent; border: none; cursor: pointer; border-radius: 4px;
}
.chip-voz .x-mini:hover { color: var(--danger) !important; background: rgba(255,255,255,0.5); }
[data-theme="dark"] .chip-voz .x-mini:hover { background: rgba(0,0,0,0.3); }

/* INDICADOR DE AUDIO */
.audio-mini-wrapper { flex-shrink: 0; display: flex; align-items: center; }
.audio-mini-btn { display: inline-flex; align-items: center; gap: 6px; background: rgba(99,102,241,0.1); color: var(--primary); padding: 4px 10px 4px 4px; border-radius: 8px; font-size: 11px; font-weight: 800; cursor: pointer; border: 1px solid rgba(99,102,241,0.3); transition: all 0.2s; white-space: nowrap; box-shadow: 0 2px 5px rgba(0,0,0,0.02); }
.audio-mini-btn:hover { background: var(--primary); color: #fff; transform: scale(1.05); box-shadow: 0 4px 10px var(--primary-glow); }
.audio-mini-icon { width: 20px; height: 20px; background: var(--primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 10px; padding-left: 2px; }
.audio-mini-btn:hover .audio-mini-icon { background: #fff; color: var(--primary); }

/* MODALES */
.modal { display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 100000 !important; align-items: center; justify-content: center; padding: 20px; }
.modal-content { background: var(--panel-solid); border: 1px solid var(--border); border-radius: 20px; padding: 24px; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5); }
.modal-content h3 { margin-bottom: 16px; font-size: 20px; }
.modal-content label { display: block; margin: 12px 0 6px; font-size: 13px; font-weight: 700; color: var(--text-muted); }
.modal-content input, .modal-content select, .modal-content textarea { width: 100%; padding: 12px 14px; background: var(--input-bg); border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-size: 14px; font-family: inherit; outline: none; }
.modal-content input:focus, .modal-content select:focus, .modal-content textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.modal-content .fila { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fila-acciones { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }
.check-miembros { max-height: 200px; overflow-y: auto; padding: 8px; background: var(--input-bg); border-radius: 10px; border: 1px solid var(--border); }
.check-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 6px; cursor: pointer; border-bottom: 1px solid var(--border); }
.check-item:hover { background: rgba(99, 102, 241, 0.05); }
.check-item input[type="checkbox"] { accent-color: var(--primary); width: 18px; height: 18px; }

/* AUDIOS PANEL */
.panel-audios { background: var(--bg); padding: 16px; border-radius: 12px; border: 1px solid var(--border); }
.audio-item { display: flex; justify-content: space-between; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 10px;}
.audio-item:last-child { border-bottom: none; }
.audio-item audio { height: 32px; width: 100%; max-width: 200px; }

/* ==========================================
   RESPONSIVE (MÓVILES Y TABLETS)
   ========================================== */
@media(max-width: 1024px) {
  .layout-cancion { 
    display: flex !important; 
    flex-direction: column !important; 
    gap: 16px !important; 
  }
  .col-sidebar { 
    position: static !important; 
    order: -1 !important; 
    width: 100% !important; 
    margin-bottom: 16px !important;
    flex-direction: row !important; 
    flex-wrap: wrap;
  }
  .col-sidebar > * { flex: 1; min-width: 300px; }
  .col-letra { width: 100% !important; }
}

@media(max-width: 768px) {
  .topbar { padding: 10px 8px; justify-content: center; border-radius: 0; }
  .topbar .logo { width: 100%; text-align: center; margin-bottom: 10px; }
  .topbar nav { width: 100%; display: flex; justify-content: space-between; gap: 4px; order: 3; margin-top: 10px; }
  .topbar nav a { flex: 1; text-align: center; padding: 8px 4px; font-size: 12px; }
  
  .contenido { padding: 0; width: 100%; max-width: 100%; overflow-x: hidden; }
  .panel { padding: 16px; border-radius: 0; border-left: none; border-right: none; margin-bottom: 8px; box-shadow: none; }
  
  .fila-header { flex-direction: column; }
  .fila-header > div:last-child { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  .fila-header > div:last-child button, .fila-header > div:last-child select { flex: 1; min-width: 120px; }
  
  .buscador { flex-direction: column; }
  .fila-acciones { flex-direction: column; }
  .fila-acciones button { width: 100%; }
  
  .col-sidebar { flex-direction: column !important; }
  .col-sidebar > * { min-width: 100%; }

  /* Ajustes finos para móvil: mantiene la fila pero con un poco de padding */
  .linea { padding: 8px 10px !important; gap: 8px !important; }
  .texto-linea { font-size: 15px; }
  .chip-voz { padding: 2px 24px 2px 8px; font-size: 10px; min-width: max-content; }
  .chip-bottom { font-size: 9px; }
  .audio-mini-btn { padding: 2px 8px 2px 2px; font-size: 10px; }
  .audio-mini-icon { width: 16px; height: 16px; font-size: 8px; }

  #barra-seleccion { 
      position: fixed !important; 
      bottom: 15px !important; 
      left: 15px !important; 
      right: 15px !important; 
      width: auto !important; 
      transform: none !important;
      justify-content: space-between !important;
      padding: 10px 16px !important;
      border-radius: 20px !important;
      z-index: 99999 !important;
  }
  #barra-seleccion button { padding: 10px 15px; font-size: 14px; }
}