/* Client Portal responsive shell — desktop left nav, mobile drawer, pinned panels */

html.portal-shell-on,
html.portal-shell-on body {
  height: 100%;
  overflow: hidden;
}

html.portal-shell-on body {
  margin: 0;
  background:
    radial-gradient(1400px 700px at 75% -15%, rgba(39, 203, 227, 0.06), transparent 55%),
    radial-gradient(1000px 560px at 8% 110%, rgba(242, 92, 92, 0.05), transparent 55%),
    #0a0b1a;
}

.portal-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh;
  max-height: 100dvh;
  width: 100%;
  margin: 0 auto;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(39, 203, 227, 0.07), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(242, 92, 92, 0.07), transparent 60%),
    var(--bg, #0d0e24);
  color: var(--text, #F5F0EA);
}

/* Desktop / large screens: center the shell with comfortable side margins */
@media (min-width: 900px) {
  .portal-shell {
    --shell-side-gap: clamp(20px, 4vw, 64px);
    --shell-max: 1180px;
    width: min(var(--shell-max), calc(100% - (var(--shell-side-gap) * 2)));
    height: calc(100dvh - 20px);
    max-height: calc(100dvh - 20px);
    margin: 10px auto;
    border-radius: 16px;
    border: 1px solid var(--border, rgba(245, 240, 234, 0.12));
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
    overflow: hidden;
  }
}

/* Ultrawide: a bit more breathing room, still centered and readable */
@media (min-width: 1600px) {
  .portal-shell {
    --shell-side-gap: clamp(48px, 8vw, 140px);
    --shell-max: 1280px;
  }
}

@media (min-width: 2200px) {
  .portal-shell {
    --shell-side-gap: clamp(80px, 12vw, 220px);
    --shell-max: 1320px;
  }
}

.portal-shell .shell-top {
  flex: 0 0 auto;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border, rgba(245, 240, 234, 0.12));
  background: rgba(13, 14, 36, 0.94);
  z-index: 20;
}

.portal-shell .shell-top .brand { margin: 0; }
.portal-shell .shell-top .brand img { height: 40px; }
.portal-shell .shell-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.portal-shell .shell-menu-btn {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--border, rgba(245, 240, 234, 0.12));
  background: var(--surface, #161736);
  color: var(--text, #F5F0EA);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.portal-shell .shell-menu-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.portal-shell .shell-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  position: relative;
}

.portal-shell .portal-side-nav {
  flex: 0 0 250px;
  width: 250px;
  background: var(--surface, #161736);
  border-right: 1px solid var(--border, rgba(245, 240, 234, 0.12));
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  overflow: auto;
  z-index: 15;
}

.portal-shell .nav-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint, #6a6780);
  padding: 4px 10px 8px;
}
.portal-shell .nav-group {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint, #6a6780);
  padding: 10px 10px 4px;
}
.portal-shell .nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted, #A09DB0);
  font-family: var(--font-body, inherit);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.portal-shell .nav-btn:hover {
  color: var(--text, #F5F0EA);
  background: var(--surface-2, #1e2045);
}
.portal-shell .nav-btn[aria-current="true"] {
  color: var(--cream, #FDF5E6);
  background: rgba(39, 203, 227, 0.1);
  border-color: rgba(39, 203, 227, 0.35);
}
.portal-shell .nav-btn .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint, #6a6780);
  flex-shrink: 0;
}
.portal-shell .nav-btn[aria-current="true"] .dot { background: var(--cyan, #27CBE3); }
.portal-shell .nav-meta {
  margin-top: auto;
  padding: 12px 10px;
  font-size: 0.72rem;
  color: var(--text-faint, #6a6780);
  line-height: 1.45;
  border-top: 1px solid var(--divider, rgba(245, 240, 234, 0.08));
}

/* Single compact footer (one line on desktop) — replaces page footer + sidebar contact */
.portal-shell .shell-footer {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0 8px;
  padding: 7px 14px;
  min-height: 0;
  font-size: 0.7rem;
  line-height: 1.2;
  color: var(--text-faint, #6a6780);
  border-top: 1px solid var(--border, rgba(245, 240, 234, 0.12));
  background: rgba(10, 11, 26, 0.96);
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.portal-shell .shell-footer::-webkit-scrollbar { display: none; }
.portal-shell .shell-footer .footer-brand {
  font-family: var(--font-display, inherit);
  font-weight: 700;
  color: var(--text-muted, #A09DB0);
  font-size: 0.72rem;
}
.portal-shell .shell-footer a {
  color: var(--text-muted, #A09DB0);
  text-decoration: none;
}
.portal-shell .shell-footer a:hover { color: var(--cream, #FDF5E6); }
.portal-shell .shell-footer-sep {
  color: var(--text-faint, #6a6780);
  opacity: 0.7;
  user-select: none;
}

@media (max-width: 520px) {
  .portal-shell .shell-footer {
    flex-wrap: wrap;
    white-space: normal;
    justify-content: center;
    text-align: center;
    row-gap: 4px;
    padding: 8px 12px;
  }
}

.portal-shell .shell-nav-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 12;
  border: none;
  cursor: pointer;
}

.portal-shell .shell-main {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.portal-shell .shell-main .live-bar {
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border, rgba(245, 240, 234, 0.12));
}

.portal-shell #content.panels {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

/* Internal scrollbars — thin, brand-matched (almost invisible until hover) */
.portal-shell .portal-side-nav,
.portal-shell #content.panels,
.portal-shell .chat-thread,
.portal-shell .revision-thread,
.portal-shell .panel-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(39, 203, 227, 0.28) transparent;
}
.portal-shell .portal-side-nav::-webkit-scrollbar,
.portal-shell #content.panels::-webkit-scrollbar,
.portal-shell .chat-thread::-webkit-scrollbar,
.portal-shell .revision-thread::-webkit-scrollbar,
.portal-shell .panel-scroll::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.portal-shell .portal-side-nav::-webkit-scrollbar-track,
.portal-shell #content.panels::-webkit-scrollbar-track,
.portal-shell .chat-thread::-webkit-scrollbar-track,
.portal-shell .revision-thread::-webkit-scrollbar-track,
.portal-shell .panel-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.portal-shell .portal-side-nav::-webkit-scrollbar-thumb,
.portal-shell #content.panels::-webkit-scrollbar-thumb,
.portal-shell .chat-thread::-webkit-scrollbar-thumb,
.portal-shell .revision-thread::-webkit-scrollbar-thumb,
.portal-shell .panel-scroll::-webkit-scrollbar-thumb {
  background: rgba(160, 157, 176, 0.28);
  border-radius: 99px;
  border: 1px solid transparent;
  background-clip: padding-box;
}
.portal-shell .portal-side-nav:hover::-webkit-scrollbar-thumb,
.portal-shell #content.panels:hover::-webkit-scrollbar-thumb,
.portal-shell .chat-thread:hover::-webkit-scrollbar-thumb,
.portal-shell .revision-thread:hover::-webkit-scrollbar-thumb,
.portal-shell .panel-scroll:hover::-webkit-scrollbar-thumb {
  background: rgba(39, 203, 227, 0.45);
}
.portal-shell .portal-side-nav::-webkit-scrollbar-corner,
.portal-shell #content.panels::-webkit-scrollbar-corner {
  background: transparent;
}

.portal-shell .panel {
  background: var(--surface, #161736);
  border: 1px solid var(--border, rgba(245, 240, 234, 0.12));
  border-radius: var(--radius, 14px);
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-bottom: 0;
  padding: 0;
}

.portal-shell .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: inherit;
  font-family: inherit;
  text-align: left;
}
.portal-shell button.panel-head { cursor: pointer; }
.portal-shell button.panel-head:hover { background: rgba(245, 240, 234, 0.03); }
.portal-shell .panel.is-pinned .panel-head { cursor: default; }

.portal-shell .panel-title {
  font-family: var(--font-display, inherit);
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--cyan, #27CBE3);
  margin: 0;
}

.portal-shell .panel-chevron {
  width: 18px;
  height: 18px;
  color: var(--text-muted, #A09DB0);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}
.portal-shell .panel.is-open .panel-chevron {
  transform: rotate(180deg);
  color: var(--cyan, #27CBE3);
}

.portal-shell .panel-body {
  display: none;
  border-top: 1px solid var(--divider, rgba(245, 240, 234, 0.08));
}
.portal-shell .panel.is-pinned .panel-body,
.portal-shell .panel.is-open .panel-body {
  display: block;
}
.portal-shell .panel-scroll {
  padding: 14px 16px 18px;
}

/* Hide old single-column page chrome when shell is on */
html.portal-shell-on .page { display: none !important; }
html.portal-shell-on > footer {
  display: none !important; /* one footer only: .shell-footer inside the shell */
}

/* Mobile: drawer nav */
@media (max-width: 899px) {
  .portal-shell .shell-menu-btn { display: inline-flex; }
  .portal-shell .portal-side-nav {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(290px, 88%);
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
  }
  .portal-shell.nav-open .portal-side-nav { transform: translateX(0); }
  .portal-shell.nav-open .shell-nav-backdrop { display: block; }
}

/* When shell + mobile-ux: hide redundant jump nav (side nav replaces it) */
html.portal-shell-on .portal-jump-nav {
  display: none !important;
}

/* Sticky CTA still OK on mobile */
html.portal-shell-on .portal-sticky-cta.is-ready {
  z-index: 30;
}
