/* ======================================
   Finvi - AI Investment Assistant
   Clean Black & White Theme
   ====================================== */

:root {
  --bg:          #f7f7f7;
  --surface:     #ffffff;
  --surface2:    #f0f0f0;
  --border:      #e2e2e2;
  --text:        #111111;
  --text-muted:  #6b7280;
  --accent:      #111111;
  --accent2:     #333333;
  --red:         #ef4444;
  --green:       #16a34a;
  --yellow:      #f59e0b;
  --radius:      12px;
  --sidebar-w:   220px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  font-family: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ===== TOPBAR (mobile only) ===== */
.topbar {
  display: none;
  position: sticky; top: 0; z-index: 200;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

/* ===== HAMBURGER ===== */
.hamburger {
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; gap: 5px;
  width: 36px; height: 36px; border: none;
  background: transparent; cursor: pointer; flex-shrink: 0;
}
.hamburger span {
  display: block; width: 20px; height: 2px;
  background: var(--text-muted); border-radius: 2px;
  transition: all .2s;
}
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

/* ===== LOGO ===== */
.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
}
.logo-mark { flex-shrink: 0; }
.logo-text {
  font-weight: 700; font-size: 17px; color: var(--text);
  letter-spacing: -0.3px; white-space: nowrap;
}
.logo-tag {
  font-size: 10px; color: var(--text-muted);
  margin-top: 2px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 100;
  padding-bottom: 24px;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-nav {
  display: flex; flex-direction: column;
  padding: 10px 8px;
  gap: 1px; flex: 1;
}
.sidebar-link {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 8px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px; font-weight: 500;
  transition: all .15s;
}
.sidebar-link:hover { color: var(--text); background: var(--surface2); }
.sidebar-link.active {
  color: #ea580c;
  background: rgba(234,88,12,.08);
  font-weight: 600;
}
.sidebar-section { margin-top: 6px; }
.sidebar-section-title {
  padding: 8px 12px 4px;
  font-size: 11px; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.sidebar-sub { padding-left: 20px; font-size: 13px; }

/* Overlay mobile */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 99;
  background: rgba(0,0,0,.3);
}
.sidebar-overlay.active { display: block; }

/* ===== APP LAYOUT ===== */
.app-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.app-content main { flex: 1; }

/* ===== LAYOUT ===== */
.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.page-header {
  text-align: center;
  margin-bottom: 36px;
}
.page-title {
  font-size: 32px; font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 8px;
}
.page-sub { color: var(--text-muted); font-size: 15px; }

/* ===== SEARCH FORM ===== */
.search-form { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.search-wrap {
  display: flex; gap: 10px; flex-wrap: wrap;
  width: 100%; max-width: 720px; align-items: center;
}
.search-input {
  flex: 1 1 auto; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px;
  padding: 0 16px; font-size: 16px; font-family: inherit;
  height: 46px;
  -webkit-appearance: none; appearance: none;
  transition: border .15s;
}
.search-input:focus { outline: none; border-color: var(--text); }
.search-input::placeholder { color: var(--text-muted); }

.tf-select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px;
  padding: 0 14px; font-size: 14px; font-family: inherit;
  height: 46px;
  -webkit-appearance: none; appearance: none;
  cursor: pointer; transition: border .15s;
}
.tf-select:focus { outline: none; border-color: var(--text); }

.btn-analyze {
  display: flex; align-items: center; gap: 8px;
  background: var(--text);
  color: #ffffff; border: none;
  height: 46px; padding: 0 22px; border-radius: 10px;
  font-size: 15px; font-weight: 700; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: opacity .15s, transform .1s;
}
.btn-analyze:hover { opacity: 0.85; }
.btn-analyze:active { transform: translateY(1px); }

/* Scan form: center on desktop, full-width on mobile */
.scan-search { justify-content: center; }
.scan-search .tf-select { min-width: 160px; }

.scan-note { font-size: 12px; color: var(--text-muted); }

/* ===== RESULT HEADER ===== */
.result-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  margin: 32px 0 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.result-symbol-wrap { display: flex; align-items: baseline; gap: 12px; }
.result-symbol { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.result-company { color: var(--text-muted); font-size: 14px; }

.decision-badge {
  padding: 8px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 700; letter-spacing: .5px;
}
.decision-BUY     { background: rgba(22,163,74,.1);  color: #15803d; border: 1px solid rgba(22,163,74,.3); }
.decision-PRE-BUY { background: rgba(22,163,74,.05); color: #16a34a; border: 1px solid rgba(22,163,74,.2); }
.decision-SELL    { background: rgba(239,68,68,.1);  color: #dc2626; border: 1px solid rgba(239,68,68,.3); }
.decision-PRE-SELL{ background: rgba(239,68,68,.05); color: #ef4444; border: 1px solid rgba(239,68,68,.2); }
.decision-NEUTRAL { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }

/* ===== CARDS GRID ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s;
}
.card:hover { border-color: #aaaaaa; }
.card-title {
  padding: 14px 18px;
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  letter-spacing: .3px;
  text-transform: uppercase;
}
.card-body { padding: 18px; }
.card-title-year {
  font-size: 11px; font-weight: 500; color: var(--text-muted);
  background: var(--border); border-radius: 4px;
  padding: 1px 6px; margin-left: 6px;
  text-transform: none; letter-spacing: 0; vertical-align: middle;
}
.card-risk { grid-column: 1 / -1; }

/* ===== PRICE ===== */
.price-big {
  font-size: 32px; font-weight: 700;
  font-family: 'DM Mono', monospace;
  letter-spacing: -1px;
  color: var(--text);
  margin-bottom: 4px;
}
.price-unit { font-size: 18px; font-weight: 400; color: var(--text-muted); }
.price-change { font-size: 18px; font-weight: 700; margin-bottom: 16px; }

.up    { color: var(--green); }
.down  { color: var(--red); }
.neutral { color: var(--text-muted); }

/* ===== STAT ROWS ===== */
.stat-rows { display: flex; flex-direction: column; gap: 2px; }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.stat-row:last-child { border-bottom: none; }
.stat-row > span:first-child { color: var(--text-muted); }
.stat-row > span:last-child  { font-family: 'DM Mono', monospace; font-size: 13px; }

/* ===== VOTE BARS ===== */
.vote-bars { display: flex; flex-direction: column; gap: 10px; }
.vote-bar-wrap { display: flex; align-items: center; gap: 8px; }
.vote-label { font-size: 13px; color: var(--text-muted); width: 90px; flex-shrink: 0; }
.vote-label strong { color: var(--text); }
.vote-track {
  flex: 1; height: 6px; background: var(--surface2);
  border-radius: 3px; overflow: hidden;
}
.vote-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.vote-fill.bull { background: var(--green); }
.vote-fill.bear { background: var(--red); }
.vote-fill.neu  { background: #cccccc; }
.vote-pct { font-size: 12px; color: var(--text-muted); width: 32px; text-align: right; }

/* ===== VOTES DETAIL ===== */
.details-votes { margin-top: 16px; }
.details-votes summary {
  cursor: pointer; font-size: 13px; color: var(--text);
  user-select: none; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.details-votes summary::before { content: '▶'; font-size: 10px; color: var(--text-muted); transition: transform .2s; }
details[open] .details-votes summary::before { transform: rotate(90deg); }
.details-votes summary::-webkit-details-marker { display: none; }

.votes-list {
  display: flex; flex-direction: column;
  margin-top: 10px; list-style: none;
  border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
}
.vote-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; padding: 7px 12px;
  border-bottom: 1px solid var(--border);
}
.vote-item:last-child { border-bottom: none; }
.vote-item:nth-child(even) { background: var(--surface2); }
.vi { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.dot-bull { background: var(--green); }
.dot-bear { background: var(--red); }
.dot-neu  { background: #cccccc; }
.vk { color: var(--text); flex: 1; font-size: 12px; }
.vv {
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 4px; white-space: nowrap;
}
.vote-TĂNG .vv     { color: #15803d; background: rgba(22,163,74,.1); }
.vote-GIẢM .vv     { color: #dc2626; background: rgba(239,68,68,.1); }
.vote-THEO\ DÕI .vv { color: var(--text-muted); background: var(--surface2); border: 1px solid var(--border); }

/* ===== RISK LIST ===== */
.risk-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.risk-list li { font-size: 14px; padding: 8px 12px; background: var(--surface2); border-radius: 8px; }
.disclaimer {
  margin-top: 14px; font-size: 12px; color: var(--text-muted);
  padding: 10px; background: rgba(245,158,11,.05);
  border-radius: 8px; border: 1px solid rgba(245,158,11,.2);
}

/* ===== NO DATA ===== */
.no-data { color: var(--text-muted); font-size: 13px; padding: 20px 0; }

/* ===== NEWS ===== */
.news-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 20px;
}
.news-title {
  padding: 14px 18px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); background: var(--surface2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: .3px;
}
.news-list { padding: 8px 0; }
.news-item {
  display: block; padding: 12px 18px;
  text-decoration: none; border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--surface2); }
.news-item-title { font-size: 14px; color: var(--text); margin-bottom: 3px; }
.news-item-date { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 5px; }
.news-source {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  background: var(--surface2); border: 1px solid var(--border);
  padding: 1px 6px; border-radius: 4px;
}

/* ===== CHAT CTA ===== */
.chat-cta {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 24px; font-size: 15px;
}
.btn-chat {
  display: inline-flex; align-items: center;
  background: var(--text); color: #ffffff;
  padding: 8px 18px; border-radius: 8px;
  text-decoration: none; font-weight: 700; font-size: 14px;
  transition: opacity .15s;
}
.btn-chat:hover { opacity: 0.85; }

/* ===== SCAN TABLE ===== */
.scan-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.scan-table th {
  text-align: left; padding: 8px 12px;
  color: var(--text-muted); font-size: 12px; font-weight: 600;
  border-bottom: 1px solid var(--border); text-transform: uppercase;
}
.scan-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.scan-table tr:last-child td { border-bottom: none; }

.badge-bull { color: var(--green); font-weight: 700; }
.badge-bear { color: var(--red); font-weight: 700; }
.badge-neu  { color: var(--text-muted); }

/* ===== ALERT ===== */
.alert-error {
  background: rgba(239,68,68,.08); border: 1px solid rgba(239,68,68,.25);
  color: #dc2626; border-radius: 10px; padding: 14px 18px;
  font-size: 14px; margin-bottom: 20px;
}

/* ===== FOOTER ===== */
.footer {
  border-top: 1px solid var(--border);
  padding: 20px; margin-top: auto;
}
.footer-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 8px;
  font-size: 13px; color: var(--text-muted);
}
.footer-brand { color: var(--text); font-weight: 700; }
.footer-sep { color: var(--border); }


/* ===== BADGE COMING SOON ===== */
.badge-wip {
  font-size: 10px; font-weight: 600; color: #92400e;
  background: #fef3c7; border-radius: 4px; padding: 1px 5px;
  margin-left: 6px; vertical-align: middle;
}


/* ===== COMING SOON ===== */
.coming-soon-box { text-align: center; padding: 80px 20px; }
.coming-soon-icon { font-size: 56px; margin-bottom: 20px; }
.coming-soon-box h1 { font-size: 28px; font-weight: 700; margin: 0 0 12px; }
.coming-soon-box p { color: var(--text-muted); margin: 0 0 32px; line-height: 1.6; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .topbar { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }
  .app-content { margin-left: 0; }
  .logo-tag { display: none; }

  .page { padding: 24px 14px 60px; }
  .page-title { font-size: 24px; }

  .cards-grid { grid-template-columns: 1fr; }
  .card-risk  { grid-column: 1; }
  .votes-list { grid-template-columns: 1fr; }

  .search-wrap { flex-direction: column; }
  .search-input, .tf-select, .btn-analyze { width: 100%; height: 46px; flex: none; }
  .scan-search { width: 100%; }

  .result-header { flex-direction: column; align-items: flex-start; }
  .chat-cta { flex-direction: column; text-align: center; }
}
