/* ==========================================================================
   Tick Market Explorer — Page Styles
   Dark theme consistent with DeltaStrike (shadcn/ui inspired)
   ========================================================================== */

:root {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #0a0a0c;
  --card-foreground: #fafafa;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --border: #27272a;
  --radius: 0.5rem;

  /* Market event colors */
  --bid-depth-addition-color: #22c55e;
  --bid-depth-addition-background: rgba(34, 197, 94, 0.15);
  --bid-depth-removal-color: #86efac;
  --bid-depth-removal-background: rgba(134, 239, 172, 0.08);
  --ask-depth-addition-color: #ef4444;
  --ask-depth-addition-background: rgba(239, 68, 68, 0.15);
  --ask-depth-removal-color: #fca5a5;
  --ask-depth-removal-background: rgba(252, 165, 165, 0.08);
  --market-buy-trade-color: #4ade80;
  --market-buy-trade-background: rgba(74, 222, 128, 0.25);
  --market-sell-trade-color: #f87171;
  --market-sell-trade-background: rgba(248, 113, 113, 0.25);
  --wall-eaten-by-trade-glow-color: rgba(251, 191, 36, 0.6);

  /* Grid layout */
  --tick-explorer-price-label-column-width: 90px;
  --tick-explorer-time-column-width: 72px;
  --tick-explorer-orderbook-snapshot-panel-width: 260px;
  --tick-explorer-cell-height: 28px;
}

/* ==========================================================================
   Base / Reset
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', system-ui, sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   Layout
   ========================================================================== */
.tick-explorer-page-container {
  max-width: 100%;
  padding: 68px 16px 16px; /* 56px navbar + 12px gap */
  min-height: 100vh;
}

/* ==========================================================================
   Demo Banner
   ========================================================================== */
.tick-explorer-demo-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  margin-bottom: 16px;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: var(--radius);
  color: #fbbf24;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.tick-explorer-demo-banner-icon {
  font-size: 16px;
  flex-shrink: 0;
}

/* ==========================================================================
   Top Controls Bar
   ========================================================================== */
.tick-explorer-controls-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  margin-bottom: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.tick-explorer-controls-bar-section {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tick-explorer-controls-bar-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.tick-explorer-playback-speed-selector,
.tick-explorer-time-resolution-selector {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--foreground);
  font-size: 12px;
  padding: 4px 8px;
  cursor: pointer;
}

.tick-explorer-playback-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--muted);
  color: var(--foreground);
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.tick-explorer-playback-button:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #3f3f46;
}

.tick-explorer-playback-button-active {
  background: rgba(74, 222, 128, 0.15);
  border-color: rgba(74, 222, 128, 0.4);
  color: #4ade80;
}

.tick-explorer-current-tick-time-display {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 13px;
  color: var(--foreground);
  padding: 4px 10px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
}

/* ==========================================================================
   Main Grid Area (heatmap + snapshot panel)
   ========================================================================== */
.tick-explorer-main-content-area {
  display: flex;
  gap: 12px;
}

/* ==========================================================================
   Heatmap Grid
   ========================================================================== */
.tick-explorer-heatmap-grid-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: calc(100vh - 240px);
  position: relative;
}

.tick-explorer-heatmap-grid-table {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
}

/* Sticky price label column */
.tick-explorer-price-level-label-cell {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--card);
  border-right: 2px solid var(--border);
  width: var(--tick-explorer-price-label-column-width);
  min-width: var(--tick-explorer-price-label-column-width);
  max-width: var(--tick-explorer-price-label-column-width);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11px;
  color: var(--muted-foreground);
  text-align: right;
  padding: 0 8px;
  height: var(--tick-explorer-cell-height);
  line-height: var(--tick-explorer-cell-height);
  white-space: nowrap;
}

/* Price level at mid price gets a highlight */
.tick-explorer-price-level-label-cell-mid-price {
  color: #fbbf24;
  font-weight: 600;
}

/* Ask price labels */
.tick-explorer-price-level-label-cell-ask-side {
  color: var(--ask-depth-addition-color);
}

/* Bid price labels */
.tick-explorer-price-level-label-cell-bid-side {
  color: var(--bid-depth-addition-color);
}

/* Sticky header row for time labels */
.tick-explorer-time-column-header-cell {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--card);
  border-bottom: 2px solid var(--border);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 10px;
  color: var(--muted-foreground);
  text-align: center;
  padding: 6px 4px;
  width: var(--tick-explorer-time-column-width);
  min-width: var(--tick-explorer-time-column-width);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.1s ease;
}

.tick-explorer-time-column-header-cell:hover {
  background: rgba(255, 255, 255, 0.04);
}

/* Corner cell (intersection of sticky row + column) */
.tick-explorer-corner-cell {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 4;
  background: var(--card);
  border-right: 2px solid var(--border);
  border-bottom: 2px solid var(--border);
  width: var(--tick-explorer-price-label-column-width);
  min-width: var(--tick-explorer-price-label-column-width);
  font-size: 10px;
  color: var(--muted-foreground);
  text-align: center;
  padding: 6px 4px;
}

/* Selected time column highlight */
.tick-explorer-time-column-header-cell-selected {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  font-weight: 600;
}

/* ==========================================================================
   Heatmap Event Cells
   ========================================================================== */
.tick-explorer-event-cell {
  width: var(--tick-explorer-time-column-width);
  min-width: var(--tick-explorer-time-column-width);
  height: var(--tick-explorer-cell-height);
  text-align: center;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 10px;
  padding: 0 2px;
  line-height: var(--tick-explorer-cell-height);
  border: 1px solid rgba(39, 39, 42, 0.4);
  transition: background 0.1s ease;
  cursor: default;
  position: relative;
  overflow: hidden;
}

/* Empty cell — subtle grid line only */
.tick-explorer-event-cell-empty {
  background: transparent;
}

/* Bid depth added (new/increased limit order on bid side) */
.tick-explorer-event-cell-bid-depth-added {
  background: var(--bid-depth-addition-background);
  color: var(--bid-depth-addition-color);
  font-weight: 500;
}

/* Bid depth removed (cancelled/decreased limit order on bid side) */
.tick-explorer-event-cell-bid-depth-removed {
  background: var(--bid-depth-removal-background);
  color: var(--bid-depth-removal-color);
  font-weight: 500;
}

/* Ask depth added (new/increased limit order on ask side) */
.tick-explorer-event-cell-ask-depth-added {
  background: var(--ask-depth-addition-background);
  color: var(--ask-depth-addition-color);
  font-weight: 500;
}

/* Ask depth removed (cancelled/decreased limit order on ask side) */
.tick-explorer-event-cell-ask-depth-removed {
  background: var(--ask-depth-removal-background);
  color: var(--ask-depth-removal-color);
  font-weight: 500;
}

/* Market buy trade executed (taker bought, lifts ask) */
.tick-explorer-event-cell-market-buy-trade {
  background: var(--market-buy-trade-background);
  color: var(--market-buy-trade-color);
  font-weight: 700;
}

/* Market sell trade executed (taker sold, hits bid) */
.tick-explorer-event-cell-market-sell-trade {
  background: var(--market-sell-trade-background);
  color: var(--market-sell-trade-color);
  font-weight: 700;
}

/* Special glow: trade eating a large wall */
.tick-explorer-event-cell-wall-eaten-by-trade {
  box-shadow: inset 0 0 12px var(--wall-eaten-by-trade-glow-color);
  animation: tick-explorer-wall-eaten-pulse 1.5s ease-in-out infinite;
}

@keyframes tick-explorer-wall-eaten-pulse {
  0%, 100% { box-shadow: inset 0 0 8px var(--wall-eaten-by-trade-glow-color); }
  50% { box-shadow: inset 0 0 16px var(--wall-eaten-by-trade-glow-color); }
}

/* Selected column highlight overlay */
.tick-explorer-event-cell-in-selected-column {
  border-left: 1px solid rgba(251, 191, 36, 0.25);
  border-right: 1px solid rgba(251, 191, 36, 0.25);
}

/* Mid price row separator */
.tick-explorer-event-cell-mid-price-row {
  border-top: 2px solid rgba(251, 191, 36, 0.3);
}

/* ==========================================================================
   Orderbook Snapshot Panel (right side)
   ========================================================================== */
.tick-explorer-orderbook-snapshot-panel {
  width: var(--tick-explorer-orderbook-snapshot-panel-width);
  min-width: var(--tick-explorer-orderbook-snapshot-panel-width);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
  overflow: hidden;
}

.tick-explorer-orderbook-snapshot-panel-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-align: center;
  background: var(--card);
  flex-shrink: 0;
}

.tick-explorer-orderbook-snapshot-panel-time-label {
  display: block;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11px;
  color: #fbbf24;
  margin-top: 4px;
}

.tick-explorer-orderbook-snapshot-scrollable-content {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.tick-explorer-orderbook-snapshot-table {
  width: 100%;
  border-collapse: collapse;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 11px;
}

.tick-explorer-orderbook-snapshot-table-header-row {
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.tick-explorer-orderbook-snapshot-table-header-cell {
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.tick-explorer-orderbook-snapshot-table-header-cell:first-child {
  text-align: left;
}

.tick-explorer-orderbook-snapshot-row {
  transition: background 0.1s ease;
}

.tick-explorer-orderbook-snapshot-row:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tick-explorer-orderbook-snapshot-price-cell {
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(39, 39, 42, 0.3);
}

.tick-explorer-orderbook-snapshot-quantity-cell {
  padding: 4px 8px;
  text-align: right;
  border-bottom: 1px solid rgba(39, 39, 42, 0.3);
}

.tick-explorer-orderbook-snapshot-row-ask-side .tick-explorer-orderbook-snapshot-price-cell {
  color: var(--ask-depth-addition-color);
}

.tick-explorer-orderbook-snapshot-row-bid-side .tick-explorer-orderbook-snapshot-price-cell {
  color: var(--bid-depth-addition-color);
}

.tick-explorer-orderbook-snapshot-quantity-cell {
  color: var(--foreground);
}

/* Quantity bar (horizontal fill behind text) */
.tick-explorer-orderbook-snapshot-quantity-cell {
  position: relative;
}

.tick-explorer-orderbook-snapshot-quantity-bar {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  opacity: 0.12;
  pointer-events: none;
}

.tick-explorer-orderbook-snapshot-row-ask-side .tick-explorer-orderbook-snapshot-quantity-bar {
  background: var(--ask-depth-addition-color);
}

.tick-explorer-orderbook-snapshot-row-bid-side .tick-explorer-orderbook-snapshot-quantity-bar {
  background: var(--bid-depth-addition-color);
}

/* Mid price separator in snapshot */
.tick-explorer-orderbook-snapshot-mid-price-separator {
  text-align: center;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.06);
  border-top: 1px solid rgba(251, 191, 36, 0.2);
  border-bottom: 1px solid rgba(251, 191, 36, 0.2);
}

/* ==========================================================================
   Time Scrubber (bottom slider)
   ========================================================================== */
.tick-explorer-time-scrubber-container {
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
}

.tick-explorer-time-scrubber-range-input {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--muted);
  outline: none;
  cursor: pointer;
}

.tick-explorer-time-scrubber-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fbbf24;
  cursor: pointer;
  border: 2px solid var(--background);
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.4);
}

.tick-explorer-time-scrubber-range-input::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fbbf24;
  cursor: pointer;
  border: 2px solid var(--background);
  box-shadow: 0 0 6px rgba(251, 191, 36, 0.4);
}

.tick-explorer-time-scrubber-current-time-label {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 12px;
  color: var(--muted-foreground);
  white-space: nowrap;
  min-width: 100px;
  text-align: center;
}

/* ==========================================================================
   Legend
   ========================================================================== */
.tick-explorer-event-color-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  margin-top: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.tick-explorer-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted-foreground);
}

.tick-explorer-legend-color-swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .tick-explorer-main-content-area {
    flex-direction: column;
  }

  .tick-explorer-orderbook-snapshot-panel {
    width: 100%;
    min-width: unset;
    max-height: 300px;
  }
}

@media (max-width: 640px) {
  .tick-explorer-page-container {
    padding: 60px 8px 8px;
  }

  .tick-explorer-controls-bar {
    padding: 8px 10px;
    gap: 10px;
  }

  :root {
    --tick-explorer-time-column-width: 56px;
    --tick-explorer-price-label-column-width: 72px;
  }
}
