/* App shell layout — PartnerPanel */
/* Consumes only design tokens from tokens.css */

html, body {
  height: 100%;
}

body {
  background-color: var(--bg-app);
  background-image: var(--bg-app-accent);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.65;
  min-height: 100vh;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}

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

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border-inline-end: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: calc(var(--z-sidebar) - 1);
}

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

  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: 280px;
    z-index: var(--z-sidebar);
    transform: translateX(100%);
    transition: transform var(--transition-base);
    box-shadow: var(--shadow-lg);
  }

  [dir="rtl"] .app-sidebar { transform: translateX(100%); }
  [dir="rtl"] body.sidebar-open .app-sidebar,
  body.sidebar-open .app-sidebar { transform: translateX(0); }

  body.sidebar-open .sidebar-overlay { display: block; }

  /* The open drawer owns the screen: without this the page behind it keeps
     scrolling under the finger (and the sticky topbar drifts). */
  body.sidebar-open { overflow: hidden; }

  /* hamburger visible only on mobile */
  .app-topbar [data-action="toggle-sidebar"] { display: inline-flex; }
}

@media (min-width: 961px) {
  .app-topbar [data-action="toggle-sidebar"] { display: none; }
}

/* Brand block: vertical (logo above, name below), so the two text spans have
   room to sit under the logo instead of next to it. */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  padding: 20px 20px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: var(--weight-semibold);
  font-size: var(--text-lg);
  color: var(--text-primary);
}

/* Name + product line. WITHOUT this rule the two <span>s are inline and the
   second one inherits font-size/weight from .sidebar-brand — measured in the
   browser, «حساب‌کتاب» rendered 16px/600, i.e. indistinguishable from the
   title. Keep them stacked and give the product line a lower emphasis. */
.sidebar-brand__text {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.3;
}

.sidebar-brand__title {
  font-weight: var(--weight-semibold);
}

.sidebar-brand__sub {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  color: var(--text-muted);
}

/* App version line under the two-line brand block. */
.sidebar-brand__version {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: .02em;
}

.sidebar-brand__logo {
  width: 50px;
  height: 50px;
  border-radius: 18px;
  object-fit: contain;
  background: var(--bg-elevated);
  padding: 8px;
}

.sidebar-nav {
  padding: 16px 12px 24px;
  flex: 1;
  overflow-y: auto;
}

.nav-section { margin-bottom: 24px; }

.nav-section__title {
  padding: 0 12px;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: var(--weight-medium);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-base);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.is-active {
  background: hsl(var(--color-primary-500) / .12);
  color: hsl(var(--color-primary-600));
  font-weight: var(--weight-medium);
}

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

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

.app-topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
}

/* The title block is a flex child: it must be allowed to shrink below its
   content width, otherwise a long page title pushes the user menu and the
   theme toggle off-screen on a 360px phone. */
.app-topbar > div { min-width: 0; }

.app-topbar__heading {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  margin: 0;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.breadcrumb__link {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb__link:hover { color: var(--text-primary); }

.breadcrumb__sep {
  margin: 0 6px;
  color: var(--border-strong);
}

.app-topbar__actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-content {
  padding: 28px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

@media (min-width: 1400px) {
  .app-content {
    padding: 36px 40px;
  }
}

/* Small phones: less chrome around the content so tables and cards keep a
   usable width instead of being squeezed by padding. */
@media (max-width: 640px) {
  .app-topbar {
    padding: 12px 14px;
    gap: 10px;
  }

  .app-content {
    padding: 16px 14px;
  }

  .app-topbar__heading { font-size: var(--text-lg); }
}
