/**
 * Shell Sidebar Drawer — SOCTI
 * Cerrado  = cero espacio (sin riel ni hueco).
 * Abierto  = empuja el contenido en desktop (no invade módulos).
 * Móvil   = overlay + backdrop.
 */

:root {
  --shell-sidebar-w: 272px;
  --shell-header-h: 50px;
  --shell-sidebar-ease: 180ms ease;
  --shell-sidebar-backdrop: rgba(15, 23, 42, 0.45);
}

@media (prefers-reduced-motion: reduce) {
  :root { --shell-sidebar-ease: 1ms linear; }
}

/* ========== SIDEBAR ========== */
html body.sidebar-mini .main-sidebar,
html body.sidebar-mini .left-side {
  position: fixed !important;
  top: var(--shell-header-h) !important;
  left: 0 !important;
  bottom: 0 !important;
  height: auto !important;
  z-index: 1040 !important;
  width: var(--shell-sidebar-w) !important;
  max-width: var(--shell-sidebar-w) !important;
  margin: 0 !important;
  padding-top: 0 !important;
  /* Degradado alineado a Menu3 (no flat opaco); sidebar-corporate aporta el resto */
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 28%),
    linear-gradient(160deg, rgba(37, 99, 235, 0.12), transparent 42%),
    linear-gradient(180deg, #0b1220 0%, #0e152b 55%, #111827 100%) !important;
  border-right: 1px solid rgba(148, 163, 184, 0.14) !important;
  box-shadow: 8px 0 32px rgba(2, 8, 23, 0.45);
  overflow-x: hidden !important;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  transition: transform var(--shell-sidebar-ease), visibility var(--shell-sidebar-ease), width var(--shell-sidebar-ease) !important;
}

/* ========== DESKTOP: cerrado = 0; abierto = empuja contenido ========== */
@media (min-width: 768px) {
  /* CERRADO */
  html body.sidebar-mini.sidebar-collapse .main-sidebar,
  html body.sidebar-mini.sidebar-collapse .left-side {
    transform: translate3d(-110%, 0, 0) !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    overflow: hidden !important;
  }

  html body.sidebar-mini.sidebar-collapse .content-wrapper,
  html body.sidebar-mini.sidebar-collapse .right-side,
  html body.sidebar-mini.sidebar-collapse .main-footer {
    margin-left: 0 !important;
    padding-left: 0 !important;
    transform: none !important;
  }

  html body.sidebar-mini.sidebar-collapse .main-header .navbar {
    margin-left: 0 !important;
  }

  /* ABIERTO: sidebar visible + contenido desplazado (no overlay) */
  html body.sidebar-mini:not(.sidebar-collapse) .main-sidebar,
  html body.sidebar-mini:not(.sidebar-collapse) .left-side {
    transform: translate3d(0, 0, 0) !important;
    width: var(--shell-sidebar-w) !important;
    min-width: var(--shell-sidebar-w) !important;
    max-width: var(--shell-sidebar-w) !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }

  html body.sidebar-mini:not(.sidebar-collapse) .content-wrapper,
  html body.sidebar-mini:not(.sidebar-collapse) .right-side,
  html body.sidebar-mini:not(.sidebar-collapse) .main-footer {
    margin-left: var(--shell-sidebar-w) !important;
    padding-left: 0 !important;
    transform: none !important;
    transition: margin-left var(--shell-sidebar-ease) !important;
  }

  html body.sidebar-mini:not(.sidebar-collapse) .main-header .navbar {
    margin-left: 0 !important; /* logo/header ya manejan el ancho */
  }

  /* Sin flyouts residuales al colapsar */
  html body.sidebar-mini.sidebar-collapse .sidebar-menu > li:hover > .treeview-menu,
  html body.sidebar-mini.sidebar-collapse .sidebar-menu > li > .treeview-menu,
  html body.sidebar-mini.sidebar-collapse .sidebar-menu > li:hover > a > span {
    display: none !important;
  }

  /* Desktop: no backdrop (no es overlay) */
  html body.sidebar-mini .shell-sidebar-backdrop {
    display: none !important;
  }
}

/* ========== MÓVIL: overlay + backdrop ========== */
@media (max-width: 767px) {
  html body.sidebar-mini .content-wrapper,
  html body.sidebar-mini .right-side,
  html body.sidebar-mini .main-footer {
    margin-left: 0 !important;
    transform: none !important;
  }

  html body.sidebar-mini:not(.sidebar-open) .main-sidebar,
  html body.sidebar-mini:not(.sidebar-open) .left-side {
    transform: translate3d(-110%, 0, 0) !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  html body.sidebar-mini.sidebar-open .main-sidebar,
  html body.sidebar-mini.sidebar-open .left-side {
    transform: translate3d(0, 0, 0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
    width: var(--shell-sidebar-w) !important;
  }

  html body.sidebar-mini.sidebar-open .content-wrapper,
  html body.sidebar-mini.sidebar-open .right-side,
  html body.sidebar-mini.sidebar-open .main-footer {
    transform: none !important; /* no empujar en móvil; overlay */
    margin-left: 0 !important;
  }

  .shell-sidebar-backdrop {
    position: fixed;
    inset: var(--shell-header-h) 0 0 0;
    background: var(--shell-sidebar-backdrop);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--shell-sidebar-ease), visibility var(--shell-sidebar-ease);
  }

  html body.sidebar-mini.sidebar-open .shell-sidebar-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
}

html body.sidebar-mini,
html body.sidebar-mini .wrapper {
  overflow-x: hidden;
}

html body.sidebar-mini .wrapper {
  background-color: #f7f9fc;
}

html body.menu3-page.sidebar-mini .wrapper,
html body.menu3-page.sidebar-mini .content-wrapper {
  background-color: #0b1220 !important;
}

/* ---- Header contextual (global) ---- */
.fge-header .fge-company-ctx {
  display: inline-flex !important;
  align-items: center;
  gap: 8px;
  max-width: 280px;
  padding: 5px 10px !important;
  border-radius: 10px !important;
  background: rgba(148, 163, 184, 0.12) !important;
  border: 1px solid rgba(148, 163, 184, 0.22) !important;
  color: #e2e8f0 !important;
  line-height: 1.15;
  text-decoration: none !important;
}

.fge-header .fge-company-ctx:hover {
  background: rgba(148, 163, 184, 0.18) !important;
  border-color: rgba(96, 165, 250, 0.35) !important;
}

.fge-header .fge-company-ctx__meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
}

.fge-header .fge-company-ctx__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  font-weight: 650;
}

.fge-header .fge-company-ctx__name {
  font-size: 12.5px;
  font-weight: 650;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}

.fge-header .fge-company-ctx__branch {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 190px;
}

.fge-header .fge-launchpad-link {
  background: transparent !important;
  border: 1px solid transparent !important;
}
.fge-header .fge-launchpad-link:hover {
  border-color: rgba(96, 165, 250, 0.35) !important;
}

.fge-header .fge-context-pill {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  padding: 2px 8px;
  line-height: 1.15;
  max-width: 220px;
}
.fge-header .fge-context-pill__emp {
  font-size: 11px;
  font-weight: 700;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fge-header .fge-context-pill__suc {
  font-size: 10.5px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 900px) {
  .fge-header .fge-company-ctx__branch,
  .fge-header .fge-company-ctx__label { display: none; }
  .fge-header .fge-company-ctx { max-width: 160px; }
}
