/* =============================================================
   WellScope LAS Log Viewer
   - Dark UI shell, white plot canvas (matches industry log style)
   - Two views: Single (one file, 4 tracks) / Multi (up to 10 files)
   ============================================================= */

:root {
  --bg-page:       #0b0f15;
  --bg-panel:      #11171f;
  --bg-panel-2:    #181f29;
  --bg-elev:       #1f2733;
  --border:        #2a323e;
  --border-strong: #3a4452;
  --text:          #e6e8ec;
  --text-dim:      #97a0ad;
  --text-faint:    #5f6875;
  --accent:        #d4a84b;
  --accent-2:      #3dbfb8;
  --danger:        #e86f68;

  /* Plot palette - matches reference image and request */
  --plot-bg:       #ffffff;
  --plot-grid:     #d6d6d6;
  --plot-grid-major: #b0b0b0;
  --plot-frame:    #555555;
  --plot-text:     #1a1a1a;
  --curve-ccl:     #111111;
  --curve-tens:    #cc1f1f;
  --curve-spd:     #1d4ed8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg-page);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

button { font-family: inherit; }

a { color: var(--accent-2); text-decoration: none; }
a:hover { color: var(--accent); }

/* ----- Top bar ------------------------------------------------- */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  height: 56px;
}
.brand { display: flex; align-items: center; }
.brand-logo {
  height: 36px;
  width: auto;
  display: block;
}
.brand-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  margin-left: 0.25rem;
}

.view-toggle {
  display: inline-flex;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px;
}
.vt-btn {
  background: transparent;
  border: 0;
  color: var(--text-dim);
  padding: 6px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 4px;
  transition: background 120ms, color 120ms;
}
.vt-btn:hover { color: var(--text); }
.vt-btn.active {
  background: var(--accent);
  color: #1a1a1a;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.hint {
  font-size: 12px;
  color: var(--text-faint);
  font-style: italic;
}
/* Live tool measured-depth readout (mirrors the kiosk/dashboard MD). */
.tool-depth {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent, #0a84ff);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  white-space: nowrap;
}
.tool-depth.stale {
  color: var(--text-faint);
  font-weight: 400;
}
.btn {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 120ms, border-color 120ms;
}
.btn:hover { background: var(--bg-panel-2); border-color: var(--border-strong); }
.btn.small { padding: 4px 8px; font-size: 12px; }

/* ----- Layout shell ------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100% - 56px);
  overflow: hidden;
}

/* ----- File panel --------------------------------------------- */
.file-panel {
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.file-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.85rem 0.5rem;
}
.fp-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-dim);
}
.fp-count {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.fp-filter { padding: 0 0.85rem 0.5rem; }
.fp-filter input {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 12px;
  outline: none;
}
.fp-filter input:focus { border-color: var(--accent); }
.fp-status {
  padding: 0 0.85rem 0.5rem;
  font-size: 11px;
  color: var(--text-faint);
  font-style: italic;
  min-height: 1.3em;
}
.fp-status.error { color: var(--danger); font-style: normal; }
.fp-status.ok    { color: var(--accent-2); }
.fp-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.5rem 0.5rem;
}
.fp-foot {
  padding: 0.5rem 0.85rem 0.75rem;
  border-top: 1px solid var(--border);
}

.fp-group-label {
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0.6rem 0.35rem 0.3rem;
  opacity: 0.85;
}
.fp-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 100ms;
  margin-bottom: 2px;
}
.fp-item:hover { background: var(--bg-panel-2); }
.fp-item.selected {
  background: rgba(212, 168, 75, 0.12);
  border-color: rgba(212, 168, 75, 0.55);
}
.fp-item.disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.fp-item-marker {
  flex: 0 0 14px;
  height: 14px;
  margin-top: 2px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--bg-page);
  position: relative;
}
.fp-item.selected .fp-item-marker {
  background: var(--accent);
  border-color: var(--accent);
}
.fp-item.selected .fp-item-marker::after {
  content: '';
  position: absolute;
  top: 1px; left: 4px;
  width: 4px; height: 8px;
  border-right: 2px solid #1a1a1a;
  border-bottom: 2px solid #1a1a1a;
  transform: rotate(45deg);
}
.fp-item-body { flex: 1; min-width: 0; }
.fp-item-name {
  font-size: 12.5px;
  font-weight: 500;
  word-break: break-all;
  line-height: 1.25;
}
.fp-live {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 3px;
  background: #d92b2b;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.06em;
  vertical-align: 1px;
  animation: fp-live-pulse 1.6s ease-in-out infinite;
}
@keyframes fp-live-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

.fp-item-ws {
  font-size: 10px;
  color: var(--accent-2);
  margin-top: 1px;
  line-height: 1.2;
  word-break: break-word;
}
.fp-item-meta {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 2px;
}
.fp-kind {
  display: inline-block;
  font-size: 9.5px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-right: 4px;
  vertical-align: middle;
  text-transform: uppercase;
}
.fp-kind.up         { background: rgba(74, 222, 128, 0.18);  color: #4ade80; }
.fp-kind.down       { background: rgba(157, 124, 216, 0.18); color: #b196f0; }
.fp-kind.continuous { background: rgba(61, 191, 184, 0.18);  color: #58d3cd; }
.fp-kind.other      { background: rgba(212, 168, 75, 0.18);  color: #d4a84b; }

/* ----- Plot area ---------------------------------------------- */
.plot-area {
  display: flex;
  flex-direction: column;
  background: var(--bg-page);
  overflow: hidden;
}
.plot-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.legend {
  display: flex;
  gap: 1rem;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
}
.swatch {
  display: inline-block;
  width: 16px;
  height: 3px;
  border-radius: 2px;
}
.swatch.ccl  { background: #ffffff; outline: 1px solid #999; }
.swatch.tens { background: var(--curve-tens); }
.swatch.spd  { background: var(--curve-spd); }
.depth-info {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.scale-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
}
.scale-picker select {
  background: var(--bg-page);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
}

.plot-canvas-wrap {
  flex: 1;
  position: relative;
  overflow: auto;
  background: var(--plot-bg);
}
/* Spacer provides the scrollable extent (which can be far taller than
   the browser's canvas-height cap); the canvas is absolutely positioned
   inside it and JS translates it to the currently rendered window. */
#plotSpacer {
  position: relative;
}
#plotCanvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}
/* Track headers on their own canvas: sticky keeps them pinned while
   the log scrolls vertically; they still pan with horizontal scroll. */
#headerCanvas {
  display: block;
  position: sticky;
  top: 0;
  z-index: 5;
}
#headerCanvas[hidden] { display: none; }
.plot-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  pointer-events: none;
  font-family: 'Inter', sans-serif;
}
.plot-empty-icon { font-size: 48px; margin-bottom: 8px; opacity: 0.4; }
.plot-empty h2 { font-size: 18px; font-weight: 500; color: var(--text-dim); margin-bottom: 4px; }
.plot-empty p  { font-size: 13px; }
.plot-empty.hidden { display: none; }

/* ----- Loading progress overlays -------------------------------- */
/* Zero-size anchor at the scroll-content origin; children are placed
   in content coordinates so they track the columns when scrolling. */
.load-overlays {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 6;
}
/* Current-tool-depth marker on the depth track: dot when the tool is
   on screen, up/down arrow pinned to the viewport edge otherwise. */
#depthMarker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: none;
  z-index: 7;
}
#depthMarker .dm-sym {
  font-size: 13px;
  line-height: 1;
  color: #e5484d;
  text-shadow: 0 0 3px rgba(255, 255, 255, 0.9);
}
#depthMarker.dm-in .dm-sym {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #e5484d;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 8px rgba(229, 72, 77, 0.7);
  animation: dm-pulse 1.6s ease-in-out infinite;
}
#depthMarker .dm-lbl {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 600;
  color: #b3282d;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(229, 72, 77, 0.5);
  border-radius: 4px;
  padding: 1px 4px;
  white-space: nowrap;
}
@keyframes dm-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 4px rgba(229, 72, 77, 0.5); }
  50%      { box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0 12px rgba(229, 72, 77, 0.95); }
}

.load-spin {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #d0d0d0;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}
.ls-ringwrap {
  position: relative;
  width: 56px;
  height: 56px;
}
.ls-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, rgba(0, 0, 0, 0.12) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 7px), #000 calc(100% - 6px));
}
.ls-ring.indeterminate {
  background: conic-gradient(from 0deg, rgba(0, 0, 0, 0.05), var(--accent));
  animation: ls-rotate 0.9s linear infinite;
}
@keyframes ls-rotate { to { transform: rotate(360deg); } }
.ls-pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #1a1a1a;
  font-variant-numeric: tabular-nums;
}
.ls-name {
  max-width: 170px;
  font-size: 10.5px;
  color: #444;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----- Context menu (right-click popups) ----------------------- */
.ctx-menu {
  position: fixed;
  z-index: 1000;
  min-width: 230px;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  padding: 6px;
  font-size: 12px;
  color: var(--text);
}
.ctx-title {
  font-weight: 700;
  font-size: 12px;
  padding: 4px 6px;
  color: var(--accent);
  word-break: break-all;
}
.ctx-note {
  font-size: 10.5px;
  color: var(--text-faint);
  padding: 0 6px 4px;
  font-style: italic;
}
.ctx-sep { height: 1px; background: var(--border); margin: 6px 0; }
.ctx-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 4px 6px;
}
.ctx-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
}
.ctx-row input[type="number"] {
  width: 76px;
  background: var(--bg-page);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 12px;
}
.ctx-row input[type="number"]:focus { border-color: var(--accent); outline: none; }
.ctx-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12.5px;
}
.ctx-item:hover { background: var(--bg-panel-2); }
.ctx-btn {
  background: var(--accent);
  color: #1a1a1a;
  border: 0;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.ctx-btn:hover { filter: brightness(1.1); }
.ctx-btn.ghost {
  background: var(--bg-panel-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

/* ----- Offline snapshot page ----------------------------------- */
.snapshot-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 34px;
  padding: 0 1rem;
  background: var(--bg-panel-2);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  overflow-x: auto;
  white-space: nowrap;
}
.snapshot-banner .sb-label { color: var(--accent); font-weight: 600; }
.snapshot-banner .sb-files { display: inline-flex; gap: 0.9rem; }
body.snapshot .layout { height: calc(100% - 56px - 34px); }

/* ----- Snapshot export modal (ZIP build progress) --------------- */
.snap-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 11, 0.62);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.snap-modal {
  width: min(440px, calc(100vw - 32px));
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  padding: 16px 18px 14px;
  font-size: 13px;
}
.snap-modal .sm-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
}
.snap-modal .sm-status { color: var(--text-dim); margin-bottom: 8px; }
.snap-modal .sm-bar {
  height: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.snap-modal .sm-bar-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.25s ease;
}
.snap-modal .sm-pct {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-faint);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.snap-modal .sm-result { margin-top: 8px; }
.snap-modal .sm-ok  { color: var(--text); }
.snap-modal .sm-err { color: #e06c5f; }
.snap-modal .sm-note {
  color: var(--text-dim);
  font-size: 11.5px;
  margin: 6px 0 4px;
  line-height: 1.4;
}
.snap-modal .sm-link {
  display: inline-block;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-panel-2);
  word-break: break-all;
}
.snap-modal .sm-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}
