/* ==========================================================================
   dashboard.css — خاص بلوحة التتبّع الشخصية، الإحصاءات، والسجل التاريخي
   ========================================================================== */

[hidden] { display: none !important; }

/* ---------- حالات التحميل والمصادقة والخطأ ---------- */
.dash-state {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 14px;
  padding: clamp(32px, 5vw, 64px);
}

.dash-state__spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--track);
  border-inline-end-color: var(--pink);
  animation: tessera-spin 0.8s linear infinite;
}

.dash-state__title { font-size: clamp(1.6rem, 3.2vw, 2.3rem); }
.dash-state__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-block-start: 6px; }

.dash-local-box {
  margin-block-start: 14px;
  padding: 16px 20px;
  border-radius: var(--r-md);
  background: var(--card-2);
  border: 1px solid var(--line);
  display: grid;
  justify-items: center;
  gap: 12px;
  font-size: 0.9rem;
}

/* ---------- رأس الترحيب بالحساب ---------- */
.dash-wrap { display: grid; gap: 28px; }

.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: clamp(22px, 3.2vw, 36px);
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.dash-head::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: 280px;
  height: 280px;
  inset-block-start: -120px;
  inset-inline-end: -60px;
  border-radius: 50%;
  background: var(--pink);
  filter: blur(75px);
  opacity: 0.24;
}

.dash-head__user { display: grid; gap: 10px; }
.dash-head__badges { display: flex; flex-wrap: wrap; gap: 8px; }
.chip--pink { background: var(--pink) !important; color: var(--on-color); }
.dash-head__title { font-size: clamp(1.5rem, 3vw, 2.2rem); }

.dash-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.dash-btn-light {
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--on-dark);
  padding: 11px 18px;
  font-size: 0.88rem;
}
.dash-btn-light:hover { border-color: var(--pink); color: var(--pink); }

.dash-btn-danger {
  border-color: rgba(255, 125, 151, 0.35);
  color: #ff9ab0;
  padding: 11px 18px;
  font-size: 0.88rem;
}
.dash-btn-danger:hover { border-color: #ff7d97; background: rgba(255, 125, 151, 0.12); }

/* ---------- شبكة اللوحة الثلاثية ---------- */
.dash {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.9fr;
  gap: var(--gap);
  align-items: start;
}

.dash__col {
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.dash__col > .label:not(:first-child) { margin-block-start: 6px; }

.big-num { font-size: 2.1rem; font-weight: 800; line-height: 1; }
.big-num small { font-size: 0.9rem; font-weight: 600; margin-inline-start: 6px; color: var(--muted); }

/* ---------- حلقة الثبات والمؤشرات ---------- */
.ring-row { display: flex; align-items: center; gap: 22px; }
.ring-meta { flex: 1; min-width: 0; display: grid; gap: 4px; }

.kv { display: flex; flex-direction: column; gap: 2px; padding-inline-start: 14px; position: relative; }
.kv::before {
  content: "";
  position: absolute;
  inset-block: 3px;
  inset-inline-start: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--ink);
}
.kv span { font-size: 0.78rem; }
.kv b { font-size: 1.15rem; }

.dash-stab-note { margin-block-start: 12px; font-size: 0.84rem; }

.ring { position: relative; width: 132px; aspect-ratio: 1; flex: none; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring__track { stroke: var(--track); }
.ring__fill {
  stroke: var(--pink);
  stroke-dasharray: var(--v, 0) 100;
  transition: stroke-dasharray 1.3s var(--ease-ios);
}
.ring__label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.ring__label b { font-size: 1.5rem; line-height: 1.1; }
.ring__label small { font-size: 0.75rem; color: var(--muted); }

.thin-set {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-block-start: 18px;
}

.thin { display: grid; gap: 7px; }
.thin b { font-size: 0.92rem; }
.thin__bar { position: relative; height: 4px; border-radius: 4px; background: var(--track); overflow: hidden; }
.thin__bar::after {
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  width: var(--w, 0%);
  background: var(--ink);
  border-radius: inherit;
  transition: width 1s var(--spring-smooth);
}
.thin small { font-size: 0.74rem; color: var(--muted); }

/* ---------- أعمدة النشاط الأسبوعي ---------- */
.dash-weekly-msg { margin-block-start: 8px; }
.bars { display: flex; gap: 10px; height: 160px; }
.bars__col { flex: 1; display: grid; grid-template-rows: 1fr auto; gap: 10px; min-width: 0; }
.bars__track { display: flex; align-items: flex-end; justify-content: center; }
.bars__bar {
  width: min(14px, 100%);
  height: var(--h, 14px);
  min-height: 14px;
  border-radius: var(--r-pill);
  background: var(--chart);
  transition: height 900ms var(--spring-bouncy);
}
.bars__day { font-size: 0.72rem; color: var(--muted); text-align: center; }

/* ---------- كبسولة التقدّم ---------- */
.cap-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.cap-info { display: grid; gap: 10px; min-width: 0; }
.cap-info .big-num { font-size: 1.7rem; }
.cap-info .row { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--muted); }
.cap-cta { padding: 10px 18px; font-size: 0.85rem; width: fit-content; }

.capsule {
  position: relative;
  flex: none;
  width: 58px;
  height: 150px;
  display: grid;
  align-items: end;
  justify-items: center;
  padding-block-end: 20px;
  border-radius: var(--r-pill);
  background: var(--card-2);
  overflow: hidden;
}

.capsule__fill {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  height: var(--p, 0%);
  background: var(--pink);
  transition: height 900ms var(--spring-bouncy);
}

.capsule__val { position: relative; font-size: 0.9rem; font-weight: 800; color: var(--on-color); }
.cap-tip { display: flex; gap: 10px; align-items: flex-start; font-size: 0.82rem; color: var(--muted); margin-block-start: 14px; }

/* ---------- الشارات والحضور ---------- */
.badge-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.badge { display: grid; justify-items: center; gap: 8px; text-align: center; font-size: 0.78rem; font-weight: 700; }

.badge__icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: var(--track);
  color: var(--muted);
  transition: rotate var(--dur-slow) var(--spring-bouncy), scale var(--dur-slow) var(--spring-bouncy);
}
.badge__icon .icon { width: 24px; height: 24px; }

.badge.is-earned .badge__icon { background: var(--dark); color: var(--pink); }
.badge.is-locked { opacity: 0.55; }
@media (hover: hover) { .badge.is-earned:hover .badge__icon { rotate: -8deg; scale: 1.08; } }

.dash-checkin-summary { font-size: 0.88rem; font-weight: 600; }
.checkins { display: flex; gap: 8px; flex-wrap: wrap; }
.checkins span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 0.78rem;
  font-weight: 700;
  background: var(--card-2);
}
.checkins .c-blue { background: var(--blue); color: var(--on-color); }
.checkins .c-pink { background: var(--pink); color: var(--on-color); }

/* ---------- الاختبارات المقترحة والمتصدّرون ---------- */
.dash-suggested { display: grid; gap: 10px; }

.test-card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 18px 20px;
  overflow: hidden;
  transition: translate var(--dur-slow) var(--spring-smooth), box-shadow 0.35s var(--ease-out);
}
.test-card h3 { font-size: 1rem; padding-inline-end: 28px; }
.test-card__pts { display: inline-flex; align-items: center; gap: 10px; font-size: 0.8rem; font-weight: 600; }
.star-dot { width: 24px; height: 24px; border-radius: 8px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.14); }
.star-dot .icon { width: 13px; height: 13px; fill: currentColor; stroke: none; }
.test-card__time { font-size: 0.78rem; color: var(--on-dark-muted); }
.test-card > .arrow {
  position: absolute;
  inset-block-start: 18px;
  inset-inline-end: 18px;
  opacity: 0;
  translate: -10px 0;
  transition: opacity 0.3s, translate var(--dur-slow) var(--spring-smooth);
}
@media (hover: hover) {
  .test-card:hover { translate: 0 -4px; box-shadow: var(--shadow-card); }
  .test-card:hover > .arrow { opacity: 1; translate: 0 0; }
}

.dash-rank-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-block-start: 6px; }
.dash-privacy-link { font-size: 0.78rem; font-weight: 700; color: var(--muted); text-decoration: underline; }
.dash-privacy-link:hover { color: var(--ink); }

.rank { display: grid; gap: 8px; }
.rank__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--card);
  border-radius: var(--r-md);
}
.rank__item.is-self { box-shadow: inset 0 0 0 2px var(--pink); }
.rank__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--av-c, var(--pink));
  color: var(--on-color);
  font-weight: 800;
}
.rank__avatar--0 { --av-c: var(--pink); }
.rank__avatar--1 { --av-c: var(--lav); }
.rank__avatar--2 { --av-c: var(--blue); }
.rank__avatar--3 { --av-c: var(--green); }

.rank__name { font-size: 0.92rem; font-weight: 700; line-height: 1.3; }
.rank__sub { font-size: 0.75rem; color: var(--muted); }
.rank__pts { font-size: 0.85rem; font-weight: 800; color: var(--muted); }

/* ---------- سجل الاختبارات ---------- */
.history-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.history-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: translate var(--dur-slow) var(--spring-smooth), box-shadow 0.35s var(--ease-out);
}
@media (hover: hover) { .history-card:hover { translate: 0 -4px; box-shadow: var(--shadow-card); } }

.history-card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.history-card__code { font-size: 1.45rem; font-weight: 800; }
.history-card__meta { font-size: 0.82rem; color: var(--muted); }
.history-card__link {
  margin-block-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.history-empty { display: grid; justify-items: start; gap: 12px; }

/* ---------- الاستجابة ---------- */
@media (max-width: 1060px) {
  .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash__col:last-child { grid-column: 1 / -1; }
  .history-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .dash,
  .history-grid { grid-template-columns: 1fr; }
  .ring-row { flex-direction: column; align-items: flex-start; }
  .dash-head__actions { width: 100%; }
  .dash-head__actions .btn { flex: 1; }
}