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

/* ── RESET / BASE ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif; color: var(--text); min-height: 100vh;
  background: linear-gradient(150deg,var(--bg) 0%,var(--bg2) 30%,var(--bg3) 64%,var(--bg3) 100%) fixed;
}
/* Grain/noise overlay matching the start-interview page */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; display: block !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: .32; mix-blend-mode: soft-light;
}
h1,h2,h3,h4 { font-family: 'Space Grotesk', sans-serif; }

/* ── PAGE WRAP ─────────────────────────────────────────────────── */
.dash-wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 48px 28px 72px; }

/* ── HEADER ────────────────────────────────────────────────────── */
.dash-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 36px;
  animation: fadeUp .5s ease both;
}
.dash-title { font-size: 1.85rem; font-weight: 800; color: var(--text); margin-bottom: 4px; }
.dash-sub   { font-size: 14px; color: var(--muted); }

/* ── STAT CARDS ────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}
@media (max-width: 860px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .stats-grid { grid-template-columns: 1fr 1fr; } }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: fadeUp .5s ease both;
  transition: transform .2s, box-shadow .2s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 30px var(--shadow-sm); }
.stat-card:nth-child(1) { animation-delay: .04s; }
.stat-card:nth-child(2) { animation-delay: .08s; }
.stat-card:nth-child(3) { animation-delay: .12s; }
.stat-card:nth-child(4) { animation-delay: .16s; }

.stat-card__icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-card__icon--blue   { background: rgba(37,99,235,.12);  color: var(--accent); }
.stat-card__icon--cyan   { background: rgba(8,145,178,.12);  color: var(--accent3); }
.stat-card__icon--purple { background: rgba(124,58,237,.12); color: var(--accent2); }
.stat-card__icon--green  { background: rgba(5,150,105,.12);  color: var(--green); }
/* Dark mode: these light-mode-tuned low-opacity tints (8-12%) sit on an
   already-dark card and barely register — raised opacity so each icon tile
   reads as clearly tinted instead of nearly the same flat dark as the card
   itself. Uses the theme's own brighter --accent/--accent2/--accent3/--green
   values already switched in under [data-theme="dark"] in main.css. */
[data-theme="dark"] .stat-card__icon--blue   { background: rgba(91,141,239,.16); }
[data-theme="dark"] .stat-card__icon--cyan   { background: rgba(34,184,214,.16); }
[data-theme="dark"] .stat-card__icon--purple { background: rgba(156,125,250,.18); }
[data-theme="dark"] .stat-card__icon--green  { background: rgba(52,211,153,.16); }
.stat-card__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 4px;
}
.stat-card__value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.stat-card__sub { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── MAIN PANEL (Recent Sessions | Coding Practice | Score History) ──
   All three panels sit side by side in one row of equal columns.
   align-self: start keeps each panel sized to its own content instead of
   stretching to match a taller sibling (previously Recent Sessions spanned
   two grid rows and stretched full height, leaving a large blank gap below
   a short session list). */
.main-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: start;
  gap: 20px;
  animation: fadeUp .5s ease .2s both;
}
@media (max-width: 1100px) {
  .main-panel { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 780px) {
  .main-panel { grid-template-columns: 1fr; }
}

/* shared panel card */
.panel-left, .panel-right {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* panels never stretch to match a taller sibling's height */
.panel-left, .panel-right { align-self: start; padding-bottom: 20px; min-height: 380px; }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 20px 24px 0;
  margin-bottom: 4px;
}
.panel-head h2  { font-size: 1rem; font-weight: 700; color: var(--text); }
.panel-sub      { font-size: 12px; color: var(--muted); }

/* ── SESSION LIST ──────────────────────────────────────────────── */
.session-list {
  padding: 4px 0 8px;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(37,99,235,.25) transparent;
}
.session-list::-webkit-scrollbar {
  width: 4px;
}
.session-list::-webkit-scrollbar-track {
  background: transparent;
}
.session-list::-webkit-scrollbar-thumb {
  background: rgba(37,99,235,.25);
  border-radius: 99px;
}
.session-list::-webkit-scrollbar-thumb:hover {
  background: rgba(37,99,235,.45);
}

.session-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 24px;
  border-bottom: 1px solid var(--border);
  animation: fadeUp .4s ease both;
  transition: background .15s, box-shadow .15s;
}
.session-row:last-child { border-bottom: none; }
.session-row:hover      { background: var(--surface2); }

.session-row--clickable {
  cursor: pointer;
}
.session-row--clickable:hover {
  background: var(--surface2);
  box-shadow: inset 3px 0 0 var(--accent);
}
.session-row--clickable:hover .session-view-arrow {
  opacity: 1;
  transform: translateX(0);
}
.session-view-arrow {
  font-size: 16px;
  color: var(--accent);
  font-weight: 700;
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .15s, transform .15s;
  width: 20px;
  text-align: center;
}

.session-rank {
  min-width: 26px;
  width: auto;
  padding: 0 6px;
  height: 26px;
  border-radius: 8px;
  background: rgba(37,99,235,.08);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
[data-theme="dark"] .session-rank { background: rgba(91,141,239,.14); }
.session-info { flex: 1; min-width: 0; }
.session-domain {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* HR Round badge — marks a session from the new HR Round feature
   (backend/routes/hr_round.py) apart from a regular interview session,
   both of which otherwise share the exact same Recent Sessions row shape. */
.session-badge {
  display: inline-flex;
  align-items: center;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .03em;
  padding: 1px 7px;
  border-radius: 99px;
  margin-left: 7px;
  vertical-align: middle;
}
.session-badge--hr {
  background: rgba(16,185,129,.12);
  color: var(--green);
}
[data-theme="dark"] .session-badge--hr { background: rgba(52,211,153,.18); }
.session-date { font-size: 11px; color: var(--muted); margin-top: 2px; }

.session-score-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; min-width: 90px; }
.session-pct { font-family: 'Syne', sans-serif; font-size: 15px; font-weight: 800; line-height: 1; }

.session-band {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 99px;
}
.band--good { background: rgba(37,99,235,.1);  color: var(--accent); }
.band--fair { background: rgba(8,145,178,.1);  color: var(--accent3); }
.band--weak { background: rgba(124,58,237,.1); color: var(--accent2); }
[data-theme="dark"] .band--good { background: rgba(91,141,239,.16); }
[data-theme="dark"] .band--fair { background: rgba(34,184,214,.16); }
[data-theme="dark"] .band--weak { background: rgba(156,125,250,.18); }

.session-bar {
  width: 80px;
  height: 4px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}
.session-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width .5s ease;
}

.loading-row { padding: 32px 24px; text-align: center; color: var(--muted); font-size: 14px; }


/* ── EMPTY STATE ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-icon  { font-size: 2.8rem; margin-bottom: 12px; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-sub   { font-size: 13px; color: var(--muted); }

/* ── BAR CHART ─────────────────────────────────────────────────── */

.chart-wrap {
  display: flex;
  gap: 8px;
  padding: 12px 20px 0 16px;
  height: 260px;         /* fixed height so bars are fully visible */
  flex-shrink: 0;
}

/* Y-axis */
.chart-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding-bottom: 28px;
  min-width: 30px;
}
.chart-yaxis span {
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  display: block;
  font-family: 'Inter', sans-serif;
}

/* chart area */
.chart-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.chart-bars {
  flex: 1;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-bottom: 4px;
  position: relative;
  overflow: hidden;       /* bars never escape the container */
}

/* subtle horizontal grid lines */
.chart-bars::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0%,
      transparent calc(25% - 1px),
      var(--border) calc(25% - 1px),
      var(--border) 25%
    );
  pointer-events: none;
}

.chart-baseline {
  height: 2px;
  background: var(--border);
  border-radius: 99px;
}

/* individual bar column */
.bar-col {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;    /* bar fills full column width */
  justify-content: flex-end;
  position: relative;
  cursor: default;
  padding-bottom: 22px;    /* room for #index label */
}

.bar-fill {
  width: 100%;
  border-radius: 6px 6px 0 0;
  min-height: 4px;
  position: relative;
  transition: height .55s cubic-bezier(.4,0,.2,1);
}
.bar-glow {
  position: absolute;
  top: 0; left: 10%; right: 10%;
  height: 30%;
  border-radius: 50%;
  opacity: .2;
  filter: blur(6px);
}
.bar-index {
  position: absolute;
  bottom: 4px;
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px 0;
  font-size: 11px;
  color: var(--muted);
  font-family: 'Inter', sans-serif;
}
.legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ── ANIMATIONS ────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: none; }
}

/* ── TOAST ─────────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 28px; right: 28px; z-index: 9999;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 13px 20px;
  font-size: 14px;
  transform: translateY(80px); opacity: 0;
  transition: all .3s;
  pointer-events: none;
  box-shadow: 0 8px 24px var(--shadow-sm);
}
#toast.show    { transform: translateY(0); opacity: 1; }
#toast.error   { border-color: var(--red);   color: var(--red); }
#toast.success { border-color: var(--green); color: var(--green); }

/* Footer sits above the fixed grain overlay (z-index:0); nav is already sticky/z-index:100 */
.footer { position: relative; z-index: 1; }

/* ── RESPONSIVE ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dash-wrap  { padding: 24px 16px 48px; }
  .dash-title { font-size: 1.55rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card  { padding: 14px 16px; }
  .stat-card__value { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  .dash-wrap  { padding: 20px 12px 40px; }
  .dash-title { font-size: 1.35rem; }
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }
  .session-row { padding: 10px 14px; gap: 10px; }
  .panel-head { padding: 16px 16px 0; }
  .chart-wrap { min-height: 160px; }
}

