/* FitPlan V784 - smartphone safe areas, check camera cleanup and mobile media modal hardening */

:root{
  --fitplan-safe-top: env(safe-area-inset-top, 0px);
  --fitplan-safe-right: env(safe-area-inset-right, 0px);
  --fitplan-safe-bottom: env(safe-area-inset-bottom, 0px);
  --fitplan-safe-left: env(safe-area-inset-left, 0px);
}

/* CLIENT: never place the app under the phone status bar/notch. */
html.client-ux-v769,
body.client-ux-v769{
  min-height:100%;
  min-height:100dvh;
}
.client-ux-v769 .app-shell{
  min-height:100vh;
  min-height:100dvh;
  padding-bottom:calc(112px + var(--fitplan-safe-bottom));
}
.client-ux-v769 .topbar{
  top:0!important;
  padding-top:calc(12px + var(--fitplan-safe-top))!important;
  padding-left:calc(15px + var(--fitplan-safe-left))!important;
  padding-right:calc(15px + var(--fitplan-safe-right))!important;
  min-height:calc(68px + var(--fitplan-safe-top));
}
.client-ux-v769 .tabs{
  left:50%;
  bottom:0!important;
  padding-left:calc(9px + var(--fitplan-safe-left))!important;
  padding-right:calc(9px + var(--fitplan-safe-right))!important;
  padding-bottom:calc(10px + var(--fitplan-safe-bottom))!important;
}

/* If an external Netlify overlay is detected, reserve a strip instead of letting it cover navigation. */
.client-ux-v769.fitplan-netlify-overlay-v784 .tabs,
body.client-ux-v769.fitplan-netlify-overlay-v784 .tabs{
  bottom:54px!important;
}
.client-ux-v769.fitplan-netlify-overlay-v784 .app-shell,
body.client-ux-v769.fitplan-netlify-overlay-v784 .app-shell{
  padding-bottom:calc(166px + var(--fitplan-safe-bottom));
}

/* CLIENT CHECK CAMERA: the instructional copy stays outside the camera image. */
#guidedCheckCameraModal{
  z-index:120500!important;
  padding:calc(10px + var(--fitplan-safe-top)) calc(10px + var(--fitplan-safe-right)) calc(10px + var(--fitplan-safe-bottom)) calc(10px + var(--fitplan-safe-left))!important;
  overflow:auto;
  overscroll-behavior:contain;
}
#guidedCheckCameraModal .guided-camera-box{
  width:min(520px,100%)!important;
  max-width:520px!important;
  max-height:calc(100dvh - 20px - var(--fitplan-safe-top) - var(--fitplan-safe-bottom));
  overflow:auto;
  padding:14px!important;
}
#guidedCheckCameraModal .section-head{
  display:grid!important;
  grid-template-columns:minmax(0,1fr) auto!important;
  align-items:start!important;
  gap:10px!important;
}
#guidedCheckCameraModal .section-head > div{min-width:0}
#guidedCheckCameraModal .section-head h2,
#guidedCheckCameraModal .section-head p{
  max-width:100%;
  white-space:normal!important;
  overflow-wrap:anywhere;
}
#guidedCheckCameraModal .guided-camera-frame{
  width:min(100%,390px)!important;
  height:min(56dvh,520px)!important;
  max-height:520px!important;
  aspect-ratio:auto!important;
  margin:0 auto 10px!important;
}
/* These labels were colliding on narrow phones. Dots/frame remain as visual guides. */
#guidedCheckCameraModal .check-ref-tag,
#guidedCheckCameraModal .check-ref-help{
  display:none!important;
}
#guidedCheckCameraModal .check-ref-frame{inset:6% 13% 8% 13%!important}
#guidedCheckCameraModal .check-ref-overlay.side .check-ref-frame{inset:6% 32% 8% 32%!important}
#guidedCheckCameraModal .guided-camera-actions{
  display:grid!important;
  grid-template-columns:1fr 1fr!important;
  gap:8px!important;
  margin:9px 0!important;
}
#guidedCheckCameraModal .guided-camera-actions .btn{width:100%!important;min-width:0!important}

/* COACH guided camera gets the same viewport-safe treatment. */
#coachGuidedCheckCameraModal{
  z-index:120500!important;
  padding:calc(10px + var(--fitplan-safe-top)) calc(10px + var(--fitplan-safe-right)) calc(10px + var(--fitplan-safe-bottom)) calc(10px + var(--fitplan-safe-left))!important;
  overflow:auto;
  overscroll-behavior:contain;
}
#coachGuidedCheckCameraModal .guided-camera-box{
  width:min(520px,100%)!important;
  max-width:520px!important;
  max-height:calc(100dvh - 20px - var(--fitplan-safe-top) - var(--fitplan-safe-bottom));
  overflow:auto;
}
#coachGuidedCheckCameraModal .section-head{display:grid!important;grid-template-columns:minmax(0,1fr) auto!important;gap:10px!important;align-items:start!important}
#coachGuidedCheckCameraModal .section-head > div{min-width:0}
#coachGuidedCheckCameraModal .section-head p{white-space:normal!important;overflow-wrap:anywhere}
#coachGuidedCheckCameraModal .guided-camera-frame{height:min(56dvh,520px)!important;max-height:520px!important;aspect-ratio:auto!important}

/* CLIENT PHOTO/VIDEO VIEWER: close control must always remain inside the visible viewport. */
.client-media-modal-v767{
  z-index:120700!important;
  align-items:center!important;
  justify-content:center!important;
  padding:calc(12px + var(--fitplan-safe-top)) calc(12px + var(--fitplan-safe-right)) calc(12px + var(--fitplan-safe-bottom)) calc(12px + var(--fitplan-safe-left))!important;
  overflow:auto!important;
  overscroll-behavior:contain;
}
.client-media-modal-card-v767{
  width:min(920px,100%)!important;
  max-width:100%!important;
  max-height:calc(100dvh - 24px - var(--fitplan-safe-top) - var(--fitplan-safe-bottom))!important;
  padding-top:52px!important;
  overflow:auto!important;
  overscroll-behavior:contain;
}
.client-media-image-v767,
.client-media-image-v767 img{
  max-height:calc(100dvh - 150px - var(--fitplan-safe-top) - var(--fitplan-safe-bottom))!important;
}
.client-media-video-v767{
  max-height:calc(100dvh - 150px - var(--fitplan-safe-top) - var(--fitplan-safe-bottom))!important;
}
.client-media-modal-close-v767{
  position:fixed!important;
  top:calc(10px + var(--fitplan-safe-top))!important;
  right:calc(10px + var(--fitplan-safe-right))!important;
  width:48px!important;
  height:48px!important;
  min-width:48px!important;
  min-height:48px!important;
  display:grid!important;
  place-items:center!important;
  z-index:120710!important;
  touch-action:manipulation;
}
.client-media-close-mobile-v784{
  display:none;
  width:100%;
  min-height:48px;
  border:1px solid rgba(255,255,255,.18);
  border-radius:14px;
  background:rgba(255,255,255,.08);
  color:#fff;
  font:inherit;
  font-weight:900;
  cursor:pointer;
}
html.fitplan-media-open-v784,
body.fitplan-media-open-v784{
  overflow:hidden!important;
  overscroll-behavior:none!important;
}

@media(max-width:760px){
  .client-media-modal-card-v767{padding-top:56px!important}
  .client-media-close-mobile-v784{display:block}
  .client-media-image-v767,
  .client-media-image-v767 img{max-width:100%!important;width:auto!important}
}

@media(max-width:430px){
  #guidedCheckCameraModal .section-head,
  #coachGuidedCheckCameraModal .section-head{
    grid-template-columns:1fr!important;
  }
  #guidedCheckCameraModal .section-head .btn,
  #coachGuidedCheckCameraModal .section-head .btn{
    justify-self:start!important;
  }
  #guidedCheckCameraModal .guided-camera-frame,
  #coachGuidedCheckCameraModal .guided-camera-frame{
    height:min(52dvh,470px)!important;
  }
}

@media(orientation:landscape) and (max-height:520px){
  #guidedCheckCameraModal .guided-camera-frame,
  #coachGuidedCheckCameraModal .guided-camera-frame{height:46dvh!important}
  .client-media-image-v767,
  .client-media-image-v767 img{max-height:62dvh!important}
}

.fitplan-author-v784{
  margin:14px 0 0!important;
  color:var(--muted,#98aaa1);
  font-size:11px;
  font-weight:750;
  letter-spacing:.03em;
  text-align:center;
}

/* COACH/WEB photo viewers: keep close controls within the mobile viewport too. */
#photoLightbox{
  z-index:120700!important;
  padding:calc(12px + var(--fitplan-safe-top)) calc(12px + var(--fitplan-safe-right)) calc(12px + var(--fitplan-safe-bottom)) calc(12px + var(--fitplan-safe-left))!important;
  overflow:auto!important;
  overscroll-behavior:contain;
}
#photoLightbox .photo-lightbox-box{
  width:min(980px,100%)!important;
  max-width:100%!important;
  max-height:calc(100dvh - 24px - var(--fitplan-safe-top) - var(--fitplan-safe-bottom))!important;
  overflow:auto!important;
}
#photoLightbox .photo-lightbox-box > div:first-child{
  position:sticky;
  top:0;
  z-index:4;
  padding:4px 0 10px;
  background:var(--theme-surface,#0d1713);
}
#photoLightboxImg{max-height:calc(100dvh - 125px - var(--fitplan-safe-top) - var(--fitplan-safe-bottom))!important}
.exercise-media-lightbox-v767{
  padding:calc(12px + var(--fitplan-safe-top)) calc(12px + var(--fitplan-safe-right)) calc(12px + var(--fitplan-safe-bottom)) calc(12px + var(--fitplan-safe-left))!important;
  overflow:auto!important;
}
.exercise-media-lightbox-close-v767{
  position:fixed!important;
  top:calc(10px + var(--fitplan-safe-top))!important;
  right:calc(10px + var(--fitplan-safe-right))!important;
  width:48px!important;
  height:48px!important;
  z-index:120710!important;
}

@media(max-width:900px){
  .coach-ux-v769 .web-shell{
    padding-top:calc(10px + var(--fitplan-safe-top))!important;
    padding-left:calc(10px + var(--fitplan-safe-left))!important;
    padding-right:calc(10px + var(--fitplan-safe-right))!important;
    padding-bottom:calc(10px + var(--fitplan-safe-bottom))!important;
  }
}
