/* ============================================================
   BIBLIA EXTENDIDA — Tema Completo
   Estilos para: toggle de modo, formulario, visor, biblioteca
   ============================================================ */

/* ── MODE TOGGLE BAR ─────────────────────────────────── */
.mode-toggle-bar {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 4px;
  gap: 4px;
  width: fit-content;
  margin: 0 auto;
}

.mode-btn {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.45rem 1.25rem;
  border-radius: 50px;
  border: none;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  letter-spacing: 0.01em;
  line-height: 1;
}

.mode-btn:hover:not(:disabled) { color: var(--text); }

.mode-btn.active {
  background: var(--gold);
  color: #080810;
  font-weight: 600;
}

.mode-btn.locked { opacity: 0.55; }
.mode-btn:disabled { cursor: not-allowed; }

/* ── TEMA COMPLETO PANEL ─────────────────────────────── */
.tema-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.25rem;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* Textarea */
.tema-input-group { position: relative; }

#tema-textarea {
  width: 100%;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.96rem;
  padding: 0.85rem 1rem 0.85rem 1rem;
  resize: none;
  min-height: 128px;
  max-height: 230px;
  line-height: 1.6;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  display: block;
}

#tema-textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,169,110,0.1);
  background: rgba(0,0,0,0.4);
}

#tema-textarea::placeholder { color: var(--text-3); font-weight: 300; }

.tema-char-count {
  font-size: 0.72rem;
  color: var(--text-3);
  line-height: 1;
}

.tema-aviso-texto {
  font-size: 0.75rem;
  color: #c0622a;
  margin: 0.35rem 0 0;
  padding: 0 0.1rem;
  line-height: 1.4;
}

/* Grupos de módulos */
.tema-modules-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.tema-group { display: flex; flex-direction: column; gap: 0.45rem; }

.tema-group-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-3);
  padding-left: 0;
  text-align: center;
}

/* Grid de botones de módulo: 4 columnas fijas */
.tema-btn-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
}

@media (max-width: 480px) {
  .tema-btn-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Botón individual de módulo */
.btn-tm {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0.2rem 0.4rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease),
              color 0.15s var(--ease), transform 0.1s;
  font-family: var(--font-sans);
  text-align: center;
  min-height: 36px;
  position: relative;
}

.btn-tm:hover:not(.tm-disabled) {
  background: var(--bg-card-hover);
  border-color: var(--gold-border);
  color: var(--text);
  transform: translateY(-1px);
}

.btn-tm.selected {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: var(--gold);
}

.btn-tm.selected::after {
  content: '✓';
  position: absolute;
  top: 3px;
  right: 5px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
}

.btn-tm.tm-disabled:not(.selected) {
  opacity: 0.28;
  cursor: not-allowed;
  transform: none !important;
}

.tm-icon { display: none; }

.tm-label {
  font-size: 0.68rem;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: 0;
  word-break: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* ── Botones dentro del modal Agregar secciones ─────── */
.btn-tm-modal {
  flex-direction: row;
  justify-content: flex-start;
  text-align: left;
  gap: 0.35rem;
  padding: 0.28rem 0.5rem;
  min-height: 34px;
}

.btn-tm-modal .tm-icon {
  display: inline;
  font-size: 0.95rem;
  flex-shrink: 0;
  line-height: 1;
}

.btn-tm-modal .tm-label {
  font-size: 0.73rem;
}

/* Footer */
.tema-footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding-top: 0.25rem;
}

.tema-footer-left {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.tc-cuota-info {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.tc-cuota-info.tc-cuota-warn {
  color: #c0622a;
}

.tc-cuota-info.tc-cuota-agotado {
  color: var(--red, #e07070);
  font-weight: 600;
}

.tc-lang-select {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-2);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  padding: 0.32rem 0.55rem;
  cursor: pointer;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.tc-lang-select:focus { outline: none; border-color: var(--gold-border); }

.btn-generar-tema {
  width: auto;
  height: 36px;
  padding: 0 0.9rem 0 0.75rem;
  gap: 0.4rem;
  background: var(--gold);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease), opacity 0.2s;
  flex-shrink: 0;
  white-space: nowrap;
}

.btn-generar-tema:hover:not(:disabled) { background: var(--gold-lt); transform: scale(0.97); }
.btn-generar-tema:active:not(:disabled) { transform: scale(0.93); }
.btn-generar-tema:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── VISOR PANEL ─────────────────────────────────────── */
.visor-panel {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.visor-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.visor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.visor-titulo-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  flex: 1;
}

.visor-nombre {
  font-family: var(--font-sans);
  font-size: calc(1.05rem * var(--content-scale, 1));
  font-weight: 600;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
  word-break: break-word;
}

.visor-tema-text {
  display: none;
}

.visor-acciones {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-shrink: 0;
}

/* Progress bar */
.visor-progress-wrap {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.visor-progress-wrap.hidden { display: none; }

.visor-progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.visor-progress-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 4px;
  transition: width 0.5s var(--ease);
}

.visor-progress-text {
  font-size: 0.75rem;
  color: var(--text-3);
}

/* Content */
.visor-contenido {
  padding: 1rem 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: calc(0.9rem * var(--content-scale, 1));
}

/* Bloque agrupado de bosquejos */
.visor-bosquejos-block {
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.visor-bosquejos-header {
  padding: 0.6rem 1rem;
  background: var(--gold-dim);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.visor-bosquejos-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.visor-bosquejos-body {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* ── BIBLIOTECA HEADER BUTTON ────────────────────────── */
.btn-biblioteca-header {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
  flex-shrink: 0;
  position: relative;
}

.btn-biblioteca-header:hover {
  color: var(--gold);
  background: var(--bg-card-hover);
  border-color: var(--gold-border);
}

/* ── BIBLIOTECA DRAWER (left side) ──────────────── */
#biblioteca-drawer {
  left: 0;
  right: auto;
  transform: translateX(-100%);
  display: flex;
  flex-direction: column;
}

#biblioteca-drawer.open {
  transform: translateX(0);
}

.biblioteca-lista-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.biblioteca-lista {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem;
  list-style: none;
}

.biblioteca-item {
  padding: 0.7rem 0.85rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.03);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.biblioteca-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--gold-border);
}

.bib-item-nombre {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bib-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.71rem;
  color: var(--text-3);
}

.bib-meta-spacer {
  flex: 1;
}

.bib-estado {
  font-size: 0.67rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bib-estado.generando {
  background: rgba(201,169,110,0.15);
  color: var(--gold);
}

.bib-estado.completo {
  background: rgba(110,201,122,0.15);
  color: #6ec97a;
}

.bib-estado.error_parcial {
  background: rgba(224,112,112,0.15);
  color: var(--red);
}

.bib-item-actions {
  display: flex;
  gap: 0.25rem;
  margin-left: auto;
}

.bib-btn-delete {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.7rem;
  transition: color 0.15s, background 0.15s;
  font-family: var(--font-sans);
}

.bib-btn-delete:hover {
  color: var(--red);
  background: rgba(224,112,112,0.1);
}

/* ── LIGHT THEME ─────────────────────────────────────── */
[data-theme="light"] .mode-toggle-bar {
  background: #ffffff;
  border-color: rgba(160,120,64,0.18);
}

[data-theme="light"] .mode-btn.active {
  background: var(--gold);
  color: #ffffff;
}

[data-theme="light"] .tema-panel {
  background: #ffffff;
  border-color: rgba(160,120,64,0.18);
}

[data-theme="light"] #tema-textarea {
  background: #faf8f5;
  border-color: rgba(160,120,64,0.2);
  color: #1a1612;
}

[data-theme="light"] #tema-textarea::placeholder { color: #b0a090; }

[data-theme="light"] #tema-textarea:focus {
  border-color: var(--gold);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(160,120,64,0.12);
}

[data-theme="light"] .btn-tm {
  background: #faf8f5;
  border-color: rgba(160,120,64,0.18);
  color: #5a4a38;
}

[data-theme="light"] .btn-tm:hover:not(.tm-disabled) {
  background: #fff9f2;
  border-color: rgba(160,120,64,0.45);
  color: #1a1612;
}

[data-theme="light"] .btn-tm.selected {
  background: rgba(160,120,64,0.09);
  border-color: var(--gold);
  color: var(--gold);
}

[data-theme="light"] .tc-lang-select {
  background: #faf8f5;
  border-color: rgba(160,120,64,0.2);
  color: #5a4a38;
}

[data-theme="light"] .visor-card {
  background: #ffffff;
  border-color: rgba(160,120,64,0.18);
}

[data-theme="light"] .biblioteca-item {
  background: #ffffff;
  border-color: rgba(160,120,64,0.14);
}

[data-theme="light"] .biblioteca-item:hover {
  background: #faf8f4;
  border-color: rgba(160,120,64,0.35);
}

[data-theme="light"] .btn-biblioteca-header {
  border-color: rgba(160,120,64,0.22);
  color: #7a6a58;
}

[data-theme="light"] .btn-biblioteca-header:hover {
  background: rgba(160,120,64,0.1);
  border-color: var(--gold);
  color: var(--gold);
}

/* ── PRINT ───────────────────────────────────────────── */
@media print {
  .app-header,
  .title-bar,
  .mode-toggle-bar,
  .tema-panel,
  .visor-header .visor-acciones,
  .visor-progress-wrap,
  .sidebar-drawer,
  .sidebar-overlay,
  .toast,
  .modal-overlay {
    display: none !important;
  }

  .visor-panel { display: block !important; }

  .visor-card {
    border: none;
    box-shadow: none;
  }

  .visor-contenido { padding: 0; }

  details.acord-seccion,
  details.bosquejo-acord { display: block; }

  details.acord-seccion > .acord-body,
  details.bosquejo-acord > .bosquejo-acord-body { display: block !important; }
  .visor-footer { display: none !important; }
}

/* ── CONTADOR DE CUOTAS ──────────────────────────────── */
.tc-cuota-info {
  font-size: 0.78rem;
  color: var(--text-3);
  text-align: center;
  padding: 0.5rem 1rem 0.15rem;
  min-height: 1.6rem;
  transition: color 0.2s;
}

.tc-cuota-info.tc-cuota-warn {
  color: #f0a060;
  font-weight: 500;
}

[data-theme="light"] .tc-cuota-info     { color: #8a7a68; }
[data-theme="light"] .tc-cuota-info.tc-cuota-warn { color: #b06020; }

/* ── VISOR FOOTER (Agregar módulos) ─────────────────── */
.visor-footer {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem 1.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.5rem;
}

.btn-guardar-pasaje {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.83rem;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  border-radius: 50px;
  border: 1.5px solid var(--text-3);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s, transform 0.15s;
}
.btn-guardar-pasaje:hover {
  border-color: var(--gold);
  color: var(--gold);
  transform: translateY(-1px);
}
.btn-guardar-pasaje.guardado {
  border-color: #4caf82;
  color: #4caf82;
}
[data-theme="light"] .btn-guardar-pasaje { border-color: var(--border); color: var(--text-2); }
[data-theme="light"] .btn-guardar-pasaje:hover { border-color: var(--gold); color: var(--gold); }
[data-theme="light"] .btn-guardar-pasaje.guardado { border-color: #2e8b57; color: #2e8b57; }

.btn-agregar-modulos {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.83rem;
  font-weight: 600;
  padding: 0.6rem 1.4rem;
  border-radius: 50px;
  border: 1.5px solid var(--gold);
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  letter-spacing: 0.02em;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), transform 0.15s;
}

.btn-agregar-modulos:hover {
  background: var(--gold);
  color: #080810;
  transform: translateY(-1px);
}

[data-theme="light"] .btn-agregar-modulos { border-color: var(--gold); color: var(--gold); }
[data-theme="light"] .btn-agregar-modulos:hover { background: var(--gold); color: #ffffff; }

/* ── MÓDULOS PASAJE USADOS: barra de chips ───────────── */
.pasaje-modulos-usados {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 0 0 var(--radius) var(--radius);
  animation: fadeUp 0.3s var(--ease) both;
}

.chip-modulo-usado {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.35rem 0.8rem;
  border-radius: 50px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, color 0.18s, transform 0.12s;
  white-space: nowrap;
}
.chip-modulo-usado:hover {
  border-color: var(--gold);
  color: var(--gold);
  transform: translateY(-1px);
}
.chip-modulo-usado.chip-activo {
  border-color: var(--gold);
  background: rgba(180,130,60,0.12);
  color: var(--gold);
  font-weight: 600;
}
.chip-modulo-usado .chip-icon { font-size: 0.9em; line-height: 1; }
.chip-modulo-usado .chip-label { line-height: 1; }

[data-theme="light"] .chip-modulo-usado { color: #555; border-color: #d0c8b8; }
[data-theme="light"] .chip-modulo-usado:hover { border-color: var(--gold); color: var(--gold); }
[data-theme="light"] .chip-modulo-usado.chip-activo { background: rgba(160,110,20,0.1); border-color: var(--gold); color: #7a5210; }

/* ── VISOR: SECCIÓN ARRASTRABLE ─────────────────────── */
.visor-seccion-item {
  margin-bottom: 0.5rem;
  border-radius: 8px;
}

.visor-seccion-ghost  { opacity: 0.35; }
.visor-seccion-chosen { box-shadow: 0 4px 20px rgba(0,0,0,0.35); }

/* Handle de arrastre */
.drag-handle {
  display: inline-flex;
  align-items: center;
  padding: 0 6px;
  cursor: grab;
  color: var(--text-3);
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.drag-handle:hover { opacity: 1; }
.drag-handle:active { cursor: grabbing; }

.drag-handle-icon { pointer-events: none; }

/* Actualizar headers de acordeón para incluir handle */
.acord-header {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
  cursor: default;
}

.acord-header .acord-titulo {
  flex: 1;
  cursor: pointer;
  font-size: calc(0.9rem * var(--content-scale, 1));
}

.visor-bosquejos-header {
  display: flex;
  align-items: center;
  gap: 0;
}

.visor-bosquejos-title { flex: 1; }

/* ── INLINE EDIT DEL NOMBRE ─────────────────────────── */
.visor-nombre-input {
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--gold);
  outline: none;
  width: 100%;
  padding: 0;
  margin: 0;
  line-height: inherit;
}

[data-theme="light"] .visor-nombre-input { color: #1a1612; }

/* ── MODAL: AGREGAR MÓDULOS ─────────────────────────── */
.modal-agregar-box {
  max-width: 680px;
  width: 95%;
  max-height: min(calc(100dvh - 40px), 780px);
  min-height: 500px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.modal-agregar-box .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-agregar-box .modal-titulo {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 85%;
}

.modal-agregar-cuerpo {
  overflow-y: auto;
  padding: 0.5rem 1rem 1rem;
  flex: 1;
}

/* Espaciado entre grupos dentro del modal */
.modal-agregar-cuerpo .tema-group + .tema-group {
  margin-top: 0.75rem;
}

/* Subtítulo del modal (nombre del tema) */
.modal-agregar-subtitulo {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-2);
  padding: 0 1rem 0.5rem;
  border-bottom: 1px solid var(--border);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* Reutilizar .tema-group / .tema-btn-grid del panel principal */

.modal-agregar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
  flex-shrink: 0;
}

/* ── BTN-TM.YA-USADO (módulo ya generado en el tema) ─ */
.btn-tm.ya-usado {
  cursor: not-allowed !important;
  opacity: 1;
  border-color: rgba(34, 197, 94, 0.45) !important;
  background: rgba(34, 197, 94, 0.06) !important;
  position: relative;
}

.btn-tm.ya-usado .tm-icon,
.btn-tm.ya-usado .tm-label { opacity: 0.65; }

.tm-ya-usado-badge {
  position: absolute;
  top: 4px;
  right: 5px;
  font-size: 0.65rem;
  color: #22c55e;
  font-weight: 700;
  line-height: 1;
}

[data-theme="light"] .btn-tm.ya-usado {
  border-color: rgba(34, 197, 94, 0.55) !important;
  background: rgba(34, 197, 94, 0.07) !important;
}

/* ── BIBLIOTECA CON CARPETAS ────────────────────────── */
.bib-carpeta-item {
  list-style: none;
  margin-bottom: 0.15rem;
}

.bib-carpeta-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.9rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.bib-carpeta-header:hover { background: rgba(255,255,255,0.05); }

.bib-carpeta-drag-handle {
  font-size: 0.85rem;
  color: var(--text-3);
  cursor: grab;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
  opacity: 0.5;
}
.bib-carpeta-drag-handle:active { cursor: grabbing; }

.bib-carpeta-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--cat-color, var(--gold));
  flex-shrink: 0;
}

.bib-carpeta-nombre {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bib-carpeta-count {
  font-size: 0.7rem;
  color: var(--text-3);
  background: rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 0 6px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.bib-carpeta-chev {
  flex-shrink: 0;
  color: var(--text-3);
  transition: transform 0.2s;
}

/* ── MODAL HISTORIAL COMPLETO ────────────────────────── */
.modal-historial-box {
  max-width: 460px;
  width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-historial-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.hist-modal-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
}
.hist-modal-item:hover { background: rgba(255,255,255,0.06); }
[data-theme="light"] .hist-modal-item:hover { background: rgba(0,0,0,0.04); }

.hist-modal-icono {
  font-size: 0.88rem;
  flex-shrink: 0;
}

.hist-modal-label {
  font-size: 0.85rem;
  color: var(--text-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.hist-modal-badge {
  font-size: 0.7rem;
  padding: 0.15em 0.5em;
  border-radius: 4px;
  flex-shrink: 0;
  opacity: 0.85;
}
.hist-badge-sermon  { background: rgba(201,169,110,0.18); color: var(--gold); }
.hist-badge-cita,
.hist-badge-idea,
.hist-badge-pasaje  { background: rgba(100,160,220,0.15); color: #7ab3df; }
[data-theme="light"] .hist-badge-sermon { background: rgba(180,140,60,0.12); color: #9a6f1e; }
[data-theme="light"] .hist-badge-cita,
[data-theme="light"] .hist-badge-idea,
[data-theme="light"] .hist-badge-pasaje { background: rgba(60,120,200,0.1); color: #2563ab; }

.hist-modal-loading,
.hist-modal-empty {
  font-size: 0.82rem;
  color: var(--text-3);
  text-align: center;
  padding: 2rem 1rem;
  margin: 0;
}

/* ── SECCIÓN RECIENTES EN BIBLIOTECA ─────────────────── */
.bib-recientes-section {
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.5rem 0.5rem;
  flex-shrink: 0;
}

.bib-recientes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0.4rem 0.4rem;
}

.bib-recientes-titulo {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
}

.bib-recientes-ver-todos {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  font-weight: 500;
}
.bib-recientes-ver-todos:hover { text-decoration: underline; }

.bib-recientes-lista {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.bib-reciente-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.38rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  overflow: hidden;
}
.bib-reciente-item:hover { background: rgba(255,255,255,0.06); }
[data-theme="light"] .bib-reciente-item:hover { background: rgba(0,0,0,0.04); }

.bib-reciente-icono {
  font-size: 0.82rem;
  flex-shrink: 0;
}

.bib-reciente-label {
  font-size: 0.78rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.bib-carpeta-item.collapsed .bib-carpeta-chev { transform: rotate(-90deg); }
.bib-carpeta-item.collapsed .bib-carpeta-lista { display: none; }

.bib-carpeta-lista {
  padding: 0 0 0.25rem 1.2rem;
  margin: 0;
}

/* Botón nueva carpeta en header de drawer */
.btn-nueva-carpeta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  margin-right: auto;  /* push close button to right */
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.btn-nueva-carpeta:hover {
  background: rgba(255,255,255,0.07);
  color: var(--gold);
  border-color: var(--gold);
}

[data-theme="light"] .bib-carpeta-header:hover { background: rgba(0,0,0,0.04); }
[data-theme="light"] .bib-carpeta-count { background: rgba(0,0,0,0.05); }
[data-theme="light"] .btn-nueva-carpeta { border-color: rgba(160,120,64,0.25); color: #8a7a68; }
[data-theme="light"] .btn-nueva-carpeta:hover { background: rgba(160,120,64,0.08); color: var(--gold); }

/* ── SPINNER DE GENERACIÓN EN BIBLIOTECA ────────────── */
@keyframes bib-spin {
  to { transform: rotate(360deg); }
}

.bib-spinner {
  width: 11px;
  height: 11px;
  border: 2px solid rgba(201,169,110,0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: bib-spin 0.75s linear infinite;
  flex-shrink: 0;
  display: inline-block;
}

/* Item container: top row con spinner */
.bib-item-top {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.bib-item-top .bib-item-nombre {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Ajuste: el nombre antes estaba directo en .biblioteca-item */
.biblioteca-item .bib-item-nombre {
  display: block; /* fallback si no hay .bib-item-top */
}

/* ── MÓDULOS MINI-ICONS ──────────────────────────────── */
.bib-mod-icons {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.bib-mod-icon {
  font-size: 0.68rem;
  line-height: 1;
  opacity: 0.7;
}

/* ── ACCIONES DE CARPETA (edit / delete) ─────────────── */
.bib-carpeta-acciones {
  display: flex;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.bib-btn-edit-cat,
.bib-btn-delete-cat {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.72rem;
  color: var(--text-3);
  line-height: 1;
  transition: background 0.15s, color 0.15s;
  font-family: var(--font-sans);
}

.bib-btn-edit-cat:hover   { color: var(--gold);  background: rgba(201,169,110,0.12); }
.bib-btn-delete-cat:hover { color: var(--red);    background: rgba(224,112,112,0.10); }

/* ── BOTÓN MOVER TEMA ────────────────────────────────── */
.bib-btn-mover {
  background: transparent;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.7rem;
  transition: color 0.15s, background 0.15s;
  font-family: var(--font-sans);
}

.bib-btn-mover:hover {
  color: var(--gold);
  background: rgba(201,169,110,0.1);
}

/* ── PALETA DE COLORES EN SWAL ───────────────────────── */
.swal-palette-wrap {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 14px;
}

.swal-cat-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  box-sizing: border-box;
  transition: border-color 0.15s, transform 0.1s;
  display: inline-block;
  flex-shrink: 0;
}

.swal-cat-dot:hover { transform: scale(1.15); }
.swal-cat-dot.sel   { border-color: #ffffff; box-shadow: 0 0 0 2px rgba(255,255,255,0.4); }

[data-theme="light"] .swal-cat-dot.sel { border-color: #333; box-shadow: 0 0 0 2px rgba(0,0,0,0.2); }
