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

:root {
  --bg-root: #08080f;
  --bg-surface: #0d0d1a;
  --bg-panel: #0a0a14;
  --border: #1a1a2e;
  --border-dim: #111;
  --text: #d4d4d4;
  --text-dim: #999;
  --text-muted: #808080;
  --text-faint: #707070;
  --text-ghost: #606060;
  --accent: #5cc9c2;
  --soql: #f4c542;
  --dml: #e8853d;
  --debug: #5cc9c2;
  --unit: #7c8dea;
  --limit: #e05577;
  --error: #ff4444;
  --warn: #f4c542;
  --validation: #b48ade;
  --workflow: #6db36d;
  --flow: #4db8d8;
  --callout: #d4a056;
  --system: #808080;
  --search-hl: #f4c542;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'IBM Plex Sans', -apple-system, sans-serif;
}

body {
  background: var(--bg-root);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}

/* -- scrollbar -- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #222; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #333; }

/* -- input view -- */
#input-view {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 24px;
}

.input-subtitle {
  font-size: 11px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-family: var(--mono);
  margin-bottom: 8px;
}

.input-title {
  font-size: 32px;
  font-weight: 700;
  color: #e8e8e8;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

.input-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 32px;
}

.drop-zone {
  position: relative;
  margin-bottom: 16px;
}

.drop-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(92,201,194,0.08);
  border: 2px dashed var(--accent);
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  z-index: 10;
  font-size: 14px;
  color: var(--accent);
  font-family: var(--mono);
}

.drop-zone.dragging .drop-overlay { display: flex; }

#log-input {
  width: 100%;
  height: 320px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #aaa;
  padding: 16px;
  font-family: var(--mono);
  font-size: 12px;
  resize: vertical;
  outline: none;
  line-height: 1.6;
}

#log-input:focus { border-color: #252540; }

.input-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-primary {
  padding: 8px 20px;
  background: var(--accent);
  color: var(--bg-root);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--sans);
  transition: opacity 0.15s;
}

.btn-primary:hover { opacity: 0.85; }

.input-hint {
  color: var(--text-ghost);
  font-size: 12px;
}

/* -- parsed view -- */
#parsed-view { display: none; }
#parsed-view.active { display: block; }
#input-view.hidden { display: none; }

/* -- header bar -- */
.header-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8,8,15,0.93);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title {
  font-size: 14px;
  font-weight: 700;
  color: #e8e8e8;
  letter-spacing: -0.3px;
}

.header-badge {
  font-size: 10px;
  color: var(--accent);
  font-family: var(--mono);
  padding: 2px 8px;
  background: rgba(92,201,194,0.1);
  border-radius: 4px;
}

.header-meta {
  font-size: 10px;
  color: var(--text-dim);
  font-family: var(--mono);
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-toolbar {
  padding: 4px 12px;
  font-size: 11px;
  background: transparent;
  border: 1px solid #222;
  border-radius: 4px;
  color: var(--text-faint);
  cursor: pointer;
  font-family: var(--mono);
  transition: all 0.15s;
}

.btn-toolbar:hover { border-color: #333; color: var(--text-dim); }
.btn-toolbar.active { background: rgba(224,85,119,0.15); border-color: var(--limit); color: var(--limit); }

/* -- filters row -- */
.filters-row {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

#search-input {
  padding: 5px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  width: 200px;
}

#search-input:focus { border-color: #252540; }

.filter-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  flex-shrink: 0;
}

.filter-chip {
  padding: 4px 10px;
  font-size: 12px;
  font-family: var(--mono);
  background: transparent;
  border: 1px solid #222;
  border-radius: 4px;
  color: var(--text-faint);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  white-space: nowrap;
}

.filter-chip:hover { border-color: #333; }

.filter-chip .chip-count {
  opacity: 0.6;
  font-size: 10px;
}

/* -- main layout -- */
.main-layout {
  display: flex;
}

.log-pane {
  flex: 1;
  min-width: 0;
}

/* -- stats bar -- */
.stats-bar {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-dim);
}

.stat-card {
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 100px;
  flex-shrink: 0;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--mono);
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 2px;
}

/* -- log lines -- */
.log-line {
  padding: 3px 12px;
  font-family: var(--mono);
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-left: 2px solid transparent;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-timestamp {
  color: var(--text-ghost);
  min-width: 78px;
  font-size: 12px;
  flex-shrink: 0;
}

.log-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
  min-width: 54px;
  text-align: center;
  flex-shrink: 0;
}

.log-content {
  word-break: break-all;
}

.log-line-num {
  color: var(--text-ghost);
  min-width: 40px;
  text-align: right;
  font-size: 11px;
  flex-shrink: 0;
  user-select: none;
  opacity: 0.7;
}

.log-line.scope-hl { background: rgba(124, 141, 234, 0.18) !important; }
.log-line.scope-hl-cap { border-left: 2px solid var(--unit) !important; background: rgba(124, 141, 234, 0.30) !important; }
.log-badge[data-pair], [data-pair] { cursor: pointer; }
.log-badge.clickable-badge:hover { filter: brightness(1.3); }

.search-hl {
  background: var(--search-hl);
  color: #000;
  border-radius: 2px;
  padding: 0 2px;
}

.search-nav-btn {
  background: transparent;
  border: 1px solid #222;
  border-radius: 3px;
  color: var(--text-ghost);
  font-size: 8px;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s;
  flex-shrink: 0;
}
.search-nav-btn:hover { border-color: #444; color: var(--text-dim); }

.log-line.search-match { background: rgba(244, 197, 66, 0.08) !important; }
.log-line.search-match-current { background: rgba(244, 197, 66, 0.22) !important; border-left: 2px solid var(--search-hl) !important; }

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-ghost);
  font-family: var(--mono);
  font-size: 13px;
}

/* -- limits panel -- */
.limits-panel {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  padding: 14px 16px;
  background: var(--bg-panel);
  overflow-y: auto;
  max-height: calc(100vh - 100px);
  position: sticky;
  top: 100px;
}

.limits-panel.hidden { display: none; }

.limits-title {
  font-size: 11px;
  color: var(--limit);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: var(--mono);
  font-weight: 600;
  margin-bottom: 14px;
}

.limit-row { margin-bottom: 6px; }

.limit-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-family: var(--mono);
  margin-bottom: 2px;
}

.limit-name { color: #bbb; }
.limit-name.warn { color: var(--warn); }
.limit-name.danger { color: var(--error); }

.limit-values { color: var(--text-faint); }

.limit-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.limit-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* -- scroll to top -- */
.scroll-top-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 16px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.2s, border-color 0.15s;
  font-family: var(--mono);
}
.scroll-top-btn:hover { border-color: var(--accent); color: var(--accent); }
.scroll-top-btn.visible { display: flex; }

/* -- responsive -- */
@media (max-width: 768px) {
  .limits-panel { display: none; }
  .stats-bar { padding: 10px 12px; gap: 8px; }
  .header-bar { padding: 8px 12px; }
  #search-input { width: 140px; }
  .input-title { font-size: 24px; }
  #input-view { padding: 32px 16px; }
}
