/* DayTradeBot — Fintech Dark UI */

:root {
  /* Surfaces */
  --bg:        #0b0e17;
  --bg-card:   #131720;
  --bg-card-2: #1a2035;
  --bg-hover:  rgba(255,255,255,0.028);

  /* Borders */
  --border:    rgba(255,255,255,0.07);
  --border-hi: rgba(255,255,255,0.13);

  /* Text */
  --text:   #eef2ff;
  --text-2: #8892a4;
  --text-3: #7a8399;

  /* Green (profit, BUY) */
  --green:    #00c896;
  --green-bg: rgba(0,200,150,0.08);
  --green-bd: rgba(0,200,150,0.2);

  /* Red (loss, SELL) */
  --red:    #ff5252;
  --red-bg: rgba(255,82,82,0.08);
  --red-bd: rgba(255,82,82,0.2);

  /* Blue (accent, BUY action) */
  --blue:    #5b8def;
  --blue-bg: rgba(91,141,239,0.1);
  --blue-bd: rgba(91,141,239,0.22);

  /* Supporting */
  --yellow: #f0b429;
  --purple: #b794f4;

  /* Typography */
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;

  /* Shape */
  --r:    12px;
  --r-sm: 6px;
  --r-lg: 20px;

  /* Shadow */
  --shadow:      0 1px 4px rgba(0,0,0,0.5), 0 2px 8px rgba(0,0,0,0.3);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.45);
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  line-height: 1.5;
  padding-bottom: 52px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Header ────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 24px;
  height: 58px;
  background: rgba(11,14,23,0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.header-logo  { flex: 1; min-width: 0; }
.header-market {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}
.header-time {
  flex: 1;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

/* Logo */
.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.logo-icon {
  width: 20px;
  height: 20px;
  color: var(--blue);
  flex-shrink: 0;
}
.logo-text {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  white-space: nowrap;
}
.logo-sub {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-2);
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* Market pill */
.market-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1px;
  border: 1px solid;
  white-space: nowrap;
  transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.market-open {
  background: var(--green-bg);
  color: var(--green);
  border-color: var(--green-bd);
  box-shadow: 0 0 16px rgba(0,200,150,0.1);
}
.market-closed {
  background: rgba(120,130,155,0.1);
  color: var(--text-2);
  border-color: var(--border);
}

.market-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.market-open .market-dot {
  animation: dot-pulse 1.8s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1;   transform: scale(1);   }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

.market-countdown {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.countdown-open   { color: var(--green); }
.countdown-closed { color: var(--text-3); }

/* Clock */
.live-clock {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.8px;
}
.updated-label {
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--mono);
}

/* Header mobile */
@media (max-width: 640px) {
  .header {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 16px 8px;
    gap: 6px;
  }
  .header-logo   { order: 1; flex: 1; }
  .header-market { order: 2; flex: 0 0 auto; flex-direction: row; gap: 8px; align-items: center; }
  .header-time   { order: 3; flex: 0 0 100%; flex-direction: row; justify-content: space-between; align-items: center; padding-top: 2px; }
  .market-countdown { display: none; }
  .logo-sub { display: none; }
}

/* ── Layout ─────────────────────────────────────── */
section {
  max-width: 1600px;
  margin: 18px auto;
  padding: 0 20px;
}
@media (max-width: 640px) {
  section { padding: 0 12px; margin: 14px auto; }
}

/* ── Base Card ──────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.card:hover {
  border-color: var(--border-hi);
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.card-badge {
  font-size: 11px;
  color: var(--text-2);
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  padding: 2px 9px;
  border-radius: var(--r-sm);
  font-family: var(--mono);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Stat Cards ─────────────────────────────────── */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 900px) { .stat-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

.stat-card {
  padding: 20px 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

/* subtle radial glow for positive/negative state */
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 100%; height: 100%;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}
.stat-card.positive::after {
  background: radial-gradient(ellipse 80% 60% at 90% 10%, rgba(0,200,150,0.08), transparent);
  opacity: 1;
}
.stat-card.negative::after {
  background: radial-gradient(ellipse 80% 60% at 90% 10%, rgba(255,82,82,0.08), transparent);
  opacity: 1;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.7px;
  position: relative;
}
.stat-value {
  font-size: 30px;
  font-weight: 800;
  font-family: var(--mono);
  color: var(--text);
  letter-spacing: -0.8px;
  line-height: 1.1;
  margin-top: 4px;
  transition: color 0.3s ease;
  position: relative;
}
.stat-sub {
  font-size: 11.5px;
  color: var(--text-2);
  margin-top: 5px;
  font-family: var(--mono);
  position: relative;
}

@media (max-width: 480px) {
  .stat-card  { padding: 16px 14px 14px; }
  .stat-value { font-size: 22px; letter-spacing: -0.5px; }
  .stat-sub   { font-size: 10.5px; }
}

/* Number flash when value updates */
@keyframes stat-flash {
  0%   { opacity: 1; }
  35%  { opacity: 0.65; }
  100% { opacity: 1; }
}
.stat-value.updating {
  animation: stat-flash 0.38s ease;
}

/* ── Charts Row ─────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 14px;
}
@media (max-width: 1000px) { .charts-row { grid-template-columns: 1fr; } }

.chart-wrap {
  padding: 16px;
  height: 240px;
}
.chart-wrap-pnl {
  height: 220px;
}

/* ── Sentiment Bars ─────────────────────────────── */
.sentiment-list {
  padding: 4px 16px 8px;
  max-height: 260px;
  overflow-y: auto;
}
.sentiment-item {
  display: grid;
  grid-template-columns: 56px 1fr 64px;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.sentiment-item:last-child { border-bottom: none; }

.sentiment-symbol {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
}
.sentiment-bar-wrap {
  height: 5px;
  background: var(--bg-card-2);
  border-radius: 3px;
  overflow: hidden;
}
.sentiment-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.sentiment-bar-positive { background: linear-gradient(90deg, rgba(0,200,150,0.25), var(--green)); }
.sentiment-bar-negative { background: linear-gradient(90deg, rgba(255,82,82,0.25), var(--red)); }

.sentiment-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}
.sentiment-score {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
}
.sentiment-signal {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* ── Planning Section ───────────────────────────── */
.planning-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 10px;
  padding: 14px 18px 16px;
}
@media (max-width: 640px) {
  .planning-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    padding: 12px 14px 14px;
  }
}

.plan-card {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.plan-card:hover {
  border-color: var(--border-hi);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.plan-buy  { border-color: var(--green-bd); background: rgba(0,200,150,0.04); }
.plan-sell { border-color: var(--red-bd);   background: rgba(255,82,82,0.04); }

.plan-top {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.plan-score {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  margin-left: auto;
}
.plan-bar { /* no extra spacing needed */ }
.plan-sources {
  font-size: 10px;
  color: var(--text-2);
  font-family: var(--mono);
  line-height: 1.6;
}

/* ── Positions + Activity ───────────────────────── */
.positions-activity-row {
  display: grid;
  grid-template-columns: 55fr 45fr;
  gap: 14px;
}
@media (max-width: 1000px) { .positions-activity-row { grid-template-columns: 1fr; } }

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Data Tables ────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 520px;
}
.data-table th {
  padding: 9px 14px;
  text-align: left;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--text);
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-hover); }

/* Row tints via background instead of side-stripe borders */
.row-buy  td { background: rgba(91,141,239,0.035); }
.row-sell td { background: rgba(120,130,155,0.05); }
.row-buy:hover  td { background: var(--bg-hover) !important; }
.row-sell:hover td { background: var(--bg-hover) !important; }

.empty-cell {
  text-align: center;
  color: var(--text-3) !important;
  padding: 28px 14px !important;
  font-family: var(--sans) !important;
  font-size: 13px !important;
  font-style: italic;
}

/* ── Activity Log ───────────────────────────────── */
.activity-list {
  padding: 4px 0;
  max-height: 320px;
  overflow-y: auto;
}
.activity-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: baseline;
  padding: 8px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.activity-item:last-child { border-bottom: none; }

.activity-level {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 2px 5px;
  border-radius: 4px;
  text-align: center;
  font-family: var(--mono);
}
.level-INFO    { background: var(--blue-bg);              color: var(--blue);   }
.level-TRADE   { background: rgba(183,148,244,0.12);       color: var(--purple); }
.level-WARNING { background: rgba(240,180,41,0.12);        color: var(--yellow); }
.level-ERROR   { background: var(--red-bg);               color: var(--red);    }

.activity-content { display: flex; flex-direction: column; gap: 2px; }
.activity-message { color: var(--text); line-height: 1.4; font-size: 12.5px; }
.activity-time    { font-size: 10.5px; color: var(--text-3); font-family: var(--mono); }

/* ── Stats Pills ────────────────────────────────── */
.stats-pills {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.stat-pill {
  font-size: 11.5px;
  color: var(--text-2);
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 20px;
}
.stat-pill strong { color: var(--text); font-weight: 600; }

/* ── Chips & Badges ─────────────────────────────── */
.symbol-chip {
  display: inline-block;
  background: var(--blue-bg);
  color: var(--blue);
  padding: 2px 7px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 12px;
  font-family: var(--mono);
  border: 1px solid var(--blue-bd);
}

/* Trade action badges (BUY = blue, SELL = muted) */
.action-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: var(--mono);
}
.action-BUY  { background: var(--blue-bg);             color: var(--blue);   border: 1px solid var(--blue-bd); }
.action-SELL { background: rgba(120,130,155,0.12);      color: var(--text-2); border: 1px solid var(--border); }

/* Signal badges used in planning section (BUY=green, SELL=red, HOLD=yellow) */
.sig-BUY  { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-bd); }
.sig-SELL { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-bd); }
.sig-HOLD { background: rgba(240,180,41,0.1); color: var(--yellow); border: 1px solid rgba(240,180,41,0.22); }

/* ── Utility Colors ─────────────────────────────── */
.pos { color: var(--green) !important; }
.neg { color: var(--red)   !important; }
.neu { color: var(--text-2) !important; }

/* ── Empty State ────────────────────────────────── */
.empty-state {
  color: var(--text-3);
  text-align: center;
  padding: 32px;
  font-style: italic;
  font-size: 13px;
}

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ── Mobile card-header overflow fixes ──────────── */
@media (max-width: 640px) {
  .card-header { flex-wrap: wrap; gap: 8px; }
  .stats-pills { order: 10; flex: 0 0 100%; }
  .card-header .card-title { flex: 1 1 auto; }
}

/* ── Reduced Motion ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
