/* ==========================================================================
   SIDEBAR - NAVEGACIÓN TEMÁTICA POR MATERIA Y CÉDULAS
   ========================================================================== */

.app-sidebar {
  width: 320px;
  min-width: 320px;
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-normal), width var(--transition-normal);
  z-index: var(--z-sidebar);
  overscroll-behavior: contain;
}

.app-sidebar.collapsed {
  width: 0;
  min-width: 0;
  transform: translateX(-100%);
  overflow: hidden;
  border-right: none;
}

/* Fila de cabecera y cierre del sidebar (paridad PC / Móvil v7.60, PROMPT 050) */
.sidebar-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sidebar-header-label {
  font-family: var(--font-display, "Cinzel", serif);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold-primary, #d4af37);
  text-transform: uppercase;
}

.sidebar-mobile-close-row {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-mobile-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold-primary);
}

.btn-close-sidebar-mobile,
.sidebar-mobile-close,
#btn-close-sidebar-mobile,
#btn-close-sidebar-pc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-surface-elevated, #171b26);
  border: 1px solid var(--border-subtle, rgba(212, 175, 55, 0.2));
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  transition: var(--transition-fast, 150ms ease);
}

.btn-close-sidebar-mobile:hover,
.sidebar-mobile-close:hover,
#btn-close-sidebar-mobile:hover,
#btn-close-sidebar-pc:hover {
  background: var(--bg-surface-hover, #202637);
  color: var(--text-main, #f8fafc);
  border-color: var(--border-strong, rgba(212, 175, 55, 0.4));
}

.btn-close-sidebar-mobile:focus-visible,
.sidebar-mobile-close:focus-visible,
#btn-close-sidebar-mobile:focus-visible,
#btn-close-sidebar-pc:focus-visible {
  outline: 2px solid var(--gold-primary, #d4af37);
  outline-offset: 2px;
}

/* Filtros por Materia */
.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.subject-filters {
  display: flex;
  gap: 6px;
  background: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.filter-pill {
  flex: 1;
  padding: 5px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: center;
}

.filter-pill:hover {
  color: var(--text-main);
}

.filter-pill.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.filter-pill.filter-civil.active {
  color: var(--civil-color);
  background: var(--civil-bg);
  border: 1px solid var(--civil-border);
}

.filter-pill.filter-procesal.active {
  color: var(--procesal-color);
  background: var(--procesal-bg);
  border: 1px solid var(--procesal-border);
}

.filter-pill.filter-constitucional.active {
  color: var(--constitucional-color);
  background: var(--constitucional-bg);
  border: 1px solid var(--constitucional-border);
}

/* Filtros por Cobertura de Apuntes (Con Apunte vs Pendiente) */
.coverage-filters {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  background: var(--bg-surface-elevated);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.coverage-pill {
  flex: 1;
  padding: 4px 6px;
  font-size: 0.7rem;
  font-weight: 600;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  text-align: center;
  white-space: nowrap;
}

.coverage-pill:hover {
  color: var(--text-main);
}

.coverage-pill.active {
  background: var(--bg-surface);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.coverage-pill.filter-covered.active {
  color: #10b981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.coverage-pill.filter-pending.active {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

/* Indicador de cobertura dentro de la cédula en el árbol */
.cedula-coverage-tag {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  margin-right: 4px;
  flex-shrink: 0;
}

.cedula-coverage-tag.covered {
  color: #10b981;
  background: rgba(16, 185, 129, 0.15);
}

.cedula-coverage-tag.pending {
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
}

/* Indicador de Administrador en el Header (Modo Icono Compacto) */
.admin-active-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: rgba(217, 119, 6, 0.18);
  border: 1px solid var(--gold-primary);
  color: var(--gold-primary);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(217, 119, 6, 0.35);
  transition: var(--transition-fast);
}

.admin-active-pill i {
  width: 17px;
  height: 17px;
}

.admin-active-pill:hover {
  background: rgba(217, 119, 6, 0.3);
  box-shadow: 0 0 16px rgba(217, 119, 6, 0.5);
  transform: translateY(-1px);
}

.admin-active-pill.hidden {
  display: none !important;
}

/* Estadísticas de Progreso del Grado */
.sidebar-meta-stats {
  padding: 10px 16px;
  background: var(--bg-surface-elevated);
  border-bottom: 1px solid var(--border-subtle);
}

.meta-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  margin-bottom: 6px;
}

.meta-label {
  color: var(--text-muted);
  font-weight: 500;
}

.meta-value {
  color: var(--gold-primary);
  font-family: var(--font-mono);
  font-weight: 600;
}

.meta-progress {
  height: 5px;
  background: var(--border-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-primary), var(--gold-hover));
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}


/* Árbol de Temas / Acordeones */
.sidebar-tree {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  overscroll-behavior: contain;
}

.category-group {
  margin-bottom: 12px;
  content-visibility: auto;
  contain-intrinsic-size: 0 44px;
}

.category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: var(--transition-fast);
  gap: 8px;
}

.category-header:hover {
  background: var(--bg-surface-hover);
}

.category-header:focus-visible {
  outline: 2px solid var(--gold-primary);
  outline-offset: -2px;
}

.category-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  min-width: 0;
  flex: 1;
}

.category-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.category-badge-dot.civil { background: var(--civil-color); }
.category-badge-dot.procesal { background: var(--procesal-color); }
.category-badge-dot.constitucional { background: var(--constitucional-color); }

.category-chevron {
  width: 14px;
  height: 14px;
  color: var(--text-subtle);
  transition: transform var(--transition-fast);
}

.category-group.open .category-chevron {
  transform: rotate(90deg);
}

.category-topics-list {
  display: none;
  list-style: none;
  padding-left: 10px;
  margin-top: 4px;
}

.category-group.open .category-topics-list {
  display: block;
}

/* Encabezados de Gran Disciplina (I, II, III) */
.discipline-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 6px 10px;
  margin-top: 14px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.discipline-section-header:first-child {
  margin-top: 4px;
}

.discipline-badge-indicator {
  width: 6px;
  height: 16px;
  border-radius: 3px;
}

.discipline-badge-indicator.civil { background: var(--civil-color); }
.discipline-badge-indicator.procesal { background: var(--procesal-color); }
.discipline-badge-indicator.constitucional { background: var(--constitucional-color); }

.discipline-title-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Capítulo Oficial */
.chapter-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-main);
  text-transform: none;
  letter-spacing: normal;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.chapter-cedulas-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-left: 4px;
}

.chapter-meta-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chapter-count-badge {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 2px 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.chapter-count-badge.all-done {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.3);
}

/* Agrupador Visual por Capítulo del Apunte (v7.55, Prompt 047) */
.sidebar-subchapter-header {
  list-style: none;
  padding: 8px 8px 4px 8px;
  margin-top: 6px;
  margin-bottom: 2px;
  font-size: 0.70rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold-secondary, #d97706);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.sidebar-subchapter-header:first-child {
  margin-top: 2px;
}

.subchapter-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* Item de Tema / Cédula Individual */
.topic-tree-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
  margin-bottom: 2px;
  border-left: 2px solid transparent;
  content-visibility: auto;
  contain-intrinsic-size: 0 44px;
}

.topic-item-left {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
}

.topic-item-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-shrink: 0;
  min-width: 24px;
}

.cedula-code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  padding: 1px 5px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--gold-primary);
  flex-shrink: 0;
  text-align: center;
}

.topic-tree-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
}

.topic-tree-item.active {
  background: var(--bg-surface-elevated);
  color: var(--gold-primary);
  font-weight: 600;
  border-left-color: var(--gold-primary);
}

.topic-tree-item.active .cedula-code-badge {
  background: var(--gold-glow);
  border-color: var(--gold-border);
}

.topic-title-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 4px;
}

.topic-mastery-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  background: var(--text-subtle);
  flex-shrink: 0;
}

.topic-mastery-dot.mastered {
  background: var(--success);
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}

.topic-mastery-dot.learning {
  background: var(--constitucional-color);
}

/* Footer Sidebar */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.sidebar-footer .btn {
  width: 100%;
}

/* ==========================================================================
   RESPONSIVO: NOTEBOOKS Y LAPTOPS (1025px a 1366px)
   ========================================================================== */
@media (min-width: 1025px) and (max-width: 1366px) {
  .app-sidebar {
    width: 260px;
    min-width: 260px;
  }

  .sidebar-header {
    padding: 10px 12px;
  }

  .sidebar-header-label {
    font-size: 0.72rem;
  }

  .subject-filters {
    gap: 4px;
    padding: 2px;
  }

  .filter-pill {
    padding: 4px 6px;
    font-size: 0.72rem;
  }

  .sidebar-meta-stats {
    padding: 8px 12px;
  }

  .meta-item {
    font-size: 0.72rem;
    margin-bottom: 4px;
  }

  .tree-category-header {
    padding: 8px 10px;
  }

  .tree-category-title {
    font-size: 0.78rem;
  }

  .topic-tree-item {
    padding: 6px 10px;
    font-size: 0.8rem;
  }

  .topic-title-text {
    font-size: 0.78rem;
    line-height: 1.35;
  }
}

/* Modo Móvil y Tablet / Drawer Off-Canvas (Hasta 1024px) */
@media (max-width: 1024px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    max-width: 86vw;
    height: 100%;
    height: 100dvh;
    z-index: var(--z-sidebar-mobile);
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-normal);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .app-sidebar.collapsed {
    width: 300px;
    min-width: 0;
    transform: translateX(-100%);
    pointer-events: none;
    display: none;
  }

  .app-sidebar:not(.collapsed) {
    transform: translateX(0);
    display: flex;
  }

  .sidebar-mobile-close-row {
    display: flex;
  }

  .sidebar-tree {
    -webkit-overflow-scrolling: touch;
  }

  .topic-tree-item {
    min-height: 44px;
  }

  .btn-close-sidebar-mobile,
  .sidebar-mobile-close,
  #btn-close-sidebar-mobile,
  #btn-close-sidebar-pc {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ==========================================================================
   BÚSQUEDA Y Q&A MIGRADOS AL HEADER (v7.34, PROMPT 027)
   Las reglas de .vault-search-box, .qa-container y sus componentes fueron
   trasladadas e integradas en css/main.css dentro del dropdown unificado
/* Estado Vacío y de Error de Temas en Sidebar (Prompt 046) */
.sidebar-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  gap: 12px;
}

.sidebar-empty-state p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: var(--lh-dense, 1.5);
  margin: 0;
}

.sidebar-empty-state.ui-state-error {
  background: rgba(239, 68, 68, 0.05);
  border: 1px dashed rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md, 8px);
  margin: 16px 12px;
  padding: 24px 16px;
  gap: 8px;
}

.sidebar-empty-state.ui-state-error .ui-state-empty-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
  margin: 0 0 4px 0;
}

.sidebar-empty-state.ui-state-error .ui-state-empty-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0 0 16px 0;
  line-height: 1.4;
}

.sidebar-empty-state .btn-retry-sidebar,
#btn-retry-sidebar,
#btn-retry-sidebar-empty {
  min-height: 44px;
  min-width: 44px;
  padding: 10px 18px;
  font-size: 0.85rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border-radius: var(--radius-sm, 6px);
}

.sidebar-partial-warning {
  padding: 8px 12px;
  margin: 8px 12px;
  font-size: 0.76rem;
  color: var(--accent-warning, #f59e0b);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-sm, 6px);
  text-align: center;
}

/* Aviso de Cuarentena (v7.59, PROMPT 049) */
.sidebar-quarantine-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  margin: 10px 12px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm, 6px);
  font-size: 0.78rem;
  color: var(--text-main, #f1f5f9);
}

.quarantine-notice-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.quarantine-notice-icon {
  width: 18px;
  height: 18px;
  color: var(--accent-warning, #f59e0b);
  flex-shrink: 0;
}

.quarantine-notice-text {
  line-height: 1.35;
  color: var(--text-muted, #94a3b8);
}

.quarantine-notice-text strong {
  color: var(--accent-warning, #f59e0b);
}

.btn-quarantine-action {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-warning, #f59e0b);
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  transition: var(--transition-fast, all 0.15s ease);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.btn-quarantine-action:hover,
.btn-quarantine-action:focus-visible {
  background: rgba(245, 158, 11, 0.25);
  border-color: var(--accent-warning, #f59e0b);
  outline: 2px solid var(--accent-warning, #f59e0b);
  outline-offset: 1px;
}

