/* =========================================================
   Enlace Médico · Navegación lateral colapsable tipo Gmail
   v4: badges estables + campana de notificaciones internas
   ========================================================= */
:root{
  --portal-sidebar-collapsed: 74px;
  --portal-sidebar-expanded: 268px;
  --portal-sidebar-width: var(--portal-sidebar-collapsed);
  --portal-header-offset: 84px;
}

body.has-portal-sidebar{
  --portal-sidebar-width: var(--portal-sidebar-collapsed);
}

body.has-portal-sidebar.portal-sidebar-expanded{
  --portal-sidebar-width: var(--portal-sidebar-expanded);
}

/* La navegación y el contenido forman una sola zona. El footer queda fuera
   de esta grilla, por lo que el rail termina naturalmente antes de él. */
.portal-page-shell{
  display: grid;
  grid-template-columns: var(--portal-sidebar-width) minmax(0, 1fr);
  align-items: stretch;
  width: 100%;
  min-height: calc(100vh - var(--portal-header-offset));
  transition: grid-template-columns .22s var(--ease);
}

.portal-page-content{
  min-width: 0;
  width: 100%;
}

.portal-sidebar-toggle{
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  color: #fff;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.portal-sidebar-toggle:hover{
  background: rgba(255,255,255,.12);
  border-color: rgba(199,162,74,.50);
}

.portal-sidebar-toggle:active{ transform: scale(.97); }
.portal-sidebar-toggle:focus-visible{ outline: none; box-shadow: var(--focus-ring); }

.portal-sidebar-toggle svg{
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* En escritorio y tablet horizontal la hamburguesa vive en el rail,
   exactamente en el lugar donde antes aparecía el bloque EM. */
.portal-sidebar-toggle--header{
  display: none;
}

.portal-sidebar-toggle--rail{
  color: #071a2b;
  background: transparent;
  border-color: rgba(7,26,43,.16);
  box-shadow: none;
}

.portal-sidebar-toggle--rail:hover{
  color: #071a2b;
  background: rgba(7,26,43,.06);
  border-color: rgba(199,162,74,.55);
}

.portal-sidebar{
  position: sticky;
  z-index: calc(var(--z-header) - 10);
  top: var(--portal-header-offset);
  align-self: start;
  width: 100%;
  height: calc(100vh - var(--portal-header-offset));
  min-height: 440px;
  background: rgba(248,250,252,.985);
  border-top: 1px solid rgba(7,26,43,.08);
  border-right: 1px solid rgba(7,26,43,.09);
  box-shadow: 6px 0 22px rgba(7,26,43,.05);
  overflow: hidden;
  transition: width .22s var(--ease), box-shadow .22s var(--ease);
}

.portal-sidebar__scroll{
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 8px 22px;
  scrollbar-width: thin;
  scrollbar-color: rgba(7,26,43,.18) transparent;
}

.portal-sidebar__identity{
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(7,26,43,.06);
}

.portal-sidebar__identity-copy{
  min-width: 0;
  width: 174px;
  opacity: 0;
  transform: translateX(-6px);
  pointer-events: none;
  transition: opacity .14s ease, transform .18s ease;
}

.portal-sidebar__identity-copy strong,
.portal-sidebar__identity-copy small{
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-sidebar__identity-copy strong{
  color: #071a2b;
  font-size: 13px;
  line-height: 1.2;
}

.portal-sidebar__identity-copy small{
  margin-top: 3px;
  color: rgba(7,26,43,.54);
  font-size: 11px;
}

.portal-sidebar__nav{
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.portal-sidebar__link{
  position: relative;
  display: flex;
  align-items: center;
  min-height: 47px;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 0 24px 24px 0;
  color: rgba(7,26,43,.80);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}

.portal-sidebar__link:hover{
  background: rgba(7,26,43,.055);
  color: #071a2b;
}

.portal-sidebar__link.is-active{
  color: #071a2b;
  background: rgba(199,162,74,.23);
  box-shadow: inset 3px 0 0 rgba(199,162,74,.98);
  font-weight: 900;
}

.portal-sidebar__link--insurance.is-active{
  background: rgba(11,52,69,.12);
  box-shadow: inset 3px 0 0 #0b3445;
}

.portal-sidebar__icon{
  width: 40px;
  height: 35px;
  min-width: 40px;
  display: grid;
  place-items: center;
  color: currentColor;
}

.portal-sidebar__icon svg{
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.portal-sidebar__label{
  flex: 1 1 auto;
  min-width: 0;
  width: 168px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transform: translateX(-5px);
  pointer-events: none;
  transition: opacity .14s ease, transform .18s ease;
}

.portal-sidebar__badge{
  flex: 0 0 auto;
  width: auto;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  border-radius: 999px;
  background: rgba(7,26,43,.09);
  color: #071a2b;
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  word-break: keep-all;
  overflow-wrap: normal;
  font-variant-numeric: tabular-nums;
  box-sizing: border-box;
  opacity: 0;
  transition: opacity .14s ease;
}

.portal-sidebar__badge--dot{
  min-width: 9px;
  width: 9px;
  height: 9px;
  padding: 0;
  background: #ef4444;
}

.portal-sidebar__section{
  position: relative;
  min-height: 28px;
  margin: 8px 8px 3px;
  border-top: 1px solid rgba(7,26,43,.08);
}

.portal-sidebar__section span{
  position: absolute;
  top: 8px;
  left: 5px;
  width: 180px;
  color: rgba(7,26,43,.47);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .11em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .14s ease;
}

body.portal-sidebar-expanded .portal-sidebar__identity-copy,
body.portal-sidebar-expanded .portal-sidebar__label,
body.portal-sidebar-expanded .portal-sidebar__badge,
body.portal-sidebar-expanded .portal-sidebar__section span{
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

body:not(.portal-sidebar-expanded) .portal-sidebar__link{
  padding-left: 8px;
  padding-right: 8px;
  justify-content: flex-start;
}

body:not(.portal-sidebar-expanded) .portal-sidebar__badge{
  position: absolute;
  top: 4px;
  right: 4px;
  width: auto;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  margin: 0;
  opacity: 1;
  font-size: 9px;
  line-height: 1;
  white-space: nowrap;
  background: #c7a24a;
  box-shadow: 0 2px 7px rgba(7,26,43,.14);
}

body:not(.portal-sidebar-expanded) .portal-sidebar__badge--dot{
  min-width: 9px;
  width: 9px;
  height: 9px;
  top: 7px;
  right: 8px;
  padding: 0;
  background: #ef4444;
}

.portal-sidebar-backdrop{ display: none; }

/* El panel administrativo antiguo queda reemplazado por esta navegación global. */
.admin-grid.admin-grid--portal-navigation{
  grid-template-columns: minmax(0, 1fr) !important;
}

/* No se aplica padding al body ni compensaciones negativas al header/footer.
   El header y el footer conservan siempre el ancho completo de la ventana. */
@media (min-width: 721px){
  body.has-portal-sidebar{
    padding-left: 0;
  }

  body.has-portal-sidebar > .site-header,
  body.has-portal-sidebar > .portal-header,
  body.has-portal-sidebar > .site-footer{
    width: 100%;
    margin-left: 0;
  }
}

/* En teléfonos el rail pasa a drawer. La hamburguesa del header solo aparece
   aquí, porque el rail está fuera de pantalla mientras permanece cerrado. */
@media (max-width: 720px){
  .portal-page-shell{
    display: block;
    min-height: 0;
  }

  body.has-portal-sidebar{ padding-left: 0; }

  .portal-sidebar-toggle--header{ display: inline-flex; }

  .portal-sidebar{
    position: fixed;
    z-index: calc(var(--z-header) + 20);
    top: var(--portal-header-offset);
    bottom: 0;
    left: 0;
    width: min(84vw, 296px);
    height: auto;
    min-height: 0;
    transform: translateX(-105%);
    box-shadow: 18px 0 46px rgba(7,26,43,.18);
    transition: transform .22s var(--ease), box-shadow .22s var(--ease);
  }

  body.portal-sidebar-mobile-open .portal-sidebar{ transform: translateX(0); }

  .portal-sidebar__identity-copy,
  .portal-sidebar__label,
  .portal-sidebar__badge,
  .portal-sidebar__section span{
    opacity: 1;
    transform: none;
    pointer-events: auto;
  }

  body:not(.portal-sidebar-expanded) .portal-sidebar__link{ padding: 6px 10px; }

  body:not(.portal-sidebar-expanded) .portal-sidebar__badge{
    position: static;
    min-width: 23px;
    height: 23px;
    padding: 0 7px;
    margin-left: auto;
    font-size: 11px;
    background: rgba(7,26,43,.09);
  }

  body:not(.portal-sidebar-expanded) .portal-sidebar__badge--dot{
    min-width: 9px;
    width: 9px;
    height: 9px;
    padding: 0;
    background: #ef4444;
  }

  .portal-sidebar-backdrop{
    position: fixed;
    z-index: calc(var(--z-header) + 15);
    inset: var(--portal-header-offset) 0 0 0;
    display: block;
    background: rgba(7,26,43,.28);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility .18s ease;
  }

  body.portal-sidebar-mobile-open .portal-sidebar-backdrop{
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  body.portal-sidebar-mobile-open{ overflow: hidden; }
}

@media (max-width: 680px){
  .portal-sidebar-toggle{
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }
}

@media (prefers-reduced-motion: reduce){
  .portal-page-shell,
  .portal-sidebar,
  .portal-sidebar__label,
  .portal-sidebar__identity-copy,
  .portal-sidebar__badge{
    transition: none !important;
  }
}
