/* ════════════════════════════════════════════════════════════════════════
   MSINDAHA design system — APP SHELL
   Sidebar, topbar, main scroll area and page header. The React dashboards
   render .app-shell inside #root; the website pages put .sidebar and .main
   directly under <body> — both layouts are covered here.
════════════════════════════════════════════════════════════════════════ */
body {
  display: flex;
}
#root {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
}
.app-shell {
  display: flex;
  width: 100%;
  height: 100vh;
  position: relative;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  position: relative;
  z-index: 30;
  transition: width var(--dur-slow) var(--ease-out);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: var(--topbar-h);
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #3b82f6 0%, #6366f1 55%, #8b5cf6 100%);
  box-shadow:
    0 6px 16px -6px rgba(59, 130, 246, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}
.brand-text {
  flex: 1;
  min-width: 0;
}
.brand-name,
.sidebar-brand h1 {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-primary);
  line-height: 1.3;
}
.brand-sub,
.sidebar-brand p {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-toggle {
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 10px;
}
.nav-group + .nav-group {
  margin-top: 14px;
}
.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 4px 10px 6px;
  white-space: nowrap;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  height: 36px;
  padding: 0 10px;
  margin-bottom: 2px;
  border-radius: 8px;
  color: var(--text-sub);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  cursor: pointer;
  transition:
    background var(--dur-fast),
    color var(--dur-fast);
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-item.active {
  background: var(--accent-dim);
  color: var(--accent-text);
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.nav-item > svg {
  width: 18px;
  height: 18px;
}
.nav-item > svg + .nav-label + svg,
.nav-item > .nav-label ~ svg:last-child {
  width: 13px;
  height: 13px;
  opacity: 0.55;
}
.nav-label,
.nav-item > span[style] {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 99px;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-active);
  color: var(--text-sub);
}
.nav-badge:empty {
  display: none;
}
.nav-item.active .nav-badge {
  background: rgba(59, 130, 246, 0.24);
  color: var(--accent-text);
}
.nav-badge-red,
.nav-item.active .nav-badge-red {
  background: var(--danger);
  color: #fff;
}
.nav-accent {
  color: var(--purple-text);
}
.nav-accent:hover {
  background: var(--purple-dim);
  color: #ddd6fe;
}
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border-radius: 10px;
  min-width: 0;
}
.sidebar-user-text {
  min-width: 0;
  flex: 1;
}
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--success-text);
  white-space: nowrap;
}
.sidebar-status.offline {
  color: var(--warning-text);
}
.sidebar-status.offline .live-dot {
  background: var(--warning);
  animation: none;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  animation: pulseDot 2s infinite;
  flex-shrink: 0;
}
.live-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--success-text);
  text-transform: uppercase;
}

/* Icon rail: the React sidebar's collapsed state on wide screens, and the
   website pages' sidebar on narrow screens (they have no menu button). */
@media (min-width: 901px) {
  .sidebar.collapsed {
    width: var(--sidebar-w-collapsed);
  }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .nav-section-label,
  .sidebar.collapsed .sidebar-user-text,
  .sidebar.collapsed .sidebar-status-text,
  .sidebar.collapsed .nav-item > .nav-label ~ svg:last-child {
    display: none;
  }
  .sidebar.collapsed .sidebar-brand {
    flex-direction: column;
    gap: 8px;
    padding: 12px 0;
  }
  .sidebar.collapsed .nav-group + .nav-group {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--border);
  }
  .sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 0;
  }
  .sidebar.collapsed .nav-item.active::before {
    left: -10px;
  }
  .sidebar.collapsed .nav-badge {
    position: absolute;
    top: 1px;
    right: 3px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9.5px;
  }
  .sidebar.collapsed .sidebar-user,
  .sidebar.collapsed .sidebar-status {
    justify-content: center;
  }
}
@media (max-width: 900px) {
  body > .sidebar {
    width: var(--sidebar-w-collapsed);
  }
  body > .sidebar .brand-text,
  body > .sidebar .sidebar-brand p,
  body > .sidebar .sidebar-brand h1,
  body > .sidebar .nav-label,
  body > .sidebar .nav-item > span[style],
  body > .sidebar .nav-section-label,
  body > .sidebar .sidebar-user-text,
  body > .sidebar .sidebar-status-text {
    display: none;
  }
  body > .sidebar .sidebar-brand {
    justify-content: center;
    padding: 12px 0;
  }
  body > .sidebar .nav-item {
    justify-content: center;
    padding: 0;
  }
  body > .sidebar .nav-badge {
    position: absolute;
    top: 1px;
    right: 3px;
    min-width: 16px;
    height: 16px;
    font-size: 9.5px;
  }
}

/* ── Main column & topbar ── */
.main-col {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(8, 11, 19, 0.78);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  position: relative;
  z-index: 20;
}
.topbar .topbar-menu,
.topbar-page {
  display: none;
}
.topbar-page {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  width: min(460px, 100%);
  padding: 0 7px 0 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
  transition:
    border-color var(--dur-fast),
    color var(--dur-fast),
    background var(--dur-fast);
}
.topbar-search:hover {
  border-color: var(--border-strong);
  color: var(--text-sub);
  background: var(--bg-card-alt);
}
.topbar-search > svg {
  width: 15px;
  height: 15px;
}
.topbar-search-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kbd-combo {
  display: inline-flex;
  gap: 3px;
}
.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
}
.topbar-btn svg {
  width: 18px;
  height: 18px;
}
.topbar-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 6px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 8px 0 5px;
  border-radius: 11px;
  color: var(--text-sub);
  transition: background var(--dur-fast);
}
.user-chip:hover,
.user-chip.active {
  background: var(--bg-hover);
}
.user-chip > svg {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}
.user-chip-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  text-align: left;
  min-width: 0;
}
.user-chip-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  max-width: 150px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-chip-role {
  font-size: 11px;
  color: var(--text-muted);
}
.offline-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  color: var(--warning-text);
  background: var(--warning-dim);
  border: 1px solid rgba(245, 158, 11, 0.3);
  animation: fadeIn 0.3s ease;
}
.offline-pill svg {
  width: 14px;
  height: 14px;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 28px 32px 56px;
}
.main-col .main {
  height: auto;
}
.page,
.tab-pane {
  max-width: var(--page-max);
  margin: 0 auto;
  animation: pageIn 0.32s var(--ease-out);
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.45px;
  line-height: 1.25;
}
.page-header p {
  font-size: 13.5px;
  color: var(--text-sub);
  margin-top: 4px;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Mobile: off-canvas sidebar for the React shell ── */
.sidebar-scrim {
  display: none;
}
@media (max-width: 900px) {
  .app-shell .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-out);
    box-shadow: var(--shadow-lg);
    z-index: 360;
  }
  .app-shell .sidebar.mobile-open {
    transform: none;
  }
  .app-shell .sidebar-toggle {
    display: none;
  }
  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 350;
    background: var(--overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--dur-slow);
  }
  .sidebar-scrim.show {
    opacity: 1;
    pointer-events: auto;
  }
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }
  .topbar .topbar-menu {
    display: inline-grid;
  }
  .topbar-page {
    display: block;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .topbar-search {
    width: 38px;
    padding: 0;
    justify-content: center;
    border-color: transparent;
    background: transparent;
  }
  .topbar-search-text,
  .topbar-search .kbd-combo,
  .user-chip-text,
  .user-chip > svg,
  .topbar-sep {
    display: none;
  }
  .topbar-right {
    margin-left: 0;
  }
  .main {
    padding: 20px 16px 48px;
  }
  .page-header h2 {
    font-size: 21px;
  }
}
