/* =============================================================
   Investment Monitor — Custom Stylesheet
   Supplements Bootstrap 5
   ============================================================= */

/* ---------- Base ---------- */
:root {
  --color-ai:        #6366f1;
  --color-advisor:   #10b981;
  --color-self:      #f59e0b;
  --color-gain:      #16a34a;
  --color-loss:      #dc2626;
  --color-neutral:   #6b7280;
  --color-bg:        #f8fafc;
  --color-card:      #ffffff;
  --color-border:    #e2e8f0;
  --color-nav-bg:    #0f172a;
  --color-nav-text:  #cbd5e1;
  --color-nav-hover: #f1f5f9;
  --radius:          0.5rem;
  --shadow:          0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:       0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

body {
  background-color: var(--color-bg);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #1e293b;
  font-size: 0.9rem;
}

/* ---------- Navigation ---------- */
.navbar-brand { font-weight: 700; letter-spacing: -0.02em; font-size: 1.1rem; }
.nav-link { color: var(--color-nav-text) !important; font-size: 0.875rem; }
.nav-link:hover, .nav-link.active { color: var(--color-nav-hover) !important; }
.navbar { background-color: var(--color-nav-bg) !important; }

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background: var(--color-card);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--color-border);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.875rem 1.25rem;
}

/* ---------- Portfolio accent cards ---------- */
.portfolio-card { transition: transform .15s ease, box-shadow .15s ease; cursor: pointer; }
.portfolio-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.portfolio-card .card-accent { height: 4px; border-radius: var(--radius) var(--radius) 0 0; }
.portfolio-card.ai     .card-accent { background: var(--color-ai); }
.portfolio-card.advisor .card-accent { background: var(--color-advisor); }
.portfolio-card.self   .card-accent { background: var(--color-self); }

/* ---------- Stats / KPI ---------- */
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.75rem; color: var(--color-neutral); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-change { font-size: 0.85rem; font-weight: 600; }

/* ---------- Gain / Loss colours ---------- */
.text-gain    { color: var(--color-gain)  !important; }
.text-loss    { color: var(--color-loss)  !important; }
.text-neutral { color: var(--color-neutral) !important; }
.text-amber   { color: #f59e0b !important; }

/* ---------- Badges ---------- */
.badge { font-weight: 500; font-size: 0.7rem; padding: 0.25em 0.6em; border-radius: 99px; }
.badge-ai      { background-color: rgba(99,102,241,.12); color: #4f46e5; }
.badge-advisor { background-color: rgba(16,185,129,.12); color: #059669; }
.badge-self    { background-color: rgba(245,158,11,.12); color: #d97706; }
.badge-risk-low  { background-color: rgba(16,185,129,.12); color: #059669; }
.badge-risk-med  { background-color: rgba(245,158,11,.12); color: #d97706; }
.badge-risk-high { background-color: rgba(220,38,38,.12);  color: #dc2626; }

/* ---------- Asset type badges (consistent across all portfolios) ----------
   Palette (left → right from swatch):
   Teal · Cyan · Lime · Yellow · Orange · Hot Pink · Lavender · Purple
   ---------------------------------------------------------------- */
.badge-type-etf              { background-color: rgba(0,188,212,.15);   color: #006b78 !important; } /* Teal      #00BCD4 */
.badge-type-stock            { background-color: rgba(136,232,64,.18);  color: #3d6810 !important; } /* Lime      #88E840 */
.badge-type-oeic             { background-color: rgba(255,68,192,.14);  color: #8a0064 !important; } /* Hot Pink  #FF44C0 */
.badge-type-unit_trust       { background-color: rgba(255,224,64,.18);  color: #7a5a00 !important; } /* Yellow    #FFE040 */
.badge-type-investment_trust { background-color: rgba(255,160,64,.16);  color: #7a4400 !important; } /* Orange    #FFA040 */
.badge-type-bond             { background-color: rgba(0,224,208,.15);   color: #006860 !important; } /* Cyan      #00E0D0 */
.badge-type-cash             { background-color: rgba(204,170,255,.18); color: #4422aa !important; } /* Lavender  #CCAAFF */
.badge-type-other            { background-color: rgba(153,102,255,.15); color: #4400bb !important; } /* Purple    #9966FF */

/* ---------- Tables ---------- */
.table { font-size: 0.85rem; }
.table thead th {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-neutral);
  border-bottom: 2px solid var(--color-border);
  font-weight: 600;
}
.table tbody tr:last-child td { border-bottom: none; }
.table-hover tbody tr:hover { background-color: rgba(241,245,249,.6); }

/* ---------- External research links ---------- */
.ext-links { margin-top: 3px; display: flex; gap: 3px; flex-wrap: wrap; }
.ext-link {
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid #cbd5e1;
  color: #94a3b8;
  text-decoration: none;
  line-height: 1.6;
  transition: border-color .15s, color .15s;
}
.ext-link:hover { color: #1e293b; border-color: #64748b; }

/* ---------- Sortable table headers ---------- */
.table thead th.sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.table thead th.sortable:hover { color: #1e293b; }
.table thead th.sortable::after { content: ' ↕'; opacity: 0.35; font-size: 0.65rem; }
.table thead th.sort-asc::after  { content: ' ↑'; opacity: 1; color: #6366f1; }
.table thead th.sort-desc::after { content: ' ↓'; opacity: 1; color: #6366f1; }

/* ---------- Charts ---------- */
.chart-container { position: relative; }

/* ---------- Page header ---------- */
.page-header { padding: 1.5rem 0 1rem; border-bottom: 1px solid var(--color-border); margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-header .breadcrumb { font-size: 0.8rem; margin: 0; }

/* ---------- Forms ---------- */
.form-label { font-weight: 500; font-size: 0.82rem; color: #374151; }
.form-control, .form-select {
  border-color: var(--color-border);
  font-size: 0.875rem;
  border-radius: 0.375rem;
}
.form-control:focus, .form-select:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-text { font-size: 0.75rem; color: var(--color-neutral); }

/* ---------- Risk slider ---------- */
.risk-display {
  display: inline-block;
  width: 2rem;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}
.risk-bar {
  position: relative;
  height: 6px;
  border-radius: 99px;
  background: linear-gradient(to right, #10b981, #f59e0b, #ef4444);
  margin: 0.25rem 0;
  overflow: visible;
}
.risk-scale {
  position: relative;
  padding: 4px 0;
}
.risk-indicator {
  position: absolute;
  top: -6px;
  width: 4px;
  height: 18px;
  background: #111827;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.95);
  transform: translateX(-50%);
  z-index: 5;
}
.risk-indicator::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -5px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #111827;
  box-shadow: 0 0 0 2px #ffffff;
  transform: translateX(-50%);
}

/* ---------- Allocation bar ---------- */
.alloc-bar { height: 8px; border-radius: 99px; background: var(--color-border); overflow: hidden; }
.alloc-bar-fill { height: 100%; border-radius: 99px; transition: width .4s ease; }

/* ---------- Flash alerts ---------- */
.alert { font-size: 0.875rem; border-radius: var(--radius); }

/* ---------- No data placeholder ---------- */
.no-data-placeholder {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-neutral);
}
.no-data-placeholder .icon { font-size: 2.5rem; margin-bottom: 0.5rem; }

/* ---------- Admin panel ---------- */
.admin-section { background: #fffbf0; border: 1px solid #fef3c7; border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }

/* ---------- Responsive tweaks ---------- */
@media (max-width: 768px) {
  .stat-value { font-size: 1.25rem; }
  .table-responsive-sm { overflow-x: auto; }
}

/* ---------- Print ---------- */
@media print {
  .navbar, .btn, .no-print { display: none !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
