@import url('https://fonts.googleapis.com/css2?family=Amiri+Quran&display=swap');

/* =====================================================================
   Nouran — /rooms : thème « WhatsApp Web » sombre
   Couche purement visuelle : chargée APRÈS les styles inline de la page,
   tout est scopé sous body.wa pour ne rien toucher ailleurs.
   Le DOM additionnel (#waSideHeader, #waSearchWrap, #waEmpty, …) vient
   de /js/rooms-wa.js.
   ===================================================================== */

body.wa {
  --wa-deep: #0b141a;
  --wa-panel: #111b21;
  --wa-header: #202c33;
  --wa-out: #005c4b;
  --wa-in: #202c33;
  --wa-accent: #00a884;
  --wa-accent-soft: #0a332c;
  --wa-text: #e9edef;
  --wa-text-2: #d1d7db;
  --wa-muted: #8696a0;
  --wa-icon: #aebac1;
  --wa-border: #222d34;
  --wa-hover: #202c33;
  --wa-active: #2a3942;
  --wa-input: #2a3942;
  --wa-system: #182229;
  --wa-danger: #f15c6d;

  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--wa-deep) !important;
  color: var(--wa-text) !important;
  font-family: 'Segoe UI', 'Helvetica Neue', Tahoma, Cairo, Arial, sans-serif !important;
}

body.wa ::-webkit-scrollbar { width: 6px; height: 6px; }
body.wa ::-webkit-scrollbar-thumb { background: rgba(134, 150, 160, 0.3); border-radius: 3px; }
body.wa ::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- Layout */
body.wa .layout {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--wa-deep);
}

body.wa .sidebar {
  width: 30%;
  min-width: 320px;
  max-width: 460px;
  flex-shrink: 0;
  background: var(--wa-panel) !important;
  border-left: 1px solid var(--wa-border) !important;
  color: var(--wa-text);
  overflow: hidden;
}

body.wa .content {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: var(--wa-deep);
}

/* ------------------------------------------------------ Sidebar : header */
body.wa .room-brand-header { display: none !important; }

#waSideHeader {
  height: 59px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--wa-header);
  position: relative;
}
#waSideHeader .wa-me-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #00a884, #005c4b);
  color: #fff; font-weight: 700; font-size: 17px;
}
#waSideHeader .wa-me-text { flex: 1; min-width: 0; line-height: 1.25; }
#waSideHeader .wa-me-name {
  font-size: 15px; font-weight: 600; color: var(--wa-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#waSideHeader .wa-me-status { font-size: 12px; color: var(--wa-muted); display: flex; align-items: center; gap: 5px; }
#waSideHeader .wa-me-status a { color: var(--wa-muted); text-decoration: none; }
#waSideHeader .wa-me-status a:hover { color: var(--wa-accent); }

.wa-icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; cursor: pointer;
  color: var(--wa-icon);
  transition: background 0.15s ease;
}
.wa-icon-btn:hover, .wa-icon-btn.is-open { background: rgba(255, 255, 255, 0.08); }
.wa-icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

.wa-menu {
  position: absolute;
  top: 52px;
  left: 12px;
  z-index: 2100;
  min-width: 230px;
  padding: 8px 0;
  border-radius: 6px;
  background: #233138;
  box-shadow: 0 6px 24px rgba(11, 20, 26, 0.6);
  display: none;
}
.wa-menu.open { display: block; }
.wa-menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 11px 22px;
  background: none; border: none; cursor: pointer;
  color: var(--wa-text-2);
  font: inherit; font-size: 14.5px;
  text-align: right;
}
.wa-menu button:hover { background: var(--wa-deep); }
.wa-menu hr { border: none; border-top: 1px solid var(--wa-border); margin: 6px 0; }

/* Existing tabs (المتواجدون / الأعضاء / الصالونات / الأصدقاء) kept, slimmed down */
body.wa .side-header {
  background: var(--wa-panel) !important;
  border-bottom: 1px solid var(--wa-border) !important;
  padding: 6px 10px 8px !important;
  gap: 6px !important;
}
body.wa .tab-btn,
body.wa #tabUsersInRoomBtn,
body.wa #tabPermanentMembersBtn {
  background: var(--wa-header) !important;
  color: var(--wa-muted) !important;
  border: none !important;
  border-radius: 16px !important;
  padding: 6px 4px !important;
  font-size: 11.5px !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}
body.wa .tab-btn:hover { color: var(--wa-text) !important; }
body.wa .tab-btn.active,
body.wa #tabUsersInRoomBtn.active,
body.wa #tabPermanentMembersBtn.active {
  background: var(--wa-accent-soft) !important;
  color: var(--wa-accent) !important;
}
body.wa #privateToggle {
  background: transparent !important;
  border: 1px dashed #2f3b43 !important;
  color: var(--wa-muted) !important;
  border-radius: 16px !important;
}

/* ------------------------------------------- Sidebar : search + filters */
#waSearchWrap {
  flex-shrink: 0;
  padding: 7px 12px 6px;
  background: var(--wa-panel);
  border-bottom: 1px solid var(--wa-border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.wa-search {
  display: flex; align-items: center; gap: 10px;
  height: 35px;
  padding: 0 12px;
  border-radius: 8px;
  background: var(--wa-header);
}
.wa-search svg { width: 18px; height: 18px; fill: var(--wa-muted); flex-shrink: 0; }
.wa-search input {
  flex: 1; min-width: 0;
  background: transparent; border: none; outline: none;
  color: var(--wa-text);
  font: inherit; font-size: 14px;
}
.wa-search input::placeholder { color: var(--wa-muted); }
.wa-search .wa-clear { display: none; background: none; border: none; color: var(--wa-muted); cursor: pointer; font-size: 16px; padding: 0; }
.wa-search.has-value .wa-clear { display: block; }

.wa-pills {
  display: flex; gap: 8px;
  padding: 9px 2px 3px;
  overflow-x: auto;
  scrollbar-width: none;
}
.wa-pills::-webkit-scrollbar { display: none; }
.wa-pill {
  flex-shrink: 0;
  padding: 6px 13px;
  border-radius: 16px;
  border: none;
  background: var(--wa-header);
  color: var(--wa-muted);
  font: inherit; font-size: 13.5px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.wa-pill:hover { background: var(--wa-active); color: var(--wa-text); }
.wa-pill.active { background: var(--wa-accent-soft); color: var(--wa-accent); }

/* Owner bar & old community nav: kept in the DOM (IDs/handlers intact) but
   their actions now live in the header menu and the pills above. */
body.wa #ownerAddRoomBar,
body.wa #communityFilterNav { display: none !important; }

/* --------------------------------------------------------- Sidebar : list */
body.wa #roomsContainer,
body.wa #roomUsersContainer,
body.wa #permanentMembersContainer,
body.wa #contactsContainer { background: var(--wa-panel) !important; }

body.wa #rooms { padding-bottom: 12px; }

body.wa .community-group {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
}
body.wa .community-group-header {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 14px 18px 6px !important;
  margin: 0 !important;
  cursor: default;
  pointer-events: none;
}
body.wa .community-group-header .comm-title-wrap,
body.wa .community-group-header .comm-title-wrap span {
  color: var(--wa-accent) !important;
  font-size: 12.5px !important;
  font-weight: 600 !important;
  background: none !important;
}
body.wa .community-group-header .comm-icon { display: none !important; }
body.wa .community-group-header .comm-count-chip {
  background: none !important;
  border: none !important;
  color: var(--wa-muted) !important;
  font-size: 11.5px !important;
  box-shadow: none !important;
}
body.wa .community-group-header .comm-arrow { display: none !important; }
/* Flat WhatsApp list: groups always expanded */
body.wa .community-group.collapsed .community-group-body,
body.wa .community-group-body {
  display: block !important;
  max-height: none !important;
  opacity: 1 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
}
body.wa .community-group.wa-empty-group { display: none !important; }

body.wa .room,
body.wa .room.owner-private {
  position: relative;
  display: flex !important;
  align-items: center;
  gap: 0;
  height: 72px;
  margin: 0 !important;
  padding: 0 13px 0 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
  cursor: pointer;
}
body.wa .room:hover { background: var(--wa-hover) !important; }
body.wa .room.active { background: var(--wa-active) !important; }
body.wa .room.wa-hidden { display: none !important; }

body.wa .room-item-left {
  flex: 1;
  min-width: 0;
  height: 100%;
  gap: 13px !important;
}
body.wa .room .icon,
body.wa .room.active .icon,
body.wa .room.owner-private .icon,
body.wa .room.owner-private.active .icon {
  width: 49px !important; height: 49px !important;
  border-radius: 50% !important;
  background: var(--wa-active) !important;
  border: none !important;
  box-shadow: none !important;
  transform: none !important;
  color: var(--wa-text) !important;
  font-size: 22px !important;
}
body.wa .room.owner-private .icon { box-shadow: inset 0 0 0 2px rgba(241, 92, 109, 0.55) !important; }

body.wa .room-name-wrap {
  flex: 1;
  min-width: 0;
  height: 100%;
  justify-content: center;
  gap: 3px !important;
  border-bottom: 1px solid var(--wa-border);
  padding-left: 8px;
}
body.wa .room:last-child .room-name-wrap { border-bottom-color: transparent; }
body.wa .room-name-text,
body.wa .room.active .room-name-text,
body.wa .room.owner-private .room-name-text {
  color: var(--wa-text) !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.wa .room-name-text span { color: inherit !important; font-weight: inherit !important; }
body.wa .room.owner-private .room-name-text { color: #ffb4bd !important; }
body.wa .room-tag-mini,
body.wa .room-tag-mini span {
  color: var(--wa-muted) !important;
  font-size: 13.5px !important;
  font-weight: 400 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.wa .room.wa-has-preview .room-tag-mini { display: none !important; }
body.wa .room-side-emoticon { display: none !important; }

.wa-preview {
  display: flex; align-items: center; gap: 5px;
  min-width: 0;
  color: var(--wa-muted);
  font-size: 13.5px;
}
.wa-preview .wa-preview-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wa-preview:empty { display: none; }
.wa-live {
  flex-shrink: 0;
  color: var(--wa-accent);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.wa-live.wa-voice { color: #53bdeb; }

.wa-row-meta {
  position: absolute;
  left: 15px;
  top: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}
.wa-row-time { font-size: 12px; color: var(--wa-muted); min-height: 15px; }
.room.wa-unread .wa-row-time { color: var(--wa-accent); }
.wa-badge {
  min-width: 20px; height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--wa-accent);
  color: var(--wa-panel);
  font-size: 12px; font-weight: 700;
  display: none; align-items: center; justify-content: center;
}
.room.wa-unread .wa-badge { display: inline-flex; }
body.wa .room .room-name-wrap { padding-left: 64px; }
.room.wa-unread .room-name-text { font-weight: 600 !important; }

.wa-no-results {
  padding: 32px 20px;
  text-align: center;
  color: var(--wa-muted);
  font-size: 14px;
}

/* Other sidebar sections (users / permanent members / friends) */
body.wa #roomUsersContainer > div:first-child,
body.wa #permanentMembersContainer > div:first-child,
body.wa #contactsContainer > div:first-child {
  background: var(--wa-header) !important;
  border-bottom: 1px solid var(--wa-border) !important;
  box-shadow: none !important;
}
body.wa #roomUsersContainer > div:first-child > span:first-child,
body.wa #permanentMembersContainer > div:first-child > span:first-child,
body.wa #contactsContainer > div:first-child > span:first-child { color: var(--wa-text) !important; }
body.wa #roomUsersContainer > div:last-child,
body.wa #permanentMembersContainer > div:last-child {
  background: var(--wa-panel) !important;
  border-top: 1px solid var(--wa-border) !important;
}
body.wa #roomUsersContainer > div:last-child button {
  background: var(--wa-header) !important;
  color: var(--wa-text) !important;
  border: none !important;
}
body.wa .side-users,
body.wa #permanentMembersList,
body.wa #friendsList { color: var(--wa-text-2); }

/* ------------------------------------------------------- Empty state */
#waEmpty {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  text-align: center;
  background: #222e35;
  border-bottom: 6px solid var(--wa-accent);
}
body.wa.wa-no-room #waEmpty { display: flex; }
#waEmpty .wa-empty-logo {
  width: 108px; height: 108px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--wa-panel);
  box-shadow: 0 0 0 10px rgba(0, 168, 132, 0.08), 0 0 0 22px rgba(0, 168, 132, 0.04);
  margin-bottom: 18px;
}
#waEmpty h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 300;
  color: var(--wa-text-2);
}
#waEmpty p {
  margin: 0;
  max-width: 470px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--wa-muted);
}
#waEmpty .wa-empty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.wa-btn {
  padding: 10px 22px;
  border-radius: 24px;
  border: none;
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.wa-btn-primary { background: var(--wa-accent); color: var(--wa-panel); }
.wa-btn-primary:hover { background: #06cf9c; }
.wa-btn-ghost { background: transparent; color: var(--wa-accent); box-shadow: inset 0 0 0 1px #2f3b43; }
.wa-btn-ghost:hover { background: rgba(0, 168, 132, 0.08); }
#waEmpty .wa-empty-foot {
  position: absolute;
  bottom: 34px;
  font-size: 13px;
  color: #667781;
}

/* ------------------------------------------------------- Chat header */
body.wa .header {
  min-height: 59px;
  flex-shrink: 0;
  padding: 0 16px !important;
  background: var(--wa-header) !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--wa-text);
  gap: 10px;
}
body.wa .header > div:first-child { min-width: 0; flex: 1; gap: 12px !important; }
body.wa .title { min-width: 0; flex: 1; color: var(--wa-text) !important; font-size: 16px !important; font-weight: 500 !important; }
/* Header card built by applyRoomAppearance() → WhatsApp avatar + name + status */
body.wa .room-title-card,
body.wa .room-title-card.owner-private-header {
  display: flex !important;
  align-items: center !important;
  gap: 13px !important;
  min-width: 0;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}
body.wa .room-title-icon-badge {
  width: 40px !important; height: 40px !important;
  min-width: 40px;
  border-radius: 50% !important;
  background: var(--wa-active) !important;
  border: none !important;
  box-shadow: none !important;
  color: var(--wa-text) !important;
  font-size: 20px !important;
  display: flex !important; align-items: center; justify-content: center;
  cursor: pointer;
}
body.wa .room-title-meta { min-width: 0; display: flex; flex-direction: column; gap: 1px; line-height: 1.3; }
body.wa .room-title-main { display: flex; align-items: center; gap: 6px; min-width: 0; }
body.wa .room-title-text,
body.wa .room-title-text span {
  color: var(--wa-text) !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.wa .owner-private-header .room-title-text { color: #ffb4bd !important; }
body.wa .room-emoticon-tag,
body.wa .room-comm-tag-header,
body.wa .room-title-card .room-subtitle { display: none !important; }
.wa-room-sub {
  font-size: 13px;
  color: var(--wa-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  cursor: pointer;
}
.wa-room-sub:empty { display: none; }
.wa-room-sub .wa-online-dot { color: var(--wa-accent); }
#waBackBtn { display: none; }

body.wa #users { display: none !important; } /* names now shown in .wa-room-sub */

body.wa .header > div:nth-child(2) { gap: 4px !important; flex-shrink: 0; }
body.wa #headerAddMemberBtn,
body.wa #headerOwnerDashboardBtn,
body.wa .header a[href="/admin/users"] {
  background: transparent !important;
  color: var(--wa-icon) !important;
  border: 1px solid #2f3b43 !important;
  border-radius: 18px !important;
  box-shadow: none !important;
  padding: 5px 11px !important;
  font-size: 12px !important;
  font-weight: 500 !important;
}
body.wa #headerAddMemberBtn:hover,
body.wa #headerOwnerDashboardBtn:hover,
body.wa .header a[href="/admin/users"]:hover { background: rgba(255, 255, 255, 0.06) !important; color: var(--wa-text) !important; }
body.wa .menu-btn {
  width: 40px; height: 40px;
  border-radius: 50% !important;
  background: transparent !important;
  border: none !important;
  color: var(--wa-icon) !important;
  font-size: 22px;
  padding: 0 !important;
  margin: 0 !important;
}
body.wa .menu-btn:hover { background: rgba(255, 255, 255, 0.08) !important; }
body.wa .menu-panel {
  background: #233138 !important;
  border: none !important;
  border-radius: 6px !important;
  box-shadow: 0 6px 24px rgba(11, 20, 26, 0.6) !important;
  color: var(--wa-text-2) !important;
}
body.wa .menu-panel * { color: var(--wa-text-2) !important; }
body.wa .menu-panel button,
body.wa .menu-panel a,
body.wa .menu-panel > div {
  background: transparent !important;
  border-color: transparent !important;
}
body.wa .menu-panel button:hover,
body.wa .menu-panel > div:hover { background: var(--wa-deep) !important; }

/* In-room message search */
#waMsgSearch {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  background: var(--wa-panel);
  border-bottom: 1px solid var(--wa-border);
}
#waMsgSearch.open { display: flex; }
#waMsgSearch .wa-search { flex: 1; }
#waMsgSearchCount { font-size: 12.5px; color: var(--wa-muted); white-space: nowrap; }

/* Live voice bar → slim WhatsApp-style call strip */
body.wa .live-bar {
  background: var(--wa-panel) !important;
  border: none !important;
  border-bottom: 1px solid var(--wa-border) !important;
  box-shadow: none !important;
  color: var(--wa-text-2) !important;
  padding: 6px 16px !important;
  margin: 0 !important;
  border-radius: 0 !important;
}
body.wa .live-badge {
  background: var(--wa-accent-soft) !important;
  color: var(--wa-accent) !important;
  border: none !important;
  box-shadow: none !important;
}
body.wa .live-status-text { color: var(--wa-muted) !important; }
body.wa .live-bar { display: flex !important; align-items: center !important; gap: 10px !important; }
body.wa .live-bar-info { min-width: 0; flex: 1; display: flex !important; align-items: center !important; gap: 8px !important; }
body.wa .live-status-text { font-size: 12.5px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body.wa .live-bar-actions { display: flex !important; flex-wrap: nowrap !important; gap: 6px !important; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; max-width: 62%; }
body.wa .live-bar-actions::-webkit-scrollbar { display: none; }
body.wa .live-bar-actions > * { white-space: nowrap !important; flex-shrink: 0; font-size: 12.5px !important; padding: 6px 12px !important; line-height: 1.2 !important; }
body.wa .live-mic-btn {
  background: var(--wa-accent) !important;
  color: var(--wa-panel) !important;
  border: none !important;
  border-radius: 18px !important;
  box-shadow: none !important;
  font-weight: 600 !important;
}
body.wa .sound-btn {
  background: var(--wa-header) !important;
  color: var(--wa-text-2) !important;
  border: none !important;
  border-radius: 18px !important;
  box-shadow: none !important;
}
body.wa #leaveVoiceBtn { background: #a32b39 !important; color: #fff !important; }

body.wa #roomDescBanner {
  background: var(--wa-system) !important;
  border: none !important;
  border-bottom: 1px solid var(--wa-border) !important;
  color: var(--wa-text-2) !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
}
body.wa #roomDescBanner .desc-label { color: #ffd279 !important; }
body.wa #roomDescBanner .desc-text { color: var(--wa-text-2) !important; }
body.wa #roomDescBanner .desc-toggle,
body.wa #roomDescBanner .desc-close { color: var(--wa-accent) !important; background: transparent !important; border: none !important; }
body.wa #roomDescTimerBadge { background: var(--wa-header) !important; color: #ffd279 !important; border: none !important; }

/* ------------------------------------------------------------ Messages */
body.wa .messages {
  padding: 18px 7% 10px !important;
  background-color: var(--wa-deep) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cg fill='none' stroke='%2300a884' stroke-opacity='0.055' stroke-width='1'%3E%3Crect x='28' y='28' width='40' height='40'/%3E%3Crect x='28' y='28' width='40' height='40' transform='rotate(45 48 48)'/%3E%3Ccircle cx='48' cy='48' r='9'/%3E%3Cpath d='M0 0l14 14M96 0L82 14M0 96l14-14M96 96L82 82'/%3E%3C/g%3E%3C/svg%3E") !important;
  background-size: 96px 96px !important;
  gap: 2px;
}

.wa-day-chip {
  align-self: center;
  margin: 8px 0 12px;
  padding: 5px 12px;
  border-radius: 7.5px;
  background: var(--wa-system);
  color: var(--wa-muted);
  font-size: 12.5px;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
}

body.wa .bubble {
  position: relative;
  display: block;
  max-width: 65% !important;
  margin: 0 0 2px !important;
  padding: 6px 9px 8px 9px !important;
  border: none !important;
  border-radius: 7.5px !important;
  box-shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13) !important;
  color: var(--wa-text) !important;
  font-size: 14.2px;
  line-height: 1.45;
}
body.wa .bubble.wa-first { margin-top: 10px !important; }

/* RTL: incoming on the right (start), outgoing on the left (end) — like WhatsApp in Arabic */
body.wa .bubble.other {
  align-self: flex-start;
  background: var(--wa-in) !important;
  margin-left: 0 !important;
}
body.wa .bubble.me {
  align-self: flex-end;
  background: var(--wa-out) !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
body.wa .bubble.other.wa-first { border-top-right-radius: 0 !important; }
body.wa .bubble.me.wa-first { border-top-left-radius: 0 !important; }
body.wa .bubble.wa-first::before {
  content: '';
  position: absolute;
  top: 0;
  width: 8px;
  height: 13px;
}
body.wa .bubble.other.wa-first::before {
  right: -8px;
  background: var(--wa-in);
  clip-path: polygon(0 0, 100% 0, 0 100%);
}
body.wa .bubble.me.wa-first::before {
  left: -8px;
  background: var(--wa-out);
  clip-path: polygon(0 0, 100% 0, 100% 100%);
}

/* Sender line (incoming only) */
.wa-sender {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 2px;
  font-size: 12.8px;
  font-weight: 500;
}
body.wa .bubble .name { font-weight: 500 !important; font-size: 12.8px; cursor: pointer; }
body.wa .bubble.me .wa-sender,
body.wa .bubble.wa-cont .wa-sender { display: none !important; }
body.wa .bubble .badge {
  font-size: 10.5px !important;
  padding: 0 6px !important;
  border-radius: 8px !important;
  background: rgba(255, 255, 255, 0.07) !important;
  color: #ffd279 !important;
  border: none !important;
}
body.wa .bubble .mod-icon { font-size: 11px; }

.wa-body { white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
body.wa .bubble a { color: #53bdeb; }
body.wa .bubble img { border-radius: 6px; max-width: 100%; }
body.wa .bubble audio { max-width: 260px; height: 40px; filter: invert(0.88) hue-rotate(180deg); }

.wa-meta {
  float: left;
  position: relative;
  top: 7px;
  margin: 0 10px 0 -2px;
  font-size: 11px;
  line-height: 15px;
  color: rgba(233, 237, 239, 0.6);
  white-space: nowrap;
  user-select: none;
}
.bubble.me .wa-meta { color: rgba(233, 237, 239, 0.6); }
.wa-ticks { margin-right: 3px; color: #8696a0; letter-spacing: -3px; font-size: 12px; }
.bubble.me .wa-ticks { color: #8fd3c3; }
.wa-meta-block { display: block; float: none; text-align: left; top: 0; margin: 2px 0 0; }

/* System messages: centered chips */
body.wa .bubble.wa-system {
  align-self: center;
  max-width: 85% !important;
  margin: 8px 0 !important;
  padding: 5px 12px !important;
  background: var(--wa-system) !important;
  color: var(--wa-muted) !important;
  font-size: 12.5px;
  text-align: center;
  border-radius: 7.5px !important;
}
body.wa .bubble.wa-system::before { display: none; }
body.wa .bubble.wa-system .wa-sender,
body.wa .bubble.wa-system .wa-meta { display: none !important; }
body.wa .bubble.wa-system button { color: var(--wa-accent) !important; }

/* Stickers / animated emoji / gifts */
body.wa .real-sticker-msg,
body.wa .real-dynamic-emoji-msg { margin: 8px 0 !important; }
body.wa .real-sticker-msg.me,
body.wa .real-dynamic-emoji-msg.me { align-self: flex-end; }
body.wa .real-sticker-msg.other,
body.wa .real-dynamic-emoji-msg.other { align-self: flex-start; }
body.wa .gift-celebration-bubble { align-self: center; max-width: 80% !important; }
body.wa .gift-celebration-bubble::before { display: none; }

/* In-room search */
body.wa .messages.wa-searching > *:not(.wa-match):not(.wa-day-chip) { opacity: 0.25; }
body.wa .wa-match { box-shadow: 0 0 0 2px var(--wa-accent) !important; }

body.wa #noti { color: var(--wa-danger) !important; background: var(--wa-deep); font-size: 12.5px; padding: 0 16px 4px !important; }
body.wa #noti:empty { display: none; }
body.wa #voicePanel { background: var(--wa-panel); color: var(--wa-text-2); }
body.wa #voicePanel * { color: var(--wa-text-2) !important; }

/* ------------------------------------------------------------ Composer */
body.wa .input {
  flex-shrink: 0;
  min-height: 62px;
  gap: 6px !important;
  padding: 5px 12px !important;
  border: none !important;
  background: var(--wa-header) !important;
}
body.wa .input input#inp {
  order: 5;
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 9px 12px !important;
  border: none !important;
  border-radius: 8px !important;
  outline: none;
  background: var(--wa-input) !important;
  color: var(--wa-text) !important;
  font-size: 15px !important;
}
body.wa .input input#inp::placeholder { color: var(--wa-muted); }
body.wa .input .btn,
body.wa .input #stickersBtn,
body.wa .input #giftBtn {
  flex-shrink: 0;
  height: 40px;
  min-width: 40px;
  padding: 0 8px !important;
  border: none !important;
  border-radius: 20px !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--wa-icon) !important;
  font-size: 20px;
  font-weight: 500 !important;
  display: inline-flex; align-items: center; justify-content: center;
}
body.wa .input .btn:hover { background: rgba(255, 255, 255, 0.07) !important; }
body.wa .input #emojiBtn { order: 1; }
body.wa .input #attachBtn { order: 2; }
body.wa .input #stickersBtn { order: 3; }
body.wa .input #giftBtn { order: 4; }
body.wa .input #bottomMicBtn { order: 6; font-size: 12.5px !important; background: rgba(0, 168, 132, 0.12) !important; color: var(--wa-accent) !important; padding: 0 12px !important; }
body.wa .input #micBtn { order: 7; font-size: 12.5px !important; padding: 0 12px !important; }
body.wa .input #sendBtn {
  order: 8;
  width: 42px; height: 42px; min-width: 42px;
  padding: 0 !important;
  border-radius: 50% !important;
  background: var(--wa-accent) !important;
  color: var(--wa-panel) !important;
  font-size: 0 !important;
}
body.wa .input #sendBtn::before {
  content: '';
  width: 20px; height: 20px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M1.1 21.8 23 12 1.1 2.2 1 9.8l15.6 2.2L1 14.2z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M1.1 21.8 23 12 1.1 2.2 1 9.8l15.6 2.2L1 14.2z'/%3E%3C/svg%3E") center / contain no-repeat;
  transform: scaleX(-1); /* point toward the start of the line in RTL */
}
body.wa .input #sendBtn:hover { background: #06cf9c !important; }
body.wa .input #waQuranBtn { order: 2; }
body.wa .input #waQuranBtn.is-open { background: rgba(0, 168, 132, 0.15) !important; color: var(--wa-accent) !important; }
body.wa .emoji-panel,
body.wa .gift-drawer { order: 9; }

/* 📖 Quran insert panel */
#waQuranPanel {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 12px;
  z-index: 60;
  width: min(380px, calc(100vw - 24px));
  padding: 14px;
  border-radius: 10px;
  background: #233138;
  box-shadow: 0 8px 28px rgba(11, 20, 26, 0.65);
  display: none;
  flex-direction: column;
  gap: 9px;
}
#waQuranPanel.open { display: flex; }
#waQuranPanel .wa-q-title { font-size: 14px; font-weight: 600; color: var(--wa-text); }
#waQuranPanel .wa-search { background: var(--wa-input); }
#waQuranPanel .wa-search input { text-align: center; letter-spacing: 1px; font-size: 15px; }
#waQuranPanel .wa-q-hint { font-size: 12.5px; color: var(--wa-muted); min-height: 16px; }
#waQuranPanel .wa-q-hint.is-error { color: var(--wa-danger); }
#waQuranPanel .wa-q-preview {
  max-height: 180px;
  overflow-y: auto;
  font-family: 'Amiri Quran', 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif;
  font-size: 21px;
  line-height: 2.1;
  color: #f3e5ab;
  text-align: center;
}
#waQuranPanel .wa-q-preview:empty { display: none; }
#waQuranPanel .wa-q-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
#waQuranPanel .wa-btn { padding: 7px 14px; font-size: 13px; }
#waQuranPanel .wa-btn[disabled] { opacity: 0.4; cursor: not-allowed; }

/* Verse bubble */
body.wa .bubble.wa-verse-bubble { max-width: min(560px, 80%) !important; }
.wa-verse {
  margin: 4px 0 2px;
  padding: 10px 14px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  border-right: 3px solid #d4af37;
}
.wa-verse-text {
  font-family: 'Amiri Quran', 'KFGQPC Uthmanic Script HAFS', 'Amiri', serif;
  font-size: 22px;
  line-height: 2.15;
  color: #f3e5ab;
  text-align: center;
  white-space: normal;
}
.wa-verse-ref, .wa-ref-link {
  color: #53bdeb !important;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
}
.wa-verse-ref { display: block; margin-top: 4px; text-align: left; }
.wa-verse-ref:hover, .wa-ref-link:hover { text-decoration: underline; }

/* Modals: recolored by rooms-wa.js; form controls need explicit rules */
body.wa .wa-dark-modal input,
body.wa .wa-dark-modal textarea,
body.wa .wa-dark-modal select {
  background-color: var(--wa-input) !important;
  color: var(--wa-text) !important;
  border-color: #2f3b43 !important;
}
body.wa .wa-dark-modal input::placeholder,
body.wa .wa-dark-modal textarea::placeholder { color: var(--wa-muted) !important; }
body.wa .wa-dark-modal option { background: var(--wa-header); color: var(--wa-text); }
body.wa .wa-dark-modal hr { border-color: var(--wa-border) !important; }
body.wa .wa-dark-modal a { color: #53bdeb; }

/* ------------------------------------------------------------- Mobile */
@media (max-width: 768px) {
  body.wa .sidebar { width: 100%; max-width: none; min-width: 0; border-left: none !important; }
  body.wa .content { display: none !important; }
  body.wa.wa-chat-open .sidebar { display: none !important; }
  body.wa.wa-chat-open .content { display: flex !important; width: 100%; }
  body.wa.wa-no-room.wa-chat-open .sidebar { display: flex !important; }
  body.wa.wa-no-room.wa-chat-open .content { display: none !important; }

  #waBackBtn { display: inline-flex; margin-left: -6px; }
  body.wa .header { padding: 0 8px !important; }
  body.wa #headerAddMemberBtn span:last-child,
  body.wa .header a[href="/admin/users"] span:last-child { display: none; }
  body.wa #headerAddMemberBtn,
  body.wa #headerOwnerDashboardBtn,
  body.wa .header a[href="/admin/users"] { padding: 5px 8px !important; }
  body.wa .messages { padding: 12px 10px 8px !important; }
  body.wa .bubble { max-width: 85% !important; }
  body.wa .live-status-text { display: none !important; }
  body.wa .input { padding: 5px 6px !important; gap: 2px !important; }
  body.wa .input .btn { min-width: 36px; height: 38px; font-size: 18px; padding: 0 6px !important; }
  body.wa .input #bottomMicBtn { display: none !important; } /* same action as the live-bar mic */
  body.wa .input input#inp { min-width: 90px; }
  body.wa .input #stickersBtn,
  body.wa .input #micBtn.wa-idle { font-size: 0 !important; width: 36px; padding: 0 !important; }
  body.wa .input #stickersBtn::before { content: '🏷️'; font-size: 18px; }
  body.wa .input #micBtn.wa-idle::before { content: '🎤'; font-size: 18px; }
  /* admin shortcuts stay reachable from the sidebar ⋮ menu */
  body.wa #headerAddMemberBtn,
  body.wa #headerOwnerDashboardBtn,
  body.wa .header a[href="/admin/users"] { display: none !important; }
  body.wa .live-badge { white-space: nowrap !important; }
  #waEmpty h1 { font-size: 22px; }
}
