/* سايدبار موحّد — يعتمد على unified-theme.css */

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width .22s ease;
  overflow: hidden;
  position: relative;
  z-index: 10;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sb-header {
  padding: 12px 12px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  flex-shrink: 0;
  position: relative;
}
.sidebar.collapsed .sb-header {
  padding: 10px 6px;
  gap: 0;
  justify-content: center;
  min-height: var(--topbar-h);
}
.sidebar.collapsed .sb-logo,
.sidebar.collapsed .sb-title { display: none; }

.sb-logo {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
  padding: 0;
}
.sb-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  mix-blend-mode: lighten;
}
.sb-title {
  font-size: 12.5px;
  font-weight: 700;
  color: rgba(255, 255, 255, .9);
  white-space: nowrap;
  text-align: center;
  line-height: 1.3;
}

.sb-toggle {
  position: absolute;
  top: 8px;
  left: 8px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, .4);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: color .15s, background .15s;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.sidebar.collapsed .sb-toggle { position: static; }
.sb-toggle:hover { color: rgba(255, 255, 255, .9); background: rgba(255, 255, 255, .08); }
.sb-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
}

aside.sidebar .sb-nav,
.sidebar .sb-nav {
  flex: 1;
  padding: 6px 8px 10px !important;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}
aside.sidebar .sb-nav::-webkit-scrollbar,
.sidebar .sb-nav::-webkit-scrollbar { width: 4px; }
aside.sidebar .sb-nav::-webkit-scrollbar-track,
.sidebar .sb-nav::-webkit-scrollbar-track { background: transparent; }
aside.sidebar .sb-nav::-webkit-scrollbar-thumb,
.sidebar .sb-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .16);
  border-radius: 99px;
}
aside.sidebar .sb-nav::-webkit-scrollbar-thumb:hover,
.sidebar .sb-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(219, 162, 39, .45);
}

aside.sidebar .sb-item,
.sidebar .sb-item {
  display: flex !important;
  align-items: center;
  gap: 10px;
  margin: 2px 0 !important;
  padding: 9px 10px !important;
  cursor: pointer;
  color: rgba(255, 255, 255, .55);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  border: none !important;
  border-right: 2.5px solid transparent !important;
  border-radius: 8px !important;
  background: transparent !important;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
  user-select: none;
  text-decoration: none;
  box-sizing: border-box;
}
aside.sidebar .sb-item:hover,
.sidebar .sb-item:hover {
  color: rgba(255, 255, 255, .92) !important;
  background: rgba(255, 255, 255, .07) !important;
  border-right-color: rgba(255, 255, 255, .22) !important;
}
aside.sidebar .sb-item.active,
.sidebar .sb-item.active {
  color: var(--gold-light) !important;
  background: rgba(219, 162, 39, .14) !important;
  border-right-color: var(--gold) !important;
  font-weight: 700;
}
aside.sidebar .sb-item.active:hover,
.sidebar .sb-item.active:hover {
  color: var(--gold-light) !important;
  background: rgba(219, 162, 39, .18) !important;
  border-right-color: var(--gold) !important;
}
.sb-item[hidden],
.sb-item.is-hidden { display: none !important; }

.sb-item-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sb-item-icon svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sb-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .sb-nav { padding: 6px 4px; }
.sidebar.collapsed .sb-item {
  justify-content: center;
  padding: 10px 6px;
  margin: 2px 0;
  border-right-width: 0;
  border-right-color: transparent;
}
.sidebar.collapsed .sb-item.active {
  background: rgba(219, 162, 39, .16);
  box-shadow: inset 0 0 0 1px rgba(219, 162, 39, .35);
}
.sidebar.collapsed .sb-item-label { display: none; }

.sb-badge {
  background: #e24b4a;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  flex-shrink: 0;
  min-width: 18px;
  text-align: center;
}
.sidebar.collapsed .sb-badge { display: none; }

.sb-section {
  padding: 14px 10px 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .8px;
  color: rgba(255, 255, 255, .28);
  white-space: nowrap;
  text-transform: uppercase;
}
.sidebar.collapsed .sb-section { display: none; }
.sb-section.is-hidden { display: none !important; }

.sb-footer {
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  flex-shrink: 0;
  position: relative;
}
.sb-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}
.sb-user:hover { background: rgba(255, 255, 255, .06); }
.sb-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(219, 162, 39, .18);
  border: 1.5px solid rgba(219, 162, 39, .3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
  overflow: hidden;
}
.sb-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.sb-user-info { flex: 1; min-width: 0; }
.sidebar.collapsed .sb-user-info,
.sidebar.collapsed .role-tag,
.sidebar.collapsed .sb-user-caret { display: none; }
.sidebar.collapsed .sb-footer .sb-user { justify-content: center; }
.sb-user-name {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, .85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-user-role {
  font-size: 10px;
  color: rgba(255, 255, 255, .35);
  white-space: nowrap;
}
.role-tag {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(219, 162, 39, .15);
  color: var(--gold-light);
  letter-spacing: .3px;
  flex-shrink: 0;
}
.sb-user-caret {
  color: rgba(255, 255, 255, .3);
  font-size: 11px;
  flex-shrink: 0;
  transition: transform .15s;
  margin-right: 2px;
}
.sb-user.open .sb-user-caret { transform: rotate(180deg); }

.user-menu {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  right: 10px;
  left: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 50;
}
.user-menu.open { display: block; }
.umi {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  transition: background .12s;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.umi:last-child { border-bottom: none; }
.umi:hover { background: var(--bg); }
.umi.cur { color: var(--navy); background: #f0f5fb; }
.umi svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  flex-shrink: 0;
}
.umi.danger { color: var(--danger); }
.umi.danger:hover { background: var(--danger-bg); }

/* تخطيط الجذر (index.html): سايدبار ثابت */
.page-wrapper.unified-shell {
  display: flex;
  min-height: 100vh;
}
.page-wrapper.unified-shell > .sidebar {
  position: fixed;
  right: 0;
  top: 0;
  height: 100%;
}
.page-wrapper.unified-shell > .main-content {
  margin-right: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  transition: margin-right .22s ease;
  width: auto;
}
.page-wrapper.unified-shell.sidebar-collapsed > .main-content {
  margin-right: var(--sidebar-collapsed);
}
.page-wrapper.unified-shell.sidebar-collapsed > .sidebar {
  width: var(--sidebar-collapsed);
}
