/* ============================================================
   Student Profile — Tab Bar + Data Tab Shell
   Depends on tokens defined in colors_and_type.css
   ============================================================ */


/* ── Tab Bar ─────────────────────────────────────────────── */

/* Sits flush below the hero card. The bar itself is just a row
   of buttons with a single hairline rule underneath — the active
   tab grows a 2px primary underline that visually "punches through"
   the hairline. This reads as secondary nav, not a top-level tab. */
.spr-tab-bar {
  display: flex;
  align-items: stretch;
  gap: var(--space-1);
  padding: 0 var(--space-2);
  margin-top: calc(var(--space-2) * -1); /* nestle against hero shadow */
  border-bottom: 1px solid var(--border-default);
  overflow-x: auto;
  overflow-y: hidden; /* prevent implicit vertical scroll from overflow-x: auto */
  scrollbar-width: none;
}
.spr-tab-bar::-webkit-scrollbar { display: none; }

.spr-tab-btn {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  margin-bottom: -1px;                 /* overlap the bar's bottom rule */

  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-normal);
  line-height: 1;
  color: var(--fg-tertiary);

  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
}
.spr-tab-btn:hover {
  color: var(--fg-primary);
  background: var(--bg-surface-alt);
}
.spr-tab-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.spr-tab-btn--active,
.spr-tab-btn[aria-selected="true"] {
  color: var(--color-primary-700);
  border-bottom-color: var(--color-primary-700);
  background: transparent;
}
.spr-tab-btn--active:hover,
.spr-tab-btn[aria-selected="true"]:hover {
  background: var(--color-primary-light);
}

/* Tab panels: respect [hidden]; the panel itself adds no
   chrome — the panels inside it carry their own card shells. */
.spr-tab-panels {
  display: block;
  margin-top: var(--space-6);
}
.spr-tab-panel {
  display: block;
}
.spr-tab-panel[hidden] {
  display: none !important;            /* hidden attr wins */
}
.spr-tab-panel[hidden] .matrix-view {
  display: none !important;            /* ensure matrix is hidden even if nested */
}


/* ── Data Tab Shell ──────────────────────────────────────── */

/* The Analysis / AI Insights tabs share a common shell with five
   states. The shell never constrains the height of its content
   area — Analysis renders variable-height charts and tables. */

/* States: skeleton / error / empty / generating / loaded.
   Each top-level state class is the wrapper. */

/* — Skeleton — */
.pdt-skeleton {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.pdt-skeleton-line {
  height: 14px;
  border-radius: var(--radius-sm);
  background: linear-gradient(
    90deg,
    var(--color-neutral-100) 0%,
    var(--color-neutral-200) 50%,
    var(--color-neutral-100) 100%
  );
  background-size: 200% 100%;
  animation: pdt-shimmer 1.4s ease-in-out infinite;
}
.pdt-skeleton-line:nth-child(1) { width: 40%; height: 18px; }
.pdt-skeleton-line:nth-child(2) { width: 100%; }
.pdt-skeleton-line:nth-child(3) { width: 78%; }

@keyframes pdt-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}


/* — Error — */
.pdt-error-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.pdt-error-msg {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: var(--leading-normal);
  color: var(--fg-secondary);
}
.pdt-retry-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  color: var(--fg-primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: var(--transition-base);
}
.pdt-retry-btn:hover {
  background: var(--bg-surface-alt);
  border-color: var(--border-strong);
}
.pdt-retry-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}


/* — Empty — */
.pdt-empty-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-12) var(--space-6);
  text-align: center;

  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.pdt-empty-icon {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--bg-surface-alt);
  color: var(--fg-tertiary);
}
.pdt-empty-icon svg {
  width: 22px;
  height: 22px;
}
.pdt-empty-message {
  max-width: 380px;
  font-size: var(--text-body);
  line-height: var(--leading-normal);
  color: var(--fg-secondary);
}
.pdt-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  color: var(--fg-on-primary);
  background: var(--color-primary-700);
  border: 1px solid var(--color-primary-700);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-primary);
  cursor: pointer;
  transition: var(--transition-base);
  margin-top: var(--space-1);
}
.pdt-cta-btn:hover {
  background: var(--color-primary-800);
  border-color: var(--color-primary-800);
}
.pdt-cta-btn:active { transform: scale(0.98); }
.pdt-cta-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus), var(--shadow-primary);
}


/* — Generating — */
.pdt-generating-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-12) var(--space-6);

  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.pdt-spinner {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: 3px solid var(--color-primary-100);
  border-top-color: var(--color-primary-700);
  animation: pdt-spin 0.9s linear infinite;
  position: relative;
}
.pdt-spinner::after {
  /* gentle pulse under the rotating arc */
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 0 rgba(26, 79, 207, 0.25);
  animation: pdt-pulse 1.8s ease-in-out infinite;
}
@keyframes pdt-spin {
  to { transform: rotate(360deg); }
}
@keyframes pdt-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26, 79, 207, 0.20); }
  50%      { box-shadow: 0 0 0 8px rgba(26, 79, 207, 0); }
}
.pdt-generating-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-normal);
  color: var(--fg-secondary);
}


/* — Loaded — */
/* The loaded wrapper hosts a card-style header followed by the
   content area, plus an optional history section beneath. */

.pdt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.pdt-header-date {
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--fg-tertiary);
}
.pdt-header-date::before {
  /* The "Latest · " prefix is part of the JS-rendered string —
     this rule just normalises rhythm if the JS only emits the date. */
  content: "";
}
.pdt-generate-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-normal);
  line-height: 1;
  color: var(--fg-link);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-base);
  white-space: nowrap;
}
.pdt-generate-btn:hover {
  background: var(--color-primary-light);
  border-color: var(--color-primary-200);
  color: var(--color-primary-800);
}
.pdt-generate-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.pdt-generate-btn svg {
  width: 12px;
  height: 12px;
}

.pdt-content-area {
  /* The card body. Must not constrain the height of its child —
     no max-height, no overflow clipping. The analysis view inside
     renders charts, tables, and collapsibles at variable height. */
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-top: none;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  padding: var(--space-5) var(--space-6) var(--space-6);
  box-shadow: var(--shadow-xs);
}
/* When the header is absent (no loaded data on a fresh card),
   round the top corners again. */
.pdt-content-area:first-child {
  border-top: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
}


/* — History — */
.pdt-history {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--border-default);
}
.pdt-history-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  margin-left: calc(var(--space-2) * -1);   /* optical alignment */

  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  line-height: 1;
  color: var(--fg-tertiary);

  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-base);
}
.pdt-history-toggle:hover {
  color: var(--fg-secondary);
  background: var(--bg-surface-alt);
}
.pdt-history-toggle:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}
.pdt-history-toggle svg,
.pdt-history-toggle::before {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  transition: transform var(--transition-base);
}
.pdt-history-toggle[aria-expanded="true"] svg,
.pdt-history-toggle[aria-expanded="true"]::before {
  transform: rotate(90deg);
}

.pdt-history-body {
  margin-top: var(--space-3);
}
.pdt-history-body[hidden] {
  display: none !important;            /* hidden attr wins */
}

.pdt-history-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-px);
  border-top: 1px solid var(--border-default);
}
.pdt-history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--fg-secondary);
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  transition: var(--transition-base);
}
.pdt-history-row:hover {
  background: var(--bg-surface-alt);
  color: var(--fg-primary);
}
.pdt-history-row:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

.pdt-load-more-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);

  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-normal);
  line-height: 1;
  color: var(--fg-link);

  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-base);
}
.pdt-load-more-btn:hover { background: var(--color-primary-light); }
.pdt-load-more-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

/* Profile-tab panel doesn't need extra top padding — the panels
   inside it already carry their own padding. */
.spr-tab-panel[data-tab="profile"] > .spr-below-fold {
  margin-top: 0;
}
