/* =====================================================================
   Alpha Strategy — P&L Dashboard
   alpha-pnl.css  ·  self-contained styling for the dashboard section
   Custom classes are prefixed `apnl-` to avoid clashing with the
   SmartAlgoTrades Bootstrap template.
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

/* ---------- Theme tokens ---------- */
.apnl {
  --bg:            #0b0f1a;
  --surface:       #121a2b;
  --surface-2:     #182238;
  --surface-hover: #1e2a44;
  --border:        rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text:          #e8edf7;
  --text-muted:    #8a97b1;
  --text-faint:    #5b6884;

  --accent:        #7c8cff;
  --accent-soft:   rgba(124, 140, 255, 0.14);

  --profit:        #2ec76b;
  --profit-soft:   rgba(46, 199, 107, 0.16);
  --profit-dim:    #1e7a45;
  --loss:          #ff5a5f;
  --loss-soft:     rgba(255, 90, 95, 0.16);
  --loss-dim:      #a83338;

  --radius:        16px;
  --radius-sm:     10px;
  --shadow:        0 18px 44px rgba(0, 0, 0, 0.35);
  --ff-display:    'Space Grotesk', system-ui, sans-serif;
  --ff-body:       'Inter', system-ui, sans-serif;

  font-family: var(--ff-body);
  color: var(--text);
}

.apnl[data-theme="light"] {
  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --surface-2:     #f7f9fd;
  --surface-hover: #eef2fb;
  --border:        rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text:          #0f172a;
  --text-muted:    #5a6785;
  --text-faint:    #94a3b8;
  --accent:        #5561f6;
  --accent-soft:   rgba(85, 97, 246, 0.10);
  --profit:        #16a34a;
  --profit-soft:   rgba(22, 163, 74, 0.12);
  --profit-dim:    #86efac;
  --loss:          #dc2626;
  --loss-soft:     rgba(220, 38, 38, 0.10);
  --loss-dim:      #fca5a5;
  --shadow:        0 14px 40px rgba(15, 23, 42, 0.10);
}

/* ---------- Layout shell ---------- */
.apnl {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 18px 40px;
}

.apnl * { box-sizing: border-box; }

/* ---------- Full-page canvas ----------
   Painted on <body> by JS so the dashboard reads as one even surface
   instead of dark cards floating on the template's white page. */
body.apnl-page-dark  { background: #0b0f1a; transition: background .25s ease; }
body.apnl-page-light { background: #f4f6fb; transition: background .25s ease; }

/* ---------- Nav ---------- */
.apnl-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 0;
  margin-bottom: 18px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.apnl-nav__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--ff-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.apnl-nav__brand img { height: 26px; width: auto; }
.apnl-nav__links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 24px;
}
.apnl-nav__links > a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color .2s;
  white-space: nowrap;
}
.apnl-nav__links > a:hover { color: var(--text); }
.apnl-nav__cta {
  background: var(--accent);
  color: #fff !important;
  padding: 8px 17px;
  border-radius: 999px;
  font-weight: 600 !important;
  transition: filter .2s;
}
.apnl-nav__cta:hover { filter: brightness(1.08); }
.apnl-nav__burger {
  display: none;
  width: 34px; height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  place-items: center;
}

/* ---------- Masthead ---------- */
.apnl-mast {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.apnl-mast__eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 4px;
}
.apnl-mast__title {
  font-family: var(--ff-display);
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
  margin: 0;
}
.apnl-mast__sub {
  color: var(--text-muted);
  font-size: 12.5px;
  margin: 6px 0 0;
}
.apnl-mast__live {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--profit);
  font-weight: 600;
  font-size: 12px;
}
.apnl-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--profit);
  box-shadow: 0 0 0 0 var(--profit-soft);
  animation: apnl-pulse 2s infinite;
}
@keyframes apnl-pulse {
  0%   { box-shadow: 0 0 0 0 var(--profit-soft); }
  70%  { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.apnl-theme-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  width: 34px; height: 34px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 15px;
  display: grid; place-items: center;
  transition: border-color .2s, color .2s, transform .2s;
}
.apnl-theme-toggle:hover { color: var(--text); border-color: var(--border-strong); transform: rotate(-12deg); }

/* ---------- KPI hero ---------- */
.apnl-hero {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 20px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.apnl-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(420px 200px at 12% -10%, var(--accent-soft), transparent 70%);
  pointer-events: none;
}
.apnl-hero__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  font-weight: 600;
}
.apnl-hero__value {
  font-family: var(--ff-display);
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin: 6px 0 8px;
  font-variant-numeric: tabular-nums;
}
.apnl-hero__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.apnl-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}
.apnl-pill--up   { background: var(--profit-soft); color: var(--profit); }
.apnl-pill--down { background: var(--loss-soft);   color: var(--loss); }
.apnl-pill--muted{ background: var(--surface-hover); color: var(--text-muted); }

.apnl-hero__spark { position: relative; min-height: 84px; }
.apnl-hero__spark canvas { position: absolute; inset: 0; }

/* ---------- KPI strip ---------- */
.apnl-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 6px;
}
.apnl-kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  transition: border-color .2s, transform .2s;
}
.apnl-kpi:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.apnl-kpi__k {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  font-weight: 600;
}
.apnl-kpi__v {
  font-family: var(--ff-display);
  font-size: 20px;
  font-weight: 600;
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.apnl-profit { color: var(--profit); }
.apnl-loss   { color: var(--loss); }

/* ---------- Section headers ---------- */
.apnl-section { margin-top: 20px; }
.apnl-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.apnl-section__title {
  font-family: var(--ff-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}
.apnl-section__hint { font-size: 12.5px; color: var(--text-faint); }

/* ---------- Calendar / heatmap ---------- */
.apnl-cal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 14px;
}
.apnl-cal-nav {
  display: grid;
  grid-template-columns: 32px 1fr 32px;
  align-items: center;
  gap: 8px;
}
.apnl-arrow {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 12px;
  transition: background .2s, opacity .2s, border-color .2s;
}
.apnl-arrow:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.apnl-arrow:disabled { opacity: 0.28; cursor: default; }

.apnl-cal-viewport {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;             /* Firefox */
  -webkit-overflow-scrolling: touch; /* iOS momentum */
}
.apnl-cal-viewport::-webkit-scrollbar { height: 0; width: 0; }
.apnl-cal-track {
  display: flex;
  gap: 20px;
  width: max-content;
}
.apnl-month { width: 150px; flex-shrink: 0; }
.apnl-month__title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.apnl-weekdays {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  font-size: 9.5px;
  color: var(--text-faint);
  text-align: center;
  margin-bottom: 6px;
  font-weight: 600;
}
.apnl-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
}
.apnl-day {
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  background: var(--surface-hover);
  transition: transform .12s ease, box-shadow .12s ease;
}
.apnl-day--has:hover {
  transform: scale(1.28);
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  z-index: 2;
}
.apnl-day--active { outline: 2px solid var(--accent); outline-offset: 1px; }

.apnl-p-strong { background: var(--profit); }
.apnl-p-light  { background: var(--profit); opacity: .5; }
.apnl-l-strong { background: var(--loss); }
.apnl-l-light  { background: var(--loss); opacity: .5; }

.apnl-month__pnl {
  margin-top: 7px;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.apnl-month__pct { color: var(--text-faint); font-weight: 500; }

.apnl-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-faint);
}
.apnl-legend i {
  width: 11px; height: 11px; border-radius: 3px; display: inline-block;
}

/* ---------- Tooltip ---------- */
.apnl-tooltip {
  position: fixed;
  background: rgba(6, 10, 20, 0.96);
  border: 1px solid var(--border-strong);
  color: #fff;
  font-size: 11.5px;
  padding: 8px 10px;
  border-radius: 8px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .12s, transform .12s;
  z-index: 2000;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.apnl-tooltip.is-on { opacity: 1; transform: translateY(0); }

/* ---------- Trades table ---------- */
.apnl-table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.apnl-table { width: 100%; }
.apnl-trow {
  display: grid;
  grid-template-columns: 100px 1fr 60px 68px 60px 68px 92px;
  gap: 8px;
  padding: 7px 14px;
  font-size: 12.5px;
  align-items: center;
  font-variant-numeric: tabular-nums;
}
.apnl-trow--head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.apnl-trow:not(.apnl-trow--head) { border-bottom: 1px solid var(--border); }
.apnl-trow:not(.apnl-trow--head):last-child { border-bottom: 0; }
.apnl-trow:not(.apnl-trow--head):hover { background: var(--surface-hover); }
.apnl-num { text-align: right; }
.apnl-empty {
  padding: 26px 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ---------- States ---------- */
.apnl-banner {
  display: none;
  align-items: center;
  gap: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-size: 12px;
  margin-bottom: 12px;
}
.apnl-banner.is-on { display: flex; }
.apnl-skeleton {
  background: linear-gradient(90deg, var(--surface-hover) 25%, var(--surface-2) 50%, var(--surface-hover) 75%);
  background-size: 200% 100%;
  animation: apnl-shimmer 1.4s infinite;
  border-radius: 6px;
}
@keyframes apnl-shimmer { to { background-position: -200% 0; } }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .apnl-hero { grid-template-columns: 1fr; }
  .apnl-hero__spark { min-height: 76px; }
  .apnl-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .apnl-nav__burger { display: grid; }
  .apnl-nav__links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 8px 0 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px;
    box-shadow: var(--shadow);
    display: none;
  }
  .apnl-nav__links.is-open { display: flex; }
  .apnl-nav__links > a { padding: 9px 10px; border-radius: 8px; font-size: 14.5px; }
  .apnl-nav__links > a:hover { background: var(--surface-hover); }
  .apnl-nav__cta { text-align: center; }
}
@media (max-width: 620px) {
  .apnl { padding: 0 14px 32px; }
  .apnl-cal-card { padding: 12px 10px; }
  .apnl-cal-nav { grid-template-columns: 1fr; }
  .apnl-arrow { display: none; }
  .apnl-hero { padding: 16px; }
  .apnl-hero__value { font-size: clamp(28px, 9vw, 40px); }
  .apnl-trow { grid-template-columns: 92px 1fr 78px; }
  .apnl-trow > :nth-child(3),
  .apnl-trow > :nth-child(4),
  .apnl-trow > :nth-child(5),
  .apnl-trow > :nth-child(6) { display: none; }
  .apnl-trow > :nth-child(7) { grid-column: 3; }
}

@media (prefers-reduced-motion: reduce) {
  .apnl *, .apnl *::before { animation: none !important; transition: none !important; }
}

/* ---------- Focus visibility ---------- */
.apnl :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Minimalist footer ----------
   Sits outside .apnl, so it's themed off the body page-class instead of vars. */
.apnl-foot {
  font-family: 'Inter', system-ui, sans-serif;
  border-top: 1px solid rgba(15, 23, 42, 0.09);
  background: #ffffff;
  transition: background .25s ease, border-color .25s ease;
}
.apnl-foot__inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 18px 22px;
}
.apnl-foot__top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.apnl-foot__logo {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: 'Space Grotesk', system-ui, sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: #0f172a;
  text-decoration: none;
}
.apnl-foot__logo img { height: 24px; width: auto; }
.apnl-foot__tag {
  margin: 9px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #5a6785;
  max-width: 320px;
}
.apnl-foot__links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding-top: 4px;
}
.apnl-foot__links a {
  color: #5a6785;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: color .2s;
}
.apnl-foot__links a:hover { color: #0f172a; }
.apnl-foot__social {
  display: flex;
  gap: 10px;
  padding-top: 2px;
}
.apnl-foot__social a {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #5a6785;
  border: 1px solid rgba(15, 23, 42, 0.10);
  font-size: 15px;
  text-decoration: none;
  transition: color .2s, border-color .2s, transform .2s;
}
.apnl-foot__social a:hover { color: #0f172a; border-color: rgba(15, 23, 42, 0.22); transform: translateY(-2px); }
.apnl-foot__bar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(15, 23, 42, 0.07);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: #94a3b8;
}

/* Dark theme footer */
body.apnl-page-dark .apnl-foot {
  background: #090d15;
  border-top-color: rgba(255, 255, 255, 0.08);
}
body.apnl-page-dark .apnl-foot__logo { color: #e8edf7; }
body.apnl-page-dark .apnl-foot__tag { color: #8a97b1; }
body.apnl-page-dark .apnl-foot__links a { color: #8a97b1; }
body.apnl-page-dark .apnl-foot__links a:hover { color: #e8edf7; }
body.apnl-page-dark .apnl-foot__social a {
  color: #8a97b1;
  border-color: rgba(255, 255, 255, 0.10);
}
body.apnl-page-dark .apnl-foot__social a:hover { color: #e8edf7; border-color: rgba(255, 255, 255, 0.22); }
body.apnl-page-dark .apnl-foot__bar {
  border-top-color: rgba(255, 255, 255, 0.07);
  color: #5b6884;
}

@media (max-width: 620px) {
  .apnl-foot__inner { padding: 22px 14px 18px; }
  .apnl-foot__bar { justify-content: flex-start; }
}
