/**
 * RVRSE Layout — App shell, sidebar, header, grid patterns
 * Brand Book V2 · DEC-009
 * Shell: Sidebar (240px fixed) | Main (flex-1)
 */

/* ═══════════════════════════════════════════════════════════════════
   APP SHELL
   ═══════════════════════════════════════════════════════════════════ */

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--color-obsidian);
}

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

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-onyx);
  border-right: 1px solid var(--border-steel);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 40;
}

.sidebar-logo-area {
  padding: 18px 16px 16px;
  border-bottom: 1px solid var(--border-steel);
  flex-shrink: 0;
}

.sidebar-nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border-steel);
  flex-shrink: 0;
}

/* ─── Main Area ──────────────────────────────────────────────────── */

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

/* ─── Sticky Header ──────────────────────────────────────────────── */

.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-height);
  background: rgba(6, 8, 13, 0.88);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-steel);
  display: flex;
  align-items: center;
  padding: 0 var(--page-padding);
  gap: 12px;
  flex-shrink: 0;
}

.header-back {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-muted);
  transition: color var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}
.header-back:hover { color: var(--color-ivory); }

.header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-ivory);
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 64px;
  justify-content: flex-end;
}

/* ─── Page Content ───────────────────────────────────────────────── */

.app-content {
  flex: 1;
  padding: var(--page-padding);
  overflow-y: auto;
}

/* ═══════════════════════════════════════════════════════════════════
   AUTH / CENTERED PAGES  (login, register, success screens)
   ═══════════════════════════════════════════════════════════════════ */

.page-auth {
  min-height: 100vh;
  background: var(--color-obsidian);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.page-auth-header {
  margin-bottom: 32px;
  text-align: center;
}

.page-auth-card {
  width: 100%;
  max-width: 432px;
}

/* Success screens */
.page-success-wrap {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════
   CONTENT GRIDS
   ═══════════════════════════════════════════════════════════════════ */

/* 4 equal-width stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* Form (7/12) + sticky summary (5/12) */
.grid-form {
  display: grid;
  grid-template-columns: 7fr 5fr;
  gap: 24px;
  align-items: start;
}

/* Two-thirds + one-third */
.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}

/* 50/50 */
.grid-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   STICKY SUMMARY COLUMN
   ═══════════════════════════════════════════════════════════════════ */

.sticky-summary {
  position: sticky;
  top: calc(var(--header-height) + 24px);
}

/* ═══════════════════════════════════════════════════════════════════
   SECTION HEADER
   ═══════════════════════════════════════════════════════════════════ */

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* ═══════════════════════════════════════════════════════════════════
   DIVIDERS
   ═══════════════════════════════════════════════════════════════════ */

.divider        { border: none; border-top: 1px solid var(--border-steel);  margin: 20px 0; }
.divider-sm     { border: none; border-top: 1px solid var(--border-subtle); margin: 12px 0; }
.divider-v      { width: 1px; background: var(--border-steel); align-self: stretch; }

/* ═══════════════════════════════════════════════════════════════════
   RESPONSIVE — collapse sidebar on narrow screens
   ═══════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .app-sidebar { transform: translateX(-100%); transition: transform var(--transition-base); }
  .app-sidebar.open { transform: translateX(0); }
  .app-main   { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-form,
  .grid-2-1   { grid-template-columns: 1fr; }
  .app-content { padding: 16px; }
  .app-header  { padding: 0 16px; }
}
