/* ============================================================
   Capital Nav Menu — style.css
   Variables heredadas del bloque vía inline style en el <nav>.
   ============================================================ */

:root {
  --cnm-z:          900;
  --cnm-h:          56px;
  --cnm-gap:        4px;
  --cnm-radius:     6px;
  --cnm-accent:     #f43151;
  --cnm-text:       #ffffff;
  --cnm-img-size:   28px;
  --cnm-transition: 0.2s ease;
  --cnm-sidebar-w:  100px; /* sobreescrito por sidebarWidth vía inline style */
}

/* ── Contenedor principal ── */
.cnm {
  background: var(--cnm-bg, #1a1a2e);
  z-index: var(--cnm-z);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* ══════════════════════════════════════════════
   POSICIONAMIENTO
══════════════════════════════════════════════ */

/* Estático */
.cnm--static {
  position: relative;
  width: 100%;
}

/* Fijo arriba */
.cnm--fixed-top {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
}

/* Fijo abajo */
.cnm--fixed-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
}

/* Sidebar izquierdo */
.cnm--sidebar-left {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--cnm-sidebar-w);
  height: 100vh;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.35);
}

/* Sidebar derecho */
.cnm--sidebar-right {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--cnm-sidebar-w);
  height: 100vh;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.35);
}

/* ══════════════════════════════════════════════
   LISTA DE ÍTEMS — modo horizontal (default)
══════════════════════════════════════════════ */

.cnm__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cnm-gap);
  margin: 0;
  padding: 0 12px;
  list-style: none;
  min-height: var(--cnm-h);
}

/* ── Ítem individual ── */
.cnm__item {
  display: flex;
  align-items: stretch;
}

/* ── Enlace — modo horizontal ── */
.cnm__link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--cnm-radius);
  text-decoration: none;
  color: var(--cnm-text);
  font-size: 0.875rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition:
    background var(--cnm-transition),
    color var(--cnm-transition),
    border-bottom var(--cnm-transition);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.cnm__link:hover,
.cnm__link:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  border-bottom-color: var(--cnm-accent);
  outline: none;
}

.cnm__link:focus-visible {
  outline: 3px solid var(--cnm-accent);
  outline-offset: 2px;
}

/* ── Imagen — modo horizontal ── */
.cnm__img-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.cnm__img {
  display: block;
  width: auto;
  height: var(--cnm-img-size);
  max-width: 100px;
  object-fit: contain;
  border-radius: 3px;
}

/* ── Etiqueta ── */
.cnm__label {
  line-height: 1.2;
}

/* ══════════════════════════════════════════════
   LISTA DE ÍTEMS — modo sidebar (vertical)
   Aplica a ambos: sidebar-left y sidebar-right
══════════════════════════════════════════════ */

.cnm--sidebar-left .cnm__list,
.cnm--sidebar-right .cnm__list {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: center;
  padding: 12px 0;
  min-height: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  gap: 2px;

  /* Scrollbar discreta */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.cnm--sidebar-left .cnm__list::-webkit-scrollbar,
.cnm--sidebar-right .cnm__list::-webkit-scrollbar {
  width: 4px;
}

.cnm--sidebar-left .cnm__list::-webkit-scrollbar-thumb,
.cnm--sidebar-right .cnm__list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
}

.cnm--sidebar-left .cnm__item,
.cnm--sidebar-right .cnm__item {
  width: 100%;
  box-sizing: border-box;
  padding: 0 0.6em;
}

/* Enlace en modo sidebar: imagen arriba, etiqueta abajo */
.cnm--sidebar-left .cnm__link,
.cnm--sidebar-right .cnm__link {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 1em 0.6em;
  border-bottom: none;
  border-left: 3px solid transparent;
  border-radius: 0;
  white-space: normal;
  text-align: center;
  min-height: 64px;
  width: 100%;
  transition:
    background var(--cnm-transition),
    border-left-color var(--cnm-transition);
    border-radius: 1em;
}

.cnm--sidebar-left .cnm__link:hover,
.cnm--sidebar-left .cnm__link:focus-visible,
.cnm--sidebar-right .cnm__link:hover,
.cnm--sidebar-right .cnm__link:focus-visible {
  background-color: #FE1450;
}

.cnm--sidebar-right .cnm__link:hover,
.cnm--sidebar-right .cnm__link:focus-visible {
  background-color: #FE1450;
}

/* Imagen en modo sidebar: tamaño cuadrado contenido */
.cnm--sidebar-left .cnm__img-wrap,
.cnm--sidebar-right .cnm__img-wrap {
  justify-content: center;
  width: 100%;
  padding: 0 2em;
  box-sizing: border-box;
}

.cnm--sidebar-left .cnm__img,
.cnm--sidebar-right .cnm__img {
  height: auto;
  width: 100%;
}
/* Etiqueta en modo sidebar */
.cnm--sidebar-left .cnm__label,
.cnm--sidebar-right .cnm__label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.2;
  word-break: break-word;
  width: 100%;
  text-align: center;
}

/* ── Texto solo para lectores de pantalla ── */
.cnm__sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Estado vacío (solo en editor) ── */
.cnm__empty {
  padding: 12px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  font-style: italic;
}

/* ── Indicador visual en el editor de bloques ── */
.block-editor-block-list__block .cnm {
  outline: 1px dashed rgba(255, 255, 255, 0.2);
}

/* ══════════════════════════════════════════════
   COMPENSACIÓN EN BODY
   Clases aplicadas por view.js en el frontend.
══════════════════════════════════════════════ */

body.has-cnm-fixed-top {
  padding-top: var(--cnm-h);
}

body.has-cnm-fixed-bottom {
  padding-bottom: var(--cnm-h);
}

body.has-cnm-sidebar-left {
  padding-left: var(--cnm-sidebar-w);
}

body.has-cnm-sidebar-right {
  padding-right: var(--cnm-sidebar-w);
}

/* ── Responsive: sidebars colapsan a barra horizontal en móvil ── */
@media (max-width: 900px) {
  .cnm--static,
  .cnm--fixed-top,
  .cnm--fixed-bottom {
    width: 100%;
  }

  .cnm__list {
    padding: 0 6px;
    gap: 2px;
  }

  .cnm__link {
    padding: 8px;
    font-size: 0.8rem;
  }

  /* Etiqueta oculta a la vista; se conserva como nombre accesible del enlace. */
  .cnm__label,
  .cnm--sidebar-left .cnm__label,
  .cnm--sidebar-right .cnm__label {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .cnm__img {
    height: 24px;
  }

  /* Sidebar colapsa a barra inferior en móvil */
  .cnm--sidebar-left,
  .cnm--sidebar-right {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.35);
    overflow-x: scroll;
  }

  .cnm--sidebar-left .cnm__list,
  .cnm--sidebar-right .cnm__list {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 6px;
    min-height: var(--cnm-h);
    height: auto;
    align-items: center;
    justify-content: center;
  }

  .cnm--sidebar-left .cnm__item,
  .cnm--sidebar-right .cnm__item {
    width: auto;
    flex-shrink: 0;
  }

  .cnm--sidebar-left .cnm__link,
  .cnm--sidebar-right .cnm__link {
    flex-direction: row;
    padding: 0.5em;
    min-height: auto;
    border-left: none;
    border-right: none;
    border-bottom: 2px solid transparent;
  }

  .cnm--sidebar-left .cnm__link:hover,
  .cnm--sidebar-right .cnm__link:hover {
    border-left-color: transparent;
    border-right-color: transparent;
    border-bottom-color: var(--cnm-accent);
  }

  .cnm--sidebar-left .cnm__img-wrap,
  .cnm--sidebar-right .cnm__img-wrap {
    padding: 0.5em;
  }


  .cnm--sidebar-left .cnm__img,
  .cnm--sidebar-right .cnm__img {
    height: 24px;
    width: auto;
    max-width: 40px;
  }

  body.has-cnm-sidebar-left,
  body.has-cnm-sidebar-right {
    padding-left: 0;
    padding-right: 0;
    padding-bottom: var(--cnm-h);
  }
}
