@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&family=JetBrains+Mono:wght@500;600&display=swap");

/* One-screen shell: header on top, dashboard fills the rest, no page scroll */
html,
body {
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 0% 0%, rgba(124, 58, 237, 0.07), transparent 60%),
    radial-gradient(900px 500px at 100% 100%, rgba(6, 182, 212, 0.07), transparent 60%),
    #f6f7fb !important;
}

.app-shell {
  background: transparent !important;
}

.app-shell,
.app-shell > * {
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
}

/* The unlicensed-DDK banner is injected as a sibling above the shell, so the
   shell's parent owns the viewport and the shell takes what's left */
:has(> .app-shell) {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-shell {
  flex: 1 1 0;
  /* DDK gives .ddk-container min-height: 100vh, which ignores the banner */
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column;
}

/* Only the dashboard grows; DDK's header would otherwise stretch too */
.app-shell > * {
  flex: 0 0 auto !important;
}

.app-shell > .dashboard-loading {
  flex: 1 1 0 !important;
}

.dashboard-loading,
.dashboard-loading > .dashboard-loading {
  min-height: 0;
  height: 100%;
}

.dashboard {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 36fr) minmax(0, 64fr);
  gap: 12px;
  padding: 12px;
  box-sizing: border-box;
}

.watchlist-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  min-height: 0;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 12px;
  min-height: 0;
}

/* Cards stretch to their grid cell; their graph or grid takes the leftover */
.fill-card {
  display: flex !important;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  background: #ffffff !important;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.fill-card:hover {
  border-color: rgba(29, 78, 216, 0.45) !important;
  box-shadow: 0 12px 32px rgba(29, 78, 216, 0.16) !important;
}

/* DDK wraps card children in .card--content; make that the flex column */
.fill-card > .card--content {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.fill-graph,
.trades-grid {
  flex: 1 1 0;
  min-height: 0;
  width: 100%;
}

/* dash-ag-grid sets an inline 400px height; let the flex layout size it */
.trades-grid {
  height: auto !important;
}

.fill-graph .js-plotly-plot,
.fill-graph .plot-container {
  height: 100% !important;
}

/* Header: deep blue gradient with a bright underline */
.app-header {
  background: linear-gradient(100deg, #0b2a6f 0%, #1d4ed8 50%, #3b82f6 100%) !important;
  position: relative;
}

.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, #06b6d4, #3b82f6 55%, #93c5fd);
}

/* Header wordmark */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 22px;
}

.brand-mark span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.85);
}

/* Rising bars, the last one picked out in the accent */
.brand-mark span:nth-child(1) { height: 30%; }
.brand-mark span:nth-child(2) { height: 50%; }
.brand-mark span:nth-child(3) { height: 40%; }
.brand-mark span:nth-child(4) { height: 70%; }
.brand-mark span:nth-child(5) { height: 100%; background: #fbbf24; box-shadow: 0 0 10px rgba(251, 191, 36, 0.8); }

.brand-name {
  font-family: "Space Grotesk", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: linear-gradient(90deg, #ffffff, #dbeafe);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.1;
}

.brand-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.35);
}

.brand-product {
  font-family: "Space Grotesk", sans-serif;
  font-size: 17px;
  font-weight: 500;
  color: #ffffff;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
}

.data-source-note {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
}

/* Connection status pill in the header */
.stream-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  padding: 4px 12px;
}

.stream-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

/* "How it works" code panel, opened by hovering the header icon */
.code-peek {
  position: relative;
  outline: none;
}

.code-peek-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.3);
  cursor: help;
  transition: background 0.15s ease;
}

.code-peek:hover .code-peek-trigger,
.code-peek:focus-within .code-peek-trigger {
  --icon-color: #1d4ed8;
  background: #ffffff;
  border-color: #ffffff;
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.5);
}

.code-peek-icon,
.code-peek-icon * {
  color: var(--icon-color, #ffffff) !important;
  font-size: 14px;
}

.code-peek-panel {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 2000;
  /* Transparent gap so the pointer can move from icon to panel */
  padding-top: 10px;
  width: min(780px, calc(100vw - 32px));
}

.code-peek:hover .code-peek-panel,
.code-peek:focus-within .code-peek-panel {
  display: block;
}

.code-peek-body {
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  background: #ffffff;
  color: #1e1b2e;
  border: 1px solid #eceef5;
  border-top: 4px solid #7c3aed;
  border-radius: 14px;
  box-shadow: 0 20px 48px rgba(76, 29, 149, 0.18);
  padding: 16px 20px 8px;
  text-align: left;
}

.code-peek-header {
  border-bottom: 1px solid #eceef5;
  padding-bottom: 10px;
  margin-bottom: 4px;
}

.code-peek-title {
  font-size: 16px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  color: #1e1b2e;
}

.code-peek-subtitle {
  font-size: 12px;
  color: #94a3b8;
}

.code-peek-heading {
  margin-top: 14px;
  font-size: 14px;
  font-weight: 700;
  color: #6d28d9;
}

.code-peek-caption {
  margin: 2px 0 6px;
  font-size: 13px;
  color: #64748b;
}

.code-peek-code pre code,
.code-peek-code .hljs {
  font-size: 12px !important;
  line-height: 1.45;
  background: transparent !important;
  padding: 0 !important;
}

.code-peek-code pre {
  margin: 0 0 8px;
  padding: 10px 12px;
  background: #f8f7ff;
  border: 1px solid #eee9fe;
  border-left: 3px solid #7c3aed;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  overflow-x: auto;
}

/* Watchlist cards */
.ticker-card {
  position: relative;
  border-top-width: 1px !important;
}

/* Per-slot neon bar along the top edge; color comes from --slot-color */
.ticker-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 14px;
  right: 14px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--slot-color);
  box-shadow: 0 2px 10px var(--slot-color);
}

.ticker-select .Select-control,
.ticker-select .Select-value-label {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  color: #1e1b2e !important;
}

.ticker-quote {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  column-gap: 10px;
  margin: 6px 0 2px;
}

.ticker-price {
  font-family: "JetBrains Mono", monospace;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #1e1b2e;
  font-variant-numeric: tabular-nums;
}

.ticker-change {
  font-size: 13px;
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 8px;
  border-radius: 999px;
}

.ticker-change.up {
  color: #059669;
  background: rgba(16, 185, 129, 0.12);
}

.ticker-change.down {
  color: #e11d48;
  background: rgba(244, 63, 94, 0.1);
}

.ticker-change.flat {
  color: #94a3b8;
}

/* Small screens: fall back to a normal scrolling page */
@media (max-width: 900px) {
  html,
  body {
    height: auto;
    overflow: auto;
  }

  :has(> .app-shell),
  .app-shell {
    height: auto;
  }

  .app-shell {
    flex: 0 0 auto;
  }

  .dashboard {
    display: flex;
    flex-direction: column;
  }

  .watchlist-row,
  .detail-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .ticker-card {
    height: 260px;
  }

  .detail-row .fill-card {
    height: 420px;
  }

  .data-source-note,
  .brand-divider,
  .brand-product {
    display: none;
  }
}

/* Market-closed banner under the header */
.market-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  /* !important: .app-shell > * zeroes padding on shell children */
  padding: 8px 18px !important;
  font-size: 13px;
  color: #92400e;
  background: linear-gradient(90deg, #fef3c7, #fde68a 50%, #fef3c7);
  border-bottom: 1px solid #fcd34d;
}

.market-banner[hidden] {
  display: none;
}

.market-banner-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25);
}
