/* =====================================================================
   Sidebar de navegación de dos niveles (cinta de kits + panel de detalle)
   Valores replicados del CSS original (sidebar.css), con nombres propios.
   ===================================================================== */

/* --details-progress se anima de 1 a 0 (y viceversa) gracias a @property */
@property --details-progress {
  syntax: "<number>";
  inherits: true;
  initial-value: 0;
}

.sb {
  --focus-outline: inset 0 0 0 3px oklch(42.4% 0.269 264.2deg / 0.469);
  --line: oklch(13.7% 0.026 175.7deg / 0.161);
  --bg: #f4f5f5;
  --hover: #e9e9e9;
  --current: #e3e3e3;
  --text: rgba(1, 5, 0, 0.898);
  --text-muted: rgba(0, 3, 0, 0.584);
  --icon: rgba(0, 4, 1, 0.526);
  --collapse-duration: 220ms;
  --details-content-width: 0px;
  --details-width: 0px;
  display: none;
  height: 100%;
}
.sb[data-mode] { display: block; }

/* ---------- Escritorio ---------- */
.sb[data-mode="desktop"] {
  --ribbon-width: 77px;
  --details-content-width: clamp(177px, 13.828125vw, 241px);
  --details-progress: 1;
  --details-width: calc(var(--details-content-width) * var(--details-progress));
}
.sb[data-mode="desktop"][compact] { --ribbon-width: 53px; }
.sb[data-mode="desktop"][compact] .sb-ribbon-item__label { display: none; }
.sb[data-mode="desktop"][collapsed],
.sb[data-mode]:not([has-details]) { --details-progress: 0; }

@media (prefers-reduced-motion: no-preference) {
  .sb[data-mode="desktop"]:has(.sb-details[animating]) {
    transition: --details-progress var(--collapse-duration) ease-out;
  }
}

.sb-nav {
  background-color: var(--bg);
  display: grid;
  grid-template-areas: "ribbon details";
  grid-template-columns: var(--ribbon-width) var(--details-width);
  height: 100%;
  position: relative;
}

/* ---------- Paneles (detalle / flotante / móvil) ---------- */
.sb-details,
.sb-hover-panel,
.sb-mobile-panel {
  border-right: 1px solid var(--line);
  display: block;
  grid-area: details;
  max-height: 100vh;
  overflow-y: auto;
  padding: 0 6px 6px;
  box-sizing: border-box;
}

.sb-panel__title {
  color: oklch(0.1 0.03 137 / 0.899);
  font-size: 14px;
  font-weight: 700;
  line-height: 20px;
  margin: 16px 12px 8px;
}
.sb-group { display: flow-root; margin-top: 12px; }
.sb-group:first-of-type { margin-top: 0; }
.sb-group__heading {
  color: oklch(0.088 0.026 147.7 / 0.583);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  margin: 8px 12px;
}
.sb-group ul { display: flex; flex-direction: column; list-style: none; margin: 0; padding: 0; }

.sb-item { display: block; position: relative; }
.sb-item__link {
  border-radius: 6px;
  color: var(--text);
  display: block;
  font-size: 14px;
  font-weight: 400;
  hyphens: manual;
  line-height: 20px;
  padding: 4px 12px;
  position: relative;
  text-decoration: none;
}
.sb-item__link:hover,
.sb-item__link:focus { background-color: var(--hover); }
.sb-item__link:focus-visible { box-shadow: var(--focus-outline); outline: none; }
.sb-item[is-current] .sb-item__link { background-color: var(--current); font-weight: 500; }

/* Icono de enlace externo: aparece sólo en hover/focus, con degradado sobre el texto */
.sb-item__ext {
  background: linear-gradient(270deg, var(--hover) 70%, #0000);
  border-radius: 6px;
  display: none;
  padding: 3px 8px 3px 24px;
  position: absolute;
  right: 3px;
  top: 3px;
}
.sb-item__ext::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%2300050262'><path d='M14.39 1.08A1 1 0 0 0 14 1H9.75a1 1 0 1 0 0 2h1.83L5.3 9.29a1 1 0 0 0 1.42 1.42L13 4.42v1.83a1 1 0 1 0 2 0V2a1 1 0 0 0-.61-.92Z'/><path d='M1 5a1 1 0 0 1 1-1h4v2H3v7h7v-3h2v4a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V5Z'/></svg>") no-repeat 50%;
}
.sb-item:hover .sb-item__ext,
.sb-item:focus-within .sb-item__ext { display: block; }

/* Elementos tipo "informe": máximo 2 líneas */
.sb-item--report .sb-item__link {
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  display: -webkit-box;
  overflow: clip;
  text-overflow: ellipsis;
  word-break: break-all;
}

/* Skeleton de carga para grupos dinámicos */
.sb-skeleton { padding: 10px 12px; }
.sb-skeleton::before {
  content: "";
  display: block;
  height: 8px;
  width: 100%;
  border-radius: 6px;
  background: oklch(0.9 0.002 177);
  animation: sb-pulse 1.2s ease-in-out infinite;
}
@keyframes sb-pulse { 50% { opacity: 0.45; } }

/* ---------- Insignias ---------- */
.sb-badge {
  border-radius: 6px;
  color: #fff;
  display: inline;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3px;
  line-height: 14px;
  margin-left: 4px;
  padding: 1px 4px;
  vertical-align: 1.5px;
  white-space: nowrap;
}
.sb-badge[data-variant="new"] { background-color: oklch(64% 0.161 170deg); }
.sb-badge[data-variant="beta"] { background-color: oklch(64% 0.196 47.3deg); }
.sb-badge[data-variant="alpha"] { background-color: oklch(64% 0.226 24.5deg); }
.sb-badge[data-variant="soon"] { background-color: oklch(64% 0.003 157.8deg); }

/* ---------- Panel de detalle (con animación de colapso) ---------- */
.sb-details { padding-bottom: 20px; }
.sb[data-mode="desktop"] .sb-details {
  justify-self: start;
  width: var(--details-content-width);
  /* Se desliza hacia la izquierda a medida que --details-width baja a 0 */
  transform: translateX(calc(var(--details-width) - var(--details-content-width)));
}
.sb[data-mode="mobile"] .sb-details { display: none; }
@media (prefers-reduced-motion: no-preference) {
  .sb-details[animating] {
    /* El contenido aparece con un fundido al final de la animación */
    transition: opacity 0.12s ease-out calc(var(--collapse-duration) - 0.12s);
  }
  @starting-style {
    .sb-details[animating] { opacity: 0; }
  }
}
.sb[collapsed] .sb-details { opacity: 0; transition-delay: 0ms; }
.sb[collapsed] .sb-details:not([animating]) { display: none; }

/* ---------- Panel flotante (hover) ---------- */
.sb-hover-panel {
  background-color: #fff;
  border: none;
  border-radius: 8px;
  box-shadow: 1px 1px 10px 0 oklch(17.6% 0.033 175.7deg / 0.07);
  display: none;
  inset: unset;
  margin: 0;
  overscroll-behavior: contain;
  position: fixed;
  width: 256px;
  color: inherit;
  font: inherit;
}
.sb-hover-panel:popover-open { display: block; }
.sb[data-mode="mobile"] .sb-hover-panel { display: none; }
/* Ancla invisible que se inserta antes del kit "hovered" para posicionar el panel */
#sb-hover-anchor { position: relative; right: -3px; top: -13px; height: 0; }
.sb[compact] #sb-hover-anchor { top: -38px; }

/* ---------- Cinta de kits ---------- */
.sb-ribbon {
  --block-margin: 4px;
  --inline-margin: 6px;
  border-right: 1px solid var(--line);
  grid-area: ribbon;
  overflow-y: hidden;
  padding-bottom: 40px;
}
.sb[data-mode="desktop"] .sb-ribbon { background-color: var(--bg); position: relative; z-index: 1; }
@media (max-height: 740px) { .sb-ribbon { padding-bottom: 36px; } }
@media (max-height: 700px) { .sb-ribbon { padding-bottom: 28px; } }
@media (min-height: 736px) { .sb-ribbon { --block-margin: 6px; } }

.sb-ribbon ul {
  display: flex;
  flex-direction: column;
  gap: 2px;
  list-style: none;
  margin: var(--block-margin) var(--inline-margin);
  padding: 0;
}
@media (min-height: 736px) { .sb-ribbon ul { gap: 4px; } }

.sb-ribbon-item { position: relative; }
.sb-ribbon-item__link {
  align-items: center;
  background-color: #0000;
  border-radius: 6px;
  box-sizing: border-box;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 500;
  gap: 1px;
  justify-content: center;
  line-height: 16px;
  min-height: 100%;
  outline: none;
  padding: 6px 2px;
  position: relative;
  text-align: center;
  text-decoration: none;
  transition: background-color 0.125s ease-in-out, color 0.125s ease-in-out;
  width: 100%;
}
@media (min-height: 736px) { .sb-ribbon-item__link { padding: 10px 2px; } }
@media (min-height: 796px) { .sb-ribbon-item__link { gap: 4px; } }
/* Amplía la zona de hover hasta los bordes de la cinta (sin huecos entre kits) */
.sb-ribbon-item__link::after {
  content: "";
  display: block;
  inset: 0 calc(var(--inline-margin, 0px) * -1);
  position: absolute;
}
.sb-ribbon-item__link:focus-visible { box-shadow: var(--focus-outline); }

.sb-ribbon-item__icon {
  color: var(--icon);
  display: block;
  height: 20px;
  width: 20px;
  transition: transform 0.125s ease-in-out;
}
.sb-ribbon-item__icon svg { display: block; height: 20px; width: 20px; }
@media (min-height: 820px) {
  .sb-ribbon-item__icon, .sb-ribbon-item__icon svg { height: 24px; width: 24px; }
}
.sb-ribbon-item__icon--active { display: none; }

.sb-ribbon-item:hover .sb-ribbon-item__link,
.sb-ribbon-item:focus-within .sb-ribbon-item__link,
.sb-ribbon-item[hovered] .sb-ribbon-item__link { background-color: var(--hover); }
.sb-ribbon-item:hover .sb-ribbon-item__icon,
.sb-ribbon-item:focus-within .sb-ribbon-item__icon,
.sb-ribbon-item[hovered] .sb-ribbon-item__icon { transform: scale(1.09); }

.sb-ribbon-item[is-current] .sb-ribbon-item__link { background-color: var(--current); color: var(--text); }
.sb-ribbon-item[is-current] .sb-ribbon-item__icon { color: var(--text-muted); display: none; }
.sb-ribbon-item[is-current] .sb-ribbon-item__icon--active { display: block; }

.sb-home {
  text-decoration: none;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  padding: 7px 4px 8px 0;
}
.sb-home:focus-visible { box-shadow: var(--focus-outline); outline: none; }
.sb-home svg { display: block; height: 26px; width: 26px; }
.sb-home__wordmark { display: none; }

/* ---------- Botón colapsar ---------- */
.sb-collapse {
  /* es hermano de .sb, no hijo: no hereda sus variables */
  --focus-outline: inset 0 0 0 3px oklch(42.4% 0.269 264.2deg / 0.469);
  --line: oklch(13.7% 0.026 175.7deg / 0.161);
  --bg: #f4f5f5;
  background-color: var(--bg);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: none;
  left: 0;
  position: absolute;
  z-index: 2;
}
.sb[data-mode="desktop"] ~ .sb-collapse { display: block; width: 76px; }
.sb[data-mode="desktop"][compact] ~ .sb-collapse { width: 52px; }
.sb-collapse__button {
  align-items: center;
  background-color: #0000;
  border: none;
  box-sizing: border-box;
  color: #62646e;
  cursor: pointer;
  display: flex;
  height: 40px;
  justify-content: center;
  margin: 0;
  outline: none;
  padding: 6px;
  width: 100%;
}
@media (max-height: 740px) { .sb-collapse__button { height: 36px; } }
@media (max-height: 700px) { .sb-collapse__button { height: 28px; } }
.sb-collapse__button svg { fill: currentColor; display: block; height: 16px; width: 16px; pointer-events: none; transition: transform 0.2s ease; }
.sb-collapse__button:hover { color: #181e15; }
.sb-collapse__button:focus-visible { box-shadow: var(--focus-outline); }
.sb[collapsed] ~ .sb-collapse svg { transform: scaleX(-1); }

/* ---------- Tooltip ---------- */
.sb-tooltip {
  background: oklch(0.23 0.01 140);
  border: none;
  border-radius: 6px;
  color: #fff;
  font: 500 12px/16px Inter, sans-serif;
  inset: unset;
  margin: 0;
  max-width: 228px;
  padding: 6px 8px;
  position: fixed;
  overflow: visible;
}
.sb-tooltip::before {
  content: "";
  position: absolute;
  left: -4px;
  top: calc(var(--arrow-offset, 50%) - 4px);
  border: 4px solid transparent;
  border-left: 0;
  border-right-color: oklch(0.23 0.01 140);
}

/* =====================================================================
   Móvil (< 1280px): drawer modal con la cinta como lista
   ===================================================================== */
.sb[data-mode="mobile"] {
  --drawer-width: clamp(100px, 100vw - 60px, 360px);
  bottom: 0;
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
}
.sb[data-mode="mobile"][modal-open] { display: block; }
.sb-backdrop {
  background-color: oklch(11.8% 0.023 170.1deg / 0.262);
  display: none;
  height: 100vh;
  left: 0;
  position: fixed;
  top: 0;
  width: 100vw;
}
.sb[modal-open] .sb-backdrop { display: block; }

.sb[data-mode="mobile"] .sb-nav { grid-template-areas: "drawer"; grid-template-columns: var(--drawer-width); }
.sb[data-mode="mobile"] .sb-ribbon {
  --block-margin: 12px;
  --inline-margin: 8px;
  border-right: none;
  display: none;
  grid-area: drawer;
  overflow-y: auto;
  padding-bottom: 0;
}
.sb[data-mode="mobile"]:not(:has(.sb-mobile-panel[use])) .sb-ribbon { display: block; }
.sb[data-mode="mobile"] .sb-ribbon ul { gap: 8px; }
.sb[data-mode="mobile"] .sb-ribbon-item__link {
  flex-direction: row;
  gap: 12px;
  justify-content: flex-start;
  padding: 8px 12px;
}
.sb[data-mode="mobile"] .sb-ribbon-item__label { font-size: 16px; line-height: 24px; }
.sb[data-mode="mobile"] .sb-home { padding: 12px 30px 4px 0; justify-content: flex-start; padding-left: 12px; gap: 8px; align-items: center; }
.sb[data-mode="mobile"] .sb-home__wordmark { display: inline; font: 700 16px/1 Inter, sans-serif; color: #181e15; }

.sb-mobile-panel { border-right: none; grid-area: drawer; }
.sb-mobile-panel:not([use]),
.sb[data-mode="desktop"] .sb-mobile-panel { display: none; }
.sb[data-mode="mobile"] .sb-mobile-panel { padding: 12px 8px; }
.sb[data-mode="mobile"] .sb-panel__title { font-size: 16px; line-height: 24px; margin-top: 28px; }
.sb[data-mode="mobile"] .sb-group__heading { font-size: 14px; line-height: 20px; }
.sb[data-mode="mobile"] .sb-item__link { font-size: 16px; line-height: 24px; padding: 8px 12px; }
.sb[data-mode="mobile"] .sb-item__ext { background: none; display: block; padding-top: 10px; }
.sb[data-mode="mobile"] .sb-badge { vertical-align: 2.5px; }

.sb-back {
  align-items: center;
  background-color: oklch(0.177 0.033 175.6 / 0.028);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: oklch(0.1 0.03 137 / 0.899);
  cursor: pointer;
  display: flex;
  font: inherit;
  font-size: 16px;
  gap: 8px;
  height: 40px;
  justify-content: center;
  margin: 0 auto 12px;
  outline: none;
  padding: 0 12px;
  width: calc(100% - 24px);
}
.sb-back:focus-visible { box-shadow: var(--focus-outline); }
.sb-back::before {
  content: "";
  display: block;
  height: 16px;
  width: 16px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='10' fill='%232D2E33'><path fill-rule='evenodd' d='M5.7 9.7a1 1 0 0 1-1.4 0l-4-4a1 1 0 0 1 0-1.4l4-4a1 1 0 0 1 1.4 1.4L3.4 4H13a1 1 0 1 1 0 2H3.4l2.3 2.3a1 1 0 0 1 0 1.4Z'/></svg>") no-repeat 50%;
}
