/* ==========================================================================
   App Shell & Responsive Workbench Grid
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text-primary);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
}

.brand-link:hover {
  text-decoration: none;
}

.brand-emblem {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.brand-title {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-main {
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 1 auto;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.header-divider {
  width: 1px;
  height: 22px;
  background: var(--border-subtle);
  margin: 0 0.1rem;
}

/* Shell body: persistent sidebar on wide desktop, slide drawer on smaller screens */
.app-body {
  display: flex;
  min-height: calc(100vh - var(--header-h));
}

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  padding: 0.85rem 0.65rem 1.5rem;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-h));
  position: sticky;
  top: var(--header-h);
}

.sidebar-backdrop {
  display: none;
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 1.25rem 1.5rem 2.5rem;
  max-width: 1460px;
  margin: 0 auto;
  width: 100%;
}

/* Compact single-line page header bar */
.page-hero {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border-subtle);
}

.page-hero-inline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.page-hero-inline h1 {
  margin: 0;
  font-size: clamp(1.18rem, 1.8vw, 1.48rem);
}

.page-hero-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.page-hero-desc {
  margin: 0.2rem 0 0;
  font-size: 0.86rem;
  max-width: 70ch;
}

/* Workbench two-column grid */
.workbench-grid {
  display: grid;
  grid-template-columns: minmax(310px, 385px) minmax(0, 1fr);
  gap: 1.15rem;
  align-items: start;
}

.workbench-controls {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.workbench-stage {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

/* Dual linked visual (e.g. 3D Globe + 2D Mercator) */
.dual-viz-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

/* Results + Steps below visual */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.65rem;
}

/* Hub page grid */
.hub-track-section {
  margin-bottom: 1.75rem;
}

.hub-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.9rem;
}

.app-footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* Tablet & Mobile breakpoints */
@media (max-width: 1180px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-h);
    bottom: 0;
    z-index: 50;
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-md);
    max-height: none;
  }

  .app-sidebar.is-open {
    transform: translateX(0);
  }

  .sidebar-backdrop.is-open {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(10, 16, 22, 0.45);
    z-index: 45;
  }
}

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

  .dual-viz-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .brand-sub {
    display: none;
  }

  .header-actions .btn-label-desktop {
    display: none;
  }

  .header-divider {
    display: none;
  }
}

@media (max-width: 600px) {
  .app-header {
    padding: 0 0.45rem;
    gap: 0.25rem;
  }

  .header-left {
    gap: 0.25rem;
  }

  .brand-emblem,
  .brand-title {
    display: none;
  }

  .header-actions {
    gap: 0.25rem;
  }

  .app-header .tab-btn {
    padding: 0.26rem 0.5rem;
    font-size: 0.76rem;
  }

  .app-header .btn-sm {
    min-height: 30px;
    padding: 0.22rem 0.42rem;
    font-size: 0.74rem;
  }

  .app-header .btn-icon {
    min-width: 30px;
  }

  .app-main {
    padding: 0.75rem 0.65rem 1.75rem;
  }
}
