/* ================================================================
   ds-sidebar.css — AetherChat Layout & Navigation
   Body, dashboard shell, sidebar, nav groups, footer.
   ================================================================ */

/* ── Global reset helpers ───────────────────────────────────── */

html { font-size: 16px; }

body,
button,
input,
textarea,
select {
  font-family: var(--font-ui);
}

body {
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-body);
  letter-spacing: 0;
  background: linear-gradient(180deg, #fbfcff 0%, var(--bg) 100%);
}

body::before,
body::after,
.bg-canvas::before,
.bg-canvas::after {
  display: none;
}

a            { color: var(--primary-600); text-decoration: none; }
a:hover      { color: var(--accent-strong); }

/* ── Dashboard shell ────────────────────────────────────────── */

.dashboard-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  background: transparent;
  position: relative;
}

.dashboard-main {
  min-width: 0;
  padding: 20px 24px;
}

.dashboard-content {
  display: grid;
  gap: 16px;
  max-width: none;
  padding: 0;
}

/* Mobile toolbar (hidden on desktop) */
.dashboard-content-tools { display: none; }

/* ── Sidebar ────────────────────────────────────────────────── */

.dashboard-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  box-shadow: none;
}

.dashboard-sidebar-inner {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 20px;
  padding: 14px 12px;
  min-height: 100%;
}

/* ── Brand header ───────────────────────────────────────────── */

.dashboard-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 0;
  border: 0;
}

.dashboard-brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  text-decoration: none;
}

.brand-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(145deg, #4fa8ff 0%, var(--primary-600) 100%);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0;
  box-shadow: var(--shadow-sm);
}

.brand-name {
  color: var(--neutral-900);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0;
}

.dashboard-brand-caption {
  color: var(--neutral-500);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
}

/* Close button (mobile) */
.dashboard-sidebar-close {
  display: none;
  align-items: center;
  gap: 4px;
  width: auto;
  padding: 0 10px;
  min-height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--neutral-200);
  background: #ffffff;
  color: var(--neutral-700);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.dashboard-sidebar-close svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── Workspace pill (tenant context) ────────────────────────── */

.dashboard-sidebar-badges {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  border: 0;
}

.workspace-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--neutral-200);
  background: var(--neutral-50);
  color: var(--neutral-700);
  font-size: 12px;
  font-weight: 600;
  box-shadow: none;
  letter-spacing: 0;
}

/* ── Navigation ─────────────────────────────────────────────── */

.dashboard-nav { width: 100%; }

.nav-group-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.nav-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group-label {
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--neutral-400);
  margin-bottom: 1px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--neutral-700);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
  overflow: visible;
}

/* Flat icon — no box container */
.nav-link-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  color: var(--neutral-500);
}

.nav-link-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.75;
  display: block;
}

.nav-link-label {
  font-size: 13.5px;
  line-height: 1;
}

/* Hover */
.nav-link:hover {
  background: var(--sidebar-link-hover);
  color: var(--neutral-900);
  border-color: var(--surface-border);
}

.nav-link:hover .nav-link-icon {
  color: var(--neutral-600);
}

/* Active */
.nav-link-active {
  background: #eef4ff;
  color: var(--primary-600);
  border-color: #dbe7ff;
  box-shadow: inset 0 0 0 1px rgba(37, 99, 255, 0.04);
}

.nav-link-active::before {
  content: "";
  display: block;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  border-radius: 0 3px 3px 0;
  background: var(--primary-600);
}

.nav-link-active .nav-link-icon {
  color: var(--primary-600);
}

.nav-link:focus-visible,
.dashboard-brand-link:focus-visible,
.dashboard-sidebar-close:focus-visible,
.dashboard-menu-button:focus-visible {
  outline: 2px solid var(--fluent-focus-stroke);
  outline-offset: 2px;
}

/* ── Sidebar footer ─────────────────────────────────────────── */

.dashboard-sidebar-footer {
  display: grid;
  gap: 2px;
  padding: 10px;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-xs);
}

/* User identity row: avatar · name · logout icon */
.sidebar-user-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
/*  padding: 2px 0 6px;
  border-bottom: 1px solid var(--neutral-100);
  margin-bottom: 2px;*/
}

.sidebar-user-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--accent-surface);
  color: var(--primary-600);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  user-select: none;
}

.sidebar-user-name {
  flex: 1;
  min-width: 0;
  color: var(--neutral-800);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout-inline-form {
    margin-right: 0;
    margin-left: auto;
}

.sidebar-logout-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--neutral-200);
  background: transparent;
  color: var(--neutral-400);
  cursor: pointer;
  transition:
    background var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast);
}

.sidebar-logout-icon-btn svg {
  width: 13px;
  height: 13px;
  pointer-events: none;
}

.sidebar-logout-icon-btn:hover {
  background: var(--error-surface);
  border-color: var(--error-border);
  color: #b91c1c;
}

.sidebar-logout-icon-btn:focus-visible {
  outline: 2px solid var(--fluent-focus-stroke);
  outline-offset: 2px;
}

/* Footer actions below identity row */
.sidebar-footer-actions {
  display: flex;
  flex-direction: column;
}

.sidebar-manage-link {
  display: flex;
  align-items: center;
  min-height: 28px;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  color: var(--neutral-600);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-manage-link:hover {
  background: var(--sidebar-link-hover);
  color: var(--neutral-900);
}

.sidebar-manage-link:focus-visible {
  outline: 2px solid var(--fluent-focus-stroke);
  outline-offset: 2px;
}

.sidebar-everywhere-form { margin: 0; }

.sidebar-everywhere-btn {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 22px;
  padding: 0 4px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--neutral-400);
  font-size: 11px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-everywhere-btn:hover {
  background: var(--error-surface);
  color: #991b1b;
}

.sidebar-everywhere-btn:focus-visible {
  outline: 2px solid var(--fluent-focus-stroke);
  outline-offset: 2px;
}

/* Logout form */
.logout-form,
.sidebar-logout-form { margin: 0; }

/* ── Overlay (mobile drawer) ────────────────────────────────── */

.dashboard-overlay {
  position: fixed;
  inset: 0;
  z-index: 39;
  background: rgba(15, 23, 42, 0.38);
  backdrop-filter: blur(3px);
}

/* ── Simple shell (login / error pages) ─────────────────────── */

.page-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
}

.site-shell {
  width: min(100%, 480px);
}

/* ── Responsive ─────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .dashboard-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    width: min(260px, calc(100vw - 48px));
    box-shadow: var(--shadow-2xl);
    will-change: transform;
  }

  .dashboard-sidebar.is-open {
    transform: translateX(0);
  }

  .dashboard-sidebar-close {
    display: inline-flex;
  }

  .dashboard-content-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
  }

  .dashboard-menu-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--neutral-200);
    background: #ffffff;
    color: var(--neutral-700);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-xs);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dashboard-sidebar {
    transition: none;
  }
}

@media (max-width: 900px) {
  .dashboard-main { padding: 16px; }
  .dashboard-content { gap: 12px; }
}

@media (max-width: 640px) {
  .dashboard-main { padding: 12px; }

  .dashboard-sidebar {
    width: min(280px, calc(100vw - 32px));
  }

  .dashboard-content-tools {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 4px 0;
    background: linear-gradient(180deg, var(--bg) 0%, rgba(248, 250, 252, 0.92) 100%);
  }

  .dashboard-menu-button {
    width: 100%;
    justify-content: center;
  }
}
