/* EPSOFT Chats (chats.epsoft.ir) - Signature Royal Sapphire & Glassmorphism Stylesheet */

:root {
  --accent: #3B6BFF;
  --accent-deep: #1E3A9A;
  --accent-hover: #2956E8;
  --danger: #ef5350;
  --online: #4dcd5e;

  --bg-app: #090e1c;
  --bg-sidebar: #101729;
  --bg-header: #101729;
  --bg-hover: #19243d;
  --bg-active: #1e3a8a;
  --bg-input: #172138;
  --bg-bubble-in: #141e36;
  --bg-bubble-out: #1f3d96;
  --bg-modal: #11192e;
  --border: #0a1020;
  --border-subtle: rgba(148, 179, 255, 0.14);

  --text-main: #f3f6ff;
  --text-sub: #8b9ec2;
  --text-time: #7b8eb3;
  --text-time-out: #adc7ff;
  --shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
}

html[data-theme="light"] {
  --accent: #1E3A9A;
  --accent-deep: #142870;
  --accent-hover: #2548B8;

  --bg-app: #e7eefb;
  --bg-sidebar: #ffffff;
  --bg-header: #ffffff;
  --bg-hover: #f0f4fc;
  --bg-active: #1E3A9A;
  --bg-input: #f2f5fb;
  --bg-bubble-in: #ffffff;
  --bg-bubble-out: #dbe7ff;
  --bg-modal: #ffffff;
  --border: #dce4f5;
  --border-subtle: #dde4f2;

  --text-main: #151c2e;
  --text-sub: #5f6c85;
  --text-time: #7a869e;
  --text-time-out: #2e4c9c;
  --shadow: 0 12px 32px rgba(24, 49, 139, 0.14);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg-app);
  color: var(--text-main);
  font-family: 'Vazirmatn', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

html[dir="ltr"] body {
  font-family: 'Inter', 'Vazirmatn', system-ui, -apple-system, sans-serif;
}

.hidden { display: none !important; }
button, input, textarea { font-family: inherit; color: inherit; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(139, 158, 194, 0.32); border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* Toast */
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 25, 46, 0.92);
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  z-index: 9999;
  font-size: 13px;
  border: 1px solid rgba(59, 107, 255, 0.45);
}

/* ================= GLASSMORPHIC AUTH SCREEN ================= */
.auth-screen {
  height: 100%;
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px 36px;
  overflow-y: auto;
  background: linear-gradient(135deg, #070b18 0%, #0e1a3a 50%, #091228 100%);
}
html[data-theme="light"] .auth-screen {
  background: linear-gradient(135deg, #dce7ff 0%, #eef3ff 50%, #d4e1ff 100%);
}

.auth-bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  animation: floatOrb 12s ease-in-out infinite alternate;
}
.orb-1 { width: 380px; height: 380px; background: #2557D6; top: -90px; right: -80px; }
.orb-2 { width: 340px; height: 340px; background: #1E3A9A; bottom: -100px; left: -60px; animation-delay: 2s; }
.orb-3 { width: 220px; height: 220px; background: #5B86FF; top: 42%; left: 52%; opacity: 0.25; animation-delay: 4s; }

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(24px, -28px) scale(1.08); }
}

.auth-split-shell {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 1120px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: stretch;
}

.auth-col-form, .auth-col-showcase {
  display: flex;
  flex-direction: column;
}

.auth-col-form .glass-card, .auth-col-showcase .glass-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-pill {
  display: inline-flex;
  align-self: flex-start;
  background: rgba(59, 107, 255, 0.18);
  border: 1px solid rgba(95, 145, 255, 0.38);
  color: #96baff;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}
html[data-theme="light"] .hero-pill { color: #1E3A9A; background: rgba(30, 58, 154, 0.1); }

.hero-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 8px;
}

.hero-sub {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.75;
  margin-bottom: 20px;
}

.features-list {
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin-bottom: 20px;
}

.feat-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(160, 190, 255, 0.12);
  transition: border-color .15s, background .15s;
}
html[data-theme="light"] .feat-item { background: rgba(30, 58, 154, 0.04); }
.feat-item:hover {
  border-color: rgba(59, 107, 255, 0.35);
  background: rgba(59, 107, 255, 0.08);
}

.feat-ico {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(59,107,255,0.26), rgba(30,58,154,0.32));
  color: #8eb6ff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
html[data-theme="light"] .feat-ico { color: #1E3A9A; background: rgba(30,58,154,0.12); }
.feat-ico svg { width: 20px; height: 20px; }

.feat-item h3 {
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 3px;
}
.feat-item p {
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.65;
}

.apps-modern-wrap {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.app-svg {
  width: 24px;
  height: 24px;
  color: #96baff;
  margin-bottom: 3px;
}
html[data-theme="light"] .app-svg { color: #1E3A9A; }

.auth-bottom-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.epsoft-brand-link {
  color: #7ea8ff;
  text-decoration: none;
  font-weight: 700;
  margin-inline-start: 4px;
}
html[data-theme="light"] .epsoft-brand-link { color: #1E3A9A; }
.epsoft-brand-link:hover { text-decoration: underline; }

.cms-pill-btn {
  background: linear-gradient(135deg, #2557D6, #1E3A9A);
  color: #fff;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 14px;
  flex-shrink: 0;
}

@media (max-width: 920px) {
  .auth-split-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
}

.glass-card {
  background: rgba(16, 24, 48, 0.62);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(160, 190, 255, 0.2);
  border-radius: 24px;
  padding: 24px 28px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.12);
}
html[data-theme="light"] .glass-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(30, 58, 154, 0.16);
  box-shadow: 0 20px 50px rgba(30, 58, 154, 0.15), inset 0 1px 0 rgba(255,255,255,0.8);
}

.auth-top-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.icon-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
html[data-theme="light"] .icon-pill { background: rgba(30, 58, 154, 0.07); }
.icon-pill:hover { background: rgba(59, 107, 255, 0.22); }

.auth-brand {
  text-align: center;
  margin-bottom: 18px;
}
.brand-logo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  padding: 0;
  margin-bottom: 12px;
}
.brand-logo-wrap::before {
  content: '';
  position: absolute;
  inset: -16px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(75, 130, 255, 0.55) 0%, rgba(37, 87, 214, 0.2) 48%, transparent 72%);
  filter: blur(14px);
  z-index: 0;
  pointer-events: none;
  animation: logoHaloPulse 3.2s ease-in-out infinite;
}
.auth-logo-img {
  position: relative;
  z-index: 1;
  height: 92px;
  width: 92px;
  object-fit: contain;
  display: block;
  animation: logoGlowPulse 3.2s ease-in-out infinite;
}
@keyframes logoHaloPulse {
  0%, 100% { opacity: 0.25; transform: scale(0.88); }
  50%      { opacity: 0.92; transform: scale(1.12); }
}
@keyframes logoGlowPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(75, 130, 255, 0.22)); }
  50%      { filter: drop-shadow(0 0 22px rgba(95, 155, 255, 0.72)); }
}
.auth-brand h1 { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.auth-brand p { font-size: 12.5px; color: var(--text-sub); }

.alert-box {
  background: rgba(239, 83, 80, 0.16);
  border: 1px solid rgba(239, 83, 80, 0.45);
  color: #ff9a98;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.6;
}
html[data-theme="light"] .alert-box { color: #c62828; }

.auth-form .field { margin-bottom: 12px; }
.auth-form .field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.auth-form label { display: block; font-size: 12px; color: var(--text-sub); margin-bottom: 5px; font-weight: 500; }

.auth-form input, .modal-body input, .modal-body textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, background .15s;
}
html[data-theme="light"] .auth-form input { background: rgba(255, 255, 255, 0.8); }
.auth-form input:focus, .modal-body input:focus, .modal-body textarea:focus {
  border-color: var(--accent);
  background: rgba(59, 107, 255, 0.08);
}

/* Password Eye Toggle */
.pass-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pass-wrap input {
  padding-inline-end: 42px;
}
.pass-toggle {
  position: absolute;
  inset-inline-end: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.72;
  padding: 4px 6px;
  border-radius: 8px;
  transition: opacity .15s, background .15s;
}
.pass-toggle:hover { opacity: 1; background: rgba(255,255,255,0.08); }

/* Single-digit Math Captcha */
.captcha-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 6px 10px;
}
html[data-theme="light"] .captcha-box { background: rgba(30, 58, 154, 0.05); }
.captcha-q {
  font-family: monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #7ea8ff;
  background: rgba(30, 58, 154, 0.32);
  padding: 6px 14px;
  border-radius: 9px;
  user-select: none;
  white-space: nowrap;
}
html[data-theme="light"] .captcha-q { color: #1E3A9A; background: rgba(30, 58, 154, 0.12); }
.captcha-refresh {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 6px;
  border-radius: 8px;
  transition: transform .2s;
}
.captcha-refresh:hover { transform: rotate(90deg); }
.captcha-input {
  flex: 1;
  min-width: 70px;
  text-align: center;
  font-weight: 700;
  font-size: 16px !important;
  padding: 7px 10px !important;
}

.otp-input {
  text-align: center;
  font-size: 24px !important;
  letter-spacing: 10px;
  font-weight: 700;
}
.otp-info { font-size: 13px; color: var(--text-sub); text-align: center; margin-bottom: 10px; }
.email-badge {
  text-align: center;
  background: rgba(59, 107, 255, 0.15);
  padding: 8px 12px;
  border-radius: 10px;
  color: #82aaff;
  font-weight: 600;
  margin-bottom: 14px;
  font-size: 13px;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #2557D6, #1E3A9A);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s, box-shadow .15s, opacity .15s;
}
.btn-glow { box-shadow: 0 8px 22px rgba(37, 87, 214, 0.42); }
.btn-primary:hover { opacity: 0.94; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
}
.btn-danger {
  background: rgba(239, 83, 80, 0.15);
  color: #ef5350;
  border: 1px solid rgba(239, 83, 80, 0.35);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  width: 100%;
  font-weight: 600;
}

.auth-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}
.link-btn {
  background: none;
  border: none;
  color: #7ea8ff;
  font-size: 13px;
  cursor: pointer;
}
html[data-theme="light"] .link-btn { color: #1E3A9A; }
.link-btn:hover { text-decoration: underline; }

/* Coming Soon App Badges */
.glass-mini {
  background: rgba(16, 24, 48, 0.52);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(160, 190, 255, 0.16);
  border-radius: 18px;
  padding: 14px 18px;
  text-align: center;
}
html[data-theme="light"] .glass-mini {
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(30, 58, 154, 0.14);
}
.apps-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 10px;
}
.apps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.app-badge {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 9px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
html[data-theme="light"] .app-badge { background: rgba(30, 58, 154, 0.05); }
.app-icon { font-size: 20px; }
.app-name { font-size: 12.5px; font-weight: 700; }
.soon-pill {
  font-size: 10.5px;
  background: rgba(59, 107, 255, 0.22);
  color: #96b8ff;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}
html[data-theme="light"] .soon-pill { color: #1E3A9A; background: rgba(30, 58, 154, 0.12); }

.auth-footer {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-sub);
  padding: 4px 8px;
}

.announcement-box {
  background: rgba(59, 107, 255, 0.16);
  border: 1px solid rgba(59, 107, 255, 0.4);
  color: #bcd3ff;
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 12.5px;
  text-align: center;
  margin-bottom: 12px;
}
html[data-theme="light"] .announcement-box { color: #1E3A9A; }

.app-badge.clickable {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform .15s, border-color .15s;
}
.app-badge.clickable:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}
.dl-pill {
  font-size: 10.5px;
  background: linear-gradient(135deg, #2557D6, #1E3A9A);
  color: #fff;
  padding: 2px 9px;
  border-radius: 10px;
  font-weight: 600;
}

.trust-seals-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}
.trust-seals-box img { max-height: 78px; border-radius: 10px; }

.social-links-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.social-links-row a {
  font-size: 12px;
  color: #8eb2ff;
  text-decoration: none;
  background: rgba(255,255,255,0.06);
  padding: 4px 12px;
  border-radius: 14px;
  border: 1px solid var(--border-subtle);
}
html[data-theme="light"] .social-links-row a { color: #1E3A9A; }

/* ================= MAIN APP SHELL ================= */
.app-shell {
  height: 100%;
  display: flex;
  position: relative;
  overflow: hidden;
}

.sidebar {
  width: 340px;
  min-width: 300px;
  max-width: 400px;
  background: var(--bg-sidebar);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}

.icon-btn {
  background: transparent;
  border: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-sub);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-main); }

.search-box {
  flex: 1;
  background: var(--bg-input);
  border-radius: 20px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  height: 38px;
}
.search-icon { font-size: 14px; opacity: 0.6; }
.search-box input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 0 8px;
  font-size: 13px;
}
.clear-btn { background: none; border: none; color: var(--text-sub); cursor: pointer; font-size: 13px; }

.folder-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-subtle);
  padding: 0 8px;
  gap: 4px;
}
.folder-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 9px 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s, border-color .15s;
}
.folder-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.chat-list { flex: 1; overflow-y: auto; padding: 6px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background .12s;
  position: relative;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); color: #fff; }
.chat-item.active .chat-sub, .chat-item.active .chat-time { color: rgba(255,255,255,0.82); }

.avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.lg { width: 62px; height: 62px; font-size: 24px; }

.avatar-wrap { position: relative; flex-shrink: 0; }
.online-dot {
  position: absolute;
  bottom: 1px;
  inset-inline-end: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--bg-sidebar);
}

.chat-meta { flex: 1; min-width: 0; }
.chat-row-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-bottom: 3px; }
.chat-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-time { font-size: 11px; color: var(--text-sub); flex-shrink: 0; }
.chat-row-bot { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.chat-sub { font-size: 13px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-typing { color: var(--accent) !important; font-weight: 500; }

.unread-badge {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.unread-badge.muted { background: var(--text-sub); }

.fab-btn {
  position: absolute;
  bottom: 18px;
  inset-inline-end: 18px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2557D6, #1E3A9A);
  color: #fff;
  border: none;
  font-size: 22px;
  box-shadow: 0 6px 20px rgba(37, 87, 214, 0.45);
  cursor: pointer;
  transition: transform .15s;
}
.fab-btn:hover { transform: scale(1.06); }

/* Drawer */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40; }
.nav-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: 285px;
  background: var(--bg-sidebar);
  z-index: 50;
  transform: translateX(100%);
  transition: transform .22s ease;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
html[dir="ltr"] .nav-drawer { transform: translateX(-100%); }
.nav-drawer.open { transform: translateX(0) !important; }

.drawer-profile {
  padding: 24px 18px 18px;
  background: linear-gradient(135deg, #1E3A9A, #101729);
  color: #fff;
}
.drawer-name { font-size: 16px; font-weight: 700; margin-top: 10px; }
.drawer-meta { font-size: 12px; opacity: 0.8; margin-top: 2px; }
.drawer-items { flex: 1; padding: 10px 8px; overflow-y: auto; }
.drawer-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 14px;
  background: none;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  text-align: start;
  text-decoration: none;
  color: inherit;
}
.drawer-item:hover { background: var(--bg-hover); }
.drawer-item.admin-link { color: #7ea8ff; font-weight: 700; background: rgba(59, 107, 255, 0.12); margin-bottom: 4px; }
.drawer-item.danger { color: #ef5350; }
.drawer-divider { height: 1px; background: var(--border-subtle); margin: 8px 10px; }
.drawer-footer { padding: 12px 16px; font-size: 11px; color: var(--text-sub); text-align: center; line-height: 1.6; }

/* ================= CHAT PANE ================= */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bg-app);
  background-image: radial-gradient(rgba(59,107,255,0.08) 1px, transparent 1px);
  background-size: 22px 22px;
  position: relative;
}

.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; }
.empty-badge {
  background: rgba(16, 23, 41, 0.82);
  backdrop-filter: blur(12px);
  padding: 28px 34px;
  border-radius: 22px;
  text-align: center;
  max-width: 380px;
  border: 1px solid var(--border-subtle);
}
html[data-theme="light"] .empty-badge { background: rgba(255,255,255,0.9); }
.empty-badge h2 { font-size: 17px; margin: 12px 0 6px; }
.empty-badge p { font-size: 13px; color: var(--text-sub); line-height: 1.7; }

.chat-active { flex: 1; display: flex; flex-direction: column; height: 100%; }

.chat-header {
  height: 60px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; display: flex; align-items: center; gap: 11px; cursor: pointer; min-width: 0; }
.chat-header-text { min-width: 0; }
.chat-header-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-header-sub { font-size: 12px; color: var(--text-sub); }
.chat-header-sub.online { color: var(--accent); }

.chat-search-bar { background: var(--bg-header); border-bottom: 1px solid var(--border); padding: 8px 14px; display: flex; gap: 8px; }
.chat-search-bar input { flex: 1; background: var(--bg-input); border: none; border-radius: 10px; padding: 8px 12px; outline: none; }

.pinned-bar { background: var(--bg-header); border-bottom: 1px solid var(--border); padding: 7px 14px; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.pinned-bar-line { width: 3px; height: 30px; background: var(--accent); border-radius: 3px; }
.pinned-bar-content { flex: 1; min-width: 0; }
.pinned-label { font-size: 11.5px; color: var(--accent); font-weight: 600; }
.pinned-text { font-size: 12.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.messages-wrap { flex: 1; overflow-y: auto; padding: 14px 5%; display: flex; flex-direction: column; }
.messages-list { margin-top: auto; display: flex; flex-direction: column; gap: 5px; max-width: 820px; width: 100%; margin-inline: auto; }

.date-divider { align-self: center; background: rgba(16, 23, 41, 0.72); color: #fff; font-size: 12px; padding: 4px 12px; border-radius: 14px; margin: 10px 0; }
.sys-msg { align-self: center; background: rgba(16, 23, 41, 0.55); color: #d6e4f0; font-size: 12px; padding: 4px 12px; border-radius: 12px; margin: 6px 0; }

.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; }
.msg-row.out { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.in  { align-self: flex-start; }

.bubble {
  background: var(--bg-bubble-in);
  padding: 8px 12px 6px;
  border-radius: 14px;
  position: relative;
  min-width: 80px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg-row.out .bubble { background: var(--bg-bubble-out); border-end-end-radius: 4px; }
.msg-row.in .bubble { border-end-start-radius: 4px; }
.bubble.deleted { opacity: 0.65; font-style: italic; }

.msg-sender { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.msg-forward { font-size: 11.5px; color: var(--accent); margin-bottom: 4px; }
.msg-reply-box { border-inline-start: 3px solid var(--accent); background: rgba(59, 107, 255, 0.12); padding: 4px 8px; border-radius: 6px; margin-bottom: 6px; cursor: pointer; font-size: 12px; }
.msg-reply-name { font-weight: 700; color: var(--accent); }
.msg-reply-txt { color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px; }

.msg-text { font-size: 14px; line-height: 1.6; white-space: pre-wrap; }
.msg-text a { color: #7ea8ff; text-decoration: underline; }
.msg-text code { background: rgba(0,0,0,0.22); padding: 1px 5px; border-radius: 4px; font-family: monospace; font-size: 13px; }

.msg-media-img { max-width: 320px; max-height: 360px; border-radius: 10px; display: block; cursor: zoom-in; margin-bottom: 5px; }
.msg-media-video { max-width: 340px; max-height: 320px; border-radius: 10px; display: block; margin-bottom: 5px; }
.msg-media-audio { width: 260px; max-width: 100%; height: 38px; margin-bottom: 4px; }

.msg-file-card { display: flex; align-items: center; gap: 10px; background: rgba(0,0,0,0.16); padding: 9px 12px; border-radius: 10px; text-decoration: none; color: inherit; margin-bottom: 4px; }
.msg-file-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 19px; flex-shrink: 0; }
.msg-file-name { font-weight: 600; font-size: 13px; }
.msg-file-size { font-size: 11.5px; color: var(--text-sub); }

.poll-box { min-width: 240px; max-width: 340px; }
.poll-q { font-weight: 700; font-size: 14.5px; margin-bottom: 8px; }
.poll-opt { background: rgba(255,255,255,0.06); border: 1px solid rgba(139,158,194,0.25); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer; position: relative; overflow: hidden; display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.poll-opt.voted { border-color: var(--accent); }
.poll-bar { position: absolute; inset-block: 0; inset-inline-start: 0; background: rgba(59, 107, 255, 0.25); z-index: 0; transition: width .25s; }
.poll-opt span { position: relative; z-index: 1; }
.poll-footer { font-size: 11px; color: var(--text-sub); margin-top: 4px; }

.msg-footer { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 3px; font-size: 11px; color: var(--text-time); }
.msg-row.out .msg-footer { color: var(--text-time-out); }

.reactions-row { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.react-pill { background: rgba(59, 107, 255, 0.14); border: 1px solid transparent; border-radius: 12px; padding: 2px 7px; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.react-pill.me { background: rgba(59, 107, 255, 0.32); border-color: var(--accent); }

.upload-bar { background: var(--bg-header); padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12px; }
.upload-track { height: 5px; background: var(--bg-input); border-radius: 4px; margin-top: 5px; overflow: hidden; }
.upload-fill { height: 100%; width: 0%; background: var(--accent); transition: width .15s; }

.reply-bar { background: var(--bg-header); border-top: 1px solid var(--border); padding: 8px 14px; display: flex; align-items: center; gap: 10px; }
.reply-bar-accent { width: 3px; height: 32px; background: var(--accent); border-radius: 3px; }
.reply-bar-body { flex: 1; min-width: 0; }
.reply-bar-title { font-size: 12px; font-weight: 700; color: var(--accent); }
.reply-bar-text { font-size: 12.5px; color: var(--text-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.composer-wrap { background: var(--bg-header); border-top: 1px solid var(--border); position: relative; }
.channel-readonly { text-align: center; padding: 14px; color: var(--text-sub); font-size: 13px; }
.composer { display: flex; align-items: flex-end; gap: 6px; padding: 8px 12px; }
.composer-left, .composer-right { display: flex; align-items: center; gap: 2px; }
#msg-input { flex: 1; background: var(--bg-input); border: none; border-radius: 18px; padding: 10px 14px; font-size: 14px; max-height: 130px; resize: none; outline: none; line-height: 1.45; }
.send-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; border: none; font-size: 17px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.voice-btn.recording { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(239,83,80,0.6); }
  70% { box-shadow: 0 0 0 12px rgba(239,83,80,0); }
  100% { box-shadow: 0 0 0 0 rgba(239,83,80,0); }
}

.emoji-picker {
  position: absolute;
  bottom: 64px;
  inset-inline-start: 14px;
  width: 340px;
  max-width: calc(100vw - 28px);
  height: 310px;
  background: var(--bg-modal);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 30;
}
.emoji-tabs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255,255,255,0.03);
  gap: 2px;
}
.emoji-tab {
  background: none;
  border: none;
  padding: 5px 6px;
  border-radius: 9px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.65;
  transition: background .12s, opacity .12s;
}
.emoji-tab:hover, .emoji-tab.active {
  background: var(--bg-hover);
  opacity: 1;
}
.emoji-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  align-content: start;
}
.emoji-grid button {
  background: none;
  border: none;
  padding: 5px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s, transform .1s;
}
.emoji-grid button:hover {
  background: var(--bg-hover);
  transform: scale(1.18);
}

.apple-emoji {
  width: 1.3em;
  height: 1.3em;
  vertical-align: -0.25em;
  display: inline-block;
  object-fit: contain;
  pointer-events: none;
}
.emoji-grid .apple-emoji { width: 24px; height: 24px; }
.emoji-tab .apple-emoji  { width: 20px; height: 20px; }
.ctx-reactions .apple-emoji { width: 22px; height: 22px; }
.react-pill .apple-emoji { width: 16px; height: 16px; }

.info-panel { width: 310px; background: var(--bg-sidebar); border-inline-start: 1px solid var(--border); display: flex; flex-direction: column; z-index: 15; }
.info-header { height: 60px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; border-bottom: 1px solid var(--border); font-weight: 700; }
.info-body { flex: 1; overflow-y: auto; padding: 18px 16px; }
.info-card-top { text-align: center; margin-bottom: 18px; }
.info-card-top h3 { margin-top: 10px; font-size: 17px; }
.info-card-top p { font-size: 12.5px; color: var(--text-sub); margin-top: 3px; }
.info-row { background: var(--bg-input); padding: 10px 12px; border-radius: 10px; margin-bottom: 10px; font-size: 13px; }
.info-row-label { font-size: 11px; color: var(--text-sub); margin-bottom: 3px; }
.member-row { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px; }
.member-row:hover { background: var(--bg-hover); }
.role-tag { margin-inline-start: auto; font-size: 11px; color: var(--accent); }

.ctx-menu { position: fixed; background: var(--bg-modal); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 6px; min-width: 190px; box-shadow: var(--shadow); z-index: 200; }
.ctx-reactions { display: flex; justify-content: space-around; padding: 4px 2px 8px; border-bottom: 1px solid var(--border-subtle); margin-bottom: 4px; }
.ctx-reactions button { background: none; border: none; font-size: 18px; cursor: pointer; border-radius: 6px; padding: 2px 4px; }
.ctx-reactions button:hover { background: var(--bg-hover); transform: scale(1.18); }
.ctx-item { width: 100%; background: none; border: none; padding: 8px 10px; border-radius: 8px; display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; text-align: start; }
.ctx-item:hover { background: var(--bg-hover); }
.ctx-item.danger { color: #ef5350; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 300; }
.modal-box { width: 100%; max-width: 440px; max-height: 88vh; background: var(--bg-modal); border: 1px solid var(--border-subtle); border-radius: 16px; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border-subtle); }
.modal-body { padding: 16px 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.88); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 20px; }
.lightbox img { max-width: 95%; max-height: 92vh; border-radius: 8px; }
.lightbox-close { position: absolute; top: 18px; inset-inline-end: 22px; background: rgba(255,255,255,0.15); color: #fff; border: none; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; cursor: pointer; }

.mobile-only { display: none; }

@media (max-width: 820px) {
  .mobile-only { display: inline-flex; }
  .sidebar { width: 100%; max-width: none; position: absolute; inset: 0; }
  .chat-pane { width: 100%; position: absolute; inset: 0; transform: translateX(100%); transition: transform .2s ease; }
  html[dir="rtl"] .chat-pane { transform: translateX(-100%); }
  .app-shell.mobile-chat-open .chat-pane { transform: translateX(0); z-index: 20; }
  .info-panel { position: fixed; inset: 0; width: 100%; z-index: 35; }
  .msg-row { max-width: 88%; }
  .messages-wrap { padding: 12px 10px; }
}


/* ================= WEBRTC VIDEO & VOICE CALLING ================= */
.incoming-call-card {
  position: fixed;
  top: 20px;
  inset-inline-end: 20px;
  z-index: 900;
  background: rgba(14, 22, 46, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(95, 145, 255, 0.45);
  border-radius: 18px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  min-width: 290px;
}
.inc-pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4dcd5e;
  box-shadow: 0 0 0 0 rgba(77, 205, 94, 0.7);
  animation: pulse 1.2s infinite;
  flex-shrink: 0;
}
.inc-info { flex: 1; }
.inc-name { font-weight: 700; font-size: 15px; color: #fff; }
.inc-type { font-size: 12px; color: #8eb6ff; margin-top: 2px; }
.inc-actions { display: flex; gap: 8px; }
.call-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.call-btn.accept { background: #3ba55d; }
.call-btn.reject { background: #e53935; }

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 850;
  background: #060a16;
  display: flex;
  flex-direction: column;
  color: #fff;
  transition: all .22s ease;
}
.call-overlay.minimized {
  inset: auto 20px 20px auto;
  width: 320px;
  height: 220px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(95, 145, 255, 0.45);
  box-shadow: 0 14px 42px rgba(0,0,0,0.65);
}
.call-overlay.minimized #call-local-video,
.call-overlay.minimized #btn-call-flip,
.call-overlay.minimized #btn-call-screen,
.call-overlay.minimized #btn-call-fs { display: none; }

.call-top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  padding: 16px 22px;
  background: linear-gradient(to bottom, rgba(6,10,22,0.85), transparent);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.call-peer-name { font-size: 17px; font-weight: 700; }
.call-status { font-size: 12.5px; color: #96baff; margin-top: 2px; }
.call-top-right { display: flex; align-items: center; gap: 8px; }
.call-timer {
  background: rgba(255,255,255,0.12);
  padding: 4px 10px;
  border-radius: 10px;
  font-family: monospace;
  font-size: 13px;
}
.call-top-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
}

.call-stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#call-remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #060a16;
}
.call-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: radial-gradient(circle, #142454 0%, #070b18 70%);
}
.call-ph-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
  animation: logoGlowPulse 3s ease-in-out infinite;
}
.call-ph-name { font-size: 20px; font-weight: 700; }

#call-local-video {
  position: absolute;
  bottom: 96px;
  inset-inline-end: 22px;
  width: 185px;
  height: 130px;
  object-fit: cover;
  border-radius: 14px;
  border: 2px solid rgba(95, 145, 255, 0.55);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  background: #0d152a;
  z-index: 6;
}

.call-controls {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 7;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(14, 22, 46, 0.78);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(160, 190, 255, 0.22);
  padding: 10px 18px;
  border-radius: 40px;
}
.call-ctrl {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.12);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  transition: transform .12s, background .15s;
}
.call-ctrl:hover { background: rgba(255,255,255,0.22); transform: scale(1.06); }
.call-ctrl.off { background: rgba(239, 83, 80, 0.35); color: #ff9a98; }
.call-ctrl.active { background: #2557D6; }
.call-ctrl.end { background: #e53935; width: 54px; height: 54px; transform: rotate(135deg); }
.call-ctrl.end:hover { background: #d32f2f; transform: rotate(135deg) scale(1.06); }

@media (max-width: 640px) {
  #call-local-video { width: 118px; height: 158px; bottom: 92px; inset-inline-end: 12px; }
  .call-controls { gap: 8px; padding: 8px 12px; }
  .call-ctrl { width: 44px; height: 44px; font-size: 18px; }
}


/* ================= NOTIFICATIONS UI ================= */
.notif-perm-bar {
  background: rgba(37, 87, 214, 0.16);
  border-bottom: 1px solid rgba(95, 145, 255, 0.25);
  padding: 9px 12px;
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.notif-perm-actions { display: flex; align-items: center; gap: 8px; }
.btn-notif-ok {
  background: linear-gradient(135deg, #2557D6, #1E3A9A);
  color: #fff;
  border: none;
  border-radius: 9px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn-notif-x {
  background: none;
  border: none;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 13px;
}

.msg-notif-stack {
  position: fixed;
  top: 16px;
  inset-inline-end: 16px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
  width: calc(100vw - 32px);
  pointer-events: none;
}
.msg-notif-card {
  pointer-events: auto;
  background: rgba(14, 22, 46, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(95, 145, 255, 0.42);
  border-radius: 16px;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 11px;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.48);
  cursor: pointer;
  color: #fff;
  animation: notifSlideIn .22s ease;
}
@keyframes notifSlideIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.msg-notif-body { flex: 1; min-width: 0; }
.msg-notif-title { font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-notif-text { font-size: 12.5px; color: #b5c8eb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
