/* analytics.css — Study Analytics Dashboard Styles */
/* Lecture Mind v0.5.0 | Mobile-first, accessible, dark-mode aware */
/* Uses semantic tokens from tokens.css — no local :root overrides */

/* Layout */
.sp-analytics-tab {
  padding: 1rem;
  background: var(--background-subtle);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--foreground);
}

.sp-analytics-section {
  margin-bottom: 1.5rem;
}

.sp-analytics-section h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
}

/* Stat Cards Grid */
.sp-stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.sp-stat-card {
  background: var(--surface);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  transition: box-shadow 0.2s, transform 0.2s;
}

.sp-stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.sp-stat-card__value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--primary);
}

.sp-stat-card__label {
  font-size: 0.875rem;
  color: var(--foreground-muted);
  margin-top: 0.25rem;
}

/* Charts — SVGs rendered directly inside .sp-analytics-section */
.sp-analytics-section svg {
  width: 100%;
  height: auto;
  display: block;
  background: var(--surface);
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

/* Error State */
.sp-analytics-error {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--error);
  font-size: 1rem;
  font-weight: 500;
  background: var(--error-bg);
  border: 1px solid var(--error);
  border-radius: 8px;
  margin: 1rem;
}

/* Results Table */
.sp-results-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.sp-results-table thead tr {
  background: var(--background-subtle);
}

.sp-results-table th {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--foreground-muted);
  padding: 0.625rem 0.75rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
}

.sp-results-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
}

.sp-results-table tbody tr:last-child {
  border-bottom: none;
}

.sp-results-table tbody tr:hover {
  background: var(--background-subtle);
}

.sp-results-table td {
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty State */
.sp-analytics-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--foreground-muted);
  font-size: 0.975rem;
}

/* Dashboard (Day 4) */
.sp-dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem;
}

.sp-dashboard__header {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 0.5rem;
}

.sp-streak-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: box-shadow 0.2s;
}

.sp-streak-card:hover {
  box-shadow: var(--shadow-md);
}

.sp-streak-card__flame {
  font-size: 2.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.sp-streak-card__count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--warning);
}

/* Focus */
.sp-stat-card:focus-visible,
.sp-results-table tbody tr:focus-visible,
.sp-streak-card:focus-visible {
  outline: 2px solid var(--ring, var(--primary));
  outline-offset: 2px;
}

/* Desktop */
@media (min-width: 768px) {
  .sp-analytics-tab {
    padding: 1.5rem 2rem;
  }

  .sp-stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .sp-dashboard {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    padding: 1.5rem 2rem;
  }

  .sp-analytics-section svg[viewBox] {
    min-height: 240px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .sp-stat-card,
  .sp-results-table tbody tr,
  .sp-streak-card {
    transition: none;
  }

  .sp-stat-card:hover {
    transform: none;
  }
}

/* High Contrast */
@media (forced-colors: active) {
  .sp-stat-card,
  .sp-analytics-section svg,
  .sp-streak-card,
  .sp-results-table {
    border: 2px solid ButtonText;
  }

  .sp-results-table tbody tr {
    border-bottom: 1px solid ButtonText;
  }
}

/* Print */
@media print {
  .sp-analytics-tab,
  .sp-dashboard {
    padding: 0;
    background: none;
  }

  .sp-stat-grid,
  .sp-dashboard {
    grid-template-columns: repeat(2, 1fr);
  }

  .sp-stat-card,
  .sp-analytics-section svg,
  .sp-streak-card,
  .sp-results-table {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
}

/* Skeleton dimensions for analytics sections */
.sp-skeleton__title {
  height: 1.25rem;
  width: 60%;
  border-radius: 4px;
  background: var(--border, #e0e0e0);
  margin-bottom: 0.5rem;
}

.sp-skeleton__course {
  height: 0.875rem;
  width: 40%;
  border-radius: 4px;
  background: var(--border, #e0e0e0);
  margin-bottom: 0.5rem;
}

.sp-skeleton__progress {
  height: 0.75rem;
  width: 25%;
  border-radius: 4px;
  background: var(--border, #e0e0e0);
}

.sp-skeleton__header {
  height: 2rem;
  width: 70%;
  border-radius: 4px;
  background: var(--border, #e0e0e0);
  margin-bottom: 1rem;
}

.sp-skeleton__stats {
  height: 4rem;
  width: 100%;
  border-radius: 8px;
  background: var(--border, #e0e0e0);
  margin-bottom: 1rem;
}

.sp-skeleton__tabs {
  height: 2.5rem;
  width: 100%;
  border-radius: 4px;
  background: var(--border, #e0e0e0);
}

.sp-detail-skeleton {
  padding: 1.5rem;
}
