/*
 * shell.css — Dockbox user dashboard shell chrome overrides.
 * Restyles sidebar, topbar, content-wrap, and right-sidebar using design tokens
 * from tokens.css. All colors are token-only (no hardcoded hex).
 * Load order: style.css → tokens.css → shell.css
 */

/* ============================================================
   App root — flat two-column layout (sidebar + main)
   ============================================================ */

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  font-family: var(--font);
}

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

.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  margin: 0;
  position: fixed;
  left: 0;
  top: 0;
  background: var(--bg-elev);
  border: none;
  border-right: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
  opacity: 1;
  transform: none;
  transition: none;
  z-index: 100;
}

/* Undo the fly-in animation from style.css */
.sidebar {
  transform: translateX(0) !important;
  opacity: 1 !important;
}

/* ---- Logo ---- */

.sidebar-logo {
  padding: var(--sp-4) var(--sp-3) var(--sp-3);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}

.sidebar-logo-text {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--text);
  display: inline;
  opacity: 1;
  white-space: nowrap;
}

/* ---- Nav ---- */

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  padding: var(--sp-3) var(--sp-3);
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

#navPinned {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

#navShelf {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

/* ---- Nav items ---- */

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  height: auto;
  padding: var(--sp-2) var(--sp-3);
  margin: 0;
  border-radius: var(--r-md);
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  color: var(--text-dim);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
  justify-content: flex-start;
  transform: none;
}

.nav-item:hover {
  background: var(--bg-sunken);
  color: var(--text);
  transform: none;
  box-shadow: none;
}

.nav-item.active {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  border-radius: var(--r-md);
  box-shadow: none;
  transform: none;
  font-weight: 600;
}

.nav-item.active .nav-icon {
  color: var(--accent);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-label {
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Show label by default (sidebar is full-width with tokens) */
.sidebar .nav-label,
.sidebar-logout-btn .nav-label {
  display: inline;
  opacity: 1;
}

/* ---- Shelf toggle ---- */

.nav-shelf-toggle {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-faint);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: background 0.15s, color 0.15s;
  margin-top: var(--sp-2);
}

.nav-shelf-toggle:hover {
  background: var(--bg-sunken);
  color: var(--text-dim);
}

.nav-shelf-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s;
}

.nav-shelf-toggle.open svg {
  transform: rotate(180deg);
}

/* ---- Fullscreen item at bottom ---- */

a.nav-item#btnFullscreen {
  margin-top: auto;
}

/* ---- Footer ---- */

.sidebar-footer {
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  justify-content: flex-start;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}

.sidebar-logout-btn:hover {
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

.sidebar-logout-btn .nav-label {
  display: inline;
  font-size: var(--fs-sm);
  font-weight: 500;
}

/* Hide tooltip pseudo-elements (labels are always visible) */
.sidebar-logout-btn[data-tooltip]::after,
.nav-item[data-tooltip]::after {
  display: none !important;
}

/* ---- Status strip ---- */

.sidebar-status {
  padding: var(--sp-2) var(--sp-1);
}

.sidebar-status:empty {
  display: none;
}

.sidebar-status-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  color: var(--text-dim);
  cursor: default;
  transition: background 0.15s;
}

.sidebar-status-item:hover {
  background: var(--bg-sunken);
}

/* ============================================================
   Main area (flex column: topbar + content-wrap)
   ============================================================ */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  margin-left: var(--sidebar-w);
}

/* ============================================================
   Topbar
   ============================================================ */

.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-5);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.topbar-username {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.topbar-userid {
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--text-faint);
  opacity: 1;
}

/* ---- Topbar icon buttons ---- */

.topbar-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--r-md);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.topbar-btn:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.topbar-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================================
   Content wrap (main content + right sidebar)
   ============================================================ */

.content-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
  background: var(--bg);
}

.content-wrap .content {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

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

.right-sidebar {
  width: var(--rsb-w);
  flex-shrink: 0;
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width 0.2s ease, opacity 0.2s ease;
}

.right-sidebar.collapsed {
  width: 0;
  opacity: 0;
  overflow: hidden;
  border-left: none;
}

.rsb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  min-height: 44px;
  flex-shrink: 0;
}

.rsb-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.rsb-close {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  font-size: 1.1rem;
  color: var(--text-faint);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  padding: 0;
  line-height: 1;
}

.rsb-close:hover {
  background: var(--bg-sunken);
  color: var(--text);
}

.rsb-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.rsb-body::-webkit-scrollbar {
  width: 4px;
}

.rsb-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.rsb-section {
  margin-bottom: var(--sp-5);
}

.rsb-section-title {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--sp-2);
}

.rsb-hint {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  line-height: 1.55;
}

.rsb-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-1) 0;
  border-bottom: 1px solid var(--border);
}

.rsb-stat-label {
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

.rsb-stat-value {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text);
}

.rsb-action-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: var(--fs-sm);
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
  margin-bottom: var(--sp-1);
}

.rsb-action-btn:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

/* ============================================================
   Left Sidebar — Collapsible (collapsed rail)
   ============================================================ */

/* Sidebar collapse toggle button */
#btnSidebarToggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  border-radius: var(--r-sm);
  color: var(--text-faint);
  cursor: pointer;
  flex-shrink: 0;
  margin-left: auto;
  transition: background 0.15s, color 0.15s;
  padding: 0;
}

#btnSidebarToggle:hover {
  background: var(--bg-sunken);
  color: var(--text-dim);
}

#btnSidebarToggle svg {
  width: 16px;
  height: 16px;
  transition: transform 0.25s ease;
}

/* Transition for smooth collapse/expand */
.sidebar {
  transition: width 0.25s ease !important;
}

/* Collapsed state — icon-only rail */
.sidebar.collapsed {
  width: 64px;
  overflow: hidden;
}

/* Hide labels when collapsed */
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-logo-text {
  display: none;
}

/* Center icons when collapsed */
.sidebar.collapsed .nav-item,
.sidebar.collapsed .sidebar-logout-btn,
.sidebar.collapsed .nav-shelf-toggle {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

/* Keep the logo area tidy when collapsed */
.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  padding-left: var(--sp-2);
  padding-right: var(--sp-2);
}

/* Hide the sidebar toggle button label text (button has only icon) */
.sidebar.collapsed #btnSidebarToggle {
  margin-left: 0;
}

/* Rotate chevron when collapsed */
.sidebar.collapsed #btnSidebarToggle svg {
  transform: rotate(180deg);
}

/* Show tooltips on nav items when sidebar is collapsed */
.sidebar.collapsed .nav-item[data-tooltip]::after,
.sidebar.collapsed .sidebar-logout-btn[data-tooltip]::after,
.sidebar.collapsed .nav-shelf-toggle[data-tooltip]::after {
  display: block !important;
}

/* Main content offset — shrinks when sidebar is collapsed.
   #sidebar is position:fixed so it doesn't affect flow; we use
   :has() to target .main when its sibling #sidebar is collapsed.
   Both #sidebar and .main are direct children of #app. */
.app:has(#sidebar.collapsed) .main {
  margin-left: 64px;
  transition: margin-left 0.25s ease;
}

.main {
  transition: margin-left 0.25s ease;
}

/* ============================================================
   Mobile — bottom nav bar
   ============================================================ */

@media (max-width: 768px) {
  .sidebar {
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    flex-direction: row;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    background: var(--bg-elev);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: var(--shadow-2);
    z-index: 200;
    transform: none !important;
    opacity: 1 !important;
  }

  .sidebar-logo {
    display: none;
  }

  .sidebar-footer {
    display: none !important;
  }

  .sidebar-nav {
    flex-direction: row;
    padding: 4px var(--sp-2);
    gap: var(--sp-1);
    width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
  }

  .sidebar-nav::-webkit-scrollbar {
    display: none;
  }

  #navPinned,
  #navShelf {
    flex-direction: row;
    gap: var(--sp-1);
  }

  .nav-item {
    padding: 4px var(--sp-2);
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
    min-width: 44px;
    width: auto;
    height: auto;
    margin: 0;
    align-items: center;
    justify-content: center;
    border-radius: var(--r-md);
    background: transparent;
  }

  .nav-item svg {
    width: 18px;
    height: 18px;
  }

  .nav-item:hover {
    transform: none;
    box-shadow: none;
  }

  .nav-item.active {
    transform: none;
  }

  .nav-label {
    font-size: 9px;
    display: inline;
  }

  .main {
    margin-left: 0;
    height: calc(100vh - 44px);
    max-height: calc(100vh - 44px);
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar {
    max-width: 100vw;
    overflow: hidden;
    padding: 0 12px;
    box-sizing: border-box;
  }
}
