/* =====================================================================
   NovaTrade — Design tokens & core theme
   Palette: near-black trading terminal, violet brand accent, teal/coral
   for up/down (functionally meaningful, not decorative).
   Type: Space Grotesk (display) + Inter (body) + JetBrains Mono (data)
   ===================================================================== */

:root {
  --bg-primary: #0a0d13;
  --bg-surface: #12161f;
  --bg-surface-2: #191f2c;
  --bg-surface-3: #212838;
  --border-subtle: #232a3a;
  --border-strong: #333c52;
  --text-primary: #e9ebf1;
  --text-secondary: #8b92a8;
  --text-muted: #5b6478;

  --brand: #7b61ff;
  --brand-dim: #5b45d6;
  --brand-glow: rgba(123, 97, 255, 0.35);

  --up: #00d3a7;
  --up-dim: rgba(0, 211, 167, 0.14);
  --down: #ff4d6a;
  --down-dim: rgba(255, 77, 106, 0.14);
  --warn: #ffb454;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Menlo, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 15px;
  min-height: 100%;
}

h1, h2, h3, h4, h5, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

.mono, .price, .balance-figure, .ticker-item, table td.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: #9c87ff; }

::selection { background: var(--brand-glow); }

/* Focus visibility (accessibility floor) */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------------
   Layout shell
   --------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 76px;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 6px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}

.sidebar .brand-mark {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--brand), var(--brand-dim));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 18px;
  margin-bottom: 18px;
}

.sidebar .nav-icon {
  width: 46px; height: 46px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.sidebar .nav-icon:hover { background: var(--bg-surface-2); color: var(--text-primary); }
.sidebar .nav-icon.active { background: var(--bg-surface-2); color: var(--brand); }
.sidebar .nav-icon.active::before {
  content: ''; position: absolute; left: -20px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; background: var(--brand); border-radius: 3px;
}
.sidebar .nav-icon .badge-dot {
  position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  background: var(--down); border-radius: 50%; border: 2px solid var(--bg-surface);
}

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-primary);
  position: sticky; top: 0; z-index: 20;
}

.wallet-toggle {
  display: flex; background: var(--bg-surface); border-radius: 999px; padding: 3px; gap: 2px;
  border: 1px solid var(--border-subtle);
}
.wallet-toggle button {
  border: none; background: transparent; color: var(--text-secondary);
  padding: 7px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
  font-family: var(--font-display);
  transition: background 0.15s, color 0.15s;
}
.wallet-toggle button.active.demo { background: var(--bg-surface-3); color: var(--warn); }
.wallet-toggle button.active.live { background: var(--up-dim); color: var(--up); }

.balance-figure { font-size: 15px; font-weight: 600; }

/* ---------------------------------------------------------------------
   Signature element: live ticker tape
   --------------------------------------------------------------------- */
.ticker-tape {
  overflow: hidden;
  white-space: nowrap;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  padding: 9px 0;
  position: relative;
}
.ticker-tape::before, .ticker-tape::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 60px; z-index: 2; pointer-events: none;
}
.ticker-tape::before { left: 0; background: linear-gradient(90deg, var(--bg-surface), transparent); }
.ticker-tape::after { right: 0; background: linear-gradient(270deg, var(--bg-surface), transparent); }

.ticker-track {
  display: inline-flex;
  animation: ticker-scroll 32s linear infinite;
}
.ticker-tape:hover .ticker-track { animation-play-state: paused; }

@keyframes ticker-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.ticker-item {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 0 22px; font-size: 13px; border-right: 1px solid var(--border-subtle);
}
.ticker-item .sym { color: var(--text-secondary); font-weight: 600; }
.ticker-item .chg.up { color: var(--up); }
.ticker-item .chg.down { color: var(--down); }

/* ---------------------------------------------------------------------
   Trading workspace
   --------------------------------------------------------------------- */
.trade-workspace { display: flex; flex: 1; min-height: 0; }

.chart-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chart-header {
  display: flex; align-items: center; gap: 16px; padding: 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
}
.asset-picker-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md); padding: 8px 14px; color: var(--text-primary);
}
.asset-picker-btn .payout-chip {
  background: var(--up-dim); color: var(--up); font-size: 12px; font-weight: 700;
  padding: 2px 9px; border-radius: 999px; font-family: var(--font-mono);
}
#tv_chart_container { flex: 1; min-height: 340px; }

.trade-panel {
  width: 340px; flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  padding: 20px;
  display: flex; flex-direction: column; gap: 18px;
  overflow-y: auto;
}

.trade-panel label.field-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); font-weight: 600; margin-bottom: 8px; display: block;
}

.amount-input-wrap {
  display: flex; align-items: center; background: var(--bg-surface-2);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); overflow: hidden;
}
.amount-input-wrap span { padding: 0 12px; color: var(--text-secondary); font-family: var(--font-mono); }
.amount-input-wrap input {
  flex: 1; background: transparent; border: none; color: var(--text-primary);
  padding: 12px 12px 12px 0; font-family: var(--font-mono); font-size: 16px; font-weight: 600;
}
.amount-input-wrap input:focus { outline: none; }
.amount-quick { display: flex; gap: 6px; margin-top: 8px; }
.amount-quick button {
  flex: 1; background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
  color: var(--text-secondary); border-radius: var(--radius-sm); padding: 6px 0; font-size: 12px;
}
.amount-quick button:hover { border-color: var(--brand); color: var(--text-primary); }

.duration-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.duration-grid button {
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle);
  color: var(--text-secondary); border-radius: var(--radius-sm); padding: 10px 0; font-size: 13px; font-weight: 600;
}
.duration-grid button.active { border-color: var(--brand); color: var(--text-primary); background: rgba(123,97,255,0.12); }

.payout-preview {
  background: var(--bg-surface-2); border-radius: var(--radius-md); padding: 12px 14px;
  display: flex; justify-content: space-between; align-items: baseline;
  border: 1px solid var(--border-subtle);
}
.payout-preview .amt { font-family: var(--font-mono); font-size: 18px; font-weight: 700; color: var(--up); }

.btn-direction {
  display: block; width: 100%; border: none; border-radius: var(--radius-md);
  padding: 15px 0; font-family: var(--font-display); font-weight: 700; font-size: 16px;
  color: #071a15; letter-spacing: 0.01em; transition: transform 0.08s, box-shadow 0.15s;
}
.btn-direction:active { transform: scale(0.98); }
.btn-up { background: var(--up); box-shadow: 0 6px 20px rgba(0,211,167,0.25); }
.btn-up:hover { box-shadow: 0 8px 26px rgba(0,211,167,0.4); }
.btn-down { background: var(--down); color: #290812; box-shadow: 0 6px 20px rgba(255,77,106,0.25); }
.btn-down:hover { box-shadow: 0 8px 26px rgba(255,77,106,0.4); }

/* ---------------------------------------------------------------------
   Cards, tables, badges (shared across user + admin)
   --------------------------------------------------------------------- */
.card-surface {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
}

.table-nova {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
.table-nova th {
  text-align: left; color: var(--text-muted); font-weight: 600; text-transform: uppercase;
  font-size: 11px; letter-spacing: 0.05em; padding: 10px 14px; border-bottom: 1px solid var(--border-subtle);
}
.table-nova td { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table-nova tbody tr:hover { background: var(--bg-surface-2); }

.badge-status {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-won { background: var(--up-dim); color: var(--up); }
.badge-lost { background: var(--down-dim); color: var(--down); }
.badge-active { background: rgba(123,97,255,0.14); color: var(--brand); }
.badge-pending { background: rgba(255,180,84,0.14); color: var(--warn); }

.btn-nova {
  font-family: var(--font-display); font-weight: 600; border-radius: var(--radius-sm);
  padding: 9px 18px; border: 1px solid transparent; font-size: 13.5px;
}
.btn-nova-primary { background: var(--brand); color: #fff; }
.btn-nova-primary:hover { background: var(--brand-dim); color: #fff; }
.btn-nova-outline { background: transparent; border-color: var(--border-strong); color: var(--text-primary); }
.btn-nova-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-nova-win { background: var(--up); color: #071a15; }
.btn-nova-lose { background: var(--down); color: #290812; }

.form-control-nova {
  background: var(--bg-surface-2); border: 1px solid var(--border-subtle); color: var(--text-primary);
  border-radius: var(--radius-sm); padding: 10px 12px; width: 100%;
}
.form-control-nova:focus { outline: none; border-color: var(--brand); background: var(--bg-surface-3); }

.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.stat-card .stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin-top: 6px; }

/* ---------------------------------------------------------------------
   Auth pages
   --------------------------------------------------------------------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, rgba(123,97,255,0.12), transparent 45%), var(--bg-primary);
  padding: 24px;
}
.auth-card { width: 100%; max-width: 400px; padding: 34px 32px; }
.auth-card .brand-row { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; }

/* Countdown ring on active trade cards */
.trade-mini {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: var(--bg-surface-2); border-radius: var(--radius-sm); margin-bottom: 8px;
  border: 1px solid var(--border-subtle);
}
.trade-mini .countdown { font-family: var(--font-mono); font-size: 12.5px; color: var(--warn); }

.flash-alert {
  border-radius: var(--radius-md); padding: 12px 16px; margin-bottom: 16px; font-size: 14px;
  border: 1px solid transparent;
}
.flash-success { background: var(--up-dim); color: var(--up); border-color: rgba(0,211,167,0.3); }
.flash-error { background: var(--down-dim); color: var(--down); border-color: rgba(255,77,106,0.3); }

@media (max-width: 991px) {
    
    #tv_chart_container { flex: 1; min-height: 170px !important; }

  /* Layout adjustments */
  .trade-workspace {
    flex-direction: column;
  }

  .trade-panel {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
  }

  /* Fixed Top Header Bar on Mobile */
  .topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000 !important;
    background-color: #121824;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-subtle, #1e293b);
  }

  /* Offset page content */
  body {
    padding-top: 60px;
  }

  /* Mobile Sidebar Drawer */
  .sidebar {
    display: block !important;      /* Override any display:none */
    position: fixed !important;
    top: 60px;                      /* Below topbar */
    left: -280px;                   /* Hidden off-screen */
    width: 53px;
    height: calc(100vh - 60px);
    z-index: 99999 !important;      /* Above charts/overlays */
    background-color: #121824 !important;
    transition: left 0.3s ease-in-out;
  }

  /* Show sidebar */
  .sidebar.show {
    left: 0 !important;
  }

}