/* Portfolio Manager – custom styles */

/* ── Single crisp typeface across the whole app ─────────────── */
:root {
  --app-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
              'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  --app-font-size-base: 15px;
  --app-line-height-base: 1.5;
  --app-size-xs: 0.74rem;
  --app-size-sm: 0.875rem;
  --app-size-md: 1rem;
  --app-size-lg: 1.05rem;
}
html { font-size: var(--app-font-size-base); }
html, body,
.btn, .form-control, .form-select, .table, .card, .dropdown-menu,
.navbar, input, select, textarea, button {
  font-family: var(--app-font);
}
body {
  padding-bottom: 40px;
  background: #f8f9fa;
  font-size: var(--app-size-md);
  line-height: var(--app-line-height-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: 'cv05', 'ss01';
  letter-spacing: 0.1px;
  color: #1f2733;
}

/* ── Typographic weights: consistent but not flattened ───── */
h1, h2, h3, h4, h5, h6,
.card-header,
.navbar-brand,
.mn-brand-text,
th,
.table > thead th,
.fw-bold,
.fw-bolder,
.fw-semibold,
.fw-medium {
  font-weight: 600 !important;
}

strong,
b,
.badge,
.btn,
label,
dt,
.nav-link,
.dropdown-item,
.discipline-banner .discipline-text {
  font-weight: 500;
}

/* ── Crisp tables ───────────────────────────────────────────── */
.table {
  --bs-table-border-color: #eef1f5;
  font-size: var(--app-size-sm);
  color: #20283a;
}
.table td, .table th { vertical-align: middle; }
.table > thead th {
  font-weight: 600;
  font-size: 0.74rem;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: #5a6577;
  background: #f6f8fb;
  border-bottom: 1px solid #e3e8ef;
  white-space: nowrap;
}
.table > tbody td { border-color: #eef1f5; }
.table-hover > tbody > tr:hover > * {
  background-color: #f3f7ff;
}
.table thead.table-dark th {
  color: #e9eef6;
  background: #1f2733;
  border-color: #2b3543;
}
.table thead.table-light th {
  color: #5a6577;
  background: #f6f8fb;
}
.table-sm > :not(caption) > * > * { padding: 0.4rem 0.55rem; }
.table-responsive { border-radius: .5rem; }

.card { border-radius: .5rem; }
.card-header { font-size: .95rem; font-weight: 600; letter-spacing: .1px; }
h1, h2, h3, h4, h5, h6 { letter-spacing: -0.2px; }
h3 small { font-size: .6em; }
code { font-size: .9em; color: #0d6efd; background: #e8f0fe; padding: 1px 5px; border-radius: 3px; }
.badge { font-weight: 500; }
footer { border-top: 1px solid #dee2e6; }

/* Decision discipline banner (shared across dashboard/categories/advisory pages) */
.discipline-banner {
  position: relative;
  border: 0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
  color: #ffffff;
  background: linear-gradient(120deg, #0b3d91 0%, #005a9c 45%, #0f766e 100%);
  box-shadow: 0 10px 24px rgba(2, 24, 66, 0.18);
  overflow: hidden;
}

.discipline-banner::after {
  content: '';
  position: absolute;
  right: -35px;
  top: -40px;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.28) 0%, rgba(255, 255, 255, 0) 72%);
  pointer-events: none;
}

.discipline-banner .discipline-text {
  position: relative;
  z-index: 1;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.discipline-banner .discipline-icon {
  position: relative;
  z-index: 1;
  margin-right: 0.5rem;
}

@media (max-width: 767.98px) {
  .discipline-banner {
    padding: 0.7rem 0.8rem;
  }
  .discipline-banner .discipline-text {
    font-size: 0.92rem;
    line-height: 1.35;
  }
}

/* ── Dashboard top: crisp & clean summary cards ─────────────── */
#tour-summary-cards .card,
#tour-profit-row .card {
  border: 0;
  border-radius: 0.75rem;
  box-shadow: 0 6px 18px rgba(15, 30, 60, 0.10);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
#tour-summary-cards .card:hover,
#tour-profit-row .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(15, 30, 60, 0.16);
}
#tour-summary-cards .card-body,
#tour-profit-row .card-body {
  padding: 0.85rem 1rem;
}
#tour-summary-cards .card-subtitle,
#tour-profit-row .card-subtitle {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  opacity: 0.85;
}
#tour-summary-cards h4,
#tour-profit-row h4 {
  font-weight: 700;
  letter-spacing: -0.4px;
  font-variant-numeric: tabular-nums;
}

/* ---- Mobile / Responsive styles ---- */
@media (max-width: 767.98px) {
  /* Compact table font on phones */
  .stock-table td, .stock-table th { font-size: .78rem; padding: .25rem .35rem; }
  .table-sm td, .table-sm th { font-size: .78rem; }

  /* Summary card values: slightly smaller on phone */
  #tour-summary-cards h4, #tour-profit-row h4 { font-size: 1.05rem; }
  #tour-summary-cards h6, #tour-profit-row h6 { font-size: .72rem; }

  /* Category header row: stack label above stats on small screens */
  .d-flex.justify-content-between.align-items-center.mb-2 { flex-direction: column; align-items: flex-start !important; gap: .25rem; }

  /* Nav tabs: smaller text on mobile */
  .nav-tabs .nav-link { font-size: .8rem; padding: .35rem .55rem; }

  /* Tour bar: reduce padding on phone */
  [id$="-tour-bar"] { padding: .4rem .75rem !important; margin-left: -.75rem !important; margin-right: -.75rem !important; }
}

@media (max-width: 575.98px) {
  /* On very small phones, hide Detail button text — show icon only */
  .stock-table .btn-outline-primary::after { content: ''; }
}

/* --- Active navbar link highlight --- */
.navbar-dark .nav-link.active {
  color: #ffffff !important;
  font-weight: 600;
  position: relative;
}
.navbar-dark .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 3px;
  background: #ffc107;
  border-radius: 3px 3px 0 0;
}
.navbar-dark .dropdown-toggle.active {
  color: #ffffff !important;
  font-weight: 600;
}
.navbar-dark .dropdown-toggle.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 3px;
  background: #ffc107;
  border-radius: 3px 3px 0 0;
}
.dropdown-item.active, .dropdown-item:active {
  background-color: #ffc107 !important;
  color: #212529 !important;
  font-weight: 600;
}

/* --- AI Summary panel --- */
.ai-summary-scroll {
  max-height: calc(100vh - 160px);
  overflow-y: auto;
  font-size: .88rem;
  line-height: 1.5;
  position: relative;
}
.ai-summary-scroll::before {
  content: "Portfolio Manager";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-30deg);
  font-size: 2.5rem;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.04);
  white-space: nowrap;
  pointer-events: none;
  z-index: 0;
  letter-spacing: 4px;
  text-transform: uppercase;
}
.ai-summary-scroll::-webkit-scrollbar { width: 5px; }
.ai-summary-scroll::-webkit-scrollbar-thumb { background: #adb5bd; border-radius: 3px; }
.ai-summary-inner h6 { font-size: .95rem; position: relative; z-index: 1; }
.ai-summary-inner h6 { font-size: .95rem; position: relative; z-index: 1; margin-top: .25rem; margin-bottom: 0; }
.ai-summary-inner ul { margin-bottom: .25rem; position: relative; z-index: 1; }
.ai-summary-inner li { font-size: .88rem; line-height: 1.45; }
.ai-summary-inner br + br { display: none; }
.ai-summary-inner { position: relative; z-index: 1; }
.ai-summary-inner .ai-table { margin-bottom: .15rem !important; }
.ai-summary-inner .row { margin-bottom: 0 !important; }

/* Compact tables inside AI summary */
.ai-table { font-size: .84rem; }
.ai-table th { font-size: .82rem; padding: .25rem .5rem; white-space: nowrap; }
.ai-table td { padding: .25rem .5rem; }
.ai-table .text-success { font-weight: 600; }
.ai-table .text-danger { font-weight: 600; }
.ai-table .text-warning { font-weight: 600; }

/* ---- Print / PDF Export styles ---- */
@media print {
  /* Hide navigation, footer, buttons, links – keep only content */
  nav, footer, .navbar, .no-print, .btn-print-pdf { display: none !important; }

  body { background: #fff !important; padding: 0; font-size: 10pt; }
  .container-fluid, .container { max-width: 100% !important; padding: 0 !important; margin: 0 !important; }

  /* Page setup */
  @page { size: landscape; margin: 12mm 10mm; }

  /* Cards: remove shadows, keep borders */
  .card { box-shadow: none !important; break-inside: avoid; page-break-inside: avoid; border-width: 1px !important; margin-bottom: 8pt !important; }
  .card-header { padding: 4pt 8pt !important; font-size: 10pt !important; }
  .card-body { padding: 6pt 8pt !important; }

  /* Tables: compact, no hover highlight */
  .table { font-size: 8.5pt !important; margin-bottom: 4pt !important; }
  .table th { font-size: 8pt !important; padding: 2pt 4pt !important; white-space: nowrap; }
  .table td { padding: 2pt 4pt !important; }
  .table-hover tbody tr:hover { background: transparent !important; }

  /* Badges */
  .badge { font-size: 7.5pt !important; padding: 1pt 4pt !important; border: 1px solid #999 !important; }

  /* Links: show as plain text */
  a { text-decoration: none !important; color: inherit !important; }
  a[href]:after { content: none !important; }

  /* Signal summary cards – keep compact in one row */
  .row.g-3.mb-4 > .col { flex: 1 !important; }
  .row.g-3.mb-4 .card-body { padding: 4pt !important; }
  .row.g-3.mb-4 h3 { font-size: 14pt !important; }
  .row.g-3.mb-4 .fs-4 { font-size: 12pt !important; }

  /* Print header */
  .print-header { display: block !important; text-align: center; margin-bottom: 8pt; }
  .print-header h2 { font-size: 14pt; margin-bottom: 2pt; }
  .print-header .print-date { font-size: 9pt; color: #666; }
}
