/* ==========================================================================
   Supreonix Medical — Application Shell
   Sidebar + Top Header + Page Header + Mobile Navigation
   ========================================================================== */

.app { min-height: 100vh; }

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: var(--z-sidebar);
  display: flex; flex-direction: column;
  background: #0d1b2a;
  color: #cdd6e1;
  transition: width var(--dur-slow) var(--ease), transform var(--dur-slow) var(--ease);
}

.sidebar-brand {
  display: flex; align-items: center; gap: var(--sp-3);
  height: var(--header-h); flex: none;
  padding: 0 var(--sp-5);
  border-bottom: 1px solid rgba(255,255,255,.07);
  overflow: hidden;
}
.sidebar-logo {
  width: 32px; height: 32px; flex: none; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff; font-weight: var(--fw-bold); font-size: var(--fs-md);
}
.sidebar-brand-text { min-width: 0; }
.sidebar-brand-name {
  font-size: var(--fs-base); font-weight: var(--fw-semibold); color: #fff;
  letter-spacing: -0.01em; white-space: nowrap;
}
.sidebar-brand-sub { font-size: 11px; color: #7c8b9d; white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--sp-4) var(--sp-3) var(--sp-6); }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); background-clip: content-box; }

.nav-group + .nav-group { margin-top: var(--sp-6); }
.nav-group-label {
  padding: 0 var(--sp-3) var(--sp-2);
  font-size: 10.5px; font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: .08em;
  color: #6b7a8d; white-space: nowrap;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: var(--sp-3);
  height: 38px; padding: 0 var(--sp-3);
  border-radius: var(--r-md);
  color: #aebbc9; font-size: var(--fs-base); font-weight: var(--fw-medium);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.is-active { background: rgba(11,107,203,.22); color: #fff; font-weight: var(--fw-semibold); }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; background: var(--c-primary); border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-item.is-active svg { opacity: 1; }
.nav-item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  flex: none; min-width: 20px; height: 19px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-primary); color: #fff;
  border-radius: var(--r-full); font-size: 11px; font-weight: var(--fw-bold);
}
.nav-badge.alert { background: var(--c-danger); }
.nav-badge.muted { background: rgba(255,255,255,.14); color: #cdd6e1; }

.sidebar-foot {
  flex: none; padding: var(--sp-3);
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2); border-radius: var(--r-md);
  transition: background var(--dur-fast) var(--ease);
}
.sidebar-user:hover { background: rgba(255,255,255,.06); }
.sidebar-user .avatar { background: rgba(255,255,255,.12); color: #fff; }
.sidebar-user-body { min-width: 0; flex: 1; }
.sidebar-user-name { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: #fff; }
.sidebar-user-role { font-size: 11px; color: #7c8b9d; }
.sidebar-user svg { width: 16px; height: 16px; color: #7c8b9d; flex: none; }

/* Collapsed desktop sidebar */
.sidebar.is-collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.is-collapsed .sidebar-brand { padding: 0 var(--sp-4); }
.sidebar.is-collapsed .sidebar-brand-text,
.sidebar.is-collapsed .nav-group-label,
.sidebar.is-collapsed .nav-item-text,
.sidebar.is-collapsed .nav-badge,
.sidebar.is-collapsed .sidebar-user-body,
.sidebar.is-collapsed .sidebar-user > svg { display: none; }
.sidebar.is-collapsed .sidebar-nav { padding-inline: var(--sp-2); }
.sidebar.is-collapsed .nav-item { justify-content: center; padding: 0; }
.sidebar.is-collapsed .nav-item.is-active::before { left: -8px; }
.sidebar.is-collapsed .sidebar-user { justify-content: center; }

/* ==========================================================================
   Top header
   ========================================================================== */

.app-header {
  position: fixed; top: 0; right: 0; left: var(--sidebar-w);
  height: var(--header-h); z-index: var(--z-header);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: rgba(255,255,255,.88);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--c-border);
  transition: left var(--dur-slow) var(--ease);
}
.sidebar.is-collapsed ~ .app-main .app-header { left: var(--sidebar-w-collapsed); }

.header-toggle {
  width: 34px; height: 34px; flex: none; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--c-text-muted); transition: all var(--dur-fast) var(--ease);
}
.header-toggle:hover { background: var(--c-surface-sunken); color: var(--c-text); }
.header-toggle svg { width: 18px; height: 18px; }

.breadcrumbs { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; }
.breadcrumbs a, .breadcrumbs span {
  font-size: var(--fs-sm); color: var(--c-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.breadcrumbs a:hover { color: var(--c-primary); }
.breadcrumbs .sep { color: var(--c-text-faint); flex: none; }
.breadcrumbs .current { color: var(--c-text); font-weight: var(--fw-semibold); }

.header-search { flex: 1 1 auto; max-width: 440px; }
.header-search .input { height: 36px; min-height: 36px; background: var(--c-surface-sunken); border-color: transparent; }
.header-search .input:hover { background: var(--c-surface); border-color: var(--c-border-strong); }
.header-search .input:focus { background: var(--c-surface); border-color: var(--c-primary); }
.header-search .input-icon { top: 50%; transform: translateY(-50%); }

.header-actions { display: flex; align-items: center; gap: var(--sp-2); margin-left: auto; }

.header-btn {
  position: relative;
  width: 36px; height: 36px; flex: none; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--c-text-muted);
  transition: all var(--dur-fast) var(--ease);
}
.header-btn:hover { background: var(--c-surface-sunken); color: var(--c-text); }
.header-btn svg { width: 18px; height: 18px; }
.header-btn .dot {
  position: absolute; top: 7px; right: 7px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-danger); border: 2px solid var(--c-surface);
}

.header-user {
  display: flex; align-items: center; gap: var(--sp-2);
  height: 36px; padding: 0 var(--sp-2) 0 var(--sp-1);
  border-radius: var(--r-md);
  transition: background var(--dur-fast) var(--ease);
}
.header-user:hover { background: var(--c-surface-sunken); }
.header-user svg { width: 15px; height: 15px; color: var(--c-text-faint); }
.header-user-name { font-size: var(--fs-sm); font-weight: var(--fw-medium); }

/* Org / context switcher chip */
.switcher {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  height: 34px; padding: 0 var(--sp-3);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  background: var(--c-surface);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  transition: all var(--dur-fast) var(--ease);
}
.switcher:hover { background: var(--c-surface-sunken); }
.switcher svg { width: 15px; height: 15px; color: var(--c-text-faint); }

/* ==========================================================================
   Main content region
   ========================================================================== */

.app-main { padding-left: var(--sidebar-w); transition: padding-left var(--dur-slow) var(--ease); }
.sidebar.is-collapsed ~ .app-main { padding-left: var(--sidebar-w-collapsed); }

.app-content { padding: var(--sp-6); }
@media (max-width: 900px) { .app-content { padding: var(--sp-5); } }
@media (max-width: 640px) { .app-content { padding: var(--sp-4); padding-bottom: calc(var(--bottomnav-h) + var(--sp-6)); } }

/* ==========================================================================
   Page header
   ========================================================================== */

.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--sp-5); flex-wrap: wrap;
  margin-bottom: var(--sp-6);
}
.page-header-main { min-width: 0; flex: 1 1 320px; }
.page-header-eyebrow {
  font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--c-primary); margin-bottom: var(--sp-2);
}
.page-title {
  font-size: var(--fs-2xl); font-weight: var(--fw-bold);
  letter-spacing: -0.025em; color: var(--c-text);
}
.page-desc { font-size: var(--fs-base); color: var(--c-text-muted); margin-top: var(--sp-2); max-width: 70ch; }
.page-header-actions { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; }
@media (max-width: 640px) {
  .page-header { gap: var(--sp-4); margin-bottom: var(--sp-5); }
  .page-title { font-size: var(--fs-xl); }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { flex: 1 1 auto; }
}

/* Section heading inside content */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-4);
}
.section-title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }

/* ==========================================================================
   Stat cards
   ========================================================================== */

.stat {
  display: flex; flex-direction: column; gap: var(--sp-4);
  padding: var(--sp-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.stat:hover { box-shadow: var(--sh-sm); border-color: var(--c-border-strong); }
.stat-top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-3); }
.stat-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--c-text-muted); }
.stat-icon {
  width: 38px; height: 38px; flex: none; border-radius: var(--r-md);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-primary-50); color: var(--c-primary);
}
.stat-icon svg { width: 19px; height: 19px; }
.stat-icon.accent { background: var(--c-accent-50); color: var(--c-accent); }
.stat-icon.success { background: var(--c-success-bg); color: var(--c-success); }
.stat-icon.warning { background: var(--c-warning-bg); color: var(--c-warning); }
.stat-icon.danger { background: var(--c-danger-bg); color: var(--c-danger); }
.stat-value { font-size: var(--fs-3xl); font-weight: var(--fw-bold); letter-spacing: -0.03em; line-height: 1; }
.stat-foot { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--c-text-muted); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: var(--fw-semibold); }
.trend.up { color: var(--c-success); }
.trend.down { color: var(--c-danger); }
.trend svg { width: 13px; height: 13px; }

/* ==========================================================================
   Dashboard grid
   ========================================================================== */

.dash-grid { display: grid; gap: var(--sp-5); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.dash-grid > .col-3 { grid-column: span 3; }
.dash-grid > .col-4 { grid-column: span 4; }
.dash-grid > .col-5 { grid-column: span 5; }
.dash-grid > .col-6 { grid-column: span 6; }
.dash-grid > .col-7 { grid-column: span 7; }
.dash-grid > .col-8 { grid-column: span 8; }
.dash-grid > .col-9 { grid-column: span 9; }
.dash-grid > .col-12 { grid-column: span 12; }
@media (max-width: 1200px) {
  .dash-grid > .col-3 { grid-column: span 6; }
  .dash-grid > .col-4 { grid-column: span 6; }
  .dash-grid > .col-5 { grid-column: span 12; }
  .dash-grid > .col-7 { grid-column: span 12; }
  .dash-grid > .col-8 { grid-column: span 12; }
  .dash-grid > .col-9 { grid-column: span 12; }
}
@media (max-width: 760px) {
  .dash-grid { gap: var(--sp-4); }
  .dash-grid > [class^="col-"] { grid-column: span 12; }
}

/* ==========================================================================
   Activity feed / timeline
   ========================================================================== */

.feed-item {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  transition: background var(--dur-fast) var(--ease);
}
.feed-item:hover { background: var(--c-surface-2); }
.feed-dot {
  width: 30px; height: 30px; flex: none; border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--c-surface-sunken); color: var(--c-text-muted);
}
.feed-dot svg { width: 15px; height: 15px; }
.feed-dot.primary { background: var(--c-primary-50); color: var(--c-primary); }
.feed-dot.success { background: var(--c-success-bg); color: var(--c-success); }
.feed-dot.warning { background: var(--c-warning-bg); color: var(--c-warning); }
.feed-dot.danger { background: var(--c-danger-bg); color: var(--c-danger); }
.feed-body { flex: 1; min-width: 0; }
.feed-text { font-size: var(--fs-base); color: var(--c-text-secondary); }
.feed-text strong { color: var(--c-text); font-weight: var(--fw-semibold); }
.feed-time { font-size: var(--fs-xs); color: var(--c-text-faint); margin-top: 2px; }

/* List rows (recent items) */
.list-row {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  transition: background var(--dur-fast) var(--ease);
}
.list-row:hover { background: var(--c-surface-2); }
.list-row + .list-row { border-top: 1px solid var(--c-border); }
.list-body { flex: 1; min-width: 0; }
.list-title { font-size: var(--fs-base); font-weight: var(--fw-semibold); }
.list-sub { font-size: var(--fs-xs); color: var(--c-text-muted); }
.list-meta { font-size: var(--fs-xs); color: var(--c-text-faint); white-space: nowrap; }

/* ==========================================================================
   Mobile bottom navigation
   ========================================================================== */

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: var(--z-sidebar);
  display: none; align-items: stretch;
  background: rgba(255,255,255,.94);
  backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--c-border);
}
.bottomnav-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--c-text-muted);
  font-size: 10.5px; font-weight: var(--fw-medium);
  transition: color var(--dur-fast) var(--ease);
  position: relative;
}
.bottomnav-item svg { width: 21px; height: 21px; }
.bottomnav-item.is-active { color: var(--c-primary); font-weight: var(--fw-semibold); }
.bottomnav-item .nav-badge {
  position: absolute; top: 6px; left: 50%; margin-left: 6px;
  min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px;
}

/* Mobile sidebar backdrop */
.sidebar-backdrop {
  position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1);
  background: var(--c-overlay);
  opacity: 0; visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
.sidebar-backdrop.is-open { opacity: 1; visibility: visible; }

/* ==========================================================================
   Responsive shell behaviour
   ========================================================================== */

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--sh-xl); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar.is-collapsed { width: var(--sidebar-w); }
  .sidebar.is-collapsed .sidebar-brand-text,
  .sidebar.is-collapsed .nav-group-label,
  .sidebar.is-collapsed .nav-item-text,
  .sidebar.is-collapsed .nav-badge,
  .sidebar.is-collapsed .sidebar-user-body,
  .sidebar.is-collapsed .sidebar-user > svg { display: revert; }
  .sidebar.is-collapsed .nav-item { justify-content: flex-start; padding: 0 var(--sp-3); }
  .app-main, .sidebar.is-collapsed ~ .app-main { padding-left: 0; }
  .app-header, .sidebar.is-collapsed ~ .app-main .app-header { left: 0; }
}

@media (max-width: 640px) {
  .app-header { padding: 0 var(--sp-4); gap: var(--sp-2); }
  .header-search { display: none; }
  .header-user-name { display: none; }
  .breadcrumbs { display: none; }
  .bottomnav { display: flex; }
}

/* ==========================================================================
   Auth / centered shell (admin login)
   ========================================================================== */

.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-6);
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--c-primary-50), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, var(--c-accent-50), transparent 55%),
    var(--c-bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  padding: var(--sp-8);
}
@media (max-width: 480px) { .auth-card { padding: var(--sp-6); } }
.auth-logo {
  width: 46px; height: 46px; border-radius: var(--r-lg);
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--c-primary), var(--c-accent));
  color: #fff; font-weight: var(--fw-bold); font-size: var(--fs-lg);
  margin-bottom: var(--sp-5);
}
