/*
  Site shell — global header, left sidebar, page layout.
  Pages opt in by adding the .site-shell wrapper and the two placeholder
  elements; site.js injects the partials. Sonia-fwd-curve aesthetic carried
  through (cards/KPIs/grids live in sonia-fwd-curve.css).
*/

:root {
  /* layout */
  --shell-header-h: 60px;
  --shell-sidebar-w: 220px;

  /* SFC palette — kept in sync with the :root block at the top of
     sonia-fwd-curve.css so legacy pages reference the same tokens. */
  --pt-navy:        #0a2540;
  --pt-navy-mid:    #143659;
  --pt-navy-light:  #1a4775;
  --pt-navy-grad:   linear-gradient(120deg, #0a2540 0%, #143659 60%, #1a4775 100%);
  --pt-navy-grad-diag: linear-gradient(135deg, #0a2540 0%, #1a4775 100%);
  --pt-orange:      #fd7e14;
  --pt-orange-soft: #fff5e9;
  --pt-line:        #e9ecef;
  --pt-line-soft:   #f1f3f5;
  --pt-text:        #243240;
  --pt-muted:       #6c757d;
  --pt-shadow-navy:        0 6px 18px rgba(10, 37, 64, 0.10);
  --pt-shadow-navy-strong: 0 10px 28px rgba(10, 37, 64, 0.16);

  /* shell aliases for the chrome */
  --shell-bg:           #f7f8fa;
  --shell-fg:           var(--pt-text);
  --shell-fg-muted:     var(--pt-muted);
  --shell-border:       var(--pt-line);
  --shell-accent:       var(--pt-orange);
  --shell-accent-soft:  var(--pt-orange-soft);
  --shell-contact:      var(--pt-navy);
}

html, body {
  background: var(--shell-bg);
  color: var(--shell-fg);
  margin: 0;
  padding: 0;
}

body.site-shell-ready { /* hook for any post-load reveal animations */ }

/* ---------- top header ---------- */
header#site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--shell-header-h);
  background: #ffffff;
  border-bottom: 1px solid var(--shell-border);
}

.site-header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1rem;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--shell-fg);
}

.site-brand-logo {
  height: 32px;
  width: auto;
  display: block;
}

.site-brand-text {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.site-brand-text-accent {
  color: var(--shell-accent);
  font-weight: 600;
}

.site-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.site-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: filter 0.12s ease, transform 0.08s ease;
}

.site-btn:active { transform: translateY(1px); }
.site-btn:hover { filter: brightness(1.06); }

.site-btn-newsletter {
  background: var(--shell-accent);
  color: #fff;
}

.site-btn-contact {
  background: var(--shell-contact);
  color: #fff;
}

/* ---------- layout ---------- */
.site-layout {
  display: grid;
  grid-template-columns: var(--shell-sidebar-w) 1fr;
  min-height: calc(100vh - var(--shell-header-h));
}

aside#site-sidebar {
  background: #ffffff;
  border-right: 1px solid var(--shell-border);
  padding: 1rem 0.6rem;
  overflow-y: auto;
}

.site-nav-group-label {
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--shell-fg-muted);
  padding: 0.6rem 0.75rem 0.4rem;
  font-weight: 600;
}

.site-nav-list {
  list-style: none;
  margin: 0 0 0.6rem;
  padding: 0;
}

.site-nav-list li { margin: 0; }

.site-nav-list a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.5rem 0.75rem;
  margin: 0.1rem 0;
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--shell-fg);
  text-decoration: none;
  transition: background 0.12s ease, color 0.12s ease;
}

.site-nav-list a i {
  color: var(--shell-fg-muted);
  font-size: 1rem;
  width: 1.1rem;
  text-align: center;
  transition: color 0.12s ease;
}

.site-nav-list a:hover {
  background: #f3f4f6;
}

.site-nav-list a.active {
  background: var(--shell-accent-soft);
  color: var(--shell-accent);
  font-weight: 600;
}
.site-nav-list a.active i {
  color: var(--shell-accent);
}

main.site-main,
.site-main-wrap {
  min-width: 0;
  padding: 1.25rem 1.5rem 2rem;
}

/* For pages where the wrap is a div containing an existing <main>, let the
   inner main fill it without doubling up padding. */
.site-main-wrap > main { padding: 0; }
.site-main-wrap > main > .container-fluid,
.site-main-wrap > main > .container { padding-left: 0; padding-right: 0; }

.site-shell-error {
  padding: 0.75rem 1rem;
  color: #b91c1c;
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
  font-size: 0.85rem;
}

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .site-layout {
    grid-template-columns: 1fr;
  }
  aside#site-sidebar {
    border-right: none;
    border-bottom: 1px solid var(--shell-border);
    padding: 0.5rem;
  }
  .site-nav-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }
  .site-nav-group-label { padding: 0.25rem 0.5rem; }
}

/* ---------- cross-page legacy-style nudges ---------- */
/* Push existing pages toward the SONIA Forward Curve aesthetic without
   rewriting per-page inline CSS. Tokens come from :root above (--pt-*),
   kept in sync with sonia-fwd-curve.css. */

/* shell-side body hygiene */
body[data-page] {
  margin: 0;
  background: var(--shell-bg) !important;
  color: var(--pt-text);
}

/* --- KPI tiles ----------------------------------------------------- */
/* Match .sfc-kpi: navy gradient, soft navy shadow, hover lift,
   radial orange highlight in the top-right corner.
   Selector covers three legacy patterns:
     - .metric-card.card                 (forward-sonia and similar)
     - .card.bg-dark                     (pwlbActivity dynamic strip)
     - .kpi-card .kpi-header             (gilts/dashboard rate widgets — header strip only) */
.site-main-wrap .metric-card.card,
.site-main-wrap .card.bg-dark {
  position: relative;
  overflow: hidden;
  background: var(--pt-navy-grad) !important;
  border: none !important;
  box-shadow: var(--pt-shadow-navy) !important;
  color: #ffffff !important;
  border-radius: 12px !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.site-main-wrap .metric-card.card::after,
.site-main-wrap .card.bg-dark::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -25%;
  width: 75%;
  height: 160%;
  background: radial-gradient(circle, rgba(253, 126, 20, 0.16) 0%, transparent 70%);
  pointer-events: none;
}

.site-main-wrap .metric-card.card > *,
.site-main-wrap .card.bg-dark > * { position: relative; z-index: 1; }

.site-main-wrap .metric-card.card:hover,
.site-main-wrap .card.bg-dark:hover {
  transform: translateY(-2px);
  box-shadow: var(--pt-shadow-navy-strong) !important;
}

.metric-card .metric-label,
.metric-card .text-white-50,
.site-main-wrap .card.bg-dark .text-white,
.site-main-wrap .card.bg-dark .small {
  color: rgba(255, 255, 255, 0.72) !important;
  letter-spacing: 0.04em;
}

.metric-card .metric-value,
.site-main-wrap .card.bg-dark .fw-bold {
  color: var(--pt-orange) !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
}

.metric-card .metric-sub {
  color: rgba(255, 255, 255, 0.55) !important;
}

/* .kpi-card style (gilts/dashboard rate widgets): white body + navy header */
.site-main-wrap .kpi-card {
  border-radius: 12px !important;
  box-shadow: var(--pt-shadow-navy) !important;
  border: 1px solid var(--pt-line) !important;
}

.site-main-wrap .kpi-card .kpi-header {
  background: var(--pt-navy-grad) !important;
  color: #ffffff !important;
  letter-spacing: 0.06em;
}

/* Card headers using Bootstrap .bg-dark (e.g. trend / chart cards) */
.site-main-wrap .card-header.bg-dark {
  background: var(--pt-navy-grad) !important;
  color: #ffffff !important;
  border-bottom: 2px solid rgba(253, 126, 20, 0.5) !important;
}

/* Header titles inside dark card-headers — keep them orange but consistent */
.site-main-wrap .card-header.bg-dark span,
.site-main-wrap .card-header.bg-dark [style*="color:#fd7e14"] {
  color: var(--pt-orange) !important;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* --- Panel cards --------------------------------------------------- */
/* Match .sfc-panel: subtle border, soft navy shadow, slim navy stripe
   on the left edge for the same vertical accent. */
.site-main-wrap .card:not(.metric-card) {
  position: relative;
  border: 1px solid var(--pt-line) !important;
  box-shadow: var(--pt-shadow-navy) !important;
  border-radius: 12px !important;
  overflow: hidden;
}

.site-main-wrap .card:not(.metric-card)::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--pt-navy-grad);
  pointer-events: none;
}

/* Don't apply the stripe to nested cards (e.g. legend chips, mini cards). */
.site-main-wrap .card .card::before { display: none; }

/* --- Section / panel titles --------------------------------------- */
.site-main-wrap .card-title {
  font-size: 0.78rem !important;
  font-weight: 600 !important;
  letter-spacing: 0.14em !important;
  text-transform: uppercase !important;
  color: var(--pt-navy) !important;
}

/* --- Page hero --------------------------------------------------- */
/* Soften legacy orange h1 page heroes to match .sfc-title. */
.site-main-wrap header h1,
.site-main-wrap .page-title,
.site-main-wrap h1.h4 {
  color: var(--pt-text) !important;
  font-weight: 600 !important;
  font-size: 1.4rem !important;
  margin-bottom: 0.25rem !important;
}

.site-main-wrap header .text-muted,
.site-main-wrap header .header-subtitle {
  font-style: italic;
  font-size: 0.78rem !important;
  color: var(--pt-muted) !important;
}

/* --- Tables: orange-on-dark theme aligned to SFC navy ------------- */
.site-main-wrap .table-wrap thead,
.site-main-wrap table.table thead {
  background: var(--pt-navy-grad) !important;
}

.site-main-wrap .table-wrap thead th,
.site-main-wrap table.table thead th {
  color: var(--pt-orange) !important;
  border-bottom: 2px solid rgba(253, 126, 20, 0.5) !important;
}

/* --- Refresh / status dot in legacy headers ----------------------- */
.site-main-wrap .refresh-dot.active {
  background: var(--pt-orange);
}

/* ---------- standardized in-content page header ---------- */
/* Injected by site.js on every page (skipped if .sfc-title already exists). */
.site-page-header {
  padding: 4px 4px 0 4px;
  margin-bottom: 0.9rem;
}

.site-page-title {
  position: relative;
  margin: 0 0 0.25rem 0;
  padding-left: 14px;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--pt-text);
  letter-spacing: -0.01em;
}

.site-page-title::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.18em;
  bottom: 0.18em;
  width: 4px;
  border-radius: 2px;
  background: var(--pt-navy-grad);
}

.site-page-subtitle {
  padding-left: 14px;
  font-size: 0.85rem;
  color: var(--pt-muted);
  font-style: italic;
}

/* ---------- KPI tiles: full-card navy gradient ---------- */
/* Covers .kpi-card (gilts, dashboard rate widgets) and the
   .dashboard-kpi-card variant. Applies the full SFC tile look — gradient
   fill, radial orange highlight, hover lift — instead of the legacy
   white-body / dark-header-strip pattern. */
.site-main-wrap .kpi-card,
.site-main-wrap .kpi-card.dashboard-kpi-card {
  position: relative;
  overflow: hidden;
  background: var(--pt-navy-grad) !important;
  border: none !important;
  box-shadow: var(--pt-shadow-navy) !important;
  border-radius: 12px !important;
  color: #ffffff !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.site-main-wrap .kpi-card::after,
.site-main-wrap .kpi-card.dashboard-kpi-card::after {
  content: "";
  position: absolute;
  top: -40%;
  right: -25%;
  width: 75%;
  height: 160%;
  background: radial-gradient(circle, rgba(253, 126, 20, 0.16) 0%, transparent 70%);
  pointer-events: none;
}

.site-main-wrap .kpi-card > * {
  position: relative;
  z-index: 1;
}

.site-main-wrap .kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--pt-shadow-navy-strong) !important;
}

.site-main-wrap .kpi-card .kpi-header {
  background: transparent !important;
  color: rgba(255, 255, 255, 0.72) !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em;
  font-size: 0.78rem !important;
  text-transform: uppercase;
  border-bottom: none !important;
  padding-bottom: 0.25rem !important;
}

.site-main-wrap .kpi-card .rate-value,
.site-main-wrap .kpi-card .kpi-value {
  color: var(--pt-orange) !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
}

.site-main-wrap .kpi-card .small,
.site-main-wrap .kpi-card .kpi-changes,
.site-main-wrap .kpi-card .text-muted {
  color: rgba(255, 255, 255, 0.65) !important;
}

/* ---------- SFC-style loading skeletons (global) ---------- */
/* Mirrors the .pt-kpi-skel / .pt-loading-* visuals from sonia-fwd-curve.css
   so legacy pages get the same shimmering placeholder while data loads. */
.pt-kpi-skel {
  display: inline-block;
  vertical-align: middle;
  width: 6ch;
  height: 1em;
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(253, 126, 20, 0.20) 0%,
    rgba(253, 126, 20, 0.55) 50%,
    rgba(253, 126, 20, 0.20) 100%
  );
  background-size: 200% 100%;
  animation: pt-skel-shimmer 1.4s ease-in-out infinite;
}

.pt-loading-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
  background: rgba(253, 126, 20, 0.12);
  color: var(--pt-orange);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.pt-loading-pulse {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--pt-orange);
  animation: pt-skel-pulse 1.2s ease-in-out infinite;
}

@keyframes pt-skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes pt-skel-pulse {
  0%, 100% { transform: scale(0.85); opacity: 0.7; }
  50%      { transform: scale(1.15); opacity: 1; }
}
