
@font-face {
  font-family: 'IRANSansWeb';
  src: url('../fonts/IRANSansWeb.ttf') format('truetype');
  font-weight: normal; font-style: normal; font-display: swap;
}

/* Mobile polish: keep header compact + make badge readable */
@media (max-width: 520px) {
  .main-header { padding: 0 12px; height: 60px; }
  .header-left { gap: 10px; }
  .header-search { width: 100%; }
  /* smaller height on mobile (requested) */
  .live-search { width: 100%; border-radius: 16px; padding: 6px 10px; font-size: 13px; height: 34px; }
  .unread-badge { --ub-size: 20px; font-size: 12px; }
}

:root {
  --bg-deep: #1c3341;
  --bg-elevated: #2a4759;
  --glass: rgba(42, 71, 89, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  --text: #f8fafc;
  --text-muted: #9baec1;
  --primary: #007aff;
  --incoming: var(--bg-elevated);
  --outgoing: var(--primary);
  --accent: #38bdf8;
  --danger: #ef4444;
  
  /* Secondary Profile Colors */
  --sec-bg: #1e293b;
  --sec-border: rgba(255, 255, 255, 0.08);
  --sec-label: #94a3b8;
  --sec-link: #3b82f6;

  --font: "IRANSansWeb", Tahoma, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; margin: 0; overflow: hidden; background: var(--bg-deep); }
body { font-family: var(--font); color: var(--text); display: flex; flex-direction: column; position: absolute; inset: 0; -webkit-font-smoothing: antialiased; }

.view-main { flex: 1; display: flex; flex-direction: column; height: 100%; width: 100%; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; background: var(--bg-deep); }
.view-chat { position: absolute; inset: 0; z-index: 200; display: flex; flex-direction: column; background: var(--bg-deep); height: 100%; width: 100%; animation: chatSlideIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) forwards; }
@keyframes chatSlideIn { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
body.chat-open .bottom-nav { display: none !important; }

.page-content { flex: 1 0 auto; overflow: visible; padding-bottom: 90px; display: none; opacity: 0; }
.page-content.active-page { display: block; animation: pageFadeSlide 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) forwards; }
@keyframes pageFadeSlide { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }

.ui-icon { width: 24px; height: 24px; display: block; object-fit: contain; filter: brightness(0) invert(1); }
.ui-icon-small { width: 16px; height: 16px; display: inline-block; object-fit: contain; vertical-align: middle; margin: 0 4px; filter: brightness(0) invert(1); }

.main-header { height: 64px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; background: transparent; flex-shrink: 0; flex-direction: row-reverse; }
.chat-header { height: 64px; padding: 0 16px; display: flex; align-items: center; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--glass-border); flex-shrink: 0; position: relative; z-index: 1000; width: 100%; }

.header-content { display: flex; align-items: center; width: 100%; height: 100%; gap: 8px; overflow: hidden; }
.chat-meta-click { display: flex; align-items: center; gap: 12px; flex: 1; height: 100%; cursor: pointer; overflow: hidden; padding: 4px; }
.chat-avatar { width: 42px; height: 42px; min-width: 42px; border-radius: 50%; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; overflow: hidden; font-weight: 700; color: #fff; flex-shrink: 0; border: 1px solid var(--glass-border); }
.chat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.chat-info { display: flex; flex-direction: column; justify-content: center; flex: 1; min-width: 0; align-items: flex-start; }
.chat-name, .chat-type { width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; direction: rtl; }
.chat-name { font-weight: 700; font-size: 15px; color: var(--text); }
.chat-type { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.brand-text { font-weight: 700; font-size: 19px; color: var(--text); letter-spacing: 0.5px; -webkit-text-stroke: 0.3px var(--text); }

/* Live search in header */
.header-left { display:flex; align-items:center; gap:12px; flex: 1; min-width: 0; }
.header-search { position: relative; display:flex; align-items:center; flex: 1; min-width: 0; margin-top: 10px; }
.live-search {
  /* full width on desktop header area (requested) */
  width: 100%;
  max-width: 100%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  border-radius: 14px;
  /* smaller height on desktop too */
  /* a bit shorter (requested) */
  padding: 6px 10px;
  box-sizing: border-box;
  height: 36px;
  outline: none;
  font-family: inherit;
  font-size: 13px;
}
.live-search:focus { border-color: rgba(255,255,255,0.22); }
.live-search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(14,18,24,0.92);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 14px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  z-index: 9999;
  max-height: 320px;
  overflow-y: auto;
}
.ls-item { display:flex; align-items:center; gap:10px; padding: 10px 12px; cursor:pointer; }
.ls-item:hover { background: rgba(255,255,255,0.06); }
.ls-avatar { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,0.08); overflow:hidden; display:flex; align-items:center; justify-content:center; font-weight:800; }
.ls-avatar img { width:100%; height:100%; object-fit:cover; }
.ls-meta { display:flex; flex-direction:column; min-width:0; }
.ls-title { font-weight:700; font-size: 13px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.ls-sub { font-size: 12px; color: var(--text-muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* Sections in chats list */
.room-section-title {
  padding: 10px 16px;
  color: var(--text-muted);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: 0.3px;
}

.filter-tabs { display: flex; padding: 0 20px; gap: 24px; height: 56px; align-items: center; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-bottom: 1px solid var(--glass-border); position: sticky; top: 0; z-index: 900; flex-shrink: 0; }
.filter-btn { background: none; border: none; color: var(--text-muted); font-family: inherit; font-weight: 600; font-size: 14px; padding: 16px 0; cursor: pointer; position: relative; transition: color 0.2s ease; }
.filter-btn.active { color: var(--text); font-weight: 700; }
.filter-btn.active::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 4px; background: var(--primary); border-radius: 4px 4px 0 0; }

.room-item, .user-item { display: flex; align-items: center; padding: 12px 20px; cursor: pointer; height: 76px; transition: background 0.2s ease; }
.room-item:active, .user-item:active { background: rgba(255,255,255,0.05); }
.room-avatar, .user-avatar { position: relative; width: 50px; height: 50px; border-radius: 50%; background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; margin-left: 14px; flex-shrink: 0; overflow: hidden; color: var(--text); border: 1px solid var(--glass-border); }
.room-avatar img, .user-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.room-info, .user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid rgba(255,255,255,0.03); padding-bottom: 14px; padding-top: 14px; height: 100%; }
.part-name { font-weight: 700; font-size: 16px; color: var(--text); margin-bottom: 4px; }
.part-bio { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-top { display: flex; justify-content: space-between; margin-bottom: 6px; align-items: center; }
.room-name { font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-kind-icon{ width:14px; height:14px; vertical-align:-2px; margin-left:6px; opacity:0.9; }

.room-time { font-size: 12px; color: var(--text-muted); flex-shrink: 0; }
.room-msg { font-size: 14px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 12px; }

/* Ensure unread badge is always visible (fix: badge could be pushed out in RTL/desktop) */
.room-msg { flex: 1; min-width: 0; }
.room-badge { flex-shrink: 0; }
.room-top { gap: 10px; }

/* Telegram-like unread badge (minimal + responsive) */
.unread-badge {
  --ub-size: 18px;
  min-width: var(--ub-size);
  height: var(--ub-size);
  padding: 0 6px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(255,79,79,0.96), rgba(220,36,36,0.96));
  box-shadow: 0 6px 16px rgba(220, 36, 36, 0.18);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1px;
  line-height: 1;
  flex-shrink: 0;
}
.unread-badge.avatar-badge{
  position: absolute;
  top: 2px;
  right: 2px;
  padding: 0 5px;
  transform: translateZ(0);
  z-index: 2;
}

.unread-badge.pulse { animation: unreadPulse 360ms ease-out; }
@keyframes unreadPulse { 0% { transform: scale(1); } 45% { transform: scale(1.16); } 100% { transform: scale(1); } }

.badge { background: var(--primary); color: #fff; font-size: 11px; min-width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; padding: 0 6px; border-radius: 11px; font-weight: 800; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0, 122, 255, 0.4); }
.room-badge:not(:empty) { margin-right: 8px; }

/* Bottom nav labels: keep in one line on desktop (fix: "پنل ادمین" wrapping) */
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@media (min-width: 900px){
  .bottom-nav .nav-label { font-size: 11px; }
}

.messages-area { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior-y: contain; }

.msg-row { width: 100%; display: flex; margin-bottom: 4px; }
html[dir="rtl"] .msg-row.me { justify-content: flex-start; direction: rtl; } 
html[dir="rtl"] .msg-row.other { justify-content: flex-start; direction: ltr; } 

html[dir="rtl"] .msg-row.other .msg-container { direction: rtl; text-align: right; } 
html[dir="rtl"] .msg-row.other .mavatar { margin-left: 0; margin-right: 10px; align-self: flex-end; } 

.msg-container { max-width: 82%; display: flex; flex-direction: column; }
.msg-bubble { padding: 10px 14px; position: relative; min-width: 70px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); cursor: pointer; word-wrap: break-word; font-size: 15px; line-height: 1.5; }

html[dir="rtl"] .msg-row.me .msg-bubble { background: var(--outgoing); color: #fff; border-radius: 18px 18px 4px 18px; }
html[dir="rtl"] .msg-row.other .msg-bubble { background: var(--incoming); color: var(--text); border-radius: 18px 18px 18px 4px; border: 1px solid rgba(255,255,255,0.05); }

.mavatar { width: 34px; height: 34px; border-radius: 50%; background: var(--bg-elevated); overflow: hidden; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 13px; border: 1px solid var(--glass-border); }
.mavatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.is-dm .msg-row.other .mavatar { display: none; }
.msg-row.me .mavatar { display: none; }

.msg-name { font-size: 12px; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.msg-body { white-space: pre-wrap; margin-bottom: 2px; }
.msg-meta { font-size: 10px; color: rgba(255,255,255,0.6); float: left; margin-top: 6px; margin-right: 12px; display: flex; align-items: center; gap: 4px; line-height: 1; direction: ltr; }
.ticks { font-size: 12px; color: #fff; letter-spacing: -1px; margin-left: 2px; }
.ticks.read { color: rgba(60, 255, 140, 0.95); }

/* minimal badges for pinned/saved inside message meta */
.msg-badges { display:inline-flex; align-items:center; gap:6px; margin-left: 6px; }
.msg-badge-icon {
  width: 14px;
  height: 14px;
  opacity: 0.92;
  filter: brightness(0) invert(1);
  transform: translateY(0.5px);
}
.msg-badge-icon.soft { opacity: 0.7; }

/* pinned bar (Telegram-like, minimal) */
.pinned-bar {
  display:none;
  padding: 10px 16px;
  background: var(--glass);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
.pinned-bar.active { display:flex; align-items:center; gap:10px; }
.pinned-bar .pin-ico { width: 18px; height: 18px; filter: brightness(0) invert(1); opacity: 0.9; }
.pinned-bar .pin-list { display:flex; gap:10px; overflow-x:auto; flex:1; scrollbar-width:none; }
.pinned-bar .pin-list::-webkit-scrollbar { display:none; }
.pinned-chip {
  flex: 0 0 auto;
  max-width: 260px;
  padding: 7px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.pinned-chip:active { transform: scale(0.98); background: rgba(255,255,255,0.06); }
.pinned-chip .pc-title { font-weight: 800; font-size: 12px; color: var(--text); white-space: nowrap; overflow:hidden; text-overflow:ellipsis; }
.pinned-chip .pc-sub { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow:hidden; text-overflow:ellipsis; margin-top: 2px; direction: rtl; }
.edited-text { font-size: 10px; font-style: italic; color: rgba(255,255,255,0.6); padding-right: 4px; }

.reply-embed { border-right: 3px solid #fff; background: rgba(0,0,0,0.15); padding: 6px 10px; border-radius: 6px; margin-bottom: 8px; font-size: 13px; cursor: pointer; overflow: hidden; transition: background 0.2s; }

.chat-thumbnail { max-width: 180px; max-height: 180px; min-width: 80px; min-height: 80px; object-fit: cover; border-radius: 12px; cursor: pointer; display: block; margin-top: 6px; background-color: var(--bg-deep); border: 1px solid var(--glass-border); }
.voice-player { display: flex; align-items: center; gap: 12px; background: rgba(0,0,0,0.15); padding: 6px 12px; border-radius: 20px; margin-top: 4px; min-width: 200px; }
.vp-play { width: 36px; height: 36px; border-radius: 50%; border: none; background: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.vp-play .ui-icon-small { filter: none; } 
html[dir="rtl"] .msg-row.other .vp-play { background: var(--primary); }
html[dir="rtl"] .msg-row.other .vp-play .ui-icon-small { filter: brightness(0) invert(1); }
.vp-waveform { flex: 1; height: 4px; background: rgba(255, 255, 255, 0.2); border-radius: 2px; position: relative; overflow: hidden; cursor: pointer; direction: ltr; }
.vp-progress { position: absolute; left: 0; top: 0; bottom: 0; width: 0%; background: #fff; border-radius: 2px; transition: width 0.1s linear; pointer-events: none; }
html[dir="rtl"] .msg-row.other .vp-progress { background: var(--primary); }
.vp-time { font-size: 11px; font-weight: 700; min-width: 32px; text-align: center; color: var(--text); opacity: 0.8; direction: ltr; }

.composer-wrapper { background: transparent; padding: 8px 16px 16px 16px; position: sticky; bottom: 0; z-index: 201; display: flex; flex-direction: column; pointer-events: none; }
.composer-inner, .composer-context, .read-only-banner { pointer-events: auto; }
.read-only-banner { background: var(--bg-elevated); color: var(--text-muted); text-align: center; padding: 12px; border-radius: 16px; font-size: 14px; font-weight: 600; border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.composer-inner { display: flex; align-items: flex-end; background: var(--bg-elevated); border-radius: 28px; padding: 6px; border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.composer-context { background: var(--bg-elevated); margin-bottom: 8px; padding: 10px 14px; display: flex; align-items: center; justify-content: space-between; border-radius: 16px; border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.action-btn, .attach-btn { border: none; flex-shrink: 0; background: transparent; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform 0.2s, opacity 0.2s; width: 44px; height: 44px; border-radius: 50%; }
.input-container { flex: 1; display: flex; align-items: center; background: transparent; min-height: 44px; padding-bottom: 2px; margin-left: 12px; transition: margin 0.3s ease; }
#msgInput { width: 100%; background: transparent; border: none; color: #fff; resize: none; outline: none; padding: 10px 12px; font-family: inherit; font-size: 15px; max-height: 120px; line-height: 1.5; }
#msgInput::placeholder { color: var(--text-muted); }
.send-btn, .mic-btn { background-color: var(--primary) !important; width: 44px; height: 44px; border-radius: 50% !important; box-shadow: 0 4px 16px rgba(0, 122, 255, 0.4); }
.send-btn:not(:disabled):active, .mic-btn:active { transform: scale(0.92); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; background-color: var(--bg-elevated) !important; }

.bottom-nav { position: fixed; bottom: 20px; left: 20px; right: 20px; height: 64px; border-radius: 32px; background: var(--glass); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); display: flex; align-items: center; z-index: 90; border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); flex-direction: row-reverse; justify-content: space-evenly; }
.nav-item { display: flex; flex-direction: column; align-items: center; color: var(--text-muted); text-decoration: none; border: none; background: none; cursor: pointer; transition: color 0.2s, transform 0.2s; padding: 0 16px; }
.nav-item.active { color: var(--text); }
.nav-item:active { transform: scale(0.9); }
.nav-label { font-size: 11px; font-weight: 700; margin-top: 4px; font-family: var(--font); }
.nav-avatar { width: 26px; height: 26px; border-radius: 50%; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--bg-elevated); color: #fff; font-size: 12px; border: 1px solid var(--glass-border); }
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.icon-btn { background: none; border: none; padding: 8px; cursor: pointer; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: background 0.2s; width: 44px; height: 44px; }
.icon-btn:hover { background: rgba(255,255,255,0.05); }
.icon-btn-small { background: none; border: none; padding: 6px; cursor: pointer; border-radius: 50%; transition: background 0.2s; }
.icon-btn-small:hover { background: rgba(255,255,255,0.05); }
.popup-menu { position: absolute; top: 60px; right: 20px; background: var(--bg-elevated); border: 1px solid var(--glass-border); border-radius: 16px; width: 220px; padding: 8px; display: flex; flex-direction: column; z-index: 99999; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.popup-item, a.popup-item { text-decoration: none !important; background: transparent; border: 0; color: var(--text); text-align: right; padding: 12px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 500; transition: background 0.2s; display: flex; align-items: center; gap: 8px; }
.popup-item:hover { background: rgba(255,255,255,0.05); }
.msg-popover { position: fixed; background: var(--bg-elevated); border: 1px solid var(--glass-border); border-radius: 12px; padding: 6px; z-index: 99999; box-shadow: var(--glass-shadow); display: flex; flex-direction: column; }
.pop-btn { background: transparent; border: 0; color: var(--text); padding: 12px 16px; border-radius: 8px; font-family: inherit; font-size: 14px; text-align: right; cursor: pointer; }
.pop-btn:hover { background: rgba(255,255,255,0.05); }
.text-danger { color: var(--danger) !important; }

.modal, .full-modal { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; }
.modal-backdrop, .full-modal { background: rgba(0,0,0,0.6); backdrop-filter: blur(8px); }
.modal-card { width: 90%; max-width: 400px; background: var(--bg-deep); border-radius: 20px; border: 1px solid var(--glass-border); display: flex; flex-direction: column; max-height: 80vh; z-index: 1001; box-shadow: 0 20px 50px rgba(0,0,0,0.5); }
.modal-header { padding: 20px; border-bottom: 1px solid var(--glass-border); display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 18px; }
.modal-body { padding: 20px; overflow-y: auto; }

.full-modal-card { width: 90%; max-width: 380px; background: var(--bg-elevated); border-radius: 24px; padding: 32px 24px; display: flex; flex-direction: column; align-items: center; position: relative; border: 1px solid var(--glass-border); box-shadow: var(--glass-shadow); }
.full-modal-close { position: absolute; top: 16px; left: 16px; background: rgba(255,255,255,0.05); width: 36px; height: 36px; border: none; cursor: pointer; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.full-modal-avatar { width: 110px; height: 110px; min-height: 110px; border-radius: 50%; overflow: hidden; margin-bottom: 20px; border: 3px solid var(--primary); background: var(--bg-deep); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: #fff; font-size: 32px; font-weight: bold; }
.full-modal-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.full-modal-name { font-size: 20px; font-weight: 800; color: #fff; margin-bottom: 8px; width: 100%; text-align: center; }
.full-modal-bio { font-size: 14px; color: var(--text-muted); text-align: center; width: 100%; }

#pageProfile { padding: 0; display: flex; flex-direction: column; height: 100%; }
.profile-static-wrapper { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 30px 20px 100px 20px; width: 100%; max-width: 440px; margin: 0 auto; }

.ps-avatar { width: 130px; height: 130px; border-radius: 28px; background: var(--bg-elevated); margin-bottom: 16px; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 48px; font-weight: bold; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,0.3); border: 2px solid var(--glass-border); flex-shrink: 0; }
.ps-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.ps-name { font-size: 22px; font-weight: 800; color: var(--text); margin-bottom: 20px; text-align: center; }

.pb-box { width: 100%; background: var(--sec-bg); border: 1px solid var(--sec-border); border-radius: 20px; padding: 8px 20px; margin-bottom: 20px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); }
.pb-row { display: flex; flex-direction: column; padding: 14px 0; border-bottom: 1px solid rgba(255,255,255,0.05); }
.pb-row:last-child { border-bottom: none; }
.pb-label { font-size: 13px; color: var(--sec-label); font-weight: 600; margin-bottom: 6px; }
.pb-value { font-size: 15px; color: var(--text); font-weight: 700; word-break: break-word; }
.pb-link-val { color: var(--sec-link); direction: ltr; text-align: right; }

.copyable-link { cursor: pointer; transition: opacity 0.2s; }
.copyable-link:active { opacity: 0.6; }

.pb-edit-btn { width: 100%; min-height: 52px; background: var(--primary); color: #fff; font-size: 16px; font-weight: 800; font-family: inherit; border: none; border-radius: 16px; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; box-shadow: 0 6px 20px rgba(0, 122, 255, 0.3); flex-shrink: 0; }
.pb-edit-btn:active { transform: scale(0.96); box-shadow: 0 2px 10px rgba(0, 122, 255, 0.2); }

.scroll-down-fab { position: absolute; bottom: 85px; right: 16px; width: 44px; height: 44px; border-radius: 50%; background: var(--glass); border: 1px solid var(--glass-border); display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 20px rgba(0,0,0,0.4); z-index: 150; cursor: pointer; backdrop-filter: blur(10px); }
.badge-counter { position: absolute; top: -4px; left: -4px; background: var(--primary); color: white; font-size: 10px; padding: 2px 6px; border-radius: 10px; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.3); }

@keyframes pulse-mic { 0% { transform: scale(1); } 50% { transform: scale(1.1); background-color: var(--danger); border-radius: 50%; } 100% { transform: scale(1); } }
.mic-btn.recording { animation: pulse-mic 1s infinite; background-color: var(--danger) !important; }


/* =========================================================
    استایل صفحه تنضیمات همون پروفایل
   ========================================================= */

.admin-body {
  background: var(--bg-deep);
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.admin-shell {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  padding-bottom: 40px;
  scroll-behavior: smooth;
}

.admin-top {
  position: relative;
  z-index: 100;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: transparent;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.admin-top .brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  letter-spacing: -0.5px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 24px 20px;
  margin: 0 16px 20px 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.card h3 {
  margin-top: 0;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 12px;
  margin-bottom: 20px;
}

.card hr {
  border: 0;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin: 24px 0;
}

.row {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.avatar.big {
  width: 110px;
  height: 110px;
  min-width: 110px;
  border-radius: 50%;
  border: 3px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: bold;
  background: var(--bg-deep);
  color: #fff;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  margin: 0 auto;
}

.avatar.big img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar.big + div {
  width: 100%;
  flex: none !important;
}

label {
  display: block;
  font-size: 13px;
  color: var(--sec-label);
  margin-bottom: 6px;
  font-weight: 600;
}

input:not([type="file"]):not([type="checkbox"]), select {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--glass-border);
  color: var(--text);
  padding: 14px 16px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 14px;
  margin-bottom: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

input:not([type="file"]):not([type="checkbox"]):focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

input::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

input[type="file"] {
  width: 100%;
  font-size: 13px;
  color: var(--text-muted);
  padding: 8px 0;
  margin-bottom: 16px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

.hint b {
  color: var(--text);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 14px 20px;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  width: 100%;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(0, 122, 255, 0.3);
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2);
}

.menu {
  position: relative;
}

.pill {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.pill:hover {
  background: rgba(255, 255, 255, 0.1);
}

.menu-dropdown {
  position: absolute;
  top: 50px;
  left: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  padding: 8px;
  min-width: 160px;
  z-index: 105;
  display: flex;
  flex-direction: column;
}

.menu-dropdown .menu-item {
  display: block;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  text-align: right;
  transition: background 0.2s;
}

.menu-dropdown .menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
}



/* =========================================================
   استایل صفحه ادمین
   ========================================================= */

.grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  margin-bottom: 16px;
  font-weight: 600;
}

label.check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.members-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  max-height: 220px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.member-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
}

.member-chip:hover, .member-chip:active {
  background: rgba(255, 255, 255, 0.08);
}

.gm-check {
  margin: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.table {
  width: 100%;
  overflow-x: auto;
  display: block;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.15);
  margin-bottom: 16px;
}

.table::-webkit-scrollbar { height: 6px; }
.table::-webkit-scrollbar-track { background: transparent; }
.table::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }

.thead, .trow {
  display: flex;
  min-width: max-content;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  align-items: center;
}

.thead {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 800;
  font-size: 12px;
  color: var(--sec-label);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.trow {
  font-size: 13px;
  font-weight: 600;
  transition: background 0.2s;
}

.trow:hover { background: rgba(255, 255, 255, 0.02); }
.trow:last-child { border-bottom: none; }

.thead > div, .trow > div {
  flex: 1 0 90px; 
  padding: 0 8px;
  word-break: break-word;
}

.thead > div:last-child, .trow > div:last-child {
  flex: 0 0 180px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end; /* Align buttons to right */
}

.pill.small {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 6px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  height: auto;
  width: auto;
}

.pill.small:hover, .pill.small:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.96);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-danger:active {
  transform: scale(0.95);
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2);
}

.mono {
  font-family: monospace;
  direction: ltr;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.meta {
  color: var(--text-muted);
  font-size: 12px;
}

.link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  transition: opacity 0.2s;
}

.link:active { opacity: 0.7; }



/* =========================================================
   استایل فرم لاگین
   ========================================================= */

.login-body {
  background: radial-gradient(circle at 50% 20%, var(--bg-elevated) 0%, var(--bg-deep) 80%);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 20px;
  overflow: hidden;
}

.login-card {
  background: rgba(30, 41, 59, 0.4);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: 40px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  animation: slideUpLogin 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
  will-change: transform, opacity;
}

@keyframes slideUpLogin {
  from { opacity: 0; transform: translateY(40px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card .brand {
  font-size: 32px;
  font-weight: 900;
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 0%, #9baec1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-card .subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
  font-weight: 500;
}

.login-card .alert {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ffb3b3;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 24px;
  animation: shakeAlert 0.4s ease-in-out;
}

@keyframes shakeAlert {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-6px); }
}

.login-card form {
  display: flex;
  flex-direction: column;
}

.login-card input {
  margin-bottom: 24px;
  background: rgba(0, 0, 0, 0.2); 
}

.login-card .btn-primary {
  margin-top: 8px;
  height: 52px;
  font-size: 16px;
}

.login-card .hint {
  text-align: center;
  margin-top: 24px;
  margin-bottom: 0;
  opacity: 0.6;
  font-size: 12px;
}



::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

/* =========================================================
   فیکس سازی دسکتاپ
   ========================================================= */
@media (min-width: 860px) {
  
  body:not(.admin-body):not(.login-body) {
    display: flex !important;
    flex-direction: row !important;
  }

  .view-main {
    width: 380px !important;
    min-width: 380px !important;
    max-width: 380px !important;
    flex: none !important;
    border-left: 1px solid var(--glass-border);
    display: flex !important;
    position: relative;
    height: 100vh !important;
    background: var(--bg-deep);
    z-index: 10;
  }

  .bottom-nav {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important; 
    left: auto !important;   
    width: 340px !important;  
    margin: 0 !important;
    z-index: 1000 !important;
    display: flex !important; 
  }

  body.chat-open .bottom-nav {
    display: flex !important;
  }

  .view-chat {
    flex: 1 !important;
    display: flex !important;
    position: relative;
    height: 100vh !important;
    animation: none !important;
    background: radial-gradient(circle at 50% 50%, #202b36 0%, var(--bg-deep) 100%);
  }

  #backBtn { display: none !important; }

  body:not(.chat-open) .view-chat::after {
    content: 'یک گفتگو را برای شروع انتخاب کنید';
    position: absolute;
    inset: 0;
    background: var(--bg-deep);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    color: var(--text-muted);
    font-size: 18px;
    font-weight: 600;
  }

  .admin-body .admin-shell {
    width: 100% !important;
    max-width: 1400px !important;
    margin: 0 auto !important;
    padding: 30px 50px !important;
    display: block !important;
  }

  .admin-body .grid {
    display: flex !important;
    flex-direction: column !important;
    gap: 30px !important;
  }

  .composer-wrapper {
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
    padding: 10px 20px 30px 20px;
  }
}

/* Saved Messages avatar icon */
.saved-avatar-icon{ width:60%; height:60%; object-fit:contain; opacity:0.95; }
