/* ============================================================
   TeamFlow — App shell: topnav, sidebar, main, right panel
   ============================================================ */

.app-shell {
  display: grid;
  grid-template-rows: var(--topnav-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas:
    "topnav topnav"
    "sidebar main";
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns var(--t-med) var(--ease);
}
.app-shell.sidebar-collapsed { grid-template-columns: 0 1fr; }
.app-shell.sidebar-collapsed .sidebar { transform: translateX(-100%); visibility: hidden; }

/* Drag-to-resize sidebar */
.sidebar { position: relative; }
.sidebar-resizer {
  position: absolute; top: 0; right: 0; width: 5px; height: 100%;
  cursor: col-resize; z-index: 65;
  transition: background-color var(--t-fast) var(--ease);
}
.sidebar-resizer:hover { background: rgba(255, 90, 31, 0.35); }
.app-shell.resizing { transition: none; user-select: none; }
.app-shell.resizing .sidebar { transition: none; }
.app-shell.resizing .sidebar-resizer { background: var(--primary); }
@media (max-width: 768px) { .sidebar-resizer { display: none; } }

/* Foldable nav sections */
.nav-section-label .fold-btn { width: 20px; height: 20px; font-size: 10px; }
.nav-section-label .fold-btn i { transition: transform var(--t-fast) var(--ease); }
.nav-section.folded .section-items { display: none; }
.nav-section.folded .fold-btn i { transform: rotate(-90deg); }
.nav-section-label .label-click { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.nav-section-label .label-click:hover { color: var(--ink-subtle); }

/* ---------- Top nav — 56px, canvas ---------- */
.topnav {
  grid-area: topnav;
  display: flex; align-items: center; gap: var(--s-md);
  height: var(--topnav-h);
  padding: 0 var(--s-md);
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 600; font-size: 16px; letter-spacing: -0.3px; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: #000; color: var(--on-primary); font-size: 13px;
  overflow: hidden; flex-shrink: 0;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topnav-search { flex: 1; max-width: 480px; margin: 0 auto; }
.topnav-search .input { background: var(--surface-1); min-height: 34px; }
.topnav-actions { display: flex; align-items: center; gap: var(--s-xxs); margin-left: auto; }
.topnav-actions .btn-icon { position: relative; }
.notif-dot {
  position: absolute; top: 5px; right: 5px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary); border: 1.5px solid var(--canvas);
}

/* ---------- Sidebar ---------- */
.sidebar {
  grid-area: sidebar;
  display: flex; flex-direction: column;
  background: var(--canvas);
  border-right: 1px solid var(--hairline);
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--s-sm) var(--s-xs);
  transition: transform var(--t-med) var(--ease);
  scrollbar-width: none;              /* Firefox: scroll works, bar hidden */
}
.sidebar::-webkit-scrollbar { display: none; }  /* Chrome/Edge/Safari */
.ws-switcher {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; margin-bottom: var(--s-sm);
  border-radius: var(--r-md); text-align: left;
  transition: background-color var(--t-fast) var(--ease);
}
.ws-switcher:hover { background: var(--surface-1); }
.ws-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid var(--hairline-strong);
  font-size: 12px; font-weight: 600;
  overflow: hidden; flex-shrink: 0;
}
.ws-logo img { width: 100%; height: 100%; object-fit: cover; }
.ws-name { font-size: 14px; font-weight: 600; }
.ws-plan { font-size: 11px; color: var(--ink-subtle); }

.nav-section { margin-bottom: var(--s-md); }
.nav-section-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; font-weight: 500; letter-spacing: 0.4px; text-transform: uppercase;
  color: var(--ink-tertiary); padding: 6px 10px 4px;
}
.nav-section-label .btn-icon { width: 20px; height: 20px; font-size: 10px; }

.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  font-size: 14px; color: var(--ink-muted); text-align: left;
  padding: 6px 10px; border-radius: var(--r-sm);
  transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-1); color: var(--ink); }
.nav-item.active { background: var(--surface-2); color: var(--ink); }
.nav-item i { width: 18px; text-align: center; font-size: 13px; color: var(--ink-subtle); }
.nav-item.active i { color: var(--primary-hover); }
.nav-item .count-pill { margin-left: auto; }
.nav-item .hash { color: var(--ink-tertiary); font-weight: 500; width: 18px; text-align: center; }
.nav-item.unread { color: var(--ink); font-weight: 600; }

/* ---------- Main ---------- */
.main {
  grid-area: main;
  overflow-y: auto;
  background: var(--canvas);
}
.main-inner { max-width: var(--content-max); margin: 0 auto; padding: var(--s-lg) var(--s-xl) var(--s-xxl); }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-md); margin-bottom: var(--s-lg); }
.page-title { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.6px; line-height: 1.2; }
.page-sub { font-size: 14px; color: var(--ink-subtle); margin-top: 4px; }

/* ---------- Split layout (chat: content + right panel) ---------- */
.split { display: grid; grid-template-columns: 1fr var(--rightpanel-w); height: 100%; overflow: hidden; }
.split.panel-hidden { grid-template-columns: 1fr 0; }
.split.panel-hidden .right-panel { display: none; }

.right-panel {
  position: relative;
  border-left: 1px solid var(--hairline);
  background: var(--canvas);
  overflow-y: auto;
  display: flex; flex-direction: column;
}
/* Drag-to-resize right panel (thread / members) — mirrors the sidebar */
.right-panel-resizer {
  position: absolute; top: 0; left: 0; width: 5px; height: 100%;
  cursor: col-resize; z-index: 65;
  transition: background-color var(--t-fast) var(--ease);
}
.right-panel-resizer:hover { background: rgba(255, 90, 31, 0.35); }
.app-shell.resizing .right-panel-resizer { background: var(--primary); }
@media (max-width: 768px) { .right-panel-resizer { display: none; } }
.right-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-sm) var(--s-md);
  border-bottom: 1px solid var(--hairline);
  font-size: 14px; font-weight: 600;
  min-height: 49px;
}

/* ---------- Responsive ---------- */
.hamburger { display: inline-flex; }

@media (max-width: 1024px) {
  .split { grid-template-columns: 1fr; }
  .right-panel { position: fixed; top: var(--topnav-h); right: 0; bottom: 0; width: var(--rightpanel-w); z-index: 70; box-shadow: -12px 0 32px rgba(0,0,0,0.35); display: none; }
  .split.panel-open .right-panel { display: flex; }
}

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 0 1fr; }
  .sidebar {
    position: fixed; top: var(--topnav-h); left: 0; bottom: 0;
    width: var(--sidebar-w); z-index: 80;
    transform: translateX(-100%);
    box-shadow: 12px 0 32px rgba(0,0,0,0.35);
  }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .hamburger { display: inline-flex; }
  .topnav-search { display: none; }
  .main-inner { padding: var(--s-md); }
  .page-title { font-size: 24px; }
}
