/* =========================================================
   MIRACLE SOCIAL — GROUPS UI
   ========================================================= */

.msn-groups .msn-groups-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

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

@media (max-width: 900px){
  .msn-groups-grid{ grid-template-columns:repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 520px){
  .msn-groups-grid{ grid-template-columns:1fr; }
}

.msn-group-card{
  display:block;
  text-decoration:none;
  color:inherit;
  border:1px solid var(--border);
  border-radius:16px;
  overflow:hidden;
  background:var(--card);
  box-shadow:var(--shadow);
}

.msn-group-card-cover{
  height:110px;
  background:linear-gradient(135deg, rgba(24,119,242,.18), rgba(251,191,36,.22));
  background-size:cover;
  background-position:center;
}

.msn-group-card-body{ padding:10px 12px; }
.msn-group-card-name{ font-weight:700; font-size:16px; margin-bottom:6px; }
.msn-group-card-meta{ display:flex; gap:6px; flex-wrap:wrap; font-size:13px; }

/* ===== Single group ===== */

.msn-group-cover{
  position:relative;
  height:220px;
  border-radius:18px;
  overflow:hidden;
  background:linear-gradient(135deg, rgba(24,119,242,.18), rgba(251,191,36,.22));
  background-size:cover;
  background-position:center;
  box-shadow:var(--shadow);
  margin-bottom:12px;
}

@media (max-width: 520px){
  .msn-group-cover{ height:160px; }
}

.msn-group-cover-btn{
  position:absolute;
  right:12px;
  bottom:12px;
  display:inline-flex;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  border-radius:999px;
  background:rgba(0,0,0,.55);
  color:#fff;
  font-size:13px;
  cursor:pointer;
}

.msn-group-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}

@media (max-width: 720px){
  .msn-group-head{ flex-direction:column; }
}

.msn-group-title{ margin:0 0 6px 0; }
.msn-group-sub{ display:flex; gap:8px; flex-wrap:wrap; }

.msn-group-compose textarea{
  width:100%;
  min-height:84px;
  resize:vertical;
}

.msn-group-compose-actions{ margin-top:10px; display:flex; justify-content:flex-end; }

/* ===== Admin panel: pending posts ===== */

.msn-group-admin-panel{
  border:1px dashed var(--border);
  margin-bottom:12px;
}

.msn-group-admin-title{
  font-weight:800;
  margin-bottom:10px;
}

.msn-group-pending{
  padding:10px;
  border-radius:12px;
  background:var(--soft);
  margin-top:10px;
}

.msn-group-pending-meta{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:8px;
}

.msn-group-pending-content{ white-space:pre-wrap; }
.msn-group-pending-actions{ margin-top:10px; display:flex; justify-content:flex-end; }

/* ===== Pending members ===== */

.msn-group-member-req{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 0;
  border-top:1px solid var(--border);
}

/* ===== Group chat embed: hide thread list ===== */

.msn-group-chat-card .msn-group-chat-title{
  font-weight:800;
  margin-bottom:10px;
}

.msn-group-chat-only .msn-msg-sidebar{ display:none !important; }
.msn-group-chat-only .msn-msg-shell{ grid-template-columns: 1fr !important; }

/* Make chat window a bit shorter inside group page */
.msn-group-chat-card .msn-chat-window{ min-height:420px; }
@media (max-width: 520px){
  .msn-group-chat-card .msn-chat-window{ min-height:360px; }
}

/* ===== Buttons ===== */

.msn-btn.msn-btn-danger{
  background:#dc2626;
  color:#fff;
  border:1px solid rgba(0,0,0,.08);
}

.msn-btn.msn-btn-danger:hover{ filter:brightness(.95); }

/* ===== Members admin list ===== */

.msn-group-member-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 0;
  border-top:1px solid var(--border);
}

.msn-group-member-left{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.msn-group-member-name{ font-weight:700; }

.msn-group-member-badge{
  font-size:12px;
  padding:4px 8px;
  border-radius:999px;
  background:var(--soft);
  border:1px solid var(--border);
  color:var(--muted);
  text-transform:capitalize;
}

.msn-group-member-actions{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

/* ===== Modal (Create Group) ===== */

html.msn-modal-open{ overflow:hidden; }

.msn-modal{
  position:fixed;
  inset:0;
  z-index:99999;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:18px;
}

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

.msn-modal-backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.45);
}

.msn-modal-dialog{
  position:relative;
  width:min(560px, 100%);
  background:var(--card);
  border-radius:18px;
  border:1px solid var(--border);
  box-shadow:0 20px 60px rgba(0,0,0,.25);
  overflow:hidden;
}

.msn-modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  border-bottom:1px solid var(--border);
}

.msn-modal-title{ font-weight:800; font-size:16px; }

.msn-modal-x{
  width:36px;
  height:36px;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--soft);
  cursor:pointer;
  font-size:22px;
  line-height:1;
}

.msn-modal-body{ padding:14px 16px; display:grid; gap:12px; }

.msn-field{ display:grid; gap:6px; }
.msn-field-label{ font-size:13px; color:var(--muted); font-weight:700; }

.msn-modal-body input,
.msn-modal-body textarea,
.msn-modal-body select{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#fff;
  font-size:14px;
}

.msn-modal-body textarea{ min-height:92px; resize:vertical; }

.msn-modal-foot{
  display:flex;
  justify-content:flex-end;
  gap:10px;
  padding:14px 16px;
  border-top:1px solid var(--border);
  background:rgba(0,0,0,.01);
}


/* =========================================================
   FIXES + BEAUTIFUL UPGRADES
   ========================================================= */

/* Back button (Group → Groups list) */
.msn-group-back{
  display:inline-flex;
  align-items:center;
  gap:10px;
  margin:6px 0 12px;
  padding:10px 12px;
  border-radius:999px;
  background:var(--card);
  border:1px solid var(--border);
  box-shadow:var(--shadow);
  font-weight:800;
  text-decoration:none;
  color:var(--text);
}
.msn-group-back:hover{ filter:brightness(1.02); }

/* Make group action buttons full width on mobile */
@media (max-width: 720px){
  .msn-group-actions{ width:100%; }
  .msn-group-actions .msn-btn{ width:100%; }
}

/* Composer: make Post button full width (nice on mobile + desktop) */
.msn-group-compose-actions .msn-btn{ width:100%; }

/* Group chat input beautify EVEN if messaging template uses default IDs */
.msn-group-chat-card #msn-chat-form{
  background:var(--card);
  border-top:1px solid rgba(0,0,0,.10);
  border-radius:0 0 18px 18px;
  overflow:hidden;
}

.msn-group-chat-card #msn-chat-form .msn-chat-form-inner{
  display:flex;
  gap:10px;
  align-items:flex-end;
  padding:12px;
}

.msn-group-chat-card #msn-attach-btn{
  width:44px;
  height:44px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,.12);
  background:var(--soft);
  font-size:22px;
  line-height:1;
}

.msn-group-chat-card #msn-message-text{
  flex:1;
  border-radius:999px;
  border:1px solid rgba(0,0,0,.12);
  padding:12px 14px;
  font-size:16px;
  outline:none;
  min-height:44px;
  max-height:140px;
  background:#fff;
}

.msn-group-chat-card #msn-message-text:focus{
  border-color:#1877f2;
  box-shadow:0 0 0 4px rgba(24,119,242,.10);
}

.msn-group-chat-card #msn-send-btn{
  height:44px;
  border-radius:999px;
  border:0;
  background:#1877f2;
  color:#fff;
  font-weight:900;
  padding:0 18px;
  box-shadow:0 10px 20px rgba(24,119,242,.18);
}

/* If very small screen, stack send button */
@media (max-width: 380px){
  .msn-group-chat-card #msn-chat-form .msn-chat-form-inner{ flex-wrap:wrap; }
  .msn-group-chat-card #msn-send-btn{ width:100%; }
}

/* When dots/menu hides the form, show a "Message" open button */
.msn-chat-openbar{
  padding:10px 12px;
  border-top:1px dashed rgba(0,0,0,.10);
  background:rgba(0,0,0,.01);
}
.msn-chat-openbar .msn-btn{ width:100%; border-radius:16px; padding:14px 16px; }
