/* ==========================================================================
   Dasa Design System — App Shell extension
   NOT part of the official token/component package (tokens.css +
   components.css) — these are additional classes for building signed-in
   app UI (sidebar, topbar, auth cards, status badges) on top of the same
   tokens. Load after styles.css / components.css.
   ========================================================================== */

/* -- App shell layout -------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  background: var(--color-bg);
}

.app-content-col { display: flex; flex-direction: column; min-width: 0; }

.app-main {
  min-width: 0;
  padding: var(--space-6) var(--space-6) var(--space-9);
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}
.page-head h1 { margin-bottom: var(--space-1); }
.page-head p { margin: 0; }
.page-head__actions { display: flex; gap: var(--space-3); flex-shrink: 0; }

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

.app-sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-5) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.app-sidebar__logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-2);
}

.app-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.app-nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: .6rem var(--space-3);
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-weight: var(--font-weight-semibold);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
}
.app-nav__item:hover { background: var(--color-surface-muted); color: var(--color-heading); }
.app-nav__item svg { width: 18px; height: 18px; flex-shrink: 0; }
.app-nav__item--active {
  background: color-mix(in srgb, var(--color-brand-primary) 12%, var(--color-surface));
  color: var(--color-brand-primary);
}
.app-nav__count {
  margin-left: auto;
  font-size: 11px;
  background: var(--color-surface-muted);
  color: var(--color-text-secondary);
  padding: 1px 7px;
  border-radius: var(--radius-pill);
}
.app-nav__item--active .app-nav__count {
  background: color-mix(in srgb, var(--color-brand-primary) 20%, var(--color-surface));
  color: var(--color-brand-primary);
}

.app-sidebar__footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

/* -- Topbar --------------------------------------------------------------------- */

.app-topbar {
  height: 64px;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding-inline: var(--space-6);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-topbar__menu-btn { display: none; }

.app-topbar__search {
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface-muted);
  border-radius: var(--radius-pill);
  padding: .55rem 1rem;
  color: var(--color-text-tertiary);
}
.app-topbar__search svg { width: 16px; height: 16px; flex-shrink: 0; }
.app-topbar__search input {
  border: none; background: none; outline: none; font: inherit;
  font-family: var(--font-copy); font-size: var(--text-sm);
  color: var(--color-text-primary); width: 100%;
}

.app-topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: none; background: transparent;
  color: var(--color-text-secondary); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
}
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn:hover { background: var(--color-surface-muted); color: var(--color-heading); }

/* -- Avatar --------------------------------------------------------------------- */

.avatar {
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-on-brand);
  background: var(--color-brand-primary);
  flex-shrink: 0;
}
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--md { width: 36px; height: 36px; font-size: var(--text-sm); }
.avatar--lg { width: 56px; height: 56px; font-size: var(--text-lg); }

/* -- Status badge variants (extends .badge from components.css) ----------------- */

.badge--success { background: color-mix(in srgb, var(--color-success) 16%, var(--color-surface)); color: var(--color-success); }
.badge--warning { background: color-mix(in srgb, var(--color-warning) 18%, var(--color-surface)); color: var(--color-warning); }
.badge--danger  { background: color-mix(in srgb, var(--color-danger) 14%, var(--color-surface)); color: var(--color-danger); }

/* -- Danger button variant (extends .btn from components.css) ------------------- */

.btn--danger { background: transparent; border-color: var(--color-danger); color: var(--color-danger); }
.btn--danger:hover { background: var(--color-danger); color: #fff; }

/* -- Stat trend indicator (pairs with .stat from components.css) ---------------- */

.stat__trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-body); font-size: var(--text-xs); font-weight: var(--font-weight-semibold);
  margin-left: var(--space-2);
}
.stat__trend svg { width: 12px; height: 12px; }
.stat__trend--up { color: var(--color-success); }
.stat__trend--down { color: var(--color-danger); }
.stat--inline { display: flex; align-items: baseline; gap: var(--space-1); text-align: left; }
.stat--inline .stat__value { margin-bottom: 0; }

/* -- Auth shell (login / register) ----------------------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  background: var(--color-surface-muted);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-7);
  box-shadow: var(--shadow-lg);
}
.auth-card__logo { display: flex; align-items: center; gap: var(--space-2); justify-content: center; margin-bottom: var(--space-6); }
.auth-card h1 { text-align: center; font-size: var(--text-xl); margin-bottom: var(--space-2); }
.auth-card > p:first-of-type { text-align: center; margin-bottom: var(--space-6); }
.auth-card__foot { text-align: center; margin-top: var(--space-5); font-family: var(--font-body); font-size: var(--text-sm); color: var(--color-text-secondary); }
.field__hint { font-family: var(--font-body); font-size: var(--text-xs); color: var(--color-text-tertiary); margin-top: -4px; }
.field__row-between { display: flex; justify-content: space-between; align-items: center; }
.checkbox-line { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-body); font-size: var(--text-sm); color: var(--color-text-secondary); }
.checkbox-line input { accent-color: var(--color-brand-primary); width: 16px; height: 16px; }

/* Hidden by default (and excluded from .app-shell's grid flow) — only ever
   shown, as a fixed overlay, inside the mobile media query below. Without
   this base rule the div is a normal in-flow grid item at desktop widths
   and breaks the 260px/1fr column layout. */
.app-shell__backdrop { display: none; }

/* -- Theme toggle (small icon button pairing light/dark, used in topbar/navbar) -- */
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* -- Responsive: sidebar becomes an off-canvas drawer below 900px --------------- */

@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-topbar__menu-btn { display: inline-flex; }
  .app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform var(--duration-base) var(--ease-standard);
    z-index: 50;
    box-shadow: var(--shadow-nav);
  }
  .app-shell--sidebar-open .app-sidebar { transform: translateX(0); }
  .app-shell__backdrop {
    display: none;
    position: fixed; inset: 0; background: color-mix(in srgb, var(--dasa-navy-ink) 55%, transparent);
    z-index: 40;
  }
  .app-shell--sidebar-open .app-shell__backdrop { display: block; }
}
