/* =========================
   BASE + TYPOGRAPHY SYSTEM (UPDATED)
========================= */
:root {
  /* Fonts */
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-slab: "Roboto Slab", "Times New Roman", serif;

  /* Typography Scale */
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;
  --text-4xl: 48px;

  /* Font Weights */
  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  /* =========================
     COLOR SYSTEM (LOCKED)
     Primary = Action / Focus
     Secondary = Reward / Gamification
     Neutral = UI foundation
  ========================= */
  --color-primary: #c62127;          /* Royal Red */
  --color-primary-hover: #a7191d;
  --color-primary-soft: #fff2f3;     /* very soft red tint */

  --color-secondary: #f2b705;        /* muted gold */
  --color-secondary-soft: #fff7dd;

  --color-bg: #f5f7fb;               /* page background */
  --color-surface: #ffffff;          /* card surface */
  --color-surface-soft: #fbfcff;     /* subtle surface alt */

  --color-border: #e6e8f0;           /* soft border */
  --color-border-strong: #dedfe7;

  --color-text: #1b1b24;
  --color-text-muted: #6b6f85;
  --color-text-soft: #8c8f9f;

  --shadow-card: 0 6px 16px rgba(31, 45, 61, 0.05);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-text);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
  font-family: var(--font-sans);
}

img {
  display: block;
  max-width: 100%;
}

/* =========================
   LAYOUT
========================= */
.dashboard {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.content {
  padding: 40px 48px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 32px;
}

.primary-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.secondary-column {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* =========================
   HEADER
========================= */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.content-header h1 {
  font-family: var(--font-slab);
  font-size: var(--text-4xl);
  font-weight: var(--font-bold);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 0;
  color: var(--color-text-muted);
  font-size: var(--text-base);
  font-weight: var(--font-normal);
}

.profile-meta-block {
  margin-left: auto;
}

.lesson-meta {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Bell only exists as a compact mobile entry point to notifications.html —
   desktop/tablet keep the full notifications card inline instead. */
.mobile-bell-link {
  display: none;
}

/* Lesson pill: chuyển về neutral + accent (không vàng/cam chói) */
.lesson-pill {
  background-color: #fffced;
  color: #9a6c00;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  border-radius: 999px;
  padding: 8px 18px;
  border: 1px solid #f0d8d4; /* soft red border */
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Chips: neutral, không dùng nhiều màu */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  color: var(--color-text);
}

.chip .icon {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.avatar-link {
  display: inline-block;
  border-radius: 50%;
}

/* =========================
   CARD SYSTEM
========================= */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow-card);
}

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

/* Card titles (Slab only for headers) */
.card h2 {
  margin: 0;
  font-family: var(--font-slab);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

/* Leaderboard section title stronger */
.leaderboard .card-header h2 {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
}

/* =========================
   TOP AREA: TASKS + PROGRESS
========================= */
.task-progress-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

/* Left card */
.next-step-card {
  padding: 0;
  overflow: hidden;
}

/* Make Next Step slightly more “hero” without changing layout */
.next-step-card {
  border: 1px solid #f0d8d4; /* subtle primary hint */
}

.next-step-content {
  background: var(--color-surface);
  padding: 28px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  border-radius: 22px 22px 0 0;
}

.next-step-kicker {
  grid-column: 1 / -1;
  margin: 0 0 6px;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  font-family: var(--font-sans);
}

.next-step-title h3 {
  margin: 0;
  font-family: var(--font-slab);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
}

.next-step-title p {
  margin: 6px 0 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-weight: var(--font-medium);
}

/* Only rendered on mobile (see the ≤768px block below) — duplicates the
   lesson-progress-card's step/percent info in the compact strip so that
   card can be hidden entirely on small screens without losing the info. */
.next-step-compact-meta {
  display: none;
}

/* =========================
   BUTTONS (UNIFIED)
========================= */
.learn-btn,
.join-btn {
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  padding: 8px 16px;
  min-height: 36px;
  line-height: 1;
  border-radius: 999px;
  letter-spacing: 0.01em;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.learn-btn,
.join-btn:not(.disabled) {
  background-color: var(--color-primary);
  color: #fff;
}

.learn-btn:hover,
.join-btn:hover {
  background-color: var(--color-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(139, 21, 56, 0.18);
}

.join-btn.disabled {
  background: #e5e6ea;
  color: #9a9dab;
  border-color: #e0e2ea;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Meeting strip */
.meeting-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-soft);
  border-radius: 0 0 22px 22px;
}

.meeting-strip-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.meeting-strip-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.meeting-strip-meta {
  margin: 0;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-soft);
  font-weight: var(--font-semibold);
  font-family: var(--font-sans);
}

.meeting-strip-title {
  margin: 4px 0 0;
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meeting-strip-time {
  margin: 4px 0 0;
  font-size: var(--text-sm);
  font-weight: var(--font-normal);
  color: var(--color-text-muted);
}

/* Right card */
.lesson-progress-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px;
}

/* =========================
   PROGRESS PIE (COLOR FIX)
   - remove pink-ish fill
   - use primary for progress
   - keep track neutral
========================= */
.progress-pie {
  --progress: 20;
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: 8px auto 18px;
  flex-shrink: 0;
}

.pie-track,
.pie-fill {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.pie-track {
  background: #eef0f7;
}

.pie-fill {
  background: conic-gradient(var(--color-primary) calc(var(--progress) * 1%), #eef0f7 0);
}

.pie-center {
  position: absolute;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  z-index: 2;
}

.pie-value {
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  color: var(--color-primary);
  z-index: 3;
}

/* Progress title should look like a card title (not muted label) */
.lesson-progress-card .progress-label {
  margin: 0;
  font-family: var(--font-slab);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--color-text);
}

.step-info {
  margin: 10px 0 12px;
  color: var(--color-text);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
}

.deadline {
  margin: 0;
  color: var(--color-primary);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
}

/* =========================
   LEADERBOARD
========================= */
.leaderboard {
  padding: 28px;
}

.leaderboard .card-header {
  flex-wrap: wrap;
  gap: 12px;
}

.leaderboard-tabs {
  display: inline-flex;
  gap: 8px;
  background-color: #f4f5fb;
  padding: 4px;
  border-radius: 999px;
}

.pill {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  color: var(--color-text-soft);
  cursor: pointer;
  font-family: var(--font-sans);
}

.pill.active {
  background-color: var(--color-primary);
  color: #fff;
}

.leaderboard-top {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  gap: 20px;
  margin-top: 16px;
  padding: 20px 10px 10px;
  border-bottom: 1px solid var(--color-border);
}

.avatar-card {
  text-align: center;
  position: relative;
  padding: 0 10px 10px;
}

.avatar-card img {
  width: 60px;
  height: 60px;
  border-radius: 20px;
  margin: 0 auto 12px;
  border: 3px solid var(--color-border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  object-fit: contain;
}

/* Top 1 highlight uses secondary (reward), not random yellow */
.avatar-card.first img {
border: 3px solid var(--color-border);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  transform: translateY(-4px);
}

.avatar-card .name {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.avatar-card .score {
  margin: 4px 0 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  background-color: var(--color-surface);
  border: 3px solid var(--color-border);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  width: 36px;
  height: 36px;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  color: #6b6f85;
}

.leaderboard-list {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.leaderboard-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.leaderboard-list li:last-child {
  border-bottom: none;
}

.list-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rank {
  width: 32px;
  height: 32px;
  border-radius: 12px;
  background-color: #f4f5fb;
  display: grid;
  place-items: center;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  color: #61647a;
}

.leaderboard-list img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
}

.leaderboard-list .name {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.leaderboard-list .score {
  margin: 2px 0 0;
  font-size: var(--text-sm);
  font-weight: var(--font-normal);
  color: var(--color-text-muted);
}

/* Reward badge uses secondary (muted), consistent */
.badge.soft {
  background-color: var(--color-secondary-soft);
  color: #9a6c00;
  padding: 6px 12px;
  border-radius: 12px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge.soft .badge-icon {
  width: 14px;
  height: 14px;
  display: block;
  object-fit: contain;
  flex-shrink: 0;
}

/* =========================
   CALENDAR
========================= */
.calendar {
  padding: 24px;
}

.calendar-title {
  flex: 1;
  display: flex;
  justify-content: center;
  text-align: center;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calendar-month {
  margin: 4px 0 0;
  font-family: var(--font-slab);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

.calendar-nav {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  font-size: var(--text-lg);
  cursor: pointer;
}

.calendar-week {
  list-style: none;
  margin: 24px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-week li {
  text-align: center;
  padding: 10px 0;
  border-radius: 20px;
  border: 1px solid transparent;
}

.calendar-week .weekday {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 35px;
  height: 60px;
}

.weekday span {
  font-size: var(--text-xs);
  font-weight: var(--font-normal);
  color: var(--color-text-soft);
}

.weekday strong {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.weekday.active {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-muted);
}

.weekday.active span {
  color: var(--color-text-muted);
}

/* =========================
   NOTIFICATIONS (COLOR FIX)
   - remove strong pink panel
   - keep soft neutral with primary accents
========================= */
.notifications {
  background-color: var(--color-surface);
  border: 1px solid #f0d8d4; /* subtle primary border */
}

.notification-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.notification-icon {
  position: relative;
  width: 50px;
  height: 50px;
}

.notification-icon img {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.9;
}

/* One clean rule for label (remove duplicates) */
.notifications .label {
  font-family: var(--font-slab);
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  margin: 0;
  color: var(--color-text);
}

.badge {
  background-color: var(--color-primary);
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  font-family: var(--font-sans);
}

/* Keep your “Coiny” number but ensure it doesn't fight CTA */
.notification-icon .badge {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: transparent;
  border: none;
  color: #fce2c0;
  font-family: "Coiny", cursive;
  padding: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
}

.notifications ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.notifications li {
  display: flex;
  gap: 8px;
  align-items: center;
}

.notification-text {
  margin: 0;
  line-height: 1.5;
  font-size: var(--text-sm);
  font-weight: var(--font-normal);
  color: var(--color-text);
}

.notification-text.clickable {
  cursor: pointer;
}

.notification-text.clickable:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  color: var(--color-primary);
}

/* =========================
   NOTIFICATIONS PAGE (notifications.html)
========================= */
.back-link {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-decoration: none;
}

.back-link:hover {
  color: var(--color-primary);
}

.notifications-page .notification-item {
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.notifications-page .notification-item:last-child {
  border-bottom: none;
}

.notification-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.notification-time {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-soft);
}

.empty-state {
  margin: 0;
  padding: 24px 0;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--color-primary);
  display: inline-block;
}

/* =========================
   ACHIEVEMENT
========================= */
.achievement {
  text-align: center;
  background-color: var(--color-surface);
  padding: 24px;
  position: relative;
}

.achievement .reward-graphic {
  width: 160px;
  aspect-ratio: 730 / 800;
  margin: 0 auto;
  position: relative;
}

.achievement .reward-graphic img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Keep your “Coiny” number, but optionally make it secondary-themed */
.achievement-number {
  font-size: var(--text-2xl);
  margin: 0;
  font-weight: var(--font-bold);
      color: #6b6f85;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: "Coiny", cursive;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 1100px) {
  .dashboard {
    grid-template-columns: minmax(0, 1fr);
  }

  .task-progress-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 768px) {
  .content {
    padding: 32px 20px 60px;
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .main-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .secondary-column {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .secondary-column .card {
    flex: 1 1 240px;
  }

  /* --- Mobile bell icon (opens the dedicated notifications page) --- */
  .mobile-bell-link {
    display: inline-flex;
    position: relative;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
  }

  .mobile-bell-link img {
    width: 22px;
    height: 22px;
    object-fit: contain;
  }

  .mobile-bell-link .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #ff4d4f;
    color: #fff;
    font-size: 10px;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 999px;
    padding: 0 4px;
  }

  /* --- Compact "next step" strip (replaces the two large task-progress
     cards with a single slim row; full detail is still one tap away via
     the Start button / lesson-progress-card link) --- */
  .task-progress-grid {
    gap: 10px;
  }

  .lesson-progress-card {
    display: none;
  }

  .next-step-content {
    grid-template-columns: minmax(0, 1fr);
    padding: 16px;
    gap: 6px;
  }

  .next-step-kicker,
  .next-step-title p {
    display: none;
  }

  .next-step-title h3 {
    font-size: var(--text-base);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .next-step-compact-meta {
    display: block;
    margin: 2px 0 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .learn-btn {
    padding: 10px 16px;
    font-size: var(--text-sm);
    white-space: nowrap;
  }

  .meeting-strip {
    padding-top: 12px;
    margin-top: 12px;
  }

  .meeting-strip-meta,
  .meeting-strip-time {
    display: none;
  }

  /* --- Notifications move to their own page on mobile --- */
  .notifications {
    display: none;
  }
}

@media (max-width: 540px) {
  .meeting-strip {
    flex-direction: column;
    align-items: stretch;
  }

  .join-btn,
  .learn-btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 20px 14px 40px;
  }

  .lesson-meta.profile-meta-block {
    width: 100%;
    justify-content: space-between;
  }

  .leaderboard-top {
    grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  }

  .achievement-number {
    font-size: var(--text-xl);
  }
}
