/* ============================================================
   Foundry Studio Demo — Engineering / IDE aesthetic
   ============================================================ */

/* ---- Reset / base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f172a;
  --surface:     #1e293b;
  --surface-2:   #263347;
  --border:      #334155;
  --border-2:    #475569;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --accent:      #3b82f6;
  --accent-dim:  #1d4ed8;
  --green:       #22c55e;
  --amber:       #f59e0b;
  --red:         #ef4444;
  --mono:        ui-monospace, 'JetBrains Mono', 'Fira Code', monospace;
  --sans:        system-ui, sans-serif;
  --sidebar-w:   240px;
  --header-h:    56px;
  --tab-h:       36px;
  --inspector-h: 240px;
  --radius:      4px;
}

html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 13px; line-height: 1.5; }

/* ---- Layout shell ---- */
#app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---- Header ---- */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 10;
}
.app-header .app-title {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.3px;
  white-space: nowrap;
}
.app-header .app-title span { color: var(--accent); }

.app-header .header-back-link {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  text-decoration: none;
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  white-space: nowrap;
  transition: color 0.1s, border-color 0.1s;
}
.app-header .header-back-link:hover {
  color: var(--text);
  border-color: var(--accent);
}

.dataset-switcher {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  margin: 0 auto;
}
.dataset-switcher button {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 12px;
  border: none;
  border-radius: 2px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.1s;
}
.dataset-switcher button.active {
  background: var(--accent);
  color: #fff;
}
.dataset-switcher button:not(.active):hover { background: var(--surface-2); color: var(--text); }

.header-stats {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  display: flex;
  gap: 12px;
}
.header-stats .stat-val { color: var(--text); }

/* ---- Tab bar ---- */
.tab-bar {
  height: var(--tab-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  padding: 0 16px;
  gap: 0;
  flex-shrink: 0;
}
.tab-bar button {
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  padding: 0 14px;
  height: var(--tab-h);
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.1s, border-color 0.1s;
  letter-spacing: 0.1px;
}
.tab-bar button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-bar button:not(.active):hover { color: var(--text); }

/* ---- Body split: sidebar + main + inspector ---- */
.body-wrap {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-section-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 10px 12px 4px;
  border-bottom: 1px solid var(--border);
}
.sidebar-list {
  overflow-y: auto;
  flex: 1;
}
.sidebar-list::-webkit-scrollbar { width: 4px; }
.sidebar-list::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: background 0.1s;
}
.sidebar-item:hover { background: var(--surface-2); }
.sidebar-item.active { background: var(--surface-2); border-left: 2px solid var(--accent); padding-left: 10px; }
.sidebar-item .item-name {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sidebar-item .item-meta {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
  white-space: nowrap;
}
.sidebar-item .item-badge {
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 2px;
  font-family: var(--mono);
}
.badge-green { background: #14532d; color: var(--green); }
.badge-amber { background: #451a03; color: var(--amber); }
.badge-red   { background: #450a0a; color: var(--red); }

.sidebar-group-label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

/* ---- Main content pane ---- */
.main-pane {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.main-content::-webkit-scrollbar { width: 6px; }
.main-content::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* ---- Inspector (bottom panel) ---- */
.inspector {
  height: var(--inspector-h);
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.inspector-header {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}
.inspector-header .inspector-title {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
}
.inspector-header .inspector-title strong { color: var(--text); font-weight: 600; }
.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
}
.inspector-body::-webkit-scrollbar { width: 4px; }
.inspector-body::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* ---- Pipeline DAG ---- */
.dag-canvas {
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  padding: 16px 0;
  min-height: 200px;
}
.dag-canvas::-webkit-scrollbar { height: 6px; }
.dag-canvas::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.dag-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 160px;
  flex-shrink: 0;
}
.dag-column-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.dag-arrow-col {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  flex-shrink: 0;
  width: 40px;
  align-self: center;
}
.dag-arrow {
  color: var(--border-2);
  font-size: 18px;
  line-height: 1;
}

.dag-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.1s, background 0.1s;
  min-width: 140px;
  max-width: 200px;
  text-align: left;
}
.dag-box:hover { border-color: var(--border-2); }
.dag-box.selected { border-color: var(--accent); background: #1e3a5f; }
.dag-box.transform { border-color: var(--accent-dim); background: #172554; }
.dag-box.transform.selected { border-color: var(--accent); background: #1e3a5f; }

.dag-box .box-type {
  font-family: var(--mono);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.dag-box .box-name {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dag-box .box-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Code pane ---- */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: 160px;
  padding: 10px 12px;
}
.code-block::-webkit-scrollbar { width: 4px; height: 4px; }
.code-block::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }
.code-block pre {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
  white-space: pre;
  line-height: 1.6;
  margin: 0;
}
.code-block .ln {
  display: inline-block;
  width: 3em;
  color: #475569;
  user-select: none;
  text-align: right;
  margin-right: 12px;
}

/* ---- Schema / data tables ---- */
.schema-table, .data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 11px;
}
.schema-table th, .data-table th {
  text-align: left;
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
}
.schema-table td, .data-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: top;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.schema-table tr:last-child td, .data-table tr:last-child td { border-bottom: none; }
.schema-table tr:hover td, .data-table tr:hover td { background: var(--surface-2); }
.data-table tr.highlighted td { background: #1e3a5f; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.clickable:hover td { background: var(--surface-2); }

.type-pill {
  display: inline-block;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--mono);
}

/* ---- Property table (entity summary) ---- */
.prop-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 11px;
}
.prop-table td {
  padding: 3px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.prop-table td:first-child {
  color: var(--text-muted);
  width: 140px;
  white-space: nowrap;
}
.prop-table td:last-child { color: var(--text); word-break: break-all; }
.prop-table tr:last-child td { border-bottom: none; }

/* ---- Lineage tree ---- */
.lineage-tree { padding: 4px 0; }
.tree-node {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 4px 0;
  font-family: var(--mono);
  font-size: 11px;
}
.tree-node .tree-icon { color: var(--accent); flex-shrink: 0; }
.tree-node .tree-label { color: var(--text); }
.tree-node .tree-meta { color: var(--text-muted); font-size: 10px; }
.tree-children { margin-left: 20px; border-left: 1px solid var(--border); padding-left: 12px; }

/* ---- Misc cards / sections ---- */
.section-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}
.section-title {
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.section-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
}

.info-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.info-chip {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-muted);
}
.info-chip strong { color: var(--text); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: #93c5fd; }

.pagination-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}
.pagination-bar button {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 2px;
  cursor: pointer;
}
.pagination-bar button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-bar button:not(:disabled):hover { border-color: var(--border-2); }

/* ---- Search input ---- */
.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  padding: 6px 10px;
  outline: none;
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-muted); }

/* ---- Entity type badge ---- */
.entity-type {
  display: inline-block;
  font-family: var(--mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 2px;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ---- Empty / placeholder states ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  gap: 8px;
  text-align: center;
}
.empty-state .empty-icon { font-size: 32px; opacity: 0.4; }

/* ---- Scrollable wrappers ---- */
.scroll-x { overflow-x: auto; }
.scroll-x::-webkit-scrollbar { height: 4px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

/* ---- Utility ---- */
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.text-mono { font-family: var(--mono); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-green  { color: var(--green); }
.text-amber  { color: var(--amber); }
.text-red    { color: var(--red); }
.nowrap { white-space: nowrap; }
