/* ============================================================
   MD-LAYOUT.CSS — App Shell, Navigation, Screen Container
   ============================================================ */

/* ---- App Shell ---- */
.md-app {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--md-g0);
  position: relative;
  max-width: var(--md-max-w);
  margin: 0 auto;
}

/* Desktop wrapper — center trên màn lớn */
@media (min-width: 520px) {
  body { background: var(--md-g1); }
  .md-app {
    border-left: 1px solid var(--md-g2);
    border-right: 1px solid var(--md-g2);
    box-shadow: 0 0 40px rgba(0,0,0,.06);
  }
}

/* ---- Header ---- */
.md-header {
  position: sticky;
  top: 0;
  height: var(--md-header-h);
  display: flex;
  align-items: center;
  padding: 0 var(--md-sp-4);
  background: var(--md-w);
  border-bottom: 1px solid var(--md-g1);
  z-index: var(--md-z-nav);
  gap: var(--md-sp-3);
}
.md-header__back {
  width: 36px; height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--md-r-sm);
  color: var(--md-g6);
  transition: background var(--md-dur-fast);
  flex-shrink: 0;
}
.md-header__back:hover { background: var(--md-g1); }
.md-header__back svg { width: 20px; height: 20px; }
.md-header__title {
  flex: 1;
  font-family: var(--md-font-h);
  font-size: var(--md-fs-md);
  font-weight: 700;
  color: var(--md-g9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.md-header__actions {
  display: flex;
  gap: var(--md-sp-1);
  flex-shrink: 0;
}

/* Header child variant */
.md-header--child {
  background: linear-gradient(135deg, var(--md-fun-green), var(--md-sky));
  border-bottom: none;
}
.md-header--child .md-header__title { color: var(--md-w); font-family: var(--md-font-c); }
.md-header--child .md-header__back { color: var(--md-w); }
.md-header--child .md-header__back:hover { background: rgba(255,255,255,.15); }

/* ---- Screen Container ---- */
.md-screen {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.md-screen.md-active {
  display: flex;
  animation: md-fadeIn var(--md-dur) var(--md-ease) both;
}
.md-screen__content {
  flex: 1;
  padding: var(--md-sp-4);
  padding-bottom: calc(var(--md-bnav-h) + var(--md-sp-4));
}

/* ---- Bottom Nav (Parent) ---- */
.md-bnav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--md-max-w);
  height: var(--md-bnav-h);
  background: var(--md-w);
  border-top: 1px solid var(--md-g1);
  display: flex;
  align-items: center;
  z-index: var(--md-z-nav);
  padding: 0 var(--md-sp-2);
  box-shadow: 0 -2px 12px rgba(0,0,0,.04);
}
.md-bnav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: var(--md-sp-2) 0;
  color: var(--md-g4);
  font-size: 0.78rem;
  font-weight: 700;
  transition: color var(--md-dur-fast);
  position: relative;
}
.md-bnav__item svg { width: 26px; height: 26px; }
.md-bnav__item.md-active {
  color: var(--md-primary);
}
.md-bnav__item.md-active::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 20%;
  right: 20%;
  height: 3px;
  border-radius: 0 0 var(--md-r-sm) var(--md-r-sm);
  background: var(--md-primary);
}

/* Bottom nav notification dot */
.md-bnav__dot {
  position: absolute;
  top: 2px;
  right: calc(50% - 14px);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--md-coral);
  border: 2px solid var(--md-w);
}

/* ---- Bottom Nav (Child) ---- */
.md-bnav--child {
  height: var(--md-bnav-c-h);
  border-top: none;
  background: linear-gradient(135deg, var(--md-fun-green), var(--md-sky));
  border-radius: var(--md-r-lg) var(--md-r-lg) 0 0;
  box-shadow: 0 -4px 20px rgba(107,203,119,.2);
}
.md-bnav--child .md-bnav__item {
  color: rgba(255,255,255,.6);
  font-family: var(--md-font-c);
  font-weight: 800;
}
.md-bnav--child .md-bnav__item.md-active {
  color: var(--md-w);
}
.md-bnav--child .md-bnav__item.md-active::before {
  background: var(--md-w);
}

/* ---- Fullscreen screens (no nav) ---- */
.md-screen--full {
  position: fixed;
  inset: 0;
  z-index: var(--md-z-sidebar);
  background: var(--md-w);
  max-width: var(--md-max-w);
  margin: 0 auto;
}
.md-screen--full .md-screen__content {
  padding-bottom: var(--md-sp-4);
}

/* ---- Splash / Welcome ---- */
.md-splash {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #EEFBF4 0%, #FFF8F0 40%, #FFF0E0 100%);
  padding: var(--md-sp-6);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.md-splash::before {
  content: '';
  position: absolute;
  top: -100px;
  right: -80px;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(43,154,112,.08) 0%, transparent 70%);
}
.md-splash::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: -40px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,166,35,.08) 0%, transparent 70%);
}

/* ---- Section ---- */
.md-section {
  margin-bottom: var(--md-sp-5);
}
.md-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--md-sp-3);
}
.md-section__title {
  font-family: var(--md-font-h);
  font-size: 1rem;
  font-weight: 700;
  color: var(--md-g7);
}
.md-section__more {
  font-size: var(--md-fs-sm);
  font-weight: 600;
  color: var(--md-primary);
}

/* ---- List ---- */
.md-list {
  display: flex;
  flex-direction: column;
  gap: var(--md-sp-2);
}
.md-list-item {
  display: flex;
  align-items: center;
  gap: var(--md-sp-3);
  padding: var(--md-sp-4) var(--md-sp-4);
  background: var(--md-w);
  border-radius: var(--md-r-md);
  border: 1px solid var(--md-g1);
  transition: all var(--md-dur-fast);
  cursor: pointer;
  min-height: 62px;
}
.md-list-item:hover { border-color: var(--md-primary-border); background: var(--md-primary-pale); }
.md-list-item__icon { font-size: 1.7rem; flex-shrink: 0; }
.md-list-item__body { flex: 1; min-width: 0; }
.md-list-item__title { font-weight: 700; color: var(--md-g8); font-size: var(--md-fs-base); }
.md-list-item__sub { font-size: var(--md-fs-sm); color: var(--md-g5); margin-top: 2px; }
.md-list-item__end { flex-shrink: 0; color: var(--md-g4); }

/* ---- FAB ---- */
.md-fab {
  position: fixed;
  bottom: calc(var(--md-bnav-h) + var(--md-sp-4));
  right: calc(50% - var(--md-max-w)/2 + var(--md-sp-4));
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--md-primary), var(--md-primary-light));
  color: var(--md-w);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(43,154,112,.3);
  z-index: var(--md-z-base);
  transition: transform var(--md-dur) var(--md-bounce);
}
.md-fab:hover { transform: scale(1.1); }
.md-fab svg { width: 24px; height: 24px; }

@media (max-width: 520px) {
  .md-fab { right: var(--md-sp-4); }
}

/* ---- Tabs ---- */
.md-tabs {
  display: flex;
  background: var(--md-g1);
  border-radius: var(--md-r-md);
  padding: 3px;
  gap: 2px;
}
.md-tab {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  font-size: var(--md-fs-sm);
  font-weight: 600;
  color: var(--md-g5);
  border-radius: var(--md-r-sm);
  transition: all var(--md-dur-fast);
}
.md-tab.md-active {
  background: var(--md-w);
  color: var(--md-primary);
  box-shadow: var(--md-sh-sm);
}

/* ---- Pull to refresh indicator ---- */
.md-ptr {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 0;
  overflow: hidden;
  transition: height var(--md-dur);
}
.md-ptr.md-active { height: 48px; }
