/* pages/dashboard.css
 *
 * Authenticated app shell. Two-column desktop layout (sidebar + main),
 * sticky in-content header with breadcrumbs on the left and the account
 * dropdown on the right. Below 768px the sidebar slides in as an off-canvas
 * drawer triggered from the header's hamburger.
 *
 * Composes NanoUI primitives (nano-sidebar, nano-dropdown, nano-avatar,
 * nano-breadcrumb, nano-card) - this file owns layout, responsive
 * behavior, and a couple of small modifiers (right-anchored dropdown,
 * sign-out button reset) scoped to the dashboard chrome.
 */

.dashboard {
  /* The dashboard runs on a clean white surface (sidebar, main, popovers
     all share it) - distinct from the warm-paper aesthetic used on the
     marketing and auth screens. Overriding the tokens here cascades to
     every NanoUI primitive inside the chrome. */
  --color-background: 0 0% 100%;
  --color-popover:    0 0% 100%;
  --color-card:       0 0% 100%;

  --dashboard-sidebar-w: 260px;
  --dashboard-header-h: 60px;
  --dashboard-gutter:   clamp(1.25rem, 4vw, 2.5rem);

  display: grid;
  grid-template-columns: var(--dashboard-sidebar-w) 1fr;
  min-height: 100vh;
  background-color: hsl(var(--color-background));
  color: hsl(var(--color-foreground));
  overflow-x: clip;
}

/* ---------- Sidebar ---------- */

.dashboard__sidebar {
  border-right: 1px solid hsl(var(--color-border));
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 30;
}

.dashboard__sidebar-header {
  min-height: var(--dashboard-header-h);
}

.dashboard__wordmark {
  font-weight: 800;
  font-size: var(--text-xl);
  letter-spacing: -0.03em;
  text-decoration: none;
  line-height: 1;
  display: inline-block;

  .dashboard__wordmark-fore   { color: hsl(var(--color-primary)); }
  .dashboard__wordmark-accent { color: hsl(var(--color-accent-bright)); }

  &:hover {
    .dashboard__wordmark-fore   { color: hsl(var(--color-primary) / 0.8); }
    .dashboard__wordmark-accent { color: hsl(var(--color-accent-bright) / 0.85); }
  }

  &:focus-visible {
    outline: 2px solid hsl(var(--color-ring));
    outline-offset: 4px;
    border-radius: var(--radius-sm);
  }
}

/* ---------- Main column ---------- */

.dashboard__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.dashboard__header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-height: var(--dashboard-header-h);
  padding-inline: var(--dashboard-gutter);
  border-bottom: 1px solid hsl(var(--color-border));
  background-color: hsl(var(--color-background) / 0.85);
  backdrop-filter: saturate(140%) blur(8px);
  -webkit-backdrop-filter: saturate(140%) blur(8px);
}

.dashboard__header-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

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

.dashboard__breadcrumb {
  min-width: 0;
}

.dashboard__hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: hsl(var(--color-muted-foreground));
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-default),
              background-color var(--duration-fast) var(--ease-default);

  &:hover {
    color: hsl(var(--color-foreground));
    background-color: hsl(var(--color-muted));
  }

  &:focus-visible {
    outline: 2px solid hsl(var(--color-ring));
    outline-offset: 2px;
    color: hsl(var(--color-foreground));
  }
}

.dashboard__content {
  flex: 1 1 auto;
  padding: clamp(1.5rem, 4vw, 2.5rem) var(--dashboard-gutter) var(--space-12);
  max-width: 80rem;
  width: 100%;
  margin-inline: auto;
}

/* ---------- Account dropdown ---------- */

.account-dropdown {
  position: relative;
}

.account-dropdown__trigger {
  display: inline-flex;
}

.account-dropdown__avatar-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--ease-default);

  &:hover {
    border-color: hsl(var(--color-border));
  }

  &:focus-visible {
    outline: none;
    border-color: hsl(var(--color-ring));
  }

  &[aria-expanded="true"] {
    border-color: hsl(var(--color-border));
  }
}

.account-dropdown__avatar {
  background-color: hsl(var(--color-primary));

  .nano-avatar__fallback {
    color: hsl(var(--color-primary-foreground, 0 0% 100%));
    font-weight: var(--font-semibold);
    letter-spacing: 0.02em;
  }
}

/* Specificity has to match NanoUI's `.nano-dropdown .nano-dropdown__content`
   ([0,2,0]) to override its default `left: 0` anchor - the account menu
   hangs from the avatar in the top-right of the header. */
.account-dropdown .account-dropdown__content {
  left: auto;
  right: 0;
  min-width: 14rem;
}

/* NanoUI's global `button { justify-content: center }` rule cascades into
   .nano-dropdown__item buttons (Sign out), which would center the icon
   and label. Pin items to flex-start so buttons match the link items. */
.account-dropdown .nano-dropdown__item {
  justify-content: flex-start;
}

.account-dropdown__identity {
  padding: var(--space-2) var(--space-2) var(--space-1);
}

.account-dropdown__email {
  margin: 0;
  font-size: var(--text-xs);
  color: hsl(var(--color-muted-foreground));
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-dropdown__signout-form {
  margin: 0;
  display: block;
}

.account-dropdown__signout {
  width: 100%;
}

/* ---------- Welcome panel (placeholder show view) ---------- */

.dashboard-welcome {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
}

.dashboard-welcome__head {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.dashboard-welcome__eyebrow {
  margin: 0;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: hsl(var(--color-muted-foreground));
}

.dashboard-welcome__title {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.05;
  color: hsl(var(--color-primary));
}

.dashboard-welcome__lede {
  margin: 0;
  font-size: var(--text-base);
  color: hsl(var(--color-muted-foreground));
  max-width: 56ch;
}

.dashboard-welcome__placeholder {
  margin: 0;
  font-size: var(--text-sm);
  color: hsl(var(--color-muted-foreground));
}

/* ---------- Mobile (< 768px) ---------- */

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

  .dashboard__sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(82vw, 320px);
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform var(--duration-normal) var(--ease-default);
    box-shadow: var(--shadow-lg);

    &.dashboard__sidebar--open {
      transform: translateX(0);
    }
  }

  .dashboard__hamburger {
    display: inline-flex;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .dashboard__sidebar,
  .account-dropdown__avatar-button {
    transition: none;
  }
}
