/* ============================================================
   MD-DESKTOP.CSS — Desktop Layout: Banner + Sidebar + Main + Right
   Breakpoint: >=769px hiện sidebar, <769px ẩn (mobile giữ nguyên)
   ============================================================ */

/* ---- Desktop outer wrapper (flex dọc: banner + 3 cột) ---- */
.md-desktop-wrap {
  max-width: 1120px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---- Banner Top ---- */
.md-top-banner {
  display: none; /* ẩn mobile */
  align-items: center;
  background: linear-gradient(160deg, #C2F0DC 0%, #E2F7ED 40%, #FDEAB8 100%);
  border-bottom: 2px solid var(--md-primary-border);
  box-shadow: 0 2px 8px rgba(43,154,112,.08);
}
.md-top-banner.md-hidden { display: none !important; }

.md-top-banner__left {
  width: 220px; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px;
}
.md-top-banner__logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--md-fun-green), var(--md-sky));
  border-radius: var(--md-r-md);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.md-top-banner__logo-name {
  font-family: var(--md-font-h); font-size: .95rem; font-weight: 800; color: var(--md-primary);
}
.md-top-banner__logo-tag {
  font-size: .72rem; font-weight: 700; color: var(--md-coral);
}

.md-top-banner__center {
  flex: 1;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 20px;
}
.md-top-banner__avatar {
  width: 40px; height: 40px; border-radius: var(--md-r-full);
  background: var(--md-w);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
  border: 2.5px solid var(--md-primary-border);
  box-shadow: 0 2px 8px rgba(43,154,112,.15);
}
.md-top-banner__greeting {
  font-family: var(--md-font-h); font-weight: 700; font-size: .95rem; color: var(--md-g8);
}
.md-top-banner__role {
  font-size: .75rem; color: var(--md-primary); font-weight: 600;
}

.md-top-banner__right {
  width: 280px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 8px 16px;
}
.md-top-banner__date {
  font-family: var(--md-font-h); font-weight: 700; font-size: .92rem; color: var(--md-g8);
}
.md-top-banner__lunar {
  font-size: .78rem; color: var(--md-secondary); font-weight: 700; margin-top: 2px;
}
/* Con bọ rùa báo lỗi — bò qua lại nhẹ */
@keyframes md-bug-crawl { 0%,100%{transform:translateX(0) rotate(0)} 25%{transform:translateX(5px) rotate(10deg)} 50%{transform:translateX(0) rotate(0)} 75%{transform:translateX(-5px) rotate(-10deg)} }
.md-bug { display:inline-block; animation: md-bug-crawl 2.4s ease-in-out infinite; transition: transform .15s; }
.md-bug:hover { animation-play-state: paused; transform: scale(1.25); }

/* ---- Desktop 3-col wrapper ---- */
.md-desktop {
  display: flex;
  flex: 1;
}

/* ---- Sidebar (ẩn mobile) ---- */
.md-sidebar {
  display: none;
  flex-direction: column;
  width: 220px;
  background: linear-gradient(180deg, #F0FAF5 0%, #FFFFFF 30%, #FFFCF5 100%);
  border-right: 1px solid var(--md-g1);
  flex-shrink: 0;
  height: auto; /* không fixed height — banner chiếm phần trên */
  overflow-y: auto;
}
.md-sidebar::-webkit-scrollbar { width: 3px; }
.md-sidebar::-webkit-scrollbar-thumb { background: var(--md-g2); border-radius: 2px; }

/* Sidebar logo — ẩn trên desktop (đã lên banner) */
.md-sb-logo {
  padding: 14px;
  border-bottom: 1px solid var(--md-g1);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.md-sb-logo__icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--md-fun-green), var(--md-sky));
  border-radius: var(--md-r-md);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.md-sb-logo__name {
  font-family: var(--md-font-h); font-size: 1rem; font-weight: 800; color: var(--md-primary);
}
.md-sb-logo__tag {
  font-size: .72rem; font-weight: 700; color: var(--md-coral);
}

/* Sidebar role switcher */
.md-sb-roles {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--md-g1);
}
.md-sb-roles__label {
  font-size: .72rem; font-weight: 700; color: var(--md-g4);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
.md-sb-role {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--md-r-md);
  cursor: pointer; border: 1.5px solid transparent;
  transition: background var(--md-dur-fast);
}
.md-sb-role:hover { background: var(--md-g0); }
.md-sb-role.md-active {
  background: var(--md-primary-pale);
  border-color: var(--md-primary-border);
}
.md-sb-role__avatar { font-size: 1.1rem; }
.md-sb-role__name { font-size: .82rem; font-weight: 600; color: var(--md-g7); }
.md-sb-role.md-active .md-sb-role__name { font-weight: 700; color: var(--md-primary); }
.md-sb-role__sub { font-size: .72rem; color: var(--md-g4); }

/* Sidebar navigation */
.md-sb-nav { flex: 0 0 auto; padding: 5px 10px 4px; }
.md-sb-nav__label {
  font-family: var(--md-font-h);
  font-size: .92rem; font-weight: 700; color: var(--md-primary);
  padding: 4px 12px 2px;
  display: flex; align-items: center; gap: 6px;
}
.md-sb-nav__item {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 12px; border-radius: var(--md-r-sm);
  cursor: pointer; margin-bottom: 1px;
  font-size: 0.9rem; color: var(--md-g9); font-weight: 600;
  border: 1px solid transparent;
  border-left: 3px solid transparent;
  transition: all var(--md-dur-fast);
  min-height: 30px;
}
.md-sb-nav__item:hover { background: rgba(43,154,112,.06); border-left-color: var(--md-primary-border); }
.md-sb-nav__item.md-active {
  background: var(--md-primary-pale); color: var(--md-primary); font-weight: 700;
  border-color: var(--md-primary-border);
  border-left-color: var(--md-primary);
  box-shadow: 0 1px 4px rgba(43,154,112,.1);
}
.md-sb-nav__item span:first-child { font-size: 1.1rem; }
.md-sb-nav__badge {
  margin-left: auto; background: var(--md-coral); color: var(--md-w);
  font-size: .75rem; padding: 2px 6px; border-radius: var(--md-r-full); font-weight: 700;
}

/* Sidebar quick actions */
.md-sb-actions {
  padding: 6px 10px 10px; display: flex; gap: 8px;
}
.md-sb-action {
  flex: 1; padding: 12px 8px; border-radius: var(--md-r-md);
  background: var(--md-w); border: 1.5px solid var(--md-g2);
  text-align: center; cursor: pointer; transition: border-color var(--md-dur-fast);
}
.md-sb-action:hover { border-color: var(--md-primary); }
.md-sb-action__icon { font-size: 1.5rem; line-height: 1; }
.md-sb-action__text {
  font-size: .75rem; font-weight: 800; color: var(--md-g8);
  margin-top: 4px; letter-spacing: .04em;
}

/* Sidebar footer */
.md-sb-footer {
  padding: 8px 14px; border-top: 1px solid var(--md-g1);
}
.md-sb-footer__family {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
}
.md-sb-footer__av {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--md-primary-pale), var(--md-sky));
  border-radius: var(--md-r-full);
  display: flex; align-items: center; justify-content: center; font-size: .8rem;
}
.md-sb-footer__name { font-size: .78rem; font-weight: 600; color: var(--md-g7); }
.md-sb-footer__info { font-size: .72rem; color: var(--md-g4); }

/* ---- Main area ---- */
.md-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Desktop: show sidebar, hide mobile nav ---- */
@media (min-width: 769px) {
  body { background: var(--md-g1); }

  .md-desktop-wrap {
    box-shadow: 0 0 60px rgba(0,0,0,.06);
    border-left: 1px solid var(--md-g2);
    border-right: 1px solid var(--md-g2);
  }

  .md-top-banner { display: flex; }
  .md-top-banner.md-hidden { display: none !important; }
  .md-sb-logo { display: none; } /* logo đã lên banner */

  .md-sidebar { display: flex; }

  /* Hide mobile bottom nav + header on desktop */
  .md-bnav { display: none !important; }
  .md-header { display: none !important; }

  /* Screens fill height */
  .md-screen { min-height: 100vh; min-height: 100dvh; }
  .md-screen__content { padding-bottom: var(--md-sp-6); }

  /* App max-width removed (sidebar handles it) */
  .md-app { max-width: none; }

  /* Chip thống kê: 4 cột trên desktop */
  .md-pd-metrics { grid-template-columns: repeat(4, 1fr); }
}

/* ---- Large desktop: wider sidebar ---- */
@media (min-width: 1200px) {
  .md-desktop-wrap { max-width: 1200px; }
  .md-sidebar { width: 240px; }
  .md-top-banner__left { width: 240px; }
  .md-top-banner__right { width: 290px; }
}

/* ============================================================
   PARENT DASHBOARD — Styles
   ============================================================ */
.md-pd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--md-sp-5);
}
.md-pd-hello {
  font-family: var(--md-font-h);
  font-size: var(--md-fs-xl);
  font-weight: 800;
  color: var(--md-g9);
}
.md-pd-date {
  font-size: var(--md-fs-sm);
  color: var(--md-g5);
  margin-top: 2px;
}
.md-pd-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--md-sp-2);
  margin-bottom: var(--md-sp-5);
}
.md-pd-metric {
  background: var(--md-w);
  border-radius: var(--md-r-md);
  padding: var(--md-sp-3);
  text-align: center;
  border: 1px solid var(--md-g1);
  cursor: pointer;
  transition: all var(--md-dur-fast);
}
.md-pd-metric:hover {
  border-color: var(--md-primary-border);
  box-shadow: var(--md-sh-sm);
}
.md-pd-metric--hl {
  border-color: var(--md-secondary-border);
  background: var(--md-secondary-pale);
}
.md-pd-metric__icon { font-size: 1.3rem; margin-bottom: 4px; }
.md-pd-metric__val {
  font-family: var(--md-font-h);
  font-size: var(--md-fs-xl);
  font-weight: 800;
  color: var(--md-g9);
}
.md-pd-metric__label {
  font-size: var(--md-fs-xs);
  color: var(--md-g5);
  font-weight: 600;
}

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

/* ============================================================
   RIGHT PANEL — Desktop only (>=769px)
   ============================================================ */
.md-right-panel {
  display: none;
  flex-direction: column;
  width: 256px;
  background: var(--md-w);
  border-left: 1px solid var(--md-g1);
  flex-shrink: 0;
  overflow-y: auto;
  padding: 0 13px 13px;
  gap: 0;
}
.md-right-panel::-webkit-scrollbar { width: 3px; }
.md-right-panel::-webkit-scrollbar-thumb { background: var(--md-g2); border-radius: 2px; }

@media (min-width: 769px) {
  .md-right-panel { display: none; }
}
@media (min-width: 900px) {
  .md-right-panel { display: flex; }
}
@media (min-width: 1200px) {
  .md-right-panel { width: 268px; padding: 0 14px 14px; }
}

/* Sections */
.md-rp-sec {
  padding: 7px 0;
  border-bottom: 1px solid var(--md-g1);
}
.md-rp-sec:first-child { padding-top: 10px; }
.md-rp-sec:last-child { border-bottom: none; }
.md-rp-title {
  font-family: var(--md-font-h);
  font-size: .9rem;
  font-weight: 700;
  color: var(--md-g7);
  margin-bottom: 5px;
}

/* Tree */
.md-rp-tree { text-align: center; padding: 4px; }
.md-rp-tree-stats { display: flex; justify-content: center; gap: 10px; margin-top: 8px; }
.md-rp-tree-st {
  font-size: .78rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--md-r-full);
}

/* Members — đồng nhất padding/font/border với sidebar items */
.md-rp-member {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 0.92rem;
  color: var(--md-g7);
  border-radius: var(--md-r-sm);
  border: 1px solid transparent;
  margin-bottom: 4px;
  min-height: 48px;
}
.md-rp-tag {
  font-size: .78rem;
  padding: 2px 8px;
  border-radius: var(--md-r-full);
  font-weight: 700;
}
.md-rp-tag.done { background: #DCFCE7; color: #16A34A; }
.md-rp-tag.active { background: #DBEAFE; color: #2563EB; }

/* Upcoming */
.md-rp-upcoming {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: .85rem;
  color: var(--md-g7);
}
.md-rp-time {
  margin-left: auto;
  font-size: .78rem;
  color: var(--md-g4);
  font-weight: 600;
}

/* Activity log */
.md-rp-log {
  font-size: .82rem;
  color: var(--md-g6);
  padding: 4px 0;
  border-bottom: 1px solid var(--md-g0);
}

/* Empty */
.md-rp-empty {
  font-size: .82rem;
  color: var(--md-g4);
  padding: 4px 0;
  font-style: italic;
}

/* Nút "Hướng dẫn sử dụng" — link trợ giúp, kiểu NHẸ, không chiếm tầm nhìn.
   (Nút hành động chính "Link thành viên" mới là nút nổi bật.) */
.md-rp-guide {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; margin-top: 8px;
  border-radius: var(--md-r-md);
  background: var(--md-g0);
  border: 1px solid var(--md-g2);
  text-decoration: none;
  transition: background var(--md-dur-fast), border-color var(--md-dur-fast);
}
.md-rp-guide span { font-weight: 600; animation: mdGuideText 4.5s ease-in-out infinite; }
.md-rp-guide:hover { background: var(--md-secondary-pale); border-color: var(--md-secondary-border); }
/* Chỉ CHỮ đổi màu nhẹ (nút vẫn trầm) — hút mắt mà không chói */
@keyframes mdGuideText {
  0%, 100% { color: #B26F00; }
  25%      { color: #3FA877; }
  50%      { color: #C2185B; }
  75%      { color: #0E7A6E; }
}
@media (prefers-reduced-motion: reduce) {
  .md-rp-guide span { animation: none; color: var(--md-g6); }
}
/* Thẻ số liệu "Tuần này" bấm được */
.md-rp-stat { cursor: pointer; transition: transform .12s var(--md-ease), box-shadow .12s var(--md-ease); }
.md-rp-stat:hover { transform: translateY(-1px); box-shadow: var(--md-sh-sm); }

/* ============================================================
   RESPONSIVE — Tablet (769-1023px)
   ============================================================ */
@media (min-width: 769px) and (max-width: 1023px) {
  .md-sidebar { width: 180px; }
  .md-top-banner__left { width: 180px; }
  .md-top-banner__logo-name { font-size: .85rem; }
  .md-top-banner__logo-tag { font-size: .75rem; }
  .md-top-banner__greeting { font-size: .85rem; }
  .md-top-banner__role { font-size: .75rem; }
  .md-top-banner__date { font-size: .72rem; }
  .md-top-banner__lunar { font-size: .75rem; }
  .md-sb-nav__item { font-size: 0.86rem; padding: 4px 12px; min-height: 28px; }
  .md-sb-nav__item span:first-child { font-size: 1rem; }
}

/* ============================================================
   RESPONSIVE — Mobile banner (hiện compact trên mobile khi login)
   ============================================================ */
@media (max-width: 768px) {
  .md-top-banner {
    display: none; /* Banner ẩn trên mobile, dùng header + bottom nav */
  }
  /* Footer menu (legal links) ẩn trên mobile — đã có bottom nav, tránh rối + đè nav */
  .md-app-footlinks { display: none !important; }
  /* Chip thống kê: 3 cột trên mobile (4 cột chữ quá nhỏ) */
  .md-pd-metrics { grid-template-columns: repeat(3, 1fr); }
  .md-pd-metric { padding: var(--md-sp-2); }
  .md-pd-metric__val { font-size: 1.05rem; }
  .md-pd-metric__label { font-size: .75rem; }
}
