/* =========================================================
   profile.css - FINAL NEW VERSION
   Profile Page + Proper Mobile Scroll Fix
   Replace complete profile.css with this
========================================================= */

/* ---------- GLOBAL SCROLL / APP LAYOUT FIX ---------- */

html,
body {
  width: 100% !important;
  height: 100% !important;
  min-height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  overscroll-behavior: none;
}

body {
  height: 100dvh !important;
  min-height: 100dvh !important;
  display: flex !important;
  flex-direction: column !important;
  background: var(--bg, #f6f7fb);
  color: var(--text, #0f172a);
  position: relative !important;
}

/* Topbar normal rahe, fixed nahi */
.topbar {
  position: relative !important;
  flex: 0 0 auto !important;
  z-index: 20 !important;
}

/* ✅ Main page is now the scroll container */
main.page,
.page {
  flex: 1 1 auto !important;
  height: 0 !important;
  min-height: 0 !important;
  max-height: none !important;

  overflow-y: auto !important;
  overflow-x: hidden !important;
  -webkit-overflow-scrolling: touch !important;

  box-sizing: border-box !important;
}

/* Sections spacing */
.page .section {
  width: 100%;
  box-sizing: border-box;
}

/* Last section ko bottom nav ke upar safe rakhna */
.page .section:last-of-type {
  margin-bottom: 115px !important;
}

/* Extra bottom gap */
.spaceBottom {
  display: block !important;
  width: 100% !important;
  height: 150px !important;
  min-height: 150px !important;
}

/* Bottom nav always visible */
.bottomNav {
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  z-index: 80 !important;
}


/* =========================================================
   HERO CARD
========================================================= */

.profileHero {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: linear-gradient(135deg, var(--chipBg, #eef4ff), rgba(255, 255, 255, 0.94));
  border-radius: 22px;
  padding: 14px;
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.06);
  box-sizing: border-box;
}

.phLeft {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.phRight {
  display: flex;
  justify-content: center;
  align-items: center;
}

.phLine {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(15, 23, 42, 0.06);
  box-sizing: border-box;
}

.phK {
  font-size: 12px;
  color: var(--muted, #64748b);
  font-weight: 900;
  flex: 0 0 auto;
}

.phV {
  font-size: 12px;
  font-weight: 1000;
  max-width: 62%;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(15, 23, 42, 0.86);
}


/* =========================================================
   AVATAR
========================================================= */

.avatarBox {
  width: 92px;
  height: 92px;
  border-radius: 26px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  background: #fff;
  overflow: hidden;
  display: grid;
  place-items: center;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
}

.avatarBox img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.avatarFallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 30px;
}


/* =========================================================
   QUICK ACTION BUTTONS
========================================================= */

.profileActions {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.profileActions a,
.profileActions button {
  min-width: 0;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  box-sizing: border-box;
}


/* =========================================================
   TILES LIST
========================================================= */

.profileTiles {
  display: grid;
  gap: 10px;
}

.tile,
.tileBtn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 68px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: #fff;
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.05);
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
}

.tileBtn {
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}

.tile:active,
.tileBtn:active {
  transform: scale(0.99);
}

.tileIco {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--chipBg, #eef4ff);
  border: 1px solid rgba(15, 23, 42, 0.06);
  font-size: 18px;
  flex: 0 0 auto;
}

.tileTitle {
  font-weight: 1100;
  font-size: 13px;
  line-height: 1.2;
}

.tileSub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted, #64748b);
  font-weight: 900;
  line-height: 1.25;
}

.tileRightBadge {
  margin-left: auto;
  font-weight: 1100;
  font-size: 12px;
  color: rgba(15, 23, 42, 0.55);
  flex: 0 0 auto;
}


/* =========================================================
   BADGES
========================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 1000;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.86);
}

.badge.ok {
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.18);
  color: #16a34a;
}

.badge.warn {
  background: rgba(234, 179, 8, 0.14);
  border-color: rgba(234, 179, 8, 0.18);
  color: #a16207;
}


/* =========================================================
   EDIT PROFILE BOTTOM SHEET
========================================================= */

.sheetOverlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
}

.sheetOverlay.show {
  opacity: 1;
  pointer-events: auto;
}

.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(96vw, 560px);
  max-height: 92dvh;
  transform: translateX(-50%) translateY(24px);
  background: #fff;
  border-top-left-radius: 26px;
  border-top-right-radius: 26px;
  z-index: 91;
  box-shadow: 0 -18px 50px rgba(2, 6, 23, 0.28);
  border: 1px solid rgba(15, 23, 42, 0.06);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
  box-sizing: border-box;
}

.sheet.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.sheetTop {
  padding: 14px 14px 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  background: linear-gradient(180deg, #fff, rgba(255, 255, 255, 0.88));
  box-sizing: border-box;
}

.sheetTitle {
  font-size: 16px;
  font-weight: 1100;
  line-height: 1.2;
}

.sheetSub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted, #64748b);
  font-weight: 900;
}

.xBtn {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  cursor: pointer;
  font-size: 16px;
  font-weight: 1000;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.sheetBody {
  padding: 12px 14px calc(22px + env(safe-area-inset-bottom));
  max-height: calc(92dvh - 66px);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.pfRow {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  background: rgba(15, 23, 42, 0.02);
  box-sizing: border-box;
}

.avatarBig {
  width: 92px;
  height: 92px;
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  display: grid;
  place-items: center;
  box-sizing: border-box;
}

.avatarBig img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}

.avatarBigFallback {
  font-size: 34px;
}

.lab {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 1000;
  color: rgba(15, 23, 42, 0.78);
}

.inp {
  width: 100%;
  margin-top: 6px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  padding: 0 12px;
  outline: none;
  font-weight: 900;
  background: #fff;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.04);
  box-sizing: border-box;
  font-family: inherit;
  color: inherit;
}

.inp:focus {
  border-color: rgba(37, 99, 235, 0.35);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}

.inp:disabled {
  background: rgba(15, 23, 42, 0.04);
  color: rgba(15, 23, 42, 0.55);
}

.ta {
  height: auto;
  min-height: 86px;
  padding: 10px 12px;
  resize: vertical;
}

.miniHelp {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted, #64748b);
  font-weight: 900;
}

.errBox {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(185, 28, 28, 0.10);
  border: 1px solid rgba(185, 28, 28, 0.18);
  color: #7f1d1d;
  font-weight: 900;
  font-size: 12px;
  box-sizing: border-box;
}

.sheetBtns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-bottom: 8px;
}


/* =========================================================
   MOBILE RESPONSIVE
========================================================= */

@media (max-width: 520px) {

  .page .section:last-of-type {
    margin-bottom: 140px !important;
  }

  .spaceBottom {
    height: 170px !important;
    min-height: 170px !important;
  }

  .profileHero {
    grid-template-columns: 1fr 82px;
    gap: 10px;
    padding: 12px;
  }

  .avatarBox {
    width: 82px;
    height: 82px;
    border-radius: 22px;
  }

  .phLine {
    padding: 9px 10px;
  }

  .phK {
    font-size: 11px;
  }

  .phV {
    font-size: 11px;
    max-width: 58%;
  }

  .profileActions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .profileActions a,
  .profileActions button {
    font-size: 11px;
    padding-left: 6px;
    padding-right: 6px;
  }

  .tile,
  .tileBtn {
    padding: 11px;
    gap: 10px;
    min-height: 64px;
  }

  .tileIco {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    font-size: 17px;
  }

  .tileTitle {
    font-size: 12px;
  }

  .tileSub {
    font-size: 11px;
  }

  .tileRightBadge {
    font-size: 11px;
  }

  .sheet {
    width: 100vw;
    max-height: 94dvh;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
  }

  .sheetBody {
    max-height: calc(94dvh - 66px);
  }

  .pfRow {
    grid-template-columns: 82px 1fr;
  }

  .avatarBig {
    width: 82px;
    height: 82px;
  }
}


/* =========================================================
   VERY SMALL MOBILE
========================================================= */

@media (max-width: 360px) {
  .profileHero {
    grid-template-columns: 1fr;
  }

  .phRight {
    justify-content: flex-start;
  }

  .avatarBox {
    width: 76px;
    height: 76px;
  }

  .profileActions {
    grid-template-columns: 1fr;
  }

  .sheetBtns {
    grid-template-columns: 1fr;
  }

  .pfRow {
    grid-template-columns: 1fr;
  }
}