/* ═══════════════════════════════════════════════
   BASE
═══════════════════════════════════════════════ */
:root {
  --navy:   #0f172a;
  --navy2:  #1e293b;
  --green:  #10b981;
  --red:    #ef4444;
  --blue:   #3b82f6;
  --gold:   #f59e0b;
  --text:   #1e293b;
  --muted:  #64748b;
  --border: #e2e8f0;
  --bg:     #f1f5f9;
  --white:  #ffffff;
}

* { box-sizing: border-box; }
body { background: var(--bg); font-family: 'Segoe UI', system-ui, sans-serif; color: var(--text); font-size: 15px; line-height: 1.6; }

/* ═══════════════════════════════════════════════
   NAVBAR
═══════════════════════════════════════════════ */
.navbar { background: var(--navy) !important; border-bottom: 3px solid var(--green); }
.navbar-brand { font-size: 1.1rem; letter-spacing: 0.5px; }

/* ═══════════════════════════════════════════════
   CONTROLS BAR
═══════════════════════════════════════════════ */
.controls-bar { background: var(--white); border-bottom: 1px solid var(--border); padding: 12px 20px; }
.form-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.form-select { font-size: 0.9rem; border-color: var(--border); }
.form-select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }

/* ═══════════════════════════════════════════════
   STOCK CARD
═══════════════════════════════════════════════ */
.stock-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.07);
  margin-bottom: 2rem;
  overflow: hidden;
}

/* ── Header ── */
.stock-card-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy2) 100%);
  color: #fff;
  padding: 1.4rem 1.8rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.stock-ticker { font-size: 2rem; font-weight: 800; letter-spacing: 2px; }
.stock-name   { font-size: 0.8rem; opacity: 0.6; margin-top: 2px; }
.stock-date        { font-size: 0.8rem; opacity: 0.5; }
.stock-analyzed-at { font-size: 0.7rem; opacity: 0.4; margin-top: 3px; }

.price-block  { margin-left: auto; text-align: right; }
.price-main   { font-size: 2.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.price-change { display: inline-block; padding: 3px 12px; border-radius: 20px; font-size: 0.9rem; font-weight: 600; margin-top: 4px; }
.price-change.up   { background: rgba(16,185,129,0.2); color: #34d399; }
.price-change.down { background: rgba(239,68,68,0.2);  color: #f87171; }
.price-change.flat { background: rgba(100,116,139,0.2); color: #94a3b8; }

/* ── Price stats ── */
.price-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}
.stat-box {
  flex: 1;
  min-width: 100px;
  padding: 12px 18px;
  border-right: 1px solid var(--border);
  text-align: center;
}
.stat-box:last-child { border-right: none; }
.stat-box .s-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.7px; color: var(--muted); font-weight: 600; }
.stat-box .s-value { font-size: 1.15rem; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.s-value.up   { color: var(--green); }
.s-value.down { color: var(--red); }
.s-value.neutral { color: var(--text); }

/* ── Tabs ── */
.card-tabs {
  display: flex;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  gap: 0;
  overflow-x: auto;
}
.card-tab {
  padding: 10px 18px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: all 0.15s;
  user-select: none;
}
.card-tab:hover { color: var(--text); }
.card-tab.active { color: var(--green); border-bottom-color: var(--green); }

/* ── Tab content ── */
.tab-content-area { padding: 1.5rem 2rem; }

/* ═══════════════════════════════════════════════
   ANALYSIS CONTENT
═══════════════════════════════════════════════ */
.analysis-content { max-width: 860px; }

.analysis-content h1, .analysis-content h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0 0 1.2rem 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

/* Section cards — each h3 becomes a styled section */
.analysis-section {
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 1.2rem;
  overflow: hidden;
}
.analysis-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--white);
}
.analysis-section-body {
  padding: 14px 18px;
  font-size: 0.92rem;
  line-height: 1.75;
  color: #334155;
}
.analysis-section-body p { margin: 0 0 0.6rem 0; }
.analysis-section-body p:last-child { margin-bottom: 0; }
.analysis-section-body ul { margin: 4px 0 8px 0; padding-left: 1.4rem; }
.analysis-section-body li { margin-bottom: 4px; }
.analysis-section-body strong { color: var(--navy); }

/* Section colour themes */
.sec-harga   .analysis-section-header { background: linear-gradient(90deg, #0369a1, #0284c7); }
.sec-smart   .analysis-section-header { background: linear-gradient(90deg, #7c3aed, #9333ea); }
.sec-algo    .analysis-section-header { background: linear-gradient(90deg, #0f766e, #0d9488); }
.sec-teknikal .analysis-section-header { background: linear-gradient(90deg, #b45309, #d97706); }
.sec-berita   .analysis-section-header { background: linear-gradient(90deg, #1d4ed8, #2563eb); }
.sec-kesimpulan  .analysis-section-header { background: linear-gradient(90deg, #065f46, #059669); }
.sec-fundamental .analysis-section-header { background: linear-gradient(90deg, #be123c, #e11d48); }
.sec-default     .analysis-section-header { background: linear-gradient(90deg, #475569, #64748b); }

.sec-harga       .analysis-section { border-color: #bae6fd; }
.sec-smart       .analysis-section { border-color: #e9d5ff; }
.sec-algo        .analysis-section { border-color: #99f6e4; }
.sec-teknikal    .analysis-section { border-color: #fde68a; }
.sec-berita      .analysis-section { border-color: #bfdbfe; }
.sec-kesimpulan  .analysis-section { border-color: #a7f3d0; }
.sec-fundamental .analysis-section { border-color: #fecdd3; }

/* Disclaimer / warning box */
.analysis-content blockquote {
  border-left: 4px solid var(--gold);
  background: #fffbeb;
  padding: 10px 16px;
  border-radius: 0 8px 8px 0;
  color: #92400e;
  font-size: 0.88rem;
  margin: 0 0 1rem 0;
}

/* Tables inside analysis — horizontal scroll on overflow */
.analysis-section-body table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; width: max-content; max-width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 8px 0; }
.analysis-section-body th { background: var(--navy2); color: #fff; padding: 7px 10px; text-align: left; white-space: nowrap; }
.analysis-section-body td { padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.analysis-section-body tr:last-child td { border-bottom: none; }
.analysis-section-body tr:nth-child(even) td { background: #f8fafc; }

/* ═══════════════════════════════════════════════
   BROKER SUMMARY — RTI-STYLE TWO-COLUMN
═══════════════════════════════════════════════ */
.broker-wrap { overflow-x: auto; }

/* Summary box */
.bs-summary-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 14px;
}
.bs-counts-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 12px;
}
.bs-count-item {
  flex: 1;
  text-align: center;
}
.bs-count-divider {
  width: 1px;
  height: 36px;
  background: var(--border);
  flex-shrink: 0;
}
.bs-count-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 2px;
}
.bs-count-val {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.bs-count-val.buy  { color: var(--green); }
.bs-count-val.sell { color: var(--red); }

.bs-acc-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.bs-acc-badge.acc  { background: rgba(16,185,129,0.18); color: #059669; }
.bs-acc-badge.dist { background: rgba(239,68,68,0.15);  color: #dc2626; }

.bs-stats-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.bs-stat {
  font-size: 0.84rem;
  color: var(--text);
}
.bs-stat-label {
  color: var(--muted);
  margin-right: 6px;
  font-size: 0.78rem;
}

/* Two-column broker table */
.broker-two-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}
.broker-two-table thead th {
  padding: 8px 10px;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  background: #fff;
}
.broker-two-table td {
  padding: 5px 10px;
  border-bottom: 1px solid #f1f5f9;
}
.broker-two-table tr:last-child td { border-bottom: none; }
.broker-two-table tr:hover td { background: #f8fafc; }

/* Column themes */
.bs-th-by   { color: var(--green); text-align: left; }
.bs-th-sl   { color: var(--red);   text-align: left; }
.bs-th-num  { color: var(--muted); text-align: right; }

.bs-by { font-weight: 700; color: var(--green); }
.bs-sl { font-weight: 700; color: var(--red); }
.bs-num { text-align: right; font-variant-numeric: tabular-nums; }
.bs-avg { color: var(--muted); font-size: 0.78rem; }
.bs-mid { width: 10px; background: var(--border); padding: 0; }
.bs-empty { background: transparent !important; }

/* Clickable investor name → holdings drill-down */
.investor-link {
  color: #2563eb;
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px dotted #93c5fd;
}
.investor-link:hover { color: #1d4ed8; border-bottom-style: solid; }

/* ═══════════════════════════════════════════════
   WEEKLY CARD
═══════════════════════════════════════════════ */
.weekly-header { background: linear-gradient(135deg, #064e3b, #065f46) !important; }
.weekly-badge { background: rgba(16,185,129,0.25); color: #34d399; padding: 4px 14px; border-radius: 20px; font-size: 0.85rem; font-weight: 600; }

/* ═══════════════════════════════════════════════
   WEEKLY SECTION CONTENT
═══════════════════════════════════════════════ */
.wk-content { width: 100%; }

/* Section sub-headings — small card style with colored background */
.wk-section-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  color: #fff;
  padding: 5px 12px;
  border-radius: 6px;
  margin: 1.1rem 0 0.5rem 0;
}
.wk-section-title:first-child { margin-top: 0; }

/* Paragraphs & lists inside weekly sections */
.wk-content p  { font-size: 0.92rem; line-height: 1.75; color: #334155; margin: 0 0 0.6rem 0; }
.wk-content p:last-child { margin-bottom: 0; }
.wk-content ul { font-size: 0.92rem; line-height: 1.7; margin: 4px 0 10px 0; padding-left: 1.4rem; color: #334155; }
.wk-content li { margin-bottom: 4px; }
.wk-content strong { color: var(--navy); }

/* Tables — styled like broker table */
.wk-table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0 1.1rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.wk-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  white-space: nowrap;
}
.wk-table thead th {
  background: var(--navy2);
  color: #fff;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: left;
}
.wk-table tbody td {
  padding: 7px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text);
}
.wk-table tbody tr:last-child td { border-bottom: none; }
.wk-table tbody tr:nth-child(even) td { background: #f8fafc; }
.wk-table tbody tr:hover td { background: #f0fdf4; }

/* Blockquotes inside weekly (strategy boxes etc.) */
.wk-content blockquote {
  border-left: 4px solid var(--gold);
  background: #fffbeb;
  padding: 10px 16px;
  border-radius: 0 8px 8px 0;
  color: #92400e;
  font-size: 0.88rem;
  margin: 0 0 1rem 0;
}

/* ═══════════════════════════════════════════════
   STATES
═══════════════════════════════════════════════ */
.loading { display: flex; align-items: center; justify-content: center; padding: 4rem; gap: 1rem; color: var(--muted); font-size: 1rem; }
.spinner-border { color: var(--green) !important; }
.error-box { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 1rem 1.5rem; color: #991b1b; }
.empty-state { padding: 5rem 2rem; color: var(--muted); }
.empty-state i { color: #cbd5e1; }

.no-analysis-notice {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
}
.no-analysis-notice i { font-size: 2.5rem; color: #cbd5e1; margin-bottom: 1rem; display: block; }
.no-analysis-notice p { margin: 0.4rem 0; }
.no-analysis-notice code { background: #f1f5f9; padding: 2px 8px; border-radius: 4px; font-size: 0.82rem; color: var(--navy); }

/* ═══════════════════════════════════════════════
   FOOTER
═══════════════════════════════════════════════ */
.site-footer {
  background: var(--navy);
  color: #94a3b8;
  font-size: 0.75rem;
  padding: 16px 24px;
  margin-top: 2rem;
  border-top: 2px solid var(--green);
}
.footer-inner {
  max-width: 1000px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer-brand {
  font-size: 0.8rem;
  color: #cbd5e1;
  letter-spacing: 0.3px;
}
.footer-disclaimer {
  color: #94a3b8;
  line-height: 1.5;
}
.footer-disclaimer strong { color: #e2e8f0; }
.footer-source { color: #64748b; }
.footer-source-name { color: #94a3b8; font-style: italic; }

/* ═══════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* Controls bar */
  .controls-bar { padding: 10px 12px; }
  .form-select  { font-size: 0.85rem; }

  /* Stock card header: stack ticker + price vertically */
  .stock-card-header { padding: 1rem 1.2rem; flex-wrap: wrap; gap: 0.75rem; }
  .stock-ticker  { font-size: 1.5rem; }
  .price-block   { margin-left: 0; text-align: left; width: 100%; }
  .price-main    { font-size: 1.75rem; }

  /* Price stats: scroll horizontally instead of shrinking */
  .price-stats-row { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .stat-box { min-width: 80px; flex-shrink: 0; padding: 10px 12px; }

  /* Tab content: reduce padding */
  .tab-content-area { padding: 1rem; }

  /* Analysis content: remove max-width cap */
  .analysis-content { max-width: 100%; }
  .analysis-section-body { padding: 12px 14px; font-size: 0.88rem; }
}

/* ═══════════════════════════════════════════════
   PRINT
═══════════════════════════════════════════════ */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .print-header { display: block !important; margin-bottom: 1rem; }
  .stock-card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; margin-bottom: 1rem; }
  .card-tabs { display: none; }
  .tab-panel { display: block !important; }
  .tab-content-area { padding: 0.8rem; }
  .stock-card-header { background: var(--navy) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .analysis-section-header { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .site-footer { background: var(--navy) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; margin-top: 1rem; padding: 10px 16px; }
}
