/**
 * layout.css — High-Throughput Fixed Viewport Shell
 */
*, *::before, *::after {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.28);
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  overflow-y: auto;
}

#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-app);
}

/* Fixed-Viewport Shell for Desktop Workstations (Audit, Provider Table) */
body.app-shell {
  height: 100vh;
  overflow: hidden;
}

body.app-shell #app-container {
  height: 100vh;
  overflow: hidden;
}

/* Global Anchor Target Clearance for Sticky Header */
[id] {
  scroll-margin-top: calc(var(--header-height, 48px) + 12px);
}

/* 1. Global Header */
#global-header {
  height: var(--header-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 20;
}

.brand-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid var(--border-subtle);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

/* 2. Audit Command Row (§3.1 & §3.7) */
#command-row {
  height: var(--command-row-height);
  background-color: #f8fafc;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
  z-index: 15;
}

.nav-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.view-tabs {
  display: flex;
  background: #f1f5f9;
  border-radius: var(--radius-md);
  padding: 2px;
  border: 1px solid var(--border-subtle);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  background: #ffffff;
  color: var(--text-main);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.tab-shortcut {
  font-size: 10px;
  background: #e2e8f0;
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--text-muted);
}

/* 3. Main Workspace Area */
#workspace-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  background-color: var(--bg-app);
}

/* Three-Pane Overview Layout (§4.1) */
.overview-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.overview-grid.gd-only {
  grid-template-columns: 1.2fr 1fr;
}

/* Two-Pane Focused Editing Layout (Words, Tables, Blocks) */
.editing-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.3fr;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

/* Individual Pane Shell */
.pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-pane);
  border-right: 1px solid var(--border-subtle);
}

.pane:last-child {
  border-right: none;
}

.pane-header {
  height: 38px;
  background-color: #f8fafc;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  flex-shrink: 0;
}

.pane-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.pane-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  position: relative;
  background-color: var(--bg-pane);
}

/* Document Canvas Image Pane */
.canvas-pane-body {
  padding: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background-color: #f1f5f9;
  overflow-y: auto;
  overflow-x: auto;
  user-select: none;
}

.image-canvas-wrapper {
  position: relative;
  transform-origin: top left;
  transition: transform 0.05s ease-out;
}

.doc-image {
  display: block;
  max-width: none;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.05);
  background-color: #ffffff;
}

.bbox-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

/* ==========================================================================
   4. Universal Table Scroll Wrappers & Sticky Columns
   ========================================================================== */
.benchmark-table-wrapper,
.doc-list-table-wrapper,
.table-scroll-wrapper {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.sticky-col,
.sticky-col-1 {
  position: sticky;
  left: 0;
  background-color: #ffffff !important;
  z-index: 3;
}

th.sticky-col,
th.sticky-col-1 {
  z-index: 4;
}

.sticky-col-2 {
  position: sticky;
  left: 36px;
  background-color: #ffffff !important;
  z-index: 3;
}

th.sticky-col-2 {
  z-index: 4;
}

/* ==========================================================================
   5. Responsive Visibility & Breakpoint Utilities
   ========================================================================== */
.mobile-only {
  display: none !important;
}

.desktop-only {
  display: block;
}

@media (max-width: 900px) {
  .header-nav.desktop-only {
    display: none !important;
  }
  .repo-links.desktop-only {
    display: none !important;
  }
  .mobile-only {
    display: block !important;
  }
}

@media (max-width: 768px) {
  :root {
    --header-height: 46px;
  }
  
  .mobile-only {
    display: block !important;
  }
  .desktop-only {
    display: none !important;
  }
  .mobile-flex {
    display: flex !important;
  }
}
