html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Open Sans', sans-serif;
    background: #f4f7fb;
    color: #334155;
}

* {
    box-sizing: border-box;
}

/* =========================
   TOPBAR
========================= */

.topbar {
    height: 68px;
    background: #fff; 
/*  background: #f8fafc; */
    border-bottom: 1px solid #e6ebf2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
}

.topbar-left,
.topbar-right {
    width: 260px;
    display: flex;
    align-items: center;
}

.topbar-right {
    justify-content: flex-end;
}

.topbar-center {
    flex: 1;
    text-align: center;
    font-family: 'Poppins', 'Open Sans', sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: #0f172a;
    letter-spacing: .02em;
}

.topbar-logo img {
    display: block;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    transition: background .18s ease;
}

.topbar-user:hover {
    background: rgba(53,75,113,0.06);
}

.topbar-user-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
}

.topbar-user-name {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
    line-height: 1.2;
    color: #23324a;
}

/* =========================
   LAYOUT
========================= */

.main-layout {
    display: flex;
    height: calc(100vh - 68px);
}

/* =========================
   SIDEBAR EXPANDIDA
========================= */

.sidebar {
    width: 370px;               /* +20px para el scroll ancho */
    scrollbar-gutter: stable;   /* reserva el lugar del scroll: el menú no se mueve al aparecer */
    background: #3a5178;
    color: #ffffff;
    overflow-y: auto;
    padding: 14px 0 20px;
    flex-shrink: 0;
}

.sidebar-group-title {
    padding: 10px 22px 14px;
    font-family: 'Poppins', 'Open Sans', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: #ffffff;
}

.sidebar-menu-wrap {
    padding: 0 10px 14px;
}

.sidebar-block {
    margin-bottom: 6px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 10px 14px;
    color: #ffffff;
    text-decoration: none;
    border-radius: 10px;
    font-family: 'Poppins', 'Open Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    transition: background .18s ease, transform .18s ease;
}

.sidebar-item:hover {
    background: rgba(255,255,255,0.08);
    transform: translateX(2px);
}

.sidebar-item-active {
    background: rgba(255,255,255,0.12);
    box-shadow: inset 3px 0 0 #ffffff;
}

.sidebar-subitem {
    display: block;
    padding: 7px 14px 7px 42px;
    color: rgba(255,255,255,0.82);
    line-height: 1.35;
    text-decoration: none;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 400;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.sidebar-subitem:hover {
    background: rgba(255,255,255,0.07);
    color: #ffffff;
    transform: translateX(2px);
}

.sidebar-divider {
    height: 1px;
    margin: 14px 10px;
    background: rgba(255,255,255,0.10);
}

.sidebar-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar-toggle-icon {
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

/* =========================
   SIDEBAR COLAPSADA
========================= */

.sidebar-collapsed {
    width: 52px;
    background: #354b71;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    flex-shrink: 0;
}

.sidebar-collapsed-top {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 48px;
}

.sidebar-collapsed-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    gap: 6px;
    min-height: 42px; 
    padding: 3px 5px; 
}

.sidebar-collapsed-item {
    width: 100%;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================
   CONTENIDO
========================= */

.main-content {
    flex: 1;
    background: #ffffff;
    min-width: 0;
}

.main-content iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}




/* =========================================================
   SCROLL ANCHO - GLOBAL
========================================================= */
html, body, * {
  scrollbar-width: auto;              /* Firefox: no acepta px, "auto" es el ancho */
  scrollbar-color: #8a94a6 #e5e7eb;   /* Firefox: barra / fondo */
}
::-webkit-scrollbar { width: 16px; height: 16px; }   /* Chrome, Edge, Safari */
::-webkit-scrollbar-track { background: #e5e7eb; }
::-webkit-scrollbar-thumb {
  background: #8a94a6;
  border-radius: 8px;
  border: 3px solid #e5e7eb;
}
::-webkit-scrollbar-thumb:hover { background: #5f6b80; }
::-webkit-scrollbar-corner { background: #e5e7eb; }


/* Menú mixto: opciones directas en el primer nivel */
.sidebar-block-direct { margin-bottom: 0; }                 /* directas seguidas = mismo grupo */
.sidebar-block-direct + .sidebar-block:not(.sidebar-block-direct) { margin-top: 8px; }
.sidebar-block .sidebar-item.sidebar-item-direct { min-height: 28px; padding: 4px 14px; }
.sidebar-divider-direct { margin: 8px 10px; }
.sidebar-item-bold  { font-weight: 600; color: #ffffff; }
.sidebar-item-plain { font-weight: 300; color: rgba(255,255,255,0.78); }
.sidebar-subitem-bold { font-weight: 600; color: #ffffff; }

/* Menú sin íconos: textos alineados a la izquierda, flecha en los capítulos */
.sidebar-menu-wrap .sidebar-item { gap: 0; }
.sidebar-menu-wrap .sidebar-subitem { padding-left: 26px; }
.sidebar-chevron {
    margin-left: auto;
    width: 7px;
    height: 7px;
    border-right: 2px solid rgba(255,255,255,0.75);
    border-bottom: 2px solid rgba(255,255,255,0.75);
    transform: translateY(-2px) rotate(45deg);          /* abajo: expandir */
    transition: transform .18s ease;
    flex-shrink: 0;
}
.sidebar-block.abierto .sidebar-chevron {
    transform: translateY(2px) rotate(-135deg);         /* arriba: contraer */
}
