/* ========== کامپوننت‌های تکراری ========== */

/* ----- وضعیت اتصال (دات) ----- */
.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot.offline { background: rgba(255,90,90,.7); }
.dot.online { background: rgba(110,231,183,.85); }

/* ----- نتایج جستجو ----- */
.search-results {
  position: absolute;
  top: 100%;
  left: 14px;
  right: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-top: 5px;
  max-height: 300px;
  overflow-y: auto;
  display: none;
  z-index: 1000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.search-results.show {
  display: block;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}
.search-result-item {
  padding: 12px;
  display: flex;
  align-items: center;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background-color 0.2s ease;
}
.search-result-item:hover { background: rgba(255,255,255,0.05); }
.search-result-item:last-child { border-bottom: none; }
.search-result-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(46,166,255,.9), rgba(110,231,183,.7));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #08131d;
  overflow: hidden;
  margin-left: 12px;
  flex-shrink: 0;
}
.search-result-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.search-result-info {
  flex: 1;
  min-width: 0;
}
.search-result-name {
  font-weight: 900;
  font-size: 14px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-result-username {
  color: var(--muted);
  font-size: 12px;
  direction: ltr;
  text-align: right;
}
.search-result-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.add-to-contacts-btn {
  margin-right: auto;
  padding: 6px 12px;
  font-size: 12px;
  background: rgba(46,166,255,0.1);
  border: 1px solid rgba(46,166,255,0.3);
  color: var(--primary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.add-to-contacts-btn:hover {
  background: rgba(46,166,255,0.2);
  transform: translateY(-1px);
}
.add-to-contacts-btn .btn-icon { font-size: 14px; }
.add-to-contacts-btn .btn-text { font-weight: 500; }

.already-in-contacts {
  margin-right: auto;
  padding: 6px 12px;
  font-size: 12px;
  background: rgba(110,231,183,0.1);
  border: 1px solid rgba(110,231,183,0.3);
  color: #6ee7b7;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  font-weight: 500;
}

/* ----- آیتم‌های اتاق ----- */
.room-item {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background-color 0.2s;
}
.room-item:hover { background: rgba(255,255,255,.04); }
.room-item.active { background: rgba(46,166,255,.12); }
.room-item .meta { color: var(--muted); font-size: 12px; }
.room-item.muted { color: var(--muted); cursor: default; }
.room-item.muted:hover { background: transparent; }
.room-item-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.room-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(46,166,255,.9), rgba(110,231,183,.7));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #08131d;
  overflow: hidden;
  flex-shrink: 0;
}
.room-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.room-avatar.group { background: linear-gradient(135deg, rgba(46,166,255,.9), rgba(110,231,183,.7)); }
.room-avatar.channel { background: linear-gradient(135deg, rgba(255,152,0,.9), rgba(255,193,7,.7)); }
.room-avatar.dm { background: linear-gradient(135deg, rgba(156,39,176,.9), rgba(233,30,99,.7)); }

.room-info {
  flex: 1;
  min-width: 0;
}
.room-name {
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}
.room-meta {
  color: var(--muted);
  font-size: 11px;
}
.room-id {
  color: var(--muted);
  font-size: 11px;
  margin-right: 5px;
  flex-shrink: 0;
}

.unread-badge {
  background-color: #4CAF50;
  color: white;
  border-radius: 50%;
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 900;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
  animation: pulse 2s infinite;
  margin-left: 8px;
  flex-shrink: 0;
}
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); }
}
.room-item.active .unread-badge {
  background-color: #ffffff;
  color: #4CAF50;
}

/* ----- مدال‌ها ----- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 2000;
}
.modal-card {
  width: min(520px, 95vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-weight: 900; }
.modal-body {
  padding: 12px 14px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}

/* ----- آیتم‌های مخاطبین ----- */
.contacts-item {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.contacts-item:hover { background-color: rgba(255,255,255,0.03); }
.contacts-item:last-child { border-bottom: none; }
.contacts-item-content {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.contacts-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(46,166,255,.9), rgba(110,231,183,.7));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #08131d;
  overflow: hidden;
  flex-shrink: 0;
  font-size: 18px;
}
.contacts-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.contacts-info {
  flex: 1;
  min-width: 0;
}
.contacts-name {
  font-weight: 900;
  font-size: 15px;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contacts-username {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
  direction: ltr;
  text-align: right;
}
.contacts-bio {
  color: var(--text);
  font-size: 13px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contacts-remove-btn {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,90,90,0.1);
  border: 1px solid rgba(255,90,90,0.3);
  color: #ff6b6b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all 0.2s ease;
  opacity: 0;
}
.contacts-item:hover .contacts-remove-btn { opacity: 1; }
.contacts-remove-btn:hover {
  background: rgba(255,90,90,0.2);
  transform: translateY(-50%) scale(1.1);
}

/* ----- بخش ویس (کامپوننت‌های ثابت) ----- */
.voice-recording-preview {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 15px;
  margin: 10px 12px;
  display: flex;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
}
.voice-waveform {
  flex: 1;
  height: 40px;
  background: rgba(255,255,255,0.03);
  border-radius: 20px;
  overflow: hidden;
  padding: 0 10px;
  display: flex;
  align-items: center;
}
.voice-waveform-bars {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  height: 100%;
}
.voice-waveform-bar {
  width: 3px;
  height: 10px;
  background: var(--primary);
  border-radius: 2px;
  animation: waveform 1.2s infinite alternate;
}
@keyframes waveform {
  0% { height: 10px; }
  100% { height: 30px; }
}
.voice-waveform-bar:nth-child(2) { animation-delay: 0.1s; }
.voice-waveform-bar:nth-child(3) { animation-delay: 0.2s; }
.voice-waveform-bar:nth-child(4) { animation-delay: 0.3s; }
.voice-waveform-bar:nth-child(5) { animation-delay: 0.4s; }
.voice-waveform-bar:nth-child(6) { animation-delay: 0.5s; }
.voice-waveform-bar:nth-child(7) { animation-delay: 0.6s; }
.voice-waveform-bar:nth-child(8) { animation-delay: 0.7s; }

.voice-recording-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.voice-recording-timer {
  font-size: 14px;
  font-weight: 900;
  color: var(--primary);
  min-width: 45px;
}
.voice-send-btn,
.voice-cancel-btn {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}
.voice-send-btn {
  background: var(--primary);
  color: #fff;
}
.voice-send-btn:hover { background: #1e90ff; }
.voice-cancel-btn {
  background: rgba(255,90,90,0.1);
  color: #ff6b6b;
  border: 1px solid rgba(255,90,90,0.3);
}
.voice-cancel-btn:hover { background: rgba(255,90,90,0.2); }

/* ----- المان‌های وضعیت (برای پنل ادمین – اختیاری) ----- */
/* این بخش در app.php استفاده نمی‌شود و فقط برای حفظ یکپارچگی منتقل شده است */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 10px 0; }
.row { display: flex; gap: 10px; margin-top: 10px; }
.row > * { flex: 1; }
hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.table { border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.thead, .trow { display: grid; }
.thead {
  background: rgba(255,255,255,.04);
  color: var(--muted);
  font-size: 12px;
}
.thead > div, .trow > div {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.trow:last-child > div { border-bottom: 0; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.thead.uploads, .trow.uploads { grid-template-columns: 1.6fr .7fr .7fr .5fr .9fr .5fr; }
.thead.rooms, .trow.rooms { grid-template-columns: 1.5fr .7fr .6fr .9fr .5fr; }