/* diwaniya-ux.css — X-grade polish for DMs, compose modal, rooms (Wave 114) */

/* ── Message bubbles (JS uses .dm-msg / .me / .other) ── */
.dm-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 78%;
  animation: dmMsgIn .18s ease;
}
@keyframes dmMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.dm-msg.me    { align-self: flex-end;  align-items: flex-end; }
.dm-msg.other { align-self: flex-start; align-items: flex-start; }
.dm-msg-body {
  padding: 11px 15px;
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.dm-msg.me .dm-msg-body {
  background: var(--white);
  color: var(--black);
  border-radius: 18px 18px 4px 18px;
}
.dm-msg.other .dm-msg-body {
  background: var(--slate);
  color: var(--white);
  border-radius: 18px 18px 18px 4px;
}
body.light .dm-msg.other .dm-msg-body { background: #e7e7e7; color: #0a0a0a; }
.dm-msg-time {
  font-size: 11px;
  color: var(--mute);
  font-family: var(--font-en, Inter, system-ui, sans-serif);
  padding: 0 6px;
  letter-spacing: .01em;
}

/* ── DM modal: X-like shell ── */
.dm-overlay {
  padding: 0 !important;
  background: rgba(0,0,0,.55) !important;
  backdrop-filter: blur(12px) !important;
  -webkit-backdrop-filter: blur(12px);
}
.dm-modal {
  max-width: 920px !important;
  height: min(720px, 92vh) !important;
  border-radius: 16px !important;
  border: 1px solid var(--line) !important;
  background: var(--ink, #000) !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,.04), 0 32px 100px rgba(0,0,0,.7) !important;
  animation: dmSlide .22s cubic-bezier(.2,.8,.2,1) !important;
}
@keyframes dmSlide {
  from { opacity: 0; transform: translateY(12px) scale(.985); }
  to   { opacity: 1; transform: none; }
}
.dm-panel-list {
  width: 38% !important;
  background: var(--ink, #000);
  border-left: 1px solid var(--line) !important;
}
body[dir="ltr"] .dm-panel-list {
  border-left: none !important;
  border-right: 1px solid var(--line) !important;
}
.dm-panel-head {
  padding: 14px 16px !important;
  min-height: 56px;
  gap: 8px !important;
}
.dm-panel-head > span:first-child,
.dm-head-title {
  font-size: 18px !important;
  font-weight: 800 !important;
  letter-spacing: -.02em;
}
.dm-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-inline-start: auto;
}
.dm-icon-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--soft);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.dm-icon-btn:hover { background: var(--char); color: var(--white); }
.dm-icon-btn svg { width: 18px; height: 18px; }

/* Search */
.dm-search-wrap {
  padding: 8px 12px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.dm-search {
  width: 100%;
  box-sizing: border-box;
  background: var(--char);
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 14px 10px 40px;
  color: var(--white);
  font-size: 14px;
  font-family: var(--font-ar, Tajawal, sans-serif);
  outline: none;
  transition: border-color .15s, background .15s;
}
body[dir="ltr"] .dm-search { padding: 10px 40px 10px 14px; }
.dm-search:focus {
  border-color: var(--line);
  background: var(--ink, #000);
}
.dm-search::placeholder { color: var(--mute); }
.dm-search-box {
  position: relative;
}
.dm-search-box svg {
  position: absolute;
  top: 50%;
  inset-inline-start: 14px;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--mute);
  pointer-events: none;
}

/* Conversation rows */
.dm-conv-item {
  padding: 12px 16px !important;
  border-bottom: none !important;
  border-radius: 0;
  gap: 12px !important;
}
.dm-conv-item:hover { background: rgba(255,255,255,.04) !important; }
.dm-conv-item.active {
  background: rgba(255,255,255,.08) !important;
  box-shadow: inset 3px 0 0 var(--white);
}
body[dir="ltr"] .dm-conv-item.active { box-shadow: inset -3px 0 0 var(--white); }
.dm-conv-ava {
  width: 48px !important;
  height: 48px !important;
  font-size: 16px !important;
}
.dm-conv-name { font-size: 15px !important; font-weight: 700 !important; }
.dm-conv-preview { font-size: 13px !important; margin-top: 3px !important; }
.dm-conv-item.has-unread .dm-conv-name { font-weight: 800 !important; }
.dm-conv-item.has-unread .dm-conv-preview { color: var(--white) !important; font-weight: 500; }

/* Chat header with avatar */
.dm-chat-peer {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  justify-content: center;
}
.dm-chat-peer-ava {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}
.dm-chat-peer-meta { min-width: 0; text-align: start; }
.dm-chat-peer-name {
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -.01em;
}
.dm-chat-peer-handle {
  font-size: 12px;
  color: var(--mute);
  font-family: var(--font-en, Inter, sans-serif);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Messages area */
.dm-messages {
  background:
    radial-gradient(ellipse at top, rgba(255,255,255,.02), transparent 55%),
    var(--ink, #000) !important;
  padding: 20px 18px !important;
  gap: 8px !important;
}
.dm-chat-placeholder {
  gap: 14px !important;
}
.dm-chat-placeholder .dm-ph-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -.02em;
}
.dm-chat-placeholder .dm-ph-sub {
  font-size: 14px;
  color: var(--mute);
  max-width: 260px;
  line-height: 1.55;
}

/* Composer */
.dm-input-row {
  padding: 10px 14px 14px !important;
  gap: 8px !important;
  background: var(--ink, #000);
  border-top: 1px solid var(--line) !important;
}
.dm-input-row textarea {
  background: var(--char) !important;
  border: 1px solid var(--line) !important;
  border-radius: 22px !important;
  padding: 11px 16px !important;
  font-size: 15px !important;
  min-height: 44px !important;
}
.dm-input-row textarea:focus {
  border-color: rgba(255,255,255,.28) !important;
  background: transparent !important;
}
.dm-send-btn {
  width: 44px !important;
  height: 44px !important;
  background: var(--white) !important;
}
.dm-send-btn:disabled {
  opacity: .25 !important;
  background: var(--slate) !important;
  color: var(--mute) !important;
}
.dm-tip-btn { display: none !important; } /* hide tip from primary DM flow */

/* Empty states */
.dm-empty {
  padding: 56px 24px !important;
  gap: 12px !important;
}
.dm-empty-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -.02em;
}
.dm-empty-label { font-size: 14px !important; line-height: 1.65 !important; max-width: 240px; }
.dm-empty-cta {
  margin-top: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--white);
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-ar, Tajawal, sans-serif);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.dm-empty-cta:hover { background: var(--char); border-color: var(--white); }

/* New message sheet */
.dm-new-sheet {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  background: var(--ink, #000);
  flex-direction: column;
}
.dm-new-sheet.open { display: flex; }
.dm-new-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-weight: 800;
  font-size: 16px;
}
.dm-new-body { padding: 16px; flex: 1; overflow-y: auto; }
.dm-new-label {
  font-size: 13px;
  color: var(--mute);
  margin-bottom: 8px;
  font-weight: 600;
}
.dm-new-input {
  width: 100%;
  box-sizing: border-box;
  background: var(--char);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  color: var(--white);
  font-size: 15px;
  font-family: var(--font-ar, Tajawal, sans-serif);
  outline: none;
  direction: ltr;
  text-align: start;
}
.dm-new-input:focus { border-color: rgba(255,255,255,.35); }
.dm-new-hint {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--mute);
  line-height: 1.5;
}
.dm-new-go {
  margin-top: 16px;
  width: 100%;
  padding: 13px;
  border-radius: 999px;
  border: 0;
  background: var(--white);
  color: var(--black);
  font-size: 15px;
  font-weight: 800;
  font-family: var(--font-ar, Tajawal, sans-serif);
  cursor: pointer;
}
.dm-new-go:disabled { opacity: .35; cursor: default; }

@media (max-width: 680px) {
  .dm-modal {
    border-radius: 0 !important;
    height: 100% !important;
    max-height: 100% !important;
    max-width: 100% !important;
  }
  .dm-overlay { background: #000 !important; }
}

/* ═══════════════════════════════════════════
   New Diwan modal — choice → form
   ═══════════════════════════════════════════ */
.ndw-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.ndw-overlay.open { display: flex; }
.ndw-card {
  background: var(--char, #111);
  border: 1px solid var(--line);
  border-radius: 20px;
  width: 100%;
  max-width: 480px;
  max-height: min(90dvh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 28px 80px rgba(0,0,0,.55);
  animation: dmSlide .22s cubic-bezier(.2,.8,.2,1);
}
.ndw-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.ndw-head h3 {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -.02em;
}
.ndw-body {
  padding: 20px 20px 24px;
  overflow-y: auto;
  flex: 1;
}
.ndw-choices {
  display: grid;
  gap: 12px;
}
.ndw-choice {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: start;
  padding: 16px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--white);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s;
  font-family: var(--font-ar, Tajawal, sans-serif);
}
.ndw-choice:hover {
  background: var(--slate);
  border-color: rgba(255,255,255,.22);
}
.ndw-choice:active { transform: scale(.985); }
.ndw-choice-ico {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: var(--slate);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--white);
}
.ndw-choice-ico svg { width: 22px; height: 22px; }
.ndw-choice-txt { flex: 1; min-width: 0; }
.ndw-choice-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.015em;
}
.ndw-choice-sub {
  margin-top: 3px;
  font-size: 13px;
  color: var(--mute);
  line-height: 1.45;
}
.ndw-choice-arrow {
  color: var(--mute);
  flex-shrink: 0;
}

.ndw-step { display: none; }
.ndw-step.active { display: block; }

.ndw-field { margin-bottom: 16px; }
.ndw-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--mute);
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.ndw-input, .ndw-textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--slate);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 15px;
  font-family: var(--font-ar, Tajawal, sans-serif);
  color: var(--white);
  outline: none;
  transition: border-color .15s;
}
.ndw-input:focus, .ndw-textarea:focus { border-color: rgba(255,255,255,.35); }
.ndw-textarea { resize: none; min-height: 96px; line-height: 1.55; }
body.light .ndw-input,
body.light .ndw-textarea { color: var(--black); background: var(--elev, #f2f2f2); }

.ndw-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ndw-seg-btn {
  padding: 12px 10px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--soft);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-ar, Tajawal, sans-serif);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: .15s;
}
.ndw-seg-btn svg { width: 16px; height: 16px; }
.ndw-seg-btn.active {
  background: var(--white);
  color: var(--black);
  border-color: var(--white);
  font-weight: 800;
}
body.light .ndw-seg-btn.active {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

.ndw-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ndw-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--soft);
  font-size: 13px;
  font-family: var(--font-ar, Tajawal, sans-serif);
  cursor: pointer;
  transition: .15s;
}
.ndw-chip.active {
  background: var(--white);
  color: var(--black);
  border-color: var(--white);
  font-weight: 700;
}

.ndw-advanced {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.ndw-advanced summary {
  cursor: pointer;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--soft);
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.ndw-advanced summary::-webkit-details-marker { display: none; }
.ndw-advanced summary::after {
  content: '▾';
  margin-inline-start: auto;
  color: var(--mute);
  transition: transform .15s;
}
.ndw-advanced[open] summary::after { transform: rotate(180deg); }
.ndw-advanced-body { padding-top: 14px; }

.ndw-primary {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  border-radius: 999px;
  border: 0;
  background: var(--white);
  color: var(--black);
  font-size: 15px;
  font-weight: 800;
  font-family: var(--font-ar, Tajawal, sans-serif);
  cursor: pointer;
  transition: opacity .15s, transform .12s;
}
.ndw-primary:hover { opacity: .92; }
.ndw-primary:active { transform: scale(.98); }
.ndw-primary:disabled { opacity: .35; cursor: default; }

.ndw-back {
  background: none;
  border: 0;
  color: var(--soft);
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.ndw-back:hover { background: var(--slate); color: var(--white); }

@media (max-width: 560px) {
  .ndw-overlay { padding: 0; align-items: flex-end; }
  .ndw-card {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 92dvh;
    animation: ndwSheet .26s cubic-bezier(.2,.8,.2,1);
  }
  @keyframes ndwSheet {
    from { transform: translateY(100%); }
    to   { transform: none; }
  }
}

/* ── Feed compose: tighter X feel ── */
.dw-compose {
  padding: 14px 16px 12px !important;
  gap: 12px !important;
}
.dw-compose textarea {
  font-size: 18px !important;
  min-height: 28px !important;
  line-height: 1.45 !important;
  font-weight: 400 !important;
}
.dw-tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(0,0,0,.78);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
body.light .dw-tabs {
  background: rgba(255,255,255,.82);
}
.dw-tab {
  padding: 15px 0 !important;
  font-size: 15px !important;
}
.dw-tab.active::after {
  width: 56px !important;
  height: 4px !important;
  border-radius: 999px !important;
  background: var(--white) !important;
}

/* FAB polish */
.dw-fab {
  position: fixed;
  bottom: calc(72px + env(safe-area-inset-bottom));
  inset-inline-end: 18px;
  z-index: 90;
  width: 56px; height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--white);
  color: var(--black);
  display: none;
  place-items: center;
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  cursor: pointer;
  transition: transform .15s, opacity .15s;
}
.dw-fab:active { transform: scale(.94); }
.dw-fab svg { width: 22px; height: 22px; }
.dw-fab--hidden { opacity: 0; pointer-events: none; }
@media (max-width: 800px) {
  .dw-fab { display: grid; }
}

/* Sidebar compose */
.dw-compose-btn {
  font-weight: 800 !important;
  letter-spacing: -.01em;
}

/* Mobile nav active indicator */
.mn-btn {
  position: relative;
  min-width: 64px;
  border-radius: 12px;
}
.mn-btn.active::before {
  content: '';
  position: absolute;
  top: 2px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--white);
}

/* ── Rooms list polish ── */
.rooms-list-view {
  padding-top: 20px !important;
}
.rooms-list-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.rooms-list-toolbar h2 {
  margin: 0 0 6px !important;
  font-size: clamp(26px, 4vw, 40px) !important;
}
.rooms-list-toolbar .sub {
  margin: 0 !important;
}
.start-room-btn {
  margin-bottom: 0 !important;
  padding: 13px 22px !important;
  font-weight: 800 !important;
  box-shadow: 0 0 0 1px rgba(255,255,255,.06);
}
.room-row {
  border-radius: 14px !important;
  margin: 0 0 4px !important;
  padding: 16px 18px !important;
  border: 1px solid transparent;
}
.room-row::after { display: none !important; }
.room-row:hover {
  background: var(--char) !important;
  border-color: var(--line);
}
.rr-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--white);
  color: var(--black);
  flex-shrink: 0;
}
.rr-live-pill::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #000;
  animation: blink 1.4s ease-in-out infinite;
}

/* Room start modal — bottom sheet on mobile */
@media (max-width: 560px) {
  .dw-modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
  }
  .dw-modal-card {
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 22px 18px calc(22px + env(safe-area-inset-bottom)) !important;
  }
}
.dw-modal-card {
  position: relative;
}
.dw-modal-x {
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--soft);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.dw-modal-x:hover { background: var(--slate); color: var(--white); }
.dw-modal-card h3 { padding-inline-start: 36px; }
.dw-modal-confirm {
  font-weight: 800 !important;
  letter-spacing: -.01em;
}
.dw-modal-input {
  font-size: 17px !important;
  font-weight: 600 !important;
  padding: 16px !important;
  border-radius: 14px !important;
}

/* Live rooms empty */
.room-empty-hint {
  text-align: center;
  padding: 48px 20px !important;
  color: var(--mute);
  line-height: 1.7;
  border: 1px dashed var(--line);
  border-radius: 16px;
  margin-top: 8px;
}
.room-empty-hint strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
}
