/* ============================================================
   Shell Layout — Sidebar 52px | Topbar 44px | Sub-nav | Content | Status 26px
   ============================================================ */

/* App wrapper */
.shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.shell-sidebar {
  width: 52px;
  min-width: 52px;
  background: var(--bg2);
  border-right: 1px solid var(--brd2);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 0;
  gap: 4px;
  z-index: 20;
}

.shell-sidebar-logo {
  width: 32px;
  height: 32px;
  margin-bottom: 8px;
  object-fit: contain;
}

.shell-sidebar-item {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r1);
  color: var(--t3);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-decoration: none;
  position: relative;
}

.shell-sidebar-item:hover {
  background: var(--brd2);
  color: var(--t1);
}

.shell-sidebar-item.active {
  background: var(--a-med);
  color: var(--accent);
}

.shell-sidebar-item svg {
  width: 20px;
  height: 20px;
}

.shell-sidebar-spacer {
  flex: 1;
}

/* Sidebar tooltip */
.shell-sidebar-item[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg3);
  color: var(--t1);
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast);
  z-index: 100;
}

.shell-sidebar-item[data-tooltip]:hover::after {
  opacity: 1;
}

/* ---- Main area ---- */
.shell-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ---- Topbar ---- */
.shell-topbar {
  height: 44px;
  min-height: 44px;
  background: var(--bg2);
  border-bottom: 1px solid var(--brd2);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 10;
}

.shell-topbar-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--t1);
  white-space: nowrap;
}

.shell-topbar-spacer {
  flex: 1;
}

.shell-topbar-clock {
  font-size: 0.72rem;
  color: var(--t2);
  font-variant-numeric: tabular-nums;
}

.shell-topbar-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r1);
  border: none;
  background: transparent;
  color: var(--t2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}

.shell-topbar-btn:hover {
  background: var(--brd2);
  color: var(--t1);
}

.shell-topbar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--a-med);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
}

/* ---- Sub-nav (horizontal tabs) ---- */
.shell-subnav {
  height: 40px;
  min-height: 40px;
  background: var(--bg);
  border-bottom: 1px solid var(--brd);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 2px;
  overflow-x: auto;
}

.shell-subnav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  height: 32px;
  border-radius: var(--r1);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--t2);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  border: none;
  background: transparent;
}

.shell-subnav-tab:hover {
  background: var(--brd2);
  color: var(--t1);
}

.shell-subnav-tab.active {
  background: var(--a-soft);
  color: var(--accent);
}

.shell-subnav-tab svg {
  width: 16px;
  height: 16px;
}

/* ---- Content area ---- */
.shell-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

.shell-pad {
  padding: 20px;
}

/* ---- Loading overlay ---- */
.shell-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.1);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.shell-loading-card {
  background: var(--bg2);
  border-radius: var(--r2);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.2);
  color: var(--t1);
  font-size: 0.82rem;
}

.shell-loading-spin {
  display: inline-flex;
  animation: shell-spin 1s linear infinite;
  color: var(--accent);
}

@keyframes shell-spin {
  to { transform: rotate(360deg); }
}

/* ---- Status bar ---- */
.shell-status {
  height: 26px;
  min-height: 26px;
  background: var(--bg2);
  border-top: 1px solid var(--brd);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 16px;
  font-size: 0.65rem;
  color: var(--t3);
}

.shell-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  display: inline-block;
  margin-right: 4px;
}

.shell-status-dot.warn { background: var(--warn); }
.shell-status-dot.err { background: var(--err); }

/* ---- Mobile hamburger (hidden by default) ---- */
.shell-hamburger {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--t2);
  cursor: pointer;
}

/* ---- Mobile overlay ---- */
.shell-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 15;
}

.shell-overlay.visible {
  display: block;
}

/* ---- Sidebar toggle button ---- */
.shell-sidebar-toggle {
  width: 38px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r1);
  border: none;
  background: transparent;
  color: var(--t3);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  margin-bottom: 4px;
}

.shell-sidebar-toggle:hover {
  background: var(--brd2);
  color: var(--t1);
}

.shell-sidebar-toggle svg {
  width: 16px;
  height: 16px;
}

/* ---- Sidebar labels (hidden in collapsed mode) ---- */
.shell-sidebar-label {
  display: none;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Sidebar expanded state ---- */
.shell-sidebar {
  transition: width var(--t-med), min-width var(--t-med);
}

.shell-sidebar.expanded {
  width: 200px;
  min-width: 200px;
  align-items: stretch;
  padding: 8px;
}

.shell-sidebar.expanded .shell-sidebar-logo {
  align-self: center;
}

.shell-sidebar.expanded .shell-sidebar-toggle {
  align-self: center;
}

.shell-sidebar.expanded .shell-sidebar-item {
  width: auto;
  height: 36px;
  justify-content: flex-start;
  padding: 0 10px;
  gap: 10px;
}

.shell-sidebar.expanded .shell-sidebar-label {
  display: inline;
}

/* Hide tooltips when sidebar is expanded */
.shell-sidebar.expanded .shell-sidebar-item[data-tooltip]::after {
  display: none;
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */

/* 1100px — tighter spacing */
@media (max-width: 1100px) {
  .shell-pad {
    padding: 16px;
  }
}

/* 900px — sidebar collapses, hamburger appears */
@media (max-width: 900px) {
  .shell-sidebar {
    position: fixed;
    left: -52px;
    top: 0;
    bottom: 0;
    transition: left var(--t-med);
    z-index: 20;
    width: 52px;
    min-width: 52px;
    align-items: center;
    padding: 8px 0;
  }

  .shell-sidebar.expanded {
    width: 52px;
    min-width: 52px;
    align-items: center;
    padding: 8px 0;
  }

  .shell-sidebar.expanded .shell-sidebar-item {
    width: 38px;
    height: 38px;
    justify-content: center;
    padding: 0;
    gap: 0;
  }

  .shell-sidebar.expanded .shell-sidebar-label {
    display: none;
  }

  .shell-sidebar-toggle {
    display: none;
  }

  .shell-sidebar.open {
    left: 0;
  }

  .shell-hamburger {
    display: flex;
  }
}

/* 650px — compact mode */
@media (max-width: 650px) {
  .shell-topbar {
    padding: 0 10px;
    gap: 8px;
  }

  .shell-topbar-clock {
    display: none;
  }

  .shell-subnav {
    padding: 0 10px;
  }

  .shell-subnav-tab {
    padding: 0 8px;
    font-size: 0.7rem;
  }

  .shell-pad {
    padding: 12px;
  }

  .shell-status {
    font-size: 0.6rem;
    padding: 0 8px;
  }
}
