/* ── Portal Shell Styles ─────────────────────────────────────────────────────
   Sidebar · Desktop topbar · Main layout · Quick-search overlay · Mobile
   Consumed exclusively by portal.html
──────────────────────────────────────────────────────────────────────────── */

:root {
  /* portal-shell tokens — override colour via --color-primary from design-system.css */
  --green:       var(--color-primary, #198754);
  --teal:        var(--clr-teal, #0f9d8a);
  --bg:          #f0f2f5;
  --slate:       #0f172a;
  --sb-bg:       #0b1523;
  --sb-border:   rgba(255,255,255,.06);
  --sb-w:        252px;
  --sb-c:        68px;
  --tx:          .24s cubic-bezier(.4,0,.2,1);
  --accent:      var(--clr-teal, #0f9d8a);
  --accent-dim:  rgba(15,157,138,.13);
  --accent-glow: rgba(15,157,138,.22);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font-body, "Plus Jakarta Sans", system-ui, -apple-system, sans-serif);
  background: var(--bg);
  color: var(--slate);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ══════════════════════════════════════════════════════
   SHELL LAYOUT
══════════════════════════════════════════════════════ */
.app-shell { display: flex; min-height: 100vh; }

/* ══════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sb-w);
  min-height: 100vh;
  background: var(--sb-bg);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  transition: width var(--tx);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sb-c); }

/* ── top accent bar ── */
.sb-accent {
  height: 3px;
  background: linear-gradient(90deg, var(--color-primary, #198754), var(--clr-teal, #0f9d8a), #06b6d4);
  flex-shrink: 0;
}

/* ── brand ── */
.sb-brand {
  height: 64px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  overflow: hidden;
}
.sb-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-primary, #198754), var(--clr-teal, #0f9d8a));
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 900; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(15,157,138,.28);
  letter-spacing: .04em;
}
.sb-brand-text { flex: 1; overflow: hidden; transition: opacity var(--tx); }
.sidebar.collapsed .sb-brand-text { opacity: 0; pointer-events: none; }
.sb-brand-name {
  font-size: .78rem; font-weight: 800; color: #fff;
  letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap; line-height: 1.2;
}
.sb-brand-sub {
  font-size: .6rem; color: rgba(255,255,255,.28);
  white-space: nowrap; margin-top: 2px; letter-spacing: .02em;
}

/* collapse toggle */
.sb-toggle {
  width: 26px; height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.32);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background .13s, color .13s, transform var(--tx);
}
.sb-toggle:hover { background: rgba(255,255,255,.1); color: rgba(255,255,255,.75); }
.sidebar.collapsed .sb-toggle { transform: rotate(180deg); }

/* ── search bar ── */
.sb-search {
  margin: 10px 10px 4px;
  position: relative; flex-shrink: 0;
  transition: opacity var(--tx), max-height var(--tx), margin var(--tx);
  max-height: 40px; opacity: 1; overflow: hidden;
}
.sidebar.collapsed .sb-search { max-height: 0; opacity: 0; margin-top: 0; margin-bottom: 0; }
.sb-search input {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 9px;
  color: rgba(255,255,255,.65);
  font-size: .74rem; font-weight: 500;
  padding: 7px 34px 7px 30px;
  outline: none; cursor: pointer;
  transition: border .13s, background .13s;
  font-family: inherit;
}
.sb-search input::placeholder { color: rgba(255,255,255,.22); }
.sb-search input:focus { border-color: var(--accent-glow); background: rgba(255,255,255,.07); }
.sb-si { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,.24); font-size: .78rem; pointer-events: none; }
.sb-kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: .53rem; padding: 1px 4px; border-radius: 4px; border: 1px solid rgba(255,255,255,.1); color: rgba(255,255,255,.18); pointer-events: none; }

/* ── nav scrollable area ── */
.sb-nav { flex: 1; padding: 6px 0 0; overflow-y: auto; overflow-x: hidden; }
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.08); border-radius: 3px; }

/* ── section ── */
.sb-section { padding: 14px 0 2px; }
.sb-section:first-child { padding-top: 6px; }
.sb-label {
  padding: 0 16px 6px;
  font-size: .55rem; font-weight: 800;
  letter-spacing: .16em; text-transform: uppercase;
  color: rgba(255,255,255,.18);
  white-space: nowrap;
  transition: opacity var(--tx), max-height var(--tx), padding var(--tx);
  max-height: 24px; opacity: 1; overflow: hidden;
}
.sidebar.collapsed .sb-label { max-height: 0; opacity: 0; padding-top: 0; padding-bottom: 0; }
.sb-items { padding: 0 8px; }

/* ── nav link ── */
.sb-link {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 0 10px;
  border: none; background: none;
  color: rgba(255,255,255,.42);
  text-decoration: none; text-align: left;
  font-size: .78rem; font-weight: 600;
  cursor: pointer;
  height: 40px; border-radius: 11px; margin: 1px 0;
  transition: background .13s, color .13s;
  white-space: nowrap; overflow: hidden;
  position: relative;
  font-family: inherit;
}
.sb-link i {
  width: 18px; font-size: .92rem;
  flex-shrink: 0; text-align: center;
  transition: color .13s;
}
.sb-lt { flex: 1; overflow: hidden; text-overflow: ellipsis; transition: opacity var(--tx); }
.sidebar.collapsed .sb-lt { opacity: 0; }
.sidebar.collapsed .sb-link { justify-content: center; padding: 0; }

.sb-link:hover { background: rgba(255,255,255,.06); color: rgba(255,255,255,.78); }
.sb-link:hover i { color: rgba(255,255,255,.78); }

/* active */
.sb-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}
.sb-link.active i { color: var(--accent); }
.sidebar.collapsed .sb-link.active { box-shadow: none; }

/* tooltip on collapsed */
.sidebar.collapsed .sb-link[title]:hover::after {
  content: attr(title);
  position: absolute;
  left: calc(var(--sb-c));
  top: 50%; transform: translateY(-50%);
  background: #1a2f4a;
  color: rgba(255,255,255,.88);
  font-size: .73rem; font-weight: 600;
  padding: 5px 11px; border-radius: 8px;
  white-space: nowrap; pointer-events: none;
  z-index: 9999;
  box-shadow: 0 6px 18px rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.08);
}

/* external link indicator */
.sb-link.newtab .sb-lt::after { content: " ↗"; font-size: .6em; opacity: .38; }

/* section divider */
.sb-sep { height: 1px; margin: 6px 10px; background: var(--sb-border); }

/* ── live widget ── */
.sb-live-wrap {
  margin: 8px 8px 4px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.02);
  overflow: hidden;
  transition: opacity var(--tx), max-height var(--tx), margin var(--tx);
  max-height: 160px; opacity: 1;
}
.sidebar.collapsed .sb-live-wrap { max-height: 0; opacity: 0; margin: 0; }
.sb-live-hd {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 11px; cursor: pointer;
}
.sb-live-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0;
  animation: ps-pulse 2s infinite;
}
@keyframes ps-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(52,211,153,.5); }
  50%      { box-shadow: 0 0 0 4px rgba(52,211,153,0); }
}
.sb-live-lbl  { font-size: .68rem; font-weight: 700; color: rgba(255,255,255,.38); flex: 1; }
.sb-live-chev { font-size: .65rem; color: rgba(255,255,255,.2); transition: transform .2s; }
.sb-live-wrap.open .sb-live-chev { transform: rotate(180deg); }
.sb-live-frame {
  display: block; width: 100%; height: 0;
  border: none; background: transparent;
  transition: height .24s;
}
.sb-live-wrap.open .sb-live-frame { height: 112px; }

/* ── bottom user area ── */
.sb-bottom {
  padding: 12px 8px;
  border-top: 1px solid var(--sb-border);
  flex-shrink: 0;
}
.sb-user {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: 12px; margin-bottom: 7px;
  overflow: hidden; cursor: default;
  transition: background .13s;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.05);
}
.sb-user:hover { background: rgba(255,255,255,.06); }
.sb-avatar {
  width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--color-primary, #198754), var(--clr-teal, #0f9d8a));
  color: #fff; font-size: .65rem; font-weight: 900;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(15,157,138,.2);
}
.sb-uinfo { flex: 1; overflow: hidden; transition: opacity var(--tx); }
.sidebar.collapsed .sb-uinfo { opacity: 0; pointer-events: none; }
.sb-uname { color: rgba(255,255,255,.72); font-size: .72rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-urole { font-size: .58rem; color: rgba(255,255,255,.25); white-space: nowrap; }

.sb-logout {
  width: 100%; padding: 7px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.07);
  background: transparent; color: rgba(255,255,255,.28);
  font-size: .72rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  cursor: pointer; transition: all .13s; overflow: hidden;
  font-family: inherit;
}
.sb-logout-t { transition: opacity var(--tx); }
.sidebar.collapsed .sb-logout-t { opacity: 0; }
.sb-logout:hover { background: rgba(239,68,68,.09); border-color: rgba(239,68,68,.24); color: #fca5a5; }

/* ══════════════════════════════════════════════════════
   MOBILE BACKDROP
══════════════════════════════════════════════════════ */
.mob-backdrop {
  display: none; position: fixed; inset: 0;
  background: rgba(11,21,35,.6); z-index: 250;
  backdrop-filter: blur(3px);
}
.mob-backdrop.open { display: block; }

/* ══════════════════════════════════════════════════════
   MAIN AREA
══════════════════════════════════════════════════════ */
.main {
  margin-left: var(--sb-w);
  width: calc(100% - var(--sb-w));
  min-height: 100vh;
  background: var(--bg);
  transition: margin-left var(--tx), width var(--tx);
}
.main.sb-col { margin-left: var(--sb-c); width: calc(100% - var(--sb-c)); }

/* ── mobile top bar ── */
.mob-topbar {
  display: none; position: sticky; top: 0; z-index: 420;
  min-height: 56px;
  padding: max(env(safe-area-inset-top),0px) 14px 0;
  background: var(--sb-bg); border-bottom: 1px solid rgba(255,255,255,.07);
  align-items: center; justify-content: space-between;
  box-shadow: 0 4px 16px rgba(11,21,35,.2);
}
.mob-ham {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.14); background: rgba(255,255,255,.07);
  color: #fff; display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.mob-title { color: rgba(255,255,255,.88); font-size: .88rem; font-weight: 800; }

/* ── DESKTOP TOPBAR ── */
.desk-topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  height: 68px; min-height: 68px;
  background: #ffffff;
  border-bottom: 1px solid rgba(15,23,42,.07);
  box-shadow: 0 1px 3px rgba(15,23,42,.05), 0 4px 16px rgba(15,23,42,.04);
  position: sticky; top: 0; z-index: 100; width: 100%;
}
.dt-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.dt-sec-chip {
  display: inline-flex; align-items: center;
  background: var(--color-primary-soft, rgba(25,135,84,.09)); color: var(--color-primary, #198754);
  border: 1px solid rgba(25,135,84,.18);
  border-radius: 20px; padding: 3px 11px;
  font-size: .65rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .08em;
  white-space: nowrap; flex-shrink: 0;
}
.dt-titles { min-width: 0; }
.dt-title { font-size: 1rem; font-weight: 800; color: var(--slate); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dt-sub   { font-size: .7rem; color: #64748b; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }

.dt-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.dt-icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid #e2e8f0; background: #f8fafc;
  color: #64748b; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .9rem;
  transition: background .13s, border-color .13s, color .13s;
  position: relative;
}
.dt-icon-btn:hover { background: var(--color-primary-light, #ecfdf5); border-color: #86efac; color: var(--color-primary, #198754); }

.dt-badge {
  position: absolute; top: -3px; right: -3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #ef4444; color: #fff;
  font-size: .52rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid #fff;
}

.dt-divider { width: 1px; height: 26px; background: #e2e8f0; flex-shrink: 0; }

.dt-user {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 7px;
  border-radius: 12px; cursor: pointer;
  background: #f8fafc; border: 1px solid #e2e8f0;
  transition: background .13s, border-color .13s;
}
.dt-user:hover { background: var(--color-primary-light, #ecfdf5); border-color: #86efac; }
.dt-av {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--color-primary, #198754), var(--clr-teal, #0f9d8a));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: .65rem; font-weight: 900; flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(25,135,84,.2);
}
.dt-ui { display: flex; flex-direction: column; }
.dt-uname { font-size: .74rem; font-weight: 700; color: var(--slate); line-height: 1.2; white-space: nowrap; }
.dt-urole { font-size: .6rem; color: #64748b; white-space: nowrap; }

/* ── WORKSPACE ── */
.workspace-card {
  margin: 0; padding: 14px;
}
.workspace-frame {
  display: block;
  width: 100%; border: none; background: #fff;
  border-radius: 18px;
  box-shadow:
    0 0 0 1px rgba(15,23,42,.06),
    0 4px 12px rgba(15,23,42,.06),
    0 16px 40px rgba(15,23,42,.06);
  height: calc(100vh - 68px - 28px);
  min-height: 400px;
  transition: box-shadow .2s;
}
.workspace-frame:hover {
  box-shadow:
    0 0 0 1px rgba(15,23,42,.08),
    0 4px 16px rgba(15,23,42,.08),
    0 20px 48px rgba(15,23,42,.08);
}

/* ══════════════════════════════════════════════════════
   QUICK SEARCH OVERLAY
══════════════════════════════════════════════════════ */
.qs-overlay {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(11,21,35,.55); backdrop-filter: blur(5px);
  align-items: flex-start; justify-content: center;
  padding-top: 100px;
}
.qs-overlay.open { display: flex; }
.qs-box {
  width: 480px; max-width: 92vw;
  background: #0f1e32;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 18px;
  box-shadow: 0 28px 72px rgba(0,0,0,.55);
  overflow: hidden;
  animation: qsIn .17s ease;
}
@keyframes qsIn { from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:translateY(0)} }
.qs-ir {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.qs-ir i { color: rgba(255,255,255,.32); font-size: 1rem; }
.qs-in {
  flex: 1; background: none; border: none; outline: none;
  color: #fff; font-size: .9rem; font-weight: 500; font-family: inherit;
}
.qs-in::placeholder { color: rgba(255,255,255,.2); }
.qs-res { padding: 6px; max-height: 320px; overflow-y: auto; }
.qs-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; cursor: pointer;
  transition: background .1s;
  color: rgba(255,255,255,.58); font-size: .8rem; font-weight: 600;
}
.qs-item:hover, .qs-item.hi { background: rgba(52,211,153,.09); color: #fff; }
.qs-item:hover i, .qs-item.hi i { color: var(--accent); }
.qs-item i { width: 18px; text-align: center; color: rgba(255,255,255,.26); font-size: .88rem; flex-shrink: 0; }
.qs-item-label { flex: 1; }
.qs-item-sec { font-size: .6rem; color: rgba(255,255,255,.2); font-weight: 500; padding: 2px 7px; background: rgba(255,255,255,.04); border-radius: 20px; }
.qs-ft {
  padding: 8px 16px; border-top: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 8px;
  font-size: .62rem; color: rgba(255,255,255,.18);
}
.qs-k { padding: 2px 5px; border: 1px solid rgba(255,255,255,.13); border-radius: 4px; font-size: .57rem; }

/* ══════════════════════════════════════════════════════
   FOCUS-VISIBLE — keyboard navigation
══════════════════════════════════════════════════════ */
.sb-link:focus-visible,
.sb-toggle:focus-visible,
.sb-logout:focus-visible,
.mob-ham:focus-visible,
.dt-icon-btn:focus-visible,
.dt-user:focus-visible {
  outline: 2px solid var(--color-primary, #198754);
  outline-offset: 2px;
}
.qs-in:focus-visible {
  outline: 2px solid var(--color-primary, #198754);
  outline-offset: 0;
}

/* ══════════════════════════════════════════════════════
   RESPONSIVE — TABLET (861px – 1100px)
   Sidebar collapses by default to give content more room.
══════════════════════════════════════════════════════ */
@media (min-width: 861px) and (max-width: 1100px) {
  :root { --sb-w: 220px; }
}

/* ══════════════════════════════════════════════════════
   MOBILE QS BUTTON (injected by portal-shell-bootstrap.js)
══════════════════════════════════════════════════════ */
.mob-qs-btn {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.8);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .9rem; flex-shrink: 0;
}
.mob-qs-btn:hover { background: rgba(255,255,255,.14); }

/* ══════════════════════════════════════════════════════
   RESPONSIVE — MOBILE (≤ 860px)
══════════════════════════════════════════════════════ */
@media (max-width: 860px) {
  .sidebar {
    width: min(84vw, 290px) !important;
    transform: translateX(-100%);
    box-shadow: 0 20px 48px rgba(11,21,35,.45);
    transition: transform .28s cubic-bezier(.4,0,.2,1) !important;
  }
  .sidebar.mob-open { transform: translateX(0) !important; }

  /* reset collapsed overrides on mobile */
  .sb-label, .sb-brand-text, .sb-lt, .sb-uinfo, .sb-logout-t,
  .sb-search, .sb-live-wrap { max-height: unset !important; opacity: 1 !important; margin: revert !important; padding: revert !important; }
  .sb-link { justify-content: flex-start !important; padding: 0 10px !important; }
  .sb-link.active { box-shadow: inset 3px 0 0 var(--accent) !important; }
  .sb-toggle { display: none; }

  .main, .main.sb-col { margin-left: 0; width: 100%; transition: none; }
  .mob-topbar { display: flex !important; }
  .desk-topbar { display: none; }
}

/* ══════════════════════════════════════════════════════
   SAFE-AREA INSETS (notch phones, iOS Safari)
══════════════════════════════════════════════════════ */
@supports (padding: max(0px, env(safe-area-inset-bottom))) {
  .sb-bottom { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
}
