/* ---------- variables ---------- */
:root {
  --bg-page: #232323;
  --bg-file: #2b2b2b;
  --accent: #beefbe;
  --mono: #e0e0e0;
  --radius: 10px;
  /* Posición del buscador y del recuadro de contenido en el panel central:
     botones de navegación (1rem + 2rem + 1rem) y margen (0.2rem) hasta el
     buscador; después el buscador y otro margen (2rem). El recuadro ocupa el
     resto, menos --content-bottom. En escritorio el panel derecho va desde
     el buscador hasta el final del recuadro. */
  --search-top: 4.2rem;
  --search-height: 3.6rem;
  --content-bottom: 2rem;
  --green-light: #98ff98;
  --table-green: #a8f4a8;
  --tool-color: #80cbc4;
}

/* ---------- layout ---------- */
html,
body,
#app {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background: var(--bg-page);
}

/* El menú de offs.es (offs-navbar.css) ocupa la parte superior */
#app {
  display: flex;
  height: calc(100% - var(--offs-navbar-h, 0px));
  min-height: 0;
}

/* ---------- panes ---------- */
.pane {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  font-family: Consolas, monospace;
  color: var(--accent);
  font-size: 0.9rem;
  line-height: 1.4;
}

.left {
  width: 20%;
  justify-content: flex-start;
}

.middle {
  width: 60%;
  justify-content: flex-start;
  align-items: center;
  overflow-y: auto;
}

.right {
  width: 20%;
}

/* ---------- contenedores ---------- */
.pane-content {
  width: 100%;
  padding: 1rem 1.2rem;
  box-sizing: border-box;
}

/* ---------- árbol (Professional Sidebar) ---------- */

/* Custom scrollbar for sidebar */
#nav::-webkit-scrollbar { width: 5px; }
#nav::-webkit-scrollbar-track { background: transparent; }
#nav::-webkit-scrollbar-thumb {
  background: rgba(190, 239, 190, 0.12);
  border-radius: 3px;
}
#nav::-webkit-scrollbar-thumb:hover {
  background: rgba(190, 239, 190, 0.25);
}

/* Sidebar background */
#nav {
  background: linear-gradient(180deg, var(--bg-page) 0%, #1d1d1d 100%);
  border-right: 1px solid rgba(190, 239, 190, 0.06);
}

/* Tree base */
.tree {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin-top: 0.25rem;
  padding: 0 0.15rem;
  width: 100%;
}

.tree,
.tree ul {
  list-style: none !important;
  margin: 0;
}

.tree { padding-left: 0; }

.tree ul {
  padding-left: 0.35rem;
  margin-left: 0.75rem;
  border-left: 1px solid rgba(190, 239, 190, 0.07);
  transition: border-color 0.3s ease;
}

/* Highlight indent guide when hovering subtree */
.tree li.directory:not(.collapsed):hover > ul {
  border-left-color: rgba(190, 239, 190, 0.18);
}

.tree li { margin: 0; }

/* ---- Tree item base ---- */
.tree-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  margin: 1px 4px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.2s ease;
  position: relative;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--accent);
  -webkit-user-select: none;
  user-select: none;
}

.tree-item .name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.tree-item i {
  font-size: 1rem;
  flex-shrink: 0;
}

/* ---- Hover ---- */
.tree-item:hover {
  background: rgba(190, 239, 190, 0.06);
  cursor: pointer;
}

/* ---- Chevron for directories ---- */
.tree-chevron {
  font-size: 0.7rem !important;
  opacity: 0.3;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s;
  margin-right: -0.1rem;
  flex-shrink: 0;
}

.tree li.directory:not(.collapsed) > .tree-item .tree-chevron {
  transform: rotate(90deg);
  opacity: 0.55;
}

.tree-item:hover .tree-chevron {
  opacity: 0.6;
}

/* ---- Folder icon ---- */
.tree-icon {
  transition: color 0.15s ease;
}

/* ---- Directory text ---- */
.tree li.directory > .tree-item .name {
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---- Collapse ---- */
.tree li.directory.collapsed > ul {
  display: none;
}

/* ---- File styles ---- */
.tree li.file > .tree-item {
  color: rgba(255, 255, 255, 0.72);
  padding-left: calc(0.6rem + 0.7rem + 0.3rem);  /* align with folder name (chevron space) */
}

.tree li.file > .tree-item:hover {
  color: rgba(255, 255, 255, 0.95);
  background: rgba(190, 239, 190, 0.05);
}

/* ---- Tool file styles ---- */
.tree li.file.tool > .tree-item {
  color: var(--tool-color);
}

.tree li.file.tool > .tree-item i {
  color: var(--tool-color);
}

.tree li.file.tool > .tree-item:hover {
  color: #a8e8e0;
  background: rgba(128, 203, 196, 0.06);
}

/* ---------- markdown “fichero” ---------- */
.markdown-body {
  background: var(--bg-file);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  margin: 2rem auto;
  padding: 2rem 3rem;
  width: calc(100% - 6rem);
  max-width: 100%;
  flex: 1 1 0;
  min-height: 0;
  color: var(--mono);
  overflow: auto;
  box-sizing: border-box;
}

.placeholder {
  font-size: 1.1rem;
  color: var(--accent);
  text-align: center;
  margin-top: 6rem;
}

/* ---------- code blocks & copy ---------- */
.markdown-body pre {
  position: relative;
  background: #1e1e1e;
  border: 1px solid rgba(224, 224, 224, 0.15);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
  overflow: auto;
  box-sizing: border-box;
}

/* asegurar color y familia dentro del pre */
.markdown-body pre code {
  background: transparent;
  color: var(--mono);
  font-family: Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.4;
}

.copy-btn {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.75rem;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 2px 6px;
  cursor: pointer;
  opacity: 0.7;
}

.copy-btn:hover {
  opacity: 1;
}

.copied {
  position: absolute;
  top: 6px;
  right: 70px;
  font-size: 0.75rem;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.3s;
}

.copied.show {
  opacity: 1;
}

/* ---------- panel derecho: favoritos (arriba) + índice (abajo) ---------- */
/* Espejo del sidebar izquierdo. Cada mitad tiene su propio scroll, así que
   el panel no se mueve aunque el documento sí. */
#toc {
  background: linear-gradient(180deg, var(--bg-page) 0%, #1d1d1d 100%);
  border-left: 1px solid rgba(190, 239, 190, 0.06);
  justify-content: flex-start;
  align-items: stretch;
  overflow: hidden;
}

.side-panels {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  width: 100%;
  height: 100%;
  padding: 1rem 0.9rem;
  box-sizing: border-box;
}

.side-section {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-height: 0;
}

.side-header {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0 0.5rem 0.55rem;
  border-bottom: 1px solid rgba(190, 239, 190, 0.08);
  color: rgba(190, 239, 190, 0.6);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.side-header i {
  font-size: 0.95rem;
}

.side-header h2 {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-count {
  margin-left: auto;
  background: rgba(190, 239, 190, 0.12);
  color: var(--accent);
  padding: 0.05rem 0.45rem;
  border-radius: 8px;
  font-size: 0.68rem;
  font-family: 'Inter', sans-serif;
}

.side-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-top: 0.45rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(190, 239, 190, 0.12) transparent;
}

.side-body::-webkit-scrollbar { width: 5px; }
.side-body::-webkit-scrollbar-track { background: transparent; }
.side-body::-webkit-scrollbar-thumb {
  background: rgba(190, 239, 190, 0.12);
  border-radius: 3px;
}
.side-body::-webkit-scrollbar-thumb:hover {
  background: rgba(190, 239, 190, 0.25);
}

.side-empty {
  margin: 0.6rem 0.5rem;
  color: var(--mono);
  opacity: 0.45;
  font-size: 0.78rem;
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
}

.side-empty i {
  vertical-align: -0.15em;
}

.side-status {
  margin: 0;
  max-height: 0;
  overflow: hidden;
  padding: 0 0.5rem;
  color: #ffb4a8;
  font-size: 0.72rem;
  font-family: 'Inter', sans-serif;
  opacity: 0;
  transition: opacity 0.2s ease, max-height 0.2s ease, padding 0.2s ease;
}

.side-status.show {
  max-height: 3rem;
  padding: 0.4rem 0.5rem 0;
  opacity: 0.9;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- favoritos ---------- */
.fav-list {
  position: relative;   /* offsetTop de los items relativo a la lista */
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.fav-item {
  position: relative;
  display: flex;
  align-items: center;
  margin: 1px 2px;
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.72);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.2s ease,
              transform 0.18s cubic-bezier(0.2, 0, 0, 1);
}

.fav-item:hover {
  background: rgba(190, 239, 190, 0.05);
  color: rgba(255, 255, 255, 0.95);
}

.fav-item.tool {
  color: var(--tool-color);
}

.fav-item.active {
  background: linear-gradient(90deg, rgba(190, 239, 190, 0.1) 0%, rgba(190, 239, 190, 0.02) 100%);
  box-shadow: inset 3px 0 0 var(--accent);
  color: var(--green-light);
}

/* Asa de arrastre: 2x3 puntos */
.fav-grip {
  flex-shrink: 0;
  width: 6px;
  height: 10px;
  margin-left: 0.3rem;
  background-image: radial-gradient(circle, currentColor 1px, transparent 1.3px);
  background-size: 3px 3.4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.fav-item:hover .fav-grip,
.fav-item:focus-within .fav-grip {
  opacity: 0.35;
}

.fav-open {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.35rem 0.3rem 0.35rem 0.4rem;
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fav-open i {
  flex-shrink: 0;
  font-size: 1rem;
}

.fav-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.fav-name,
.fav-where {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fav-name {
  font-size: 0.8rem;
  line-height: 1.35;
}

.fav-item.active .fav-name {
  font-weight: 600;
}

.fav-where {
  font-size: 0.66rem;
  line-height: 1.3;
  opacity: 0.45;
}

.fav-edit,
.fav-remove {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  margin-right: 0.2rem;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 5px;
  color: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.fav-edit {
  margin-right: 0;
  font-size: 0.85rem;
}

.fav-item:hover .fav-edit,
.fav-item:focus-within .fav-edit,
.fav-item:hover .fav-remove,
.fav-item:focus-within .fav-remove {
  opacity: 0.5;
}

.fav-edit:hover,
.fav-edit:focus-visible {
  opacity: 1 !important;
  color: var(--accent);
  background: rgba(190, 239, 190, 0.1);
}

/* Renombrando: el nombre pasa a ser un input en la misma línea */
.fav-editor {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.3rem 0.3rem 0.3rem 0.4rem;
}

.fav-editor > i {
  flex-shrink: 0;
  font-size: 1rem;
}

.fav-input {
  width: 100%;
  min-width: 0;
  padding: 0.1rem 0.3rem;
  margin: -0.1rem -0.3rem 0.1rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(190, 239, 190, 0.45);
  border-radius: 4px;
  outline: none;
  color: rgba(255, 255, 255, 0.95);
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.35;
}

.fav-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(190, 239, 190, 0.12);
}

.fav-input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

.fav-item.editing {
  background: rgba(190, 239, 190, 0.06);
}

.fav-item.editing .fav-grip,
.fav-item.editing .fav-edit,
.fav-item.editing .fav-remove {
  display: none;
}

.fav-remove:hover,
.fav-remove:focus-visible {
  opacity: 1 !important;
  color: #ff8a80;
  background: rgba(255, 107, 107, 0.1);
}

.fav-open:focus-visible,
.fav-edit:focus-visible,
.fav-remove:focus-visible {
  outline: 1px solid rgba(190, 239, 190, 0.5);
  outline-offset: -1px;
  border-radius: 5px;
}

/* Pulsación larga: feedback de que va a empezar el arrastre */
.fav-item.pressing {
  transform: scale(0.98);
  background: rgba(190, 239, 190, 0.06);
}

.fav-list.is-sorting,
.fav-list.is-sorting * {
  cursor: grabbing !important;
}

.fav-item.dragging {
  z-index: 2;
  background: #2f352f;
  color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(190, 239, 190, 0.35);
  transition: background 0.15s ease, box-shadow 0.2s ease;   /* sin transform: sigue al puntero */
}

.fav-item.dragging .fav-grip {
  opacity: 0.6;
}

/* En táctil no hay hover: controles siempre visibles, discretos */
@media (hover: none) {
  .fav-grip { opacity: 0.3; }
  .fav-edit,
  .fav-remove { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  .fav-item { transition: background 0.15s ease, color 0.15s ease; }
}

/* ---------- toc ---------- */
#toc-container ul {
  list-style: none;
  margin: 0;
  padding: 0 0.5rem;
}

#toc-container li {
  margin: 0.25rem 0;
  cursor: pointer;
}

#toc-container a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

#toc-container a:hover {
  text-decoration: underline;
}

/* ---------- loader ---------- */
.loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border: 4px solid var(--accent);
  border-top: 4px solid transparent;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  z-index: 10;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Animación de entrada para el contenido */
@keyframes fadeInSlide {
  from {
    opacity: 0;
    transform: translateY(10px); /* Empieza un poco más abajo */
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-anim {
  animation: fadeInSlide 1s ease-out forwards;
}

.hidden {
  display: none;
}

.welcome-card {

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-file);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  margin: 2rem auto;
  padding: 2rem 3rem;
  width: calc(100% - 6rem);
  max-width: 100%;
  flex: 1 1 0;
  min-height: 0;
  color: var(--mono);
  overflow: auto;
  box-sizing: border-box;
}

.welcome-card i {
  font-size: 3rem;
  color: var(--accent);
}

.welcome-card h2 {
  margin: 0;
  font-size: 1.5rem;
}

.welcome-card p {
  margin: 0;
  font-size: 1rem;
  opacity: 0.8;


}

#markdown-container {
  display: none;
}


/* ---------- buscador ---------- */
.search-box {
  background: var(--bg-file);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  margin: 0.2rem auto 0 auto;
  /* mismo margen horizontal que markdown */
  padding: 0.8rem 1.2rem;
  width: calc(100% - 6rem);
  /* mismo ancho que markdown */
  height: var(--search-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  box-sizing: border-box;
  position: relative;
  /* crea un nuevo stacking-context */
  z-index: 100;
  /* por encima del overlay (90) y resultados (95) */
  transition: transform .25s ease, box-shadow .25s ease;
}

.search-box i {
  font-size: 1.3rem;
  color: var(--accent);
}

.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--mono);
  font-family: inherit;
  font-size: 1rem;
}

.search-box.is-active {
  transform: scale(1.05);
  box-shadow: 0 0 18px 4px var(--accent);
  border-color: var(--accent);
}


/* overlay de desenfoque */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(4px);
  z-index: 90;
}

.overlay.hidden {
  display: none;
}

/* contenedor de resultados */
.search-results {
  position: absolute;
  top: calc(var(--offs-navbar-h, 0px) + 8rem + 2.6rem + 2px);
  /* margen superior + altura aproximada del input + 2px de border */
  left: 50%;
  transform: translateX(-50%);
  width: calc(70% - 6rem);
  /* igual ancho que .search-box */
  max-height: 50vh;
  overflow-y: auto;
  background: var(--bg-file);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  box-sizing: border-box;
  z-index: 95;
}

.search-results.hidden {
  display: none;
}

/* ── Resultado individual (se mantiene para keyboard navigation) ── */
.search-results .result-item {
  display: flex;
  align-items: flex-start;
  width: 100%;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
}

.search-results .result-item:hover {
  background: rgba(190, 239, 190, 0.08);
}

/* ── Resumen de búsqueda ── */
.search-summary {
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  color: var(--mono);
  opacity: 0.6;
  border-bottom: 1px solid rgba(190, 239, 190, 0.12);
  margin-bottom: 0.3rem;
}

/* ── Grupo de fichero ── */
.search-file-group {
  margin-bottom: 0.15rem;
}

/* ── Cabecera de fichero ── */
.search-file-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.84rem;
  color: var(--accent);
  user-select: none;
}
.search-file-header:hover {
  background: rgba(190, 239, 190, 0.1);
}
.search-file-header i {
  font-size: 0.95rem;
  flex-shrink: 0;
}
.search-chevron {
  transition: transform 0.2s ease;
  font-size: 0.85rem !important;
  opacity: 0.5;
}
.search-file-group.collapsed .search-chevron {
  transform: rotate(-90deg);
}
.search-file-path.tool {
  color: var(--tool-color);
}
.search-match-badge {
  margin-left: auto;
  background: rgba(190, 239, 190, 0.15);
  color: var(--accent);
  padding: 0.05rem 0.45rem;
  border-radius: 8px;
  font-size: 0.72rem;
  flex-shrink: 0;
}

/* ── Lista de coincidencias bajo cada fichero ── */
.search-match-list {
  padding-left: 1rem;
  margin-left: 0.85rem;
  border-left: 1px solid rgba(190, 239, 190, 0.1);
}
.search-file-group.collapsed .search-match-list {
  display: none;
}

.search-match-line {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  color: var(--mono);
  line-height: 1.45;
}
.search-line-num {
  color: var(--accent);
  opacity: 0.45;
  min-width: 2rem;
  text-align: right;
  flex-shrink: 0;
  font-size: 0.76rem;
  line-height: 1.55;
}
.search-line-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* ── Resaltado del término ── */
.search-hl {
  background: rgba(255, 200, 0, 0.35);
  color: #fff;
  border-radius: 2px;
  padding: 0 2px;
}

/* ── Flash al hacer scroll a un match ── */
.search-flash {
  animation: search-flash-anim 1.8s ease-out;
}
@keyframes search-flash-anim {
  0%   { background: rgba(255, 200, 0, 0.35); border-radius: 3px; }
  100% { background: transparent; }
}

.search-hint {
  color: var(--mono);
  opacity: 0.5;
  font-size: 0.85rem;
  text-align: center;
  padding: 0.5rem 0;
  margin: 0;
}

/* Elemento seleccionado del `search-result` */
.search-results .result-item.selected {
  background-color: rgba(168, 244, 168, 0.2); 
  color: var(--mono);
  border-radius: 4px;
}

.search-results .result-item.selected:hover {
  background-color: rgba(168, 244, 168, 0.3); 
  border-radius: 4px;
}


a {
  color: var(--accent);
}

.markdown-body img{
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  margin: 1.5rem auto;
  border-radius: 4px;
}

/**** Estilos de tablas ****/


/* Estilos generales para tablas en markdown */
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  /* Para que no haya doble línea */
  margin-bottom: 1.5rem;
}

/* Líneas de tabla: borde en todas las celdas y en la tabla */
.markdown-body table,
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--table-green);
}

/* Espaciado interno */
.markdown-body th,
.markdown-body td {
  padding: 0.5rem 0.75rem;
}

/* Encabezados con fondo semi-transparente */
.markdown-body th {
  background: rgba(152, 255, 152, 0.1);
  color: var(--mono);
  font-weight: bold;
}

/* Opcional: zebra-striping muy sutil */
.markdown-body tr:nth-child(even) td {
  background: rgba(152, 255, 152, 0.025);
}

/** Estilos de la selección de texto **/
/* Selección de texto */
::selection {
  background: #beefbe60;
  /* fondo oscuro */
  color: #fff;
  /* letras verdosas */
}

/* Para compatibilidad con otros navegadores */
::-moz-selection {
  background: #beefbe60;
  color: #fff;
}

.markdown-body blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem;
  border-left: 4px solid var(--accent);
  color: var(--mono);
  background: rgba(255, 255, 255, 0.05);
}

/** Block quotes **/
.markdown-body blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
  color: var(--mono);
  background: rgba(255, 255, 255, 0.05);
}

/* ====== Obsidian-style Callouts ====== */
.markdown-body .callout {
  border: none;
  border-left: 4px solid;
  border-radius: var(--radius);
  padding: 0;
  margin: 1.5rem 0;
  overflow: hidden;
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  font-weight: bold;
  font-size: 0.95rem;
}

.callout-title i:first-child {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.callout-body {
  padding: 0 1rem 0.7rem;
  color: var(--mono);
}

.callout-body > :first-child {
  margin-top: 0;
}

.callout-body > :last-child {
  margin-bottom: 0;
}

.callout-body.collapsed {
  display: none;
}

.callout-title.foldable {
  cursor: pointer;
}

.callout-chevron {
  margin-left: auto;
  font-size: 1.1rem;
  transition: transform 0.2s ease;
}

.callout-title.foldable.folded .callout-chevron {
  transform: rotate(-90deg);
}

/*** Estilos para los code `` ***/
.markdown-body code {
  background: rgba(224, 224, 224, 0.08);
  color: var(--mono);
  padding: 0.2em 0.4em;
  border-radius: calc(var(--radius) / 2);
  font-size: 0.9em;
  font-family: Consolas, monospace;
}

.markdown-body a code {
  background: rgba(43, 255, 0, 0.08);
  color: #bdefd6;
}


/*** Strong emphasis ***/
.markdown-body strong {
  color: var(--accent);
  font-weight: bold;
}

/**** Mantenemos el botón de copy fijo en el pre ****/
/* 1) Convertimos el <pre> en un grid de una sola celda */
.markdown-body pre {
  display: grid;
  position: relative;
  /* por si acaso */
}

/* 2) El <code> (o lo que sea que tenga overflow) ocupa toda la celda */
.markdown-body pre>code {
  grid-area: 1 / 1;
  overflow: auto;
  /* scroll sólo en el code */
}

/* 3) El botón también ocupa esa celda, pero se alinea arriba-derecha */
.copy-btn {
  grid-area: 1 / 1;
  justify-self: end;
  align-self: start;
  margin: -15px 1px;
  z-index: 1;
}


/************** Marcar la ruta actual **************/
/* Active/selected file with left accent bar and glow */
.tree li.file.active > .tree-item {
  background: linear-gradient(90deg, rgba(190, 239, 190, 0.1) 0%, rgba(190, 239, 190, 0.02) 100%);
  box-shadow: inset 3px 0 0 var(--accent), 0 0 15px rgba(190, 239, 190, 0.04);
  color: var(--green-light);
}

.tree li.file.active > .tree-item .name {
  font-weight: 600;
}

/* Active directory path indicator */
.tree li.directory.active > .tree-item {
  color: var(--green-light);
}

.tree li.directory.active > .tree-item .name {
  font-weight: 700;
}

/* ====== HELP BUTTON ====== */
.help-btn{
  position:fixed;
  bottom:1.2rem;
  right:1.2rem;
  width:45px;height:45px;
  border-radius:50%;
  background:var(--accent);
  color:#000;
  font-weight:bold;
  border:none;
  cursor:pointer;
  box-shadow:0 0 10px rgba(0,0,0,.4);
  transition:transform .3s ease;
  z-index:130;                     /* por encima de overlays & drawers */
}
@keyframes spin360{from{transform:rotate(0)}to{transform:rotate(360deg)}}
.help-btn.spin{animation:spin360 .6s ease-out}

/* ====== POP-UP DE AYUDA ====== */
.help-popup{
  position:fixed;
  bottom:6.2rem;                  /* un poco encima del botón */
  right:1rem;
  width:260px;
  max-width:80vw;
  background:var(--bg-file);
  color:var(--mono);
  border:1px solid var(--accent);
  border-radius:var(--radius);
  padding:1rem 1.2rem;
  box-shadow:0 0 14px rgba(0,0,0,.6);
  z-index:125;
}
.help-popup.hidden{display:none}
.help-popup h4{
  margin:0 0 .6rem;
  font-size:1rem;
  color:var(--accent);
}
.help-popup ul{
  margin:0;padding:0;list-style:none;
}
.help-popup li{
  margin:.4rem 0;font-size:.85rem;
}
.help-popup kbd{
  background:#333;
  color:var(--green-light);
  padding:2px 6px;
  border-radius:4px;
  font-size:.8rem;
  font-family:Consolas,monospace;
}

.ri-question-mark {
  font-size: 1.7rem;
  color: var(--bg-page);
  cursor: pointer;
}

/* Botones de avanzar y retroceder en el contexto */
.nav-buttons {
  display: flex;
  flex-shrink: 0;
  gap: 0.5rem;
  margin: 1rem 0;           /* separa un poco del search-box */
}

.nav-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  width: 2rem;
  height: 2rem;
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.2s ease;
}
.nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}    
.nav-btn:not(:disabled):hover {
  opacity: 1;
}  
.nav-arrow  {
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--bg-page);
}

/* Estrella de favorito: mismo botón, en hueco para no competir con la navegación */
.nav-btn.fav-toggle {
  display: grid;
  place-items: center;
  padding: 0;
  margin-left: 0.25rem;
  background: transparent;
  border: 1px solid rgba(190, 239, 190, 0.45);
  color: var(--accent);
  transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.nav-btn.fav-toggle[hidden] {
  display: none;
}

.nav-btn.fav-toggle i {
  font-size: 1.1rem;
}

.nav-btn.fav-toggle:not(:disabled):hover {
  background: rgba(190, 239, 190, 0.1);
  border-color: var(--accent);
}

.nav-btn.fav-toggle.is-fav {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg-page);
}

.nav-btn.fav-toggle.is-fav:hover {
  background: var(--accent);
}

.nav-btn.fav-toggle.is-fav i {
  animation: fav-pop 0.3s ease-out;
}

/* Enlace a writeups (sólo Admin): mismo hueco que la estrella, en el rojo
   de la sección de writeups para anticipar a dónde lleva */
.nav-btn.nav-link {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  padding: 0;
  text-decoration: none;
}

.nav-btn.nav-link-writeups {
  margin-left: 0.25rem;
  background: transparent;
  border: 1px solid rgba(229, 115, 115, 0.55);
  color: #e57373;
  transition: opacity 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.nav-btn.nav-link-writeups i {
  font-size: 1.05rem;
}

.nav-btn.nav-link-writeups:hover {
  opacity: 1;
  background: rgba(229, 115, 115, 0.12);
  border-color: #e57373;
}

@keyframes fav-pop {
  0%   { transform: scale(0.6); }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* No mostrar botones toggle cuando esté abierto un menú */
body:has(.drawer.open) .toggle-btn {
  display: none !important;
}


/* ---------- drawers ---------- */
.close-btn {
  display: none;
}  

.drawer {
  position: static;
}  

.toggle-btn {
  display: none;
}  

/* ====  DRAWERS EN PANTALLAS PEQUEÑAS  ==== */
@media (max-width: 1255px) {
  .pane-content {
    padding-top: 20%;
  }

  .side-panels {
    padding-top: 3.4rem;   /* hueco para el botón de cerrar */
  }

  .search-results {
    position: absolute;
    top: calc(var(--offs-navbar-h, 0px) + 11rem + 2.6rem + 2px);
    /* margen superior + altura aproximada del input + 2px de border */
    left: 50%;
    transform: translateX(-50%);
    width: calc(70% - 6rem);
    /* igual ancho que .search-box */
    max-height: 50vh;
    overflow-y: auto;
    background: var(--bg-file);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    box-sizing: border-box;
    z-index: 95;
  }  

  .right.drawer .close-btn {
    /* quita el right y pon un left */
    right: auto;
    left: 0.6rem;
  }  

  /* 2️⃣ empujar buscador y contenido hacia abajo */
  .middle {
    /* añade un padding-top para todo el bloque central */
    padding-top: 3.5rem;
    /* ajusta a tu gusto (3–4 rem) */
    box-sizing: border-box;
  }  

  /* si necesitas más margen extra concreto en el input/markdown */
  .search-box {
    margin-top: 1;
    /* ya lo empuja el padding del padre */
  }  

  .markdown-body,
  .welcome-card {
    margin-top: 2rem;
    /* poca separación adicional */
  }  


  .drawer {
    display: flex;
    position: fixed;
  }  

  .drawer .close-btn,
  .toggle-btn {
    display: block !important;
    transition: opacity 1s ease;
    opacity: 100;  
  }  

  .middle {
    width: 100%;
  }  

  .left:not(.drawer),
  .right:not(.drawer) {
    display: none;
  }  


  /* Botones flotantes */
  .toggle-btn {
    position: fixed;
    top: calc(var(--offs-navbar-h, 0px) + 0.8rem);
    z-index: 120;
    background: var(--bg-file);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.4rem 0.6rem;
    font-size: 1.4rem;
    color: var(--accent);
    cursor: pointer;
    width: 10%;
  }  

  .toggle-btn.left {
    left: 0.8rem;
  }  

  .toggle-btn.right {
    right: 0.8rem;
  }

  /* La pestaña del menú (offs-navbar.css) va a la izquierda del botón del
     índice, que ocupa la misma esquina justo debajo del menú. */
  .oe-nav-toggle {
    right: calc(1.6rem + 10%);
  }

  /* Botón de cierre dentro del cajón */
  .drawer .close-btn {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    background: transparent;
    border: none;
    font-size: 2rem;
    color: var(--accent);
    cursor: pointer;
  }  

  /* Cajones laterales */
  .drawer {
    position: fixed;
    top: var(--offs-navbar-h, 0px);
    bottom: 0;
    width: min(70%, 320px);
    overflow-y: auto;
    background: var(--bg-page);
    box-shadow: 0 0 12px #000;
    transition: transform 0.3s ease;
    z-index: 110;
  }  

  /* Estado cerrado */
  .left.drawer {
    left: 0;
    transform: translateX(-100%);
  }  

  .right.drawer {
    right: 0;
    transform: translateX(100%);
  }  

  /* Estado abierto */
  .drawer.open {
    transform: translateX(0);
  }  

  /* Overlay que oscurece el fondo cuando hay un cajón abierto */
  #drawer-overlay {
    z-index: 100;
    /* por debajo del cajón y por encima del resto */
    background: rgba(0, 0, 0, 0.35);
  }  

  /* Los botones flotantes solo aparecen en móvil */
  .toggle-btn {
    display: block;
  }  
}  

/* En pantallas grandes los ocultamos para no estorbar */
@media (min-width: 1255px) {
  .toggle-btn {
    display: none;
  }  
}

/* Escritorio: Favoritos + índice van desde el buscador hasta el final del
   recuadro de contenido, la mitad cada uno. Con cajones (< 1256px) siguen a
   pantalla completa. */
@media (min-width: 1256px) {
  .side-panels {
    padding-top: var(--search-top);
    padding-bottom: var(--content-bottom);
  }
}  

@media (max-width: 700px) {

  /* Cajones laterales */
  .drawer {
    position: fixed;
    top: var(--offs-navbar-h, 0px);
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    overflow-y: auto;
    background: var(--bg-page);
    box-shadow: none;
    transition: transform 0.3s ease;
    z-index: 110;
  }  

  /* Ajustamos el tamaño de los botones */
  .toggle-btn {
    width: 20%;
  }  

  body.drawer-open .toggle-btn {
    display: none;
  }

  .markdown-body {
    padding: 0.5rem 1rem;
  }

  .help-btn {
    display: none;
  }

  .search-results {
    width: 70%;
  }
}
