/* ========================================
   Dashboard Page — Command Center
   ======================================== */

/* Hero: Progress Ring + Root of the Day */
.dashboard-hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* ========================================
   Progress Ring
   ======================================== */

.progress-ring-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.progress-ring-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin-bottom: 16px;
}

.progress-ring__svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring__bg {
  fill: none;
  stroke: var(--bg-accent);
  stroke-width: 8;
}

.progress-ring__fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}

.progress-ring__text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.progress-ring__value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
}

.progress-ring__label {
  font-size: 13px;
  color: var(--text-muted);
}

.progress-ring__info {
  text-align: center;
}

.progress-ring__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.progress-ring__subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

/* ========================================
   Root of the Day
   ======================================== */

.root-of-day-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.root-of-day__header {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.root-of-day__arabic {
  font-size: calc(var(--arabic-size) * 1.4);
  margin-bottom: 8px;
  text-align: center;
  direction: rtl;
}

.root-of-day__latin {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.root-of-day__stats {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.root-of-day__actions {
  margin-bottom: 8px;
}

.root-of-day__badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 500;
  background: #d1fae5;
  color: #059669;
}

.btn-sm {
  padding: 6px 16px;
  font-size: 13px;
}

/* ========================================
   Heatmap
   ======================================== */

.heatmap-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.heatmap-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.streak-display {
  display: flex;
  align-items: center;
  gap: 6px;
}

.streak-display__flame {
  font-size: 20px;
  line-height: 1;
}

.streak-display__value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.streak-display__label {
  font-size: 13px;
  color: var(--text-muted);
}

.heatmap__grid {
  display: flex;
  gap: 3px;
  direction: ltr;
}

.heatmap__week {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.heatmap__day {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--bg-accent);
  cursor: default;
  position: relative;
}

.heatmap__day--l1 { background: #d6e4c0; }
.heatmap__day--l2 { background: #a3c77a; }
.heatmap__day--l3 { background: #6da034; }
.heatmap__day--l4 { background: #3d6b1a; }

.heatmap__day-labels {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-right: 6px;
  font-size: 10px;
  color: var(--text-muted);
}

.heatmap__day-labels span {
  height: 14px;
  display: flex;
  align-items: center;
}

.heatmap__wrapper {
  display: flex;
}

.heatmap__legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 12px;
  font-size: 11px;
  color: var(--text-muted);
}

.heatmap__legend-box {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* Tooltip */
.heatmap__tooltip {
  position: fixed;
  background: var(--bg-nav);
  color: var(--text-nav);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 200;
  display: none;
}

/* ========================================
   Session History
   ======================================== */

.history__list {
  list-style: none;
}

.history__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.history__item:first-child {
  border-top: none;
}

.history__date {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.history__details {
  display: flex;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

.history__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.history__badge--reviews {
  background: #dbeafe;
  color: #1d4ed8;
}

.history__badge--new {
  background: #d1fae5;
  color: #059669;
}

.history__badge--again {
  background: #fee2e2;
  color: #dc2626;
}

/* ========================================
   Responsive
   ======================================== */

@media (max-width: 640px) {
  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .progress-ring-container {
    width: 120px;
    height: 120px;
  }

  .progress-ring__value {
    font-size: 26px;
  }

  .heatmap__day {
    width: 11px;
    height: 11px;
  }

  .history__item {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .heatmap-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

/* ========================================
   Chart: Header
   ======================================== */

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* ========================================
   Chart: Retention Curve (horizontal bars)
   ======================================== */

.retention-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.retention-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.retention-row__label {
  width: 80px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
}

.retention-row__track {
  flex: 1;
  height: 28px;
  background: var(--bg-accent);
  border-radius: 6px;
  position: relative;
  overflow: hidden;
}

.retention-row__fill {
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
  transition: width 0.6s ease;
}

.retention-row__value {
  width: 50px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  flex-shrink: 0;
}

.retention-row__count {
  font-size: 12px;
  color: var(--text-muted);
  width: 60px;
  text-align: right;
  flex-shrink: 0;
}

/* ========================================
   Chart: Mastery Distribution (donut)
   ======================================== */

.mastery-container {
  display: flex;
  align-items: center;
  gap: 32px;
  justify-content: center;
}

.mastery-donut {
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}

.mastery-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mastery-legend__item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.mastery-legend__dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.mastery-legend__count {
  font-weight: 600;
  color: var(--text-primary);
  margin-inline-start: auto;
  padding-inline-start: 16px;
}

/* ========================================
   Chart: Daily Accuracy (bar chart)
   ======================================== */

.accuracy-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 120px;
  padding-top: 8px;
}

.accuracy-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.accuracy-bar__fill {
  width: 100%;
  max-width: 24px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  transition: height 0.3s ease;
}

.accuracy-bar__label {
  font-size: 8px;
  color: var(--text-muted);
  margin-top: 6px;
  white-space: nowrap;
  transform: rotate(-45deg);
  transform-origin: top center;
}

.accuracy-bars {
  padding-bottom: 24px;
  overflow: hidden;
}

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

@media (max-width: 640px) {
  .mastery-container {
    flex-direction: column;
  }

  .retention-row__label {
    width: 60px;
    font-size: 11px;
  }

  .accuracy-bar__label {
    display: none;
  }

  .chart-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
