/* App shell (feat/shell-redesign) — theme + layout for the top bar,
   left sidebar, and content frame.  Loaded AFTER bootstrap and the legacy
   style.css.  The shell only frames existing Bootstrap page content; it does
   not restyle individual pages. */

:root {
  --shell-accent: #4f46e5;
  --shell-sidebar-bg: #0f172a;
  --shell-sidebar-width: 248px;
  --shell-bg: #f8fafc;
  --shell-border: #e2e8f0;
  --shell-radius: 10px;
  --shell-topbar-height: 56px;
}

body.app-body {
  background-color: var(--shell-bg);
}

.app-shell {
  min-height: calc(100vh - var(--shell-topbar-height));
}

.app-main {
  min-width: 0; /* let tables shrink instead of overflowing the flex row */
}

.app-content {
  max-width: 1320px;
}

/* ---- Top bar ------------------------------------------------------------ */

.app-topbar {
  background-color: #fff;
  border-bottom: 1px solid var(--shell-border);
  min-height: var(--shell-topbar-height);
  z-index: 1040;
}

.app-brand {
  font-weight: 600;
  color: #0f172a;
}

.app-brand i {
  color: var(--shell-accent);
}

/* ---- Avatars ------------------------------------------------------------ */

.app-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1;
}

.app-avatar-lg {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 0.85rem;
}

/* ---- Client switcher ---------------------------------------------------- */

.app-switcher-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--shell-border);
  border-radius: 8px;
  background-color: #fff;
  padding: 0.3rem 0.6rem;
  max-width: 340px;
}

.app-switcher-name {
  font-weight: 600;
  max-width: 180px;
}

.app-fw-chip {
  background-color: #eef2ff;
  color: var(--shell-accent);
  font-weight: 600;
}

.app-switcher-panel {
  width: 340px;
  max-width: 92vw;
  border-radius: var(--shell-radius);
  border-color: var(--shell-border);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.12);
}

.app-switcher-list {
  max-height: 320px;
  overflow-y: auto;
}

.app-switcher-row.is-current {
  background-color: #f1f5f9;
}

.app-switcher-row.is-highlighted,
.app-switcher-row:hover {
  background-color: #eef2ff;
}

.app-switcher-footer .dropdown-item {
  flex: 1 1 0;
}

.app-switcher-static .app-switcher-name {
  font-weight: 600;
}

/* ---- Sidebar ------------------------------------------------------------ */

/* .offcanvas-lg forces transparent background above the lg breakpoint, so
   the sidebar color needs !important to win in both render modes. */
.app-sidebar {
  --bs-offcanvas-width: var(--shell-sidebar-width);
  background-color: var(--shell-sidebar-bg) !important;
  color: #cbd5e1;
  width: var(--shell-sidebar-width);
  flex-shrink: 0;
}

@media (min-width: 992px) {
  .app-sidebar {
    position: sticky !important;
    top: var(--shell-topbar-height);
    height: calc(100vh - var(--shell-topbar-height));
    overflow-y: auto;
  }
}

.app-sidebar .offcanvas-header {
  color: #fff;
}

.app-sidebar-client {
  padding: 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.app-sidebar-client-name {
  color: #fff;
}

/* Framework switcher inside the dark client block */
.app-sidebar-fw .badge {
  background-color: #312e81 !important;
  color: #c7d2fe;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-radius: 5px;
}

.app-sidebar-fw .text-muted {
  color: #94a3b8 !important;
}

.app-sidebar-fw a {
  color: #a5b4fc;
}

.app-sidebar-manage {
  color: #94a3b8;
  text-decoration: none;
  display: inline-block;
  margin-top: 0.5rem;
}

.app-sidebar-manage:hover {
  color: #fff;
}

.app-sidebar-group-label {
  color: #64748b;
  letter-spacing: 0.06em;
  font-size: 0.68rem;
  font-weight: 700;
}

.app-sidebar-link {
  color: #cbd5e1;
  padding: 0.42rem 0.65rem;
  font-size: 0.9rem;
  border-radius: 8px;
  margin: 1px 0.5rem;
}

.app-sidebar-link:hover,
.app-sidebar-link:focus {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.06);
}

.app-sidebar-link.active {
  color: #fff;
  font-weight: 600;
  background-color: var(--shell-accent);
}

.app-sidebar-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

/* ---- Content frame ------------------------------------------------------ */

.card {
  border-color: var(--shell-border);
  border-radius: var(--shell-radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.footer {
  background-color: transparent;
}

/* ---- Sidebar live badges / framework tags / compliance bar --------------
   feat/sidebar-live-badges: right-aligned count pills + tiny framework tag
   chips on sidebar items, and the client-block compliance bar.  Values per
   the approved mockup (dark-sidebar palette). */

.app-sidebar-link {
  display: flex;
  align-items: center;
}

/* Label span (first span after the icon) grows; badge/tag stay right.
   Plain <span> (no class) is load-bearing for nav render tests. */
.app-sidebar-link > span:first-of-type {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-left: 0.25rem;
}

.app-sidebar-badge {
  flex-shrink: 0;
  margin-left: 0.5rem;
  background-color: #334155;
  color: #cbd5e1;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.28em 0.6em;
}

.app-sidebar-badge-warn {
  background-color: #7c2d12;
  color: #fdba74;
}

.app-sidebar-tag {
  flex-shrink: 0;
  margin-left: 0.5rem;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.2;
  color: #818cf8;
  border: 1px solid #3730a3;
  border-radius: 4px;
  padding: 1px 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.app-sidebar-score {
  margin-top: 0.5rem;
}

.app-sidebar-score-label {
  color: #94a3b8;
}

.app-sidebar-score-pct {
  color: #fff;
  font-weight: 600;
}

.app-sidebar-score-track {
  height: 5px;
  margin-top: 0.25rem;
  background-color: #1e293b;
  border-radius: 999px;
  overflow: hidden;
}

.app-sidebar-score-fill {
  height: 100%;
  border-radius: 999px;
}

.app-sidebar-score-fill.app-score-amber {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}

.app-sidebar-score-fill.app-score-green {
  background: linear-gradient(90deg, #f59e0b, #22c55e);
}

/* ---- Switcher per-client compliance percent (mockup parity) ---- */

.app-switcher-score {
  margin-left: auto;
  flex-shrink: 0;
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.app-score-text-green {
  color: #16a34a;
}

.app-score-text-amber {
  color: #d97706;
}

/* ---- MSP home client-card grid (mockup parity) ---- */

.app-client-card {
  display: block;
  height: 100%;
  padding: 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.app-client-card:hover {
  color: inherit;
  border-color: #c7d2fe;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.app-client-card-new {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 132px;
  background: transparent;
  border: 2px dashed #cbd5e1;
  color: #64748b;
  font-weight: 600;
}

.app-client-card-new:hover {
  border-color: #4f46e5;
  color: #4f46e5;
  box-shadow: none;
}

.app-client-card-fw {
  min-height: 1.1em;
  color: #64748b;
}

.app-client-bar-track {
  height: 5px;
  margin: 0.5rem 0 0.4rem;
  background-color: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.app-client-bar-fill {
  height: 100%;
  border-radius: 999px;
}

.app-client-stats {
  font-size: 0.8rem;
  color: #475569;
}

.app-client-flag-ok {
  color: #16a34a;
  font-weight: 600;
}

.app-client-flag-warn {
  color: #d97706;
  font-weight: 600;
}

.app-client-flag-danger {
  color: #dc2626;
  font-weight: 600;
}

.app-client-bar-fill.app-score-amber {
  background: linear-gradient(90deg, #d97706, #f59e0b);
}

.app-client-bar-fill.app-score-green {
  background: linear-gradient(90deg, #4ade80, #22c55e);
}
