/* =========================================================
MIRACLE SOCIAL — PAGES (Facebook-style)
Uses tokens from msn-ui-final.css
✅ Includes: Directory + Page View + Tabs + Photos + Followers
✅ Includes: Lightbox
✅ Includes: Facebook-like Bottom Sheet Modal (mobile) + Center (desktop)
========================================================= */

.msn-pages-shell, .msn-pages-shell *{ box-sizing:border-box; }
.msn-pages-shell{ max-width:1100px; margin:0 auto; padding:12px; }

.msn-pages-top{
  display:flex; align-items:flex-end; justify-content:space-between;
  gap:12px; margin:10px 0 14px;
}
.msn-pages-title h2{ margin:0; font-size:26px; }
.msn-pages-sub{ margin-top:4px; color:var(--muted); }

.msn-pages-grid{
  display:grid; gap:14px;
  grid-template-columns: 1fr 1fr;
}
@media (max-width: 860px){
  .msn-pages-grid{ grid-template-columns: 1fr; }
  .msn-pages-top{ flex-direction:column; align-items:stretch; }
}

.msn-pages-card .msn-card-h{ display:flex; align-items:baseline; justify-content:space-between; gap:10px; }
.msn-pages-list{ display:flex; flex-direction:column; gap:10px; padding-top:10px; }

.msn-page-row{
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:10px; border:1px solid var(--border); border-radius:14px; background:#fff;
}
.msn-page-row-a{ display:flex; align-items:center; gap:10px; text-decoration:none; color:inherit; min-width:0; }
.msn-page-row-meta{ min-width:0; }
.msn-page-row-name{ font-weight:800; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.msn-page-row-sub{ color:var(--muted); font-size:13px; }
.msn-page-row-cta{ flex:0 0 auto; }

.msn-page-ava{ display:inline-flex; border-radius:999px; overflow:hidden; border:2px solid #fff; box-shadow:0 6px 18px rgba(0,0,0,.10); }
.msn-page-ava img{ width:100%; height:100%; object-fit:cover; display:block; }

.msn-pages-login{ padding:14px; }
.msn-pages-login-inner{ display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.msn-pages-login-title{ font-weight:900; font-size:16px; margin-bottom:4px; }

/* ================= PAGE VIEW ================= */

.msn-page-view, .msn-page-view *{ box-sizing:border-box; }

.msn-page-cover{
  height:280px; background-size:cover; background-position:center;
  position:relative;
  border-radius:18px;
  overflow:hidden;
  max-width:1100px;
  margin:0 auto;
}
@media (max-width: 860px){
  .msn-page-cover{ height:220px; border-radius:14px; }
}

.msn-page-cover-shade{
  position:absolute; inset:0;
  background:linear-gradient(180deg, rgba(0,0,0,.12), rgba(0,0,0,.55));
}

.msn-page-edit-cover{
  position:absolute; right:14px; bottom:14px;
  z-index:2;
  border:1px solid rgba(255,255,255,.45);
  background:rgba(0,0,0,.35);
  color:#fff;
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:800;
  backdrop-filter: blur(8px);
}
.msn-page-edit-cover:hover{ background:rgba(0,0,0,.45); }

.msn-page-head{
  max-width:1100px;
  margin:-60px auto 0;
  padding:0 12px;
}
.msn-page-head-inner{
  display:flex;
  gap:14px;
  align-items:flex-end;
  padding:0 10px;
}
@media (max-width: 860px){
  .msn-page-head{ margin-top:-45px; }
  .msn-page-head-inner{ align-items:flex-start; }
}

.msn-page-avatar{
  width:140px; height:140px;
  border-radius:999px; overflow:hidden;
  border:5px solid #fff;
  background:#fff;
  box-shadow:0 10px 26px rgba(0,0,0,.15);
  flex:0 0 auto;
  position:relative;
}
@media (max-width: 860px){
  .msn-page-avatar{ width:110px; height:110px; border-width:4px; }
}
.msn-page-avatar img{ width:100%; height:100%; object-fit:cover; display:block; }

.msn-page-edit-avatar{
  position:absolute;
  right:6px;
  bottom:6px;
  width:40px; height:40px;
  border-radius:999px;
  border:1px solid var(--border);
  background:#fff;
  cursor:pointer;
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 10px 20px rgba(0,0,0,.18);
}

.msn-page-meta{ min-width:0; flex:1; padding-bottom:8px; }
.msn-page-name{
  font-size:28px; font-weight:900;
  color:#fff;
  text-shadow:0 2px 18px rgba(0,0,0,.35);
  line-height:1.05;
}
.msn-page-badge{
  display:inline-flex; align-items:center; justify-content:center;
  width:22px; height:22px; margin-left:8px;
  border-radius:999px; background:var(--accent); color:#fff;
  font-size:12px;
}
.msn-page-sub{
  margin-top:6px; color:#eef2ff; opacity:.95;
  text-shadow:0 2px 18px rgba(0,0,0,.35);
}
.msn-dot{ margin:0 6px; opacity:.8; }
.msn-page-actions{ margin-top:10px; display:flex; flex-wrap:wrap; gap:8px; }

/* ================= TABS ================= */
.msn-page-tabs{
  margin-top:12px;
  display:flex; gap:8px; flex-wrap:wrap;
  padding:10px;
  background:#fff;
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow);
}
.msn-page-tabs .msn-tab{
  border:0; background:transparent;
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:800;
  color:var(--muted);
}
.msn-page-tabs .msn-tab.is-active{ background:var(--soft); color:var(--text); }

/* Panels */
.msn-page-panel{ display:none; }
.msn-page-panel.is-active{ display:block; }

/* ================= BODY LAYOUT ================= */
.msn-page-body{
  max-width:1100px;
  margin:12px auto 50px;
  padding:0 12px;
  display:grid;
  gap:12px;
  grid-template-columns: 360px 1fr;
}
@media (max-width: 980px){
  .msn-page-body{ grid-template-columns: 1fr; }
}

/* Intro card */
.msn-page-intro{ white-space:pre-wrap; line-height:1.35; }
.msn-page-kv{ margin-top:10px; display:flex; flex-direction:column; gap:8px; }
.msn-kv-row{ display:flex; gap:10px; align-items:flex-start; }
.msn-kv-k{ width:90px; color:var(--muted); font-weight:800; font-size:13px; }
.msn-kv-v{ flex:1; min-width:0; word-break:break-word; }

/* ================= COMPOSER ================= */
.msn-page-composer textarea{
  width:100%;
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px;
  resize:vertical;
  min-height:60px;
  font:inherit;
  background:#fff;
}
.msn-page-composer-h{ display:flex; gap:10px; align-items:flex-start; }
.msn-page-composer-actions{
  display:flex;
  justify-content:space-between;
  gap:10px;
  margin-top:10px;
  align-items:center;
  flex-wrap:wrap;
}
.msn-file{ position:relative; overflow:hidden; }
.msn-mt{ margin-top:12px; }

/* post media inside page post card */
.msn-page-post .msn-post-media img{
  width:100%;
  display:block;
  border-radius:0 0 16px 16px;
}

/* ================= FOLLOWERS ================= */
.msn-follow-row{ padding:10px 0; border-bottom:1px solid var(--border); }
.msn-follow-row:last-child{ border-bottom:0; }
.msn-follow-a{ display:flex; align-items:center; gap:10px; text-decoration:none; color:inherit; }
.msn-follow-meta{ min-width:0; }
.msn-follow-name{ font-weight:900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ================= PHOTOS / VIDEOS GRID ================= */
.msn-page-photos{
  display:grid;
  grid-template-columns: repeat(4, 1fr);
  gap:10px;
}
@media (max-width: 980px){ .msn-page-photos{ grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 600px){ .msn-page-photos{ grid-template-columns: repeat(2, 1fr); } }

.msn-media{
  position:relative;
  display:block;
  border-radius:14px;
  overflow:hidden;
  border:1px solid var(--border);
  background:#fff;
}
.msn-media img{
  width:100%;
  height:180px;
  object-fit:cover;
  display:block;
}
@media (max-width: 600px){ .msn-media img{ height:150px; } }

.msn-media-play{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  width:52px; height:52px;
  border-radius:999px;
  display:grid;
  place-items:center;
  background:rgba(0,0,0,.55);
  color:#fff;
  font-size:20px;
  font-weight:900;
  box-shadow:0 10px 30px rgba(0,0,0,.25);
}

/* ================= LIGHTBOX ================= */
.msn-lightbox[hidden]{ display:none !important; }
.msn-lightbox{
  position:fixed;
  inset:0;
  z-index:999999;
  background:rgba(0,0,0,.86);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}
.msn-lightbox-card{
  width:min(1100px, 100%);
  display:grid;
  grid-template-columns: 1fr 320px;
  gap:14px;
}
@media (max-width: 980px){
  .msn-lightbox{ padding:12px; }
  .msn-lightbox-card{ grid-template-columns: 1fr; }
}
.msn-lightbox-media{
  position:relative;
  background:#000;
  border-radius:18px;
  overflow:hidden;
  min-height:300px;
  display:flex;
  align-items:center;
  justify-content:center;
}
.msn-lightbox-media img,
.msn-lightbox-media video{
  width:100%;
  height:100%;
  max-height:78vh;
  object-fit:contain;
  display:block;
}
.msn-lightbox-side{
  background:#0f1115;
  border:1px solid rgba(255,255,255,.10);
  border-radius:18px;
  padding:12px;
  color:#fff;
}
.msn-lightbox-h{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.msn-lightbox-title{ font-weight:900; }
.msn-lightbox-actions{ display:flex; gap:8px; flex-wrap:wrap; }
.msn-lb-btn{
  border:1px solid rgba(255,255,255,.15);
  background:rgba(255,255,255,.08);
  color:#fff;
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
  font-weight:800;
}
.msn-lb-btn:hover{ background:rgba(255,255,255,.12); }
.msn-lb-btn:disabled{ opacity:.5; cursor:not-allowed; }

.msn-lb-close{
  width:40px;
  height:40px;
  border-radius:999px;
  display:grid;
  place-items:center;
  font-size:18px;
}

.msn-lb-nav{
  position:absolute;
  top:50%;
  transform:translateY(-50%);
  width:44px;
  height:44px;
  border-radius:999px;
  display:grid;
  place-items:center;
  border:1px solid rgba(255,255,255,.18);
  background:rgba(0,0,0,.35);
  color:#fff;
  font-size:18px;
  font-weight:900;
  cursor:pointer;
}
.msn-lb-nav:hover{ background:rgba(0,0,0,.50); }
.msn-lb-prev{ left:10px; }
.msn-lb-next{ right:10px; }

/* =========================================================
MODAL SYSTEM (Facebook Bottom Sheet on mobile)
IMPORTANT: Put modal CSS in msn-ui-final.css if possible,
but this works here too.
========================================================= */

.msn-modal[hidden]{ display:none !important; }

/* Bottom sheet default (mobile) */
.msn-modal{
  position:fixed !important;
  inset:0 !important;
  z-index:999999 !important;
  display:flex !important;
  align-items:flex-end !important;
  justify-content:center !important;
  padding:0 !important;
}

/* Backdrop */
.msn-modal .msn-modal-backdrop{
  position:absolute !important;
  inset:0 !important;
  background:rgba(0,0,0,.55) !important;
}

/* Card */
.msn-modal .msn-modal-card{
  position:relative !important;
  z-index:2 !important;
  width:100% !important;
  max-width:720px !important;
  max-height:85vh !important;
  overflow:auto !important;
  -webkit-overflow-scrolling:touch !important;

  background:#fff !important;
  border:1px solid var(--border) !important;
  border-radius:22px 22px 0 0 !important;
  box-shadow:0 -12px 40px rgba(0,0,0,.28) !important;
  padding:14px 14px 18px !important;
}

/* Grab handle */
.msn-sheet-handle{
  width:46px;
  height:5px;
  border-radius:999px;
  background:#d1d5db;
  margin:0 auto 10px;
}

/* Header */
.msn-modal .msn-modal-h{
  display:flex !important;
  align-items:flex-start !important;
  justify-content:space-between !important;
  gap:10px !important;
  padding-bottom:10px !important;
  border-bottom:1px solid var(--border) !important;
  margin-bottom:12px !important;
}

.msn-modal .msn-modal-title{
  font-size:18px !important;
  font-weight:900 !important;
  margin:0 !important;
}

/* Close */
.msn-modal .msn-icon-btn{
  border:1px solid var(--border) !important;
  background:#fff !important;
  width:40px !important;
  height:40px !important;
  border-radius:14px !important;
  cursor:pointer !important;
  display:grid !important;
  place-items:center !important;
}

/* Fields */
.msn-modal .msn-field label{
  display:block !important;
  font-weight:900 !important;
  margin-bottom:6px !important;
}

.msn-modal input[type="text"],
.msn-modal textarea{
  width:100% !important;
  border:1px solid var(--border) !important;
  border-radius:14px !important;
  padding:12px !important;
  font:inherit !important;
  background:#fff !important;
  outline:none !important;
}

/* Actions */
.msn-modal .msn-form-actions{
  display:flex !important;
  gap:10px !important;
  justify-content:flex-end !important;
  flex-wrap:wrap !important;
  margin-top:12px !important;
}

/* Lock scroll */
body.msn-modal-open{
  overflow:hidden !important;
  touch-action:none !important;
}

/* Desktop: centered modal */
@media (min-width: 860px){
  .msn-modal{
    align-items:center !important;
    padding:16px !important;
  }
  .msn-modal .msn-modal-card{
    width:min(560px, 100%) !important;
    max-height:calc(100vh - 32px) !important;
    border-radius:18px !important;
    box-shadow:0 18px 50px rgba(0,0,0,.25) !important;
  }
}