/* BabylonChat — نافذة الدردشة (زجاجية، عمودان على الحاسوب وشاشة واحدة على الهاتف) */
.chat-modal { padding: 12px; }
.chat-box { width: min(1040px, 100%); max-width: none; height: min(86vh, 760px); padding: 0; display: grid; grid-template-columns: 300px 1fr; overflow: hidden; gap: 0; }
.chat-side { border-inline-end: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: rgba(255,255,255,.03); }
.chat-me { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.chat-me b { display: block; font-size: 14px; }
.chat-me small { color: var(--ink-soft); font-size: 12px; }
.chat-status-sel { display: block; margin-top: 3px; font: inherit; font-size: 12px; padding: 2px 6px; border-radius: 8px; width: auto; background: rgba(0,0,0,.2); }
:root[data-theme="light"] .chat-status-sel { background: rgba(255,255,255,.9); }
.chat-me .grow, .chat-room .grow, .chat-head .grow { flex: 1; min-width: 0; }
.chat-close-side { display: none; }
.chat-rooms { overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.chat-sep { font-size: 11.5px; color: var(--ink-faint); padding: 8px 8px 2px; letter-spacing: .3px; }
.chat-room { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid transparent; border-radius: 12px; background: transparent; color: inherit; font: inherit; text-align: start; cursor: pointer; transition: background .2s; }
.chat-room:hover { background: rgba(255,255,255,.06); }
.chat-room.on { background: var(--accent-soft); border-color: rgba(34, 211, 238, .35); }
.chat-room b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-room small { display: block; color: var(--ink-soft); font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex: none; display: inline-grid; place-items: center; font-weight: 800; font-size: 14px; color: #0b1020; border: 0; padding: 0; cursor: pointer; overflow: hidden; }
.chat-avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.chat-avatar-txt.h0 { background: linear-gradient(135deg, #67e8f9, #60a5fa); }
.chat-avatar-txt.h1 { background: linear-gradient(135deg, #fde68a, #fb923c); }
.chat-avatar-txt.h2 { background: linear-gradient(135deg, #c4b5fd, #a78bfa); }
.chat-avatar-txt.h3 { background: linear-gradient(135deg, #86efac, #34d399); }
.chat-avatar-txt.h4 { background: linear-gradient(135deg, #fca5a5, #f472b6); }
.chat-avatar-txt.h5 { background: linear-gradient(135deg, #a5f3fc, #818cf8); }
.chat-avatar-txt.h6 { background: linear-gradient(135deg, #fcd34d, #f59e0b); }
.chat-avatar-txt.h7 { background: linear-gradient(135deg, #99f6e4, #2dd4bf); }
.chat-avatar-gen { background: var(--brand-grad); font-size: 18px; }
.chat-avatar-me { position: relative; }
.chat-avatar-me::after { content: '✎'; position: absolute; bottom: -2px; inset-inline-start: -2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface-solid); color: var(--ink); font-size: 10px; display: grid; place-items: center; border: 1px solid var(--line); }
.chat-av-wrap { position: relative; flex: none; display: inline-flex; }
.chat-dot { position: absolute; bottom: 0; inset-inline-start: 0; width: 11px; height: 11px; border-radius: 50%; background: #6b7280; border: 2px solid var(--surface-solid); }
.chat-dot.on { background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,.7); }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.03); }
.chat-head b { display: block; font-size: 15px; }
.chat-head small { color: var(--ink-soft); font-size: 12px; }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 6px; scroll-behavior: smooth; }
.chat-empty { text-align: center; margin: auto; }
.chat-day { text-align: center; margin: 8px 0 4px; }
.chat-day span { font-size: 11.5px; color: var(--ink-soft); background: rgba(255,255,255,.06); border-radius: 999px; padding: 3px 12px; }
.chat-m { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; animation: chatIn .25s var(--ease-out); }
.chat-m.mine { align-self: flex-end; flex-direction: row-reverse; }   /* RTL: رسائلي على اليسار كواتساب */
.chat-m:not(.mine) { align-self: flex-start; }
@keyframes chatIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.chat-bubble { background: rgba(255,255,255,.09); border: 1px solid var(--line); border-radius: 16px 16px 16px 4px; padding: 8px 12px 6px; font-size: 14px; line-height: 1.55; position: relative; min-width: 90px; word-break: break-word; }
.chat-m.mine .chat-bubble { background: rgba(34, 211, 238, .16); border-color: rgba(34, 211, 238, .3); border-radius: 16px 16px 4px 16px; }
.chat-who { display: block; font-size: 12px; color: var(--brand-dark); margin-bottom: 2px; }
.chat-bubble time { display: block; text-align: left; font-size: 10.5px; color: var(--ink-faint); margin-top: 2px; }
.chat-text a.chat-hash { color: var(--brand-dark); text-decoration: underline dotted; cursor: pointer; }
.chat-img { max-width: min(320px, 70vw); max-height: 320px; border-radius: 12px; display: block; }
.chat-voice audio { width: min(260px, 60vw); height: 36px; }
.chat-voice small { display: block; color: var(--ink-soft); font-size: 11px; }
.chat-refs { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.chat-ref { display: flex; flex-direction: column; gap: 1px; text-align: start; font: inherit; font-size: 12.5px; color: inherit; background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; cursor: pointer; transition: border-color .2s; }
.chat-ref:hover { border-color: var(--brand); }
.chat-ref b { color: var(--brand-dark); }
.chat-ref-miss { display: inline-block; color: var(--ink-faint); font-size: 12px; }
.chat-mention { position: absolute; bottom: 70px; inset-inline: 14px; max-height: 240px; overflow-y: auto; background: var(--surface-solid); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 2px; box-shadow: 0 16px 40px rgba(0,0,0,.5); z-index: 2; }
.chat-main { position: relative; }
.chat-mention-item { display: flex; justify-content: space-between; gap: 10px; font: inherit; color: inherit; background: transparent; border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer; text-align: start; }
.chat-mention-item:hover { background: var(--accent-soft); }
.chat-mention-item small { color: var(--ink-soft); }
.chat-rec { display: flex; align-items: center; gap: 10px; padding: 8px 14px; font-size: 13px; border-top: 1px solid var(--line); background: var(--danger-bg); }
.chat-rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; animation: recBlink 1s infinite; }
@keyframes recBlink { 50% { opacity: .2; } }
.chat-composer { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: rgba(255,255,255,.03); }
.chat-composer textarea { flex: 1; min-height: 42px; max-height: 120px; resize: none; padding: 10px 12px; font-size: 14.5px; line-height: 1.4; border-radius: 14px; }
.chat-tool { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255,255,255,.08); font-size: 18px; cursor: pointer; flex: none; transition: background .2s, transform .15s; }
.chat-tool:active { transform: scale(.94); }
.chat-tool.on { background: var(--danger-solid); border-color: transparent; animation: recBlink 1.2s infinite; }
.chat-send { width: 44px; height: 42px; border-radius: 14px; border: 0; background: var(--brand-grad); color: #0b1020; font-size: 18px; cursor: pointer; flex: none; transform: scaleX(-1); }
.chat-main .msg { padding: 0 14px 8px; min-height: 0; }
.chat-ref-pop { position: fixed; inset: 0; z-index: 60; background: rgba(5,8,22,.6); display: grid; place-items: center; padding: 20px; }
.chat-ref-card { background: var(--surface-solid); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; width: min(380px, 100%); display: grid; gap: 6px; font-size: 14px; box-shadow: 0 30px 80px rgba(0,0,0,.55); }
.chat-ref-card .row { display: flex; gap: 8px; margin-top: 8px; }
.chat-ref-card b { font-size: 16px; color: var(--brand-dark); }
/* زر الشريط */
.chat-btn { position: relative; }
.chat-btn .tab-badge { position: absolute; top: -6px; inset-inline-start: -4px; }

@media (max-width: 720px) {
  .modal.chat-modal { padding: 0; align-items: stretch; }
  .modal .modal-box.chat-box { width: 100%; height: 100vh; height: 100dvh; max-height: none; border-radius: 0; grid-template-columns: 1fr; padding: 0; animation: none; }
  .modal .modal-box.chat-box::before { display: none; }
  .chat-side { border: 0; }
  .chat-close-side { display: inline-flex; }
  .chat-main { display: none; }
  .chat-modal.is-room .chat-side { display: none; }
  .chat-modal.is-room .chat-main { display: flex; }
  .chat-back { display: inline-flex; }
  .chat-m { max-width: 88%; }
  .chat-msgs { padding: 10px; }
}
