/* DT Nexus Charts — app shell.
 *
 * Everything inside the chart itself is painted by TradingView's own theme
 * (driven from src/theme.js via widget.changeTheme). These rules only cover
 * the header, the chart frame, and the loading / error overlays — but they
 * use the same two palettes so the seam between shell and chart is invisible.
 */

:root {
  --brand-red: #e8232a;

  /* Light palette (matches TradingView's light theme surfaces). */
  --bg: #ffffff;
  --surface: #ffffff;
  --header-bg: #ffffff;
  --border: #e0e3eb;
  --text: #131722;
  --text-muted: #6a7185;
  --hover: #f0f3fa;
}

:root[data-theme="dark"] {
  /* Dark palette (matches TradingView's dark theme surfaces). */
  --bg: #131722;
  --surface: #1e222d;
  --header-bg: #1e222d;
  --border: #2a2e39;
  --text: #d1d4dc;
  --text-muted: #868993;
  --hover: #2a2e39;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  /* dvh keeps the chart off the mobile URL bar as it collapses; the vh line
     above it is the fallback for browsers without dvh. */
  height: 100vh;
  height: 100dvh;
}

/* ---------------------------------------------------------------- header */

.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand__mark {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
}

.brand__mark--dark,
:root[data-theme="dark"] .brand__mark--light {
  display: none;
}

:root[data-theme="dark"] .brand__mark--dark {
  display: block;
}

.brand__name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand__name-accent {
  color: var(--brand-red);
}

.brand__divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  flex: 0 0 auto;
}

.brand__sub {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ----------------------------------------------------------- theme toggle */

.theme-toggle {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover {
  background: var(--hover);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--brand-red);
  outline-offset: 2px;
}

.theme-toggle__icon {
  width: 18px;
  height: 18px;
}

/* Show the icon for the mode the button switches *to*. */
.theme-toggle__icon--sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle__icon--sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle__icon--moon {
  display: none;
}

/* ----------------------------------------------------------------- chart */

.chart-shell {
  flex: 1 1 auto;
  position: relative;
  min-height: 0;
  background: var(--bg);
}

.chart-shell__chart {
  width: 100%;
  height: 100%;
}

/* -------------------------------------------------------------- overlays */

.chart-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: var(--bg);
}

.chart-overlay[hidden] {
  display: none;
}

.chart-overlay__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chart-overlay__text {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 40ch;
}

.chart-overlay__button {
  margin-top: 4px;
  padding: 8px 20px;
  border: none;
  border-radius: 8px;
  background: var(--brand-red);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 2.4s;
  }
}

/* ----------------------------------------------------------- feed notice */

.feed-notice {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(90vw, 420px);
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 18%);
  opacity: 0;
  transform: translate(-50%, 8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.feed-notice--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------------------------------------------------------------- mobile */

@media (max-width: 480px) {
  .app-header {
    height: 48px;
    padding: 0 12px;
  }

  .brand__divider,
  .brand__sub {
    display: none;
  }
}

