/**
 * Armazón de aplicación para CiviCRM: barra lateral izquierda + cabecera.
 *
 * QUÉ HACE Y QUÉ NO
 * Cambia la ESTRUCTURA EXTERIOR (dónde vive el menú, dónde empieza el
 * contenido) y el acabado de lo que hay dentro: espaciado, jerarquía, tarjetas,
 * tablas, botones. NO toca el layout INTERIOR de las pantallas de CiviCRM —
 * nada de display, position, float, width ni height dentro del contenido—
 * porque son cientos de pantallas que nadie va a revisar una por una, y son
 * esas propiedades las que las descolocan.
 *
 * COLORES: no hay ni uno nuevo. Todos salen de la identidad que ya existe en
 * harold-theme.css. Se declaran aquí como respaldo por si ese tema no cargara.
 */

:root {
  --hu-navy: #1B3A6B;         /* azul marino institucional */
  --hu-navy-dark: #122A52;
  --hu-navy-darker: #0E2244;
  --hu-blue: #2B5AA0;         /* azul medio */
  --hu-blue-light: #5BA4D6;
  --hu-red: #E1251B;          /* rojo institucional: acento */
  --hu-red-dark: #B81C14;
  --hu-gold: #F2A900;
  --hu-bg: #F3F5F9;           /* gris muy claro de fondo */
  --hu-surface: #FFFFFF;
  --hu-border: #E4E8EF;
  --hu-text: #1F2733;
  --hu-text-muted: #66707F;

  --shell-ancho: 250px;
  --shell-ancho-min: 72px;    /* cuando está contraído */
  --shell-cabecera: 50px;
  --shell-radio: 6px;
}

/* ============================================================
   1. EL ARMAZÓN
   ============================================================ */
body.hu-shell {
  background: var(--hu-bg);
  margin: 0;
}

/* El contenido se corre a la derecha del sidebar y debajo de la cabecera.
   Es el ÚNICO desplazamiento de layout que se hace, y sobre un contenedor
   exterior: nada de lo que hay dentro se mueve. */
body.hu-shell #crm-container,
body.hu-shell .crm-container {
  margin-left: var(--shell-ancho);
  padding-top: calc(var(--shell-cabecera) + 18px);
  padding-right: 26px;
  padding-bottom: 40px;
  padding-left: 26px;
  transition: margin-left .18s ease;
  background: transparent;
}
body.hu-shell.hu-contraido #crm-container,
body.hu-shell.hu-contraido .crm-container {
  margin-left: var(--shell-ancho-min);
}

/* ============================================================
   2. BARRA LATERAL
   Clara, como la de las pantallas de captación: fondo blanco, borde a la
   derecha y la marca sobre gris muy claro. Se decidió así para que el equipo
   no sienta que usa dos productos distintos.
   ============================================================ */
.hu-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--shell-ancho);
  background: var(--hu-surface);
  border-right: 1px solid var(--hu-border);
  color: var(--hu-text);
  display: flex;
  flex-direction: column;
  z-index: 1001;
  transition: width .18s ease, transform .22s ease;
  overflow: hidden;
}
.hu-contraido .hu-sidebar { width: var(--shell-ancho-min); }

/* -- Marca -------------------------------------------------- */
.hu-marca {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: #F4F6FA;
  border-bottom: 1px solid var(--hu-border);
  min-height: var(--shell-cabecera);
  box-sizing: border-box;
}
.hu-marca__logo {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: var(--shell-radio);
  background: #fff center/86% no-repeat;
  border: 1px solid var(--hu-border);
}
.hu-marca__txt { min-width: 0; }
.hu-marca__nombre {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .01em;
  line-height: 1.15;
  color: var(--hu-navy);
  white-space: nowrap;
}
.hu-marca__cargo {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--hu-text-muted);
  margin-top: 2px;
  white-space: nowrap;
}
.hu-contraido .hu-marca__txt { display: none; }
.hu-contraido .hu-marca { justify-content: center; padding: 11px 0; }

/* -- Navegación --------------------------------------------- */
.hu-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 9px 18px;
}
.hu-nav::-webkit-scrollbar { width: 7px; }
.hu-nav::-webkit-scrollbar-thumb { background: #CBD3E0; border-radius: 4px; }

.hu-grupo {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: #8791A0;
  padding: 14px 10px 6px;
}
.hu-contraido .hu-grupo {
  font-size: 0;
  padding: 10px 0 5px;
  border-top: 1px solid var(--hu-border);
  margin: 5px 7px 0;
}

.hu-item > a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--shell-radio);
  color: #55606F;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  line-height: 1.25;
  position: relative;
  transition: background-color .15s ease, color .15s ease;
}
.hu-item > a:hover {
  background: #F4F6FA;
  color: var(--hu-navy);
  text-decoration: none;
}
.hu-item__icono { flex: 0 0 18px; width: 18px; height: 18px; opacity: .72; }
.hu-item > a:hover .hu-item__icono { opacity: 1; }
.hu-item__txt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hu-contraido .hu-item__txt { display: none; }
.hu-contraido .hu-item > a { justify-content: center; padding: 9px 0; }

/* La opción activa: azul suave con texto azul marino, igual que en la
   pantalla de captación. El acento rojo la remata sin gritar. */
.hu-item.hu-activo > a {
  background: #E8EEF7;
  color: var(--hu-navy);
  font-weight: 600;
}
.hu-item.hu-activo > a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--hu-red);
}
.hu-item.hu-activo .hu-item__icono { opacity: 1; }

/* La flecha que indica que la opción se abre hacia abajo. */
.hu-item__flecha {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  margin-left: auto;
  opacity: .55;
  transition: transform .16s ease;
}
.hu-item.hu-abierto > a .hu-item__flecha { transform: rotate(90deg); opacity: .85; }
.hu-contraido .hu-item__flecha { display: none; }

/* Submenús: ocultos hasta que se pulsa la opción de arriba. */
.hu-item ul { list-style: none; margin: 1px 0 3px; padding: 0 0 0 27px; }
.hu-item ul[hidden] { display: none; }
.hu-item ul a {
  display: block;
  padding: 5px 9px;
  border-radius: var(--shell-radio);
  color: #8791A0;
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hu-item ul a:hover { background: #F4F6FA; color: var(--hu-navy); text-decoration: none; }
.hu-contraido .hu-item ul { display: none; }

/* ============================================================
   3. CABECERA
   ============================================================ */
.hu-cabecera {
  position: fixed;
  top: 0;
  left: var(--shell-ancho);
  right: 0;
  height: var(--shell-cabecera);
  background: #F4F6FA;
  border-bottom: 1px solid var(--hu-border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  z-index: 1000;
  transition: left .18s ease;
}
.hu-contraido .hu-cabecera { left: var(--shell-ancho-min); }

.hu-cabecera__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: none;
  color: var(--hu-text-muted);
  cursor: pointer;
  position: relative;
  padding: 0;
}
.hu-cabecera__btn:hover {
  background: var(--hu-bg);
  color: var(--hu-navy);
  border-color: var(--hu-border);
}
.hu-cabecera__fecha {
  font-size: 12.5px;
  color: var(--hu-text-muted);
  white-space: nowrap;
}
.hu-cabecera__hueco { flex: 1 1 auto; }

.hu-punto {
  position: absolute;
  top: 6px;
  right: 7px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--hu-red);
  border: 1.5px solid var(--hu-surface);
}

.hu-usuario {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 14px;
  border-left: 1px solid var(--hu-border);
}
.hu-usuario__ini {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--hu-navy);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: .02em;
}
.hu-usuario__nombre {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--hu-text);
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hu-salir {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid var(--hu-border);
  border-radius: 8px;
  background: var(--hu-surface);
  color: var(--hu-text-muted);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.hu-salir:hover {
  border-color: var(--hu-red);
  color: var(--hu-red);
  text-decoration: none;
}

/* ============================================================
   4. RESPONSIVE
   Bajo 900px el sidebar se sale de pantalla y vuelve al pulsar
   el botón. En móvil, un velo para poder cerrarlo tocando fuera.
   ============================================================ */
.hu-velo {
  position: fixed;
  inset: 0;
  background: rgba(31, 39, 51, .38);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

@media (max-width: 900px) {
  .hu-sidebar { transform: translateX(-100%); width: var(--shell-ancho); }
  body.hu-abierto .hu-sidebar { transform: translateX(0); }
  body.hu-abierto .hu-velo { opacity: 1; pointer-events: auto; }

  body.hu-shell #crm-container,
  body.hu-shell .crm-container,
  body.hu-shell.hu-contraido #crm-container,
  body.hu-shell.hu-contraido .crm-container {
    margin-left: 0;
    padding-left: 14px;
    padding-right: 14px;
  }
  .hu-cabecera,
  .hu-contraido .hu-cabecera { left: 0; padding: 0 14px; }
  .hu-cabecera__fecha { display: none; }
  .hu-usuario__nombre { display: none; }
}

@media (max-width: 560px) {
  .hu-salir span { display: none; }
  .hu-salir { padding: 0 9px; }
}

/* Al imprimir no hay armazón que valga: solo el contenido. */
@media print {
  .hu-sidebar, .hu-cabecera, .hu-velo { display: none !important; }
  body.hu-shell #crm-container,
  body.hu-shell .crm-container { margin-left: 0 !important; padding-top: 0 !important; }
}

/* ============================================================
   El menubar nativo, fuera del todo

   crm-shell.js esconde el <ul> #civicrm-menu, pero su envoltorio
   (#civicrm-menu-nav / #crm-menubar) se quedaba puesto con z-index
   100000, por encima de nuestra cabecera. En escritorio no se notaba
   porque va vacío; en el teléfono el menubar dibuja su propio botón de
   hamburguesa, y salía un recuadro negro encima del nuestro.

   Va por CSS y no por JS a propósito: si el armazón no llega a montar,
   la clase hu-shell no está y el menú nativo sigue disponible, que es
   la única forma de navegar cuando lo nuestro falla.
   ============================================================ */
body.hu-shell #civicrm-menu-nav,
body.hu-shell #crm-menubar,
body.hu-shell #civicrm-menu { display: none !important; }
