/* consulta-sidebar.css — layout de dos columnas, sidebar del índice, árbol (títulos/capítulos/secciones/artículos), filtro y scrim móvil. */

/* ============== LAYOUT ============== */
.layout {
  max-width: 1480px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 0;
  position: relative;
}

/* ============== SIDEBAR / ÍNDICE INTERACTIVO ============== */
aside.index {
  border-right: 1px solid var(--rule);
  background: var(--paper-soft);
  height: calc(100vh - 71px);
  position: sticky;
  top: 71px;
  display: flex;
  flex-direction: column;
}

.index-header {
  padding: 1.5rem 1.5rem 0.8rem;
  border-bottom: 1px solid var(--rule);
  flex-shrink: 0;
}

.index-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.index-title h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--navy);
}

.index-controls {
  display: flex;
  gap: 0.3rem;
}

.index-ctrl-btn {
  background: var(--white);
  border: 1px solid var(--rule);
  color: var(--ink-dim);
  padding: 0.32rem 0.55rem;
  border-radius: 5px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.05em;
  transition: all 0.15s ease;
}

.index-ctrl-btn:hover {
  border-color: var(--royal);
  color: var(--royal);
}

/* Filtro dentro del índice */
.index-filter-wrap {
  position: relative;
}

.index-filter {
  width: 100%;
  background: var(--white);
  border: 1px solid var(--rule);
  color: var(--ink);
  font-family: var(--body);
  font-size: 0.82rem;
  padding: 0.55rem 0.8rem 0.55rem 2rem;
  border-radius: 6px;
  outline: none;
  transition: all 0.15s ease;
}

.index-filter:focus {
  border-color: var(--royal);
  box-shadow: 0 0 0 3px var(--royal-soft);
}

.index-filter-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  pointer-events: none;
}

/* Árbol del índice */
.index-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.5rem 3rem;
}

.index-scroll::-webkit-scrollbar { width: 7px; }
.index-scroll::-webkit-scrollbar-track { background: transparent; }
.index-scroll::-webkit-scrollbar-thumb {
  background: var(--rule);
  border-radius: 4px;
}
.index-scroll::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* Nivel 1: TÍTULO */
.titulo-item {
  margin-bottom: 0.15rem;
  border-radius: 7px;
  overflow: hidden;
}

.titulo-trigger {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--display);
  font-weight: 600;
  font-size: 0.83rem;
  text-align: left;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.35;
  border-radius: 7px;
}

.titulo-trigger:hover {
  background: var(--white);
  color: var(--navy);
}

.titulo-item.open > .titulo-trigger {
  background: var(--navy);
  color: var(--white);
}

.titulo-item.open > .titulo-trigger .titulo-num {
  background: var(--royal);
  color: var(--white);
}

.titulo-num {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.72rem;
  background: var(--royal-soft);
  color: var(--royal);
  padding: 0.18rem 0.45rem;
  border-radius: 4px;
  min-width: 2rem;
  text-align: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
  letter-spacing: 0.02em;
}

.titulo-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-size: 0.74rem;
}

.titulo-count {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--ink-faint);
  flex-shrink: 0;
}

.titulo-item.open .titulo-count {
  color: rgba(255,255,255,0.6);
}

.titulo-chevron {
  transition: transform 0.2s ease;
  color: currentColor;
  opacity: 0.6;
  flex-shrink: 0;
}

.titulo-item.open .titulo-chevron {
  transform: rotate(90deg);
}

.titulo-children {
  display: none;
  padding: 0.4rem 0 0.5rem 0.5rem;
  margin-left: 1.05rem;
  border-left: 1px solid var(--rule);
}

.titulo-item.open > .titulo-children { display: block; }

/* Nivel 2: CAPÍTULO / SECCIÓN */
.capitulo-item, .seccion-item {
  margin: 0.1rem 0;
}

.capitulo-trigger, .seccion-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-family: var(--display);
  font-weight: 500;
  font-size: 0.76rem;
  text-align: left;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  border-radius: 5px;
  transition: all 0.15s ease;
  line-height: 1.35;
}

.seccion-trigger {
  font-size: 0.73rem;
  color: var(--ink-dim);
  padding-left: 1.2rem;
}

.capitulo-trigger:hover, .seccion-trigger:hover {
  background: var(--white);
  color: var(--royal);
}

.capitulo-item.open > .capitulo-trigger,
.seccion-item.open > .seccion-trigger {
  color: var(--royal);
  font-weight: 600;
}

.cap-num, .sec-num {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--ink-faint);
  background: var(--paper-deep);
  padding: 0.14rem 0.35rem;
  border-radius: 3px;
  flex-shrink: 0;
  min-width: 1.6rem;
  text-align: center;
}

.capitulo-item.open .cap-num,
.seccion-item.open .sec-num {
  background: var(--royal-soft);
  color: var(--royal);
}

.cap-label, .sec-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cap-chevron, .sec-chevron {
  transition: transform 0.2s ease;
  color: var(--ink-faint);
  flex-shrink: 0;
  opacity: 0.7;
}

.capitulo-item.open .cap-chevron,
.seccion-item.open .sec-chevron {
  transform: rotate(90deg);
  color: var(--royal);
}

.cap-children, .sec-children {
  display: none;
  padding: 0.2rem 0 0.4rem 0.5rem;
  margin-left: 0.7rem;
  border-left: 1px solid var(--rule-soft);
}

.capitulo-item.open > .cap-children,
.seccion-item.open > .sec-children { display: block; }

/* Nivel 3: ARTÍCULO */
.art-link {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  background: transparent;
  border: none;
  color: var(--ink-dim);
  font-family: var(--body);
  font-size: 0.78rem;
  padding: 0.32rem 0.7rem;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.12s ease;
  text-align: left;
}

.art-link::before {
  content: '';
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--ink-faint);
  flex-shrink: 0;
  transition: all 0.12s ease;
}

.art-link:hover {
  color: var(--royal);
  background: var(--white);
}

.art-link:hover::before {
  background: var(--royal);
  transform: scale(1.5);
}

.art-link.active {
  color: var(--white);
  background: var(--royal);
  font-weight: 700;
}

.art-link.active::before {
  background: var(--white);
}

.art-num-label {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 0.74rem;
}

/* Estado oculto al filtrar */
.hidden-by-filter { display: none !important; }

/* ============== RESPONSIVE ============== */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  aside.index {
    position: fixed;
    top: 0;
    left: 0;
    width: 88%;
    max-width: 360px;
    height: 100vh;
    background: var(--paper-soft);
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
  }
  aside.index.open { transform: translateX(0); }
  .scrim {
    position: fixed;
    inset: 0;
    background: rgba(0, 3, 40, 0.5);
    backdrop-filter: blur(3px);
    z-index: 150;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .scrim.active { opacity: 1; pointer-events: auto; }
}
