/* ========================= SIDEBAR ========================= */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; z-index: 50;
  transition: width .25s var(--ease), transform .25s var(--ease);
}
.sb-logo {
  height: var(--header-h); flex: 0 0 var(--header-h);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  color: #fff; font-weight: 700; font-size: 21px; letter-spacing: .4px;
  padding: 0 16px;
}
.sb-logo .mark { width: 34px; height: 34px; flex: 0 0 34px; }
.sb-logo small { display: block; font-size: 9.5px; font-weight: 500; letter-spacing: 2.2px; color: #8C8BB5; margin-top: -2px; }
.sb-logo .wordmark { line-height: 1.1; }

.sb-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px 0 30px; scrollbar-color: #2E2C58 transparent; }
.sb-scroll::-webkit-scrollbar-thumb { background: #2E2C58; }

.sb-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .9px; text-transform: uppercase;
  color: var(--sidebar-label); padding: 22px 28px 8px; white-space: nowrap;
}
.sb-list { list-style: none; margin: 0; padding: 0; }
.sb-item { position: relative; }

.sb-link {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 20px 11px 26px; margin: 1px 0;
  color: var(--sidebar-text); font-size: 13.8px; white-space: nowrap;
  border: 0; background: none; width: 100%; text-align: left; position: relative;
  transition: color .15s, background .15s;
}
.sb-link:hover { color: #fff; }
.sb-link .sb-ic { width: 20px; height: 20px; flex: 0 0 20px; display: grid; place-items: center; opacity: .82; }
.sb-link .sb-ic svg { width: 19px; height: 19px; }
.sb-link .sb-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sb-link .sb-caret { width: 14px; height: 14px; opacity: .6; transition: transform .2s; }
.sb-item.open > .sb-link .sb-caret { transform: rotate(90deg); }
.sb-badge { background: var(--danger); color: #fff; font-size: 10px; font-weight: 600; border-radius: 10px; padding: 1px 7px; }

/* Estado activo: pestaña lavanda conectada al área de contenido */
.sb-item.active > .sb-link {
  background: var(--bg); color: var(--primary); font-weight: 500;
  margin-left: 14px; width: calc(100% - 14px);
  padding-left: 6px; border-radius: 30px 0 0 30px;
}
.sb-item.active > .sb-link .sb-ic {
  width: 38px; height: 38px; flex-basis: 38px; border-radius: 50%; opacity: 1;
  background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(var(--primary-rgb), .16);
}
.sb-item.active > .sb-link .sb-ic svg { width: 18px; height: 18px; }
.sb-item.active > .sb-link::before,
.sb-item.active > .sb-link::after {
  content: ""; position: absolute; right: 0; width: 24px; height: 24px; background: transparent; pointer-events: none;
}
.sb-item.active > .sb-link::before { top: -24px; border-bottom-right-radius: 24px; box-shadow: 8px 8px 0 8px var(--bg); }
.sb-item.active > .sb-link::after { bottom: -24px; border-top-right-radius: 24px; box-shadow: 8px -8px 0 8px var(--bg); }

/* Submenús */
.sb-sub { list-style: none; margin: 0; padding: 4px 0 6px; display: none; }
.sb-item.open > .sb-sub { display: block; }
.sb-sub a {
  display: flex; align-items: center; gap: 12px; padding: 8px 18px 8px 34px; color: var(--sidebar-text); font-size: 13px;
  white-space: nowrap;
}
.sb-sub a::before {
  content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-top: 1.5px solid currentColor;
  transform: rotate(45deg); opacity: .55; flex: 0 0 6px;
}
.sb-sub a:hover { color: #fff; }
.sb-sub a.active { color: #fff; font-weight: 600; }
.sb-sub a.active::before { opacity: 1; }

/* Pie: tarjeta de perfil demo */
.sb-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.sb-role-card { display: flex; align-items: center; gap: 10px; background: var(--sidebar-hover); border-radius: 10px; padding: 9px 10px; border: 0; width: 100%; color: #fff; text-align: left; }
.sb-role-card .av { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; flex: 0 0 32px; }
.sb-role-card small { display: block; color: #8C8BB5; font-size: 10.5px; }
.sb-role-card b { font-weight: 500; font-size: 12.5px; }

/* Colapsado (desktop) */
body.sb-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sb-collapsed .sb-logo .wordmark,
body.sb-collapsed .sb-label,
body.sb-collapsed .sb-link .sb-text,
body.sb-collapsed .sb-link .sb-caret,
body.sb-collapsed .sb-badge,
body.sb-collapsed .sb-role-card div { display: none; }
body.sb-collapsed .sb-label { display: block; height: 14px; padding: 0; font-size: 0; }
body.sb-collapsed .sb-link { justify-content: center; padding-left: 0; padding-right: 0; }
body.sb-collapsed .sb-item.active > .sb-link { margin-left: 10px; width: calc(100% - 10px); justify-content: flex-start; padding-left: 8px; }
body.sb-collapsed .sb-sub { display: none !important; }
body.sb-collapsed .sb-item:hover > .sb-sub,
body.sb-collapsed .sb-item.flyout > .sb-sub {
  display: block !important; position: fixed; left: var(--sidebar-w-collapsed); margin-top: -44px; background: var(--sidebar);
  border-radius: 0 10px 10px 0; min-width: 210px; box-shadow: var(--shadow-lg); z-index: 70;
}
body.sb-collapsed .sb-role-card { justify-content: center; }
