/* Application shell: sidebar + topbar + content area. */

body {
  background: var(--color-bg);
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  width: 100%;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: var(--sidebar-width-collapsed) 1fr;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 10px 12px;
  transition: width var(--transition-normal);
  z-index: 20;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  background: var(--color-bg);
}

/* CRITICAL: .sidebar-backdrop is a third DOM child of the two-column .app-shell grid
   (sidebar, backdrop, main — see app.js buildShell()). Without an unconditional base rule
   taking it out of grid flow, CSS Grid's default auto-placement fills row-by-row: sidebar ->
   row1/col1, backdrop -> row1/col2, and then MAIN gets pushed to a new row2/col1 — directly
   underneath/behind the sidebar's column. This single missing rule was the root cause of the
   "content hidden behind the sidebar" layout break at every desktop width. `position: fixed`
   removes it from grid flow entirely, at ALL viewport widths, regardless of whether the mobile
   media query's display toggle is active. Do not remove this base rule. */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 15;
}

.app-topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-search {
  position: relative;
  flex: 0 1 360px;
}
.topbar-search .form-input { padding-left: 16px; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.topbar-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: min(360px, calc(100vw - 24px));
  max-height: 420px;
  overflow-y: auto;
  z-index: 50;
  padding: 10px;
  box-shadow: var(--shadow-lg);
}
.topbar-search .topbar-popover {
  left: 0;
  right: auto;
  width: min(420px, calc(100vw - 24px));
}
.topbar-popover-title {
  padding: 8px 10px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.topbar-popover-item {
  display: block;
  padding: 10px;
  border-radius: var(--radius-sm);
}
.topbar-popover-item:hover { background: var(--color-primary-soft); }
.topbar-user-button {
  width: auto;
  min-width: 40px;
  padding: 0 5px;
}
.topbar-new-request { white-space: nowrap; }
.topbar-actions > div { display: flex; }

.app-topbar input[type="search"] {
  border-radius: var(--radius-lg);
  background: var(--color-bg);
  border-color: transparent;
}
.app-topbar input[type="search"]:focus {
  background: var(--color-surface);
  border-color: var(--color-primary);
}

.app-content {
  flex: 1;
  padding: 22px 24px 30px;
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.page-header .page-subtitle {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  margin-top: var(--space-1);
}

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

.section-title {
  font-size: var(--font-size-lg);
  font-weight: 600;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}

.grid-summary-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.dashboard-widgets-column {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.full-page-loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  color: var(--color-text-secondary);
  font-weight: 600;
}
.full-page-loading-overlay::before {
  content: "";
  width: 28px;
  height: 28px;
  margin-right: 12px;
  border: 3px solid var(--color-primary-soft);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: loading-spin .8s linear infinite;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
