/* ============================================================
   analytics.css — Analytics screen styles for MedPREP Admin
   ============================================================ */

/* ── Loading overlay ─────────────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-neutral);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.spinner--sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Range pills ─────────────────────────────────────────────── */

.an-range-pills {
  display: flex;
  gap: var(--sp-1);
  background: var(--bg-card);
  border: 1px solid var(--border-neutral);
  border-radius: var(--radius-full);
  padding: 3px;
}

.range-pill {
  padding: 5px 14px;
  border-radius: var(--radius-full);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.range-pill:hover {
  color: var(--text-primary);
}

.range-pill.active {
  background: var(--gold);
  color: var(--bg-primary);
}

/* ── Metrics grid ────────────────────────────────────────────── */

.an-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

@media (max-width: 900px) {
  .an-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .an-metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
  }
}

.an-metric-card {
  flex-direction: row;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5);
}

.an-metric-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  color: var(--gold);
  margin-top: 2px;
}

.an-metric-icon svg {
  width: 100%;
  height: 100%;
}

.an-metric-body {
  flex: 1;
  min-width: 0;
}

.an-metric-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--sp-1);
  font-weight: 500;
}

.an-metric-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-1);
}

.an-coming-soon {
  font-size: var(--text-base) !important;
  color: var(--text-muted) !important;
  font-weight: 500 !important;
}

.an-metric-change {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 500;
}

.an-metric-change.positive {
  color: var(--success);
}

.an-metric-change.negative {
  color: var(--danger);
}

.an-manual-verify {
  color: var(--gold) !important;
  font-size: var(--text-xs) !important;
  font-weight: 600 !important;
}

.an-metric-subtext {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Sections ────────────────────────────────────────────────── */

.an-section {
  margin-bottom: var(--sp-6);
}

.an-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.an-section-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -0.01em;
}

.an-section-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.an-section-label-right {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Card ────────────────────────────────────────────────────── */

.an-card {
  background: var(--bg-card);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ── Loading state inside card ───────────────────────────────── */

.an-chart-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  padding: var(--sp-10) var(--sp-6);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

/* ── Empty state ─────────────────────────────────────────────── */

.an-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  gap: var(--sp-2);
}

.an-empty-state svg {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  margin-bottom: var(--sp-1);
}

.an-empty-state p {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-secondary);
}

.an-empty-state span {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 300px;
  line-height: 1.5;
}

/* ── Chart wrap ──────────────────────────────────────────────── */

.an-chart-wrap {
  padding: var(--sp-5) var(--sp-4) var(--sp-4);
  position: relative;
}

/* ── Horizontal bar list (notes + college) ───────────────────── */

.an-bar-list {
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.an-bar-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.an-bar-rank {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--gold-border);
  color: var(--gold);
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.an-bar-label {
  flex: 1;
  min-width: 0;
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.an-bar-track {
  width: 140px;
  flex-shrink: 0;
  height: 6px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  overflow: hidden;
}

@media (max-width: 560px) {
  .an-bar-track {
    width: 80px;
  }
}

.an-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: var(--radius-full);
  transition: width 0.6s ease;
}

.an-bar-count {
  min-width: 48px;
  text-align: right;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* ── MCQ list ────────────────────────────────────────────────── */

.an-mcq-list {
  display: flex;
  flex-direction: column;
}

.an-mcq-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--border-neutral);
  transition: background var(--transition-fast);
}

.an-mcq-row:last-child {
  border-bottom: none;
}

.an-mcq-row:hover {
  background: var(--bg-card-hover);
}

.an-mcq-rank {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(239,68,68,0.4);
  color: var(--danger);
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.an-mcq-stem {
  flex: 1;
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.an-mcq-rate {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--danger);
  flex-shrink: 0;
  min-width: 44px;
  text-align: right;
}

.an-mcq-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Coming soon card ────────────────────────────────────────── */

.an-coming-soon-card {
  border-style: dashed;
  border-color: var(--border-neutral);
}

.an-coming-soon-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  gap: var(--sp-2);
}

.an-coming-soon-content svg {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  margin-bottom: var(--sp-1);
}

.an-coming-soon-content p {
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-muted);
}

.an-coming-soon-content span {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 320px;
  line-height: 1.5;
}

/* ── Skeleton ────────────────────────────────────────────────── */

.skeleton-line {
  display: inline-block;
  height: 1em;
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
    var(--bg-input) 25%,
    var(--bg-card-hover) 50%,
    var(--bg-input) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-sweep 1.4s ease-in-out infinite;
}

@keyframes skeleton-sweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Toast (global, placed in body) ─────────────────────────── */

.toast {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--sp-4));
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 9999;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { background: #16532d; border: 1px solid var(--success); color: var(--success); }
.toast-warning { background: #3d2708; border: 1px solid var(--warning); color: var(--warning); }
.toast-danger  { background: #4c1d1d; border: 1px solid var(--danger);  color: var(--danger);  }
.toast-info    { background: #1e3a5f; border: 1px solid var(--info);    color: var(--info);    }

@media (min-width: 769px) {
  .toast {
    bottom: var(--sp-6);
    left: auto;
    right: var(--sp-6);
    transform: translateY(12px);
  }
  .toast.show {
    transform: translateY(0);
  }
}
