/* ═══════════════════════════════════════════════
   COMPONENTS.CSS — الأزرار، البطاقات، النوافذ
   ═══════════════════════════════════════════════ */

/* ═══ بطاقة المستخدم ═══ */
.user-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.user-card:active {
  transform: scale(0.96);
  background: var(--glass-hover);
}

/* حلقة التوهج حول الصورة */
.user-avatar-wrap {
  position: relative;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-avatar-wrap::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid transparent;
  transition: var(--transition);
}

.user-card.speaking .user-avatar-wrap::before {
  border-color: var(--success);
  box-shadow:
    0 0 0 2px rgba(0, 255, 136, 0.3),
    0 0 20px var(--success-glow),
    inset 0 0 15px rgba(0, 255, 136, 0.2);
  animation: speakingPulse 1.4s ease-in-out infinite;
}

.user-card.speaking .user-avatar-wrap::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--success);
  opacity: 0.5;
  animation: speakingRipple 1.6s ease-out infinite;
}

.user-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: block;
  position: relative;
  z-index: 1;
}

.user-card.muted .user-avatar {
  filter: grayscale(0.5) brightness(0.7);
  border: 2px solid var(--danger);
}

.user-card.banned {
  opacity: 0.4;
  pointer-events: none;
}

/* اسم المستخدم */
.user-name {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  color: var(--text-primary);
}

/* حالة المايك */
.user-status {
  font-size: 10px;
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.user-status.muted {
  color: var(--danger);
}

.user-status.speaking {
  color: var(--success);
}

/* شارة الأدمن */
.user-card.is-admin::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  width: 20px;
  height: 20px;
  background: url('../../../public/icons/crown.svg') center/contain no-repeat;
  filter: drop-shadow(0 0 6px var(--crown));
  z-index: 2;
}

/* ═══ الأزرار السفلية ═══ */
.controls {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(5, 7, 26, 0.98), rgba(5, 7, 26, 0));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 15;
}

.control-btn {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  color: #fff;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.control-btn:active {
  transform: scale(0.9);
}

.control-btn .icon {
  width: 26px;
  height: 26px;
  filter: brightness(0) invert(1);
  transition: var(--transition);
}

/* الأزرار الجانبية (مكبر + مشاركة) */
.control-side {
  width: 54px;
  height: 54px;
}

.control-side.active {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-color: transparent;
  box-shadow: 0 0 25px var(--primary-glow);
}

/* زر المايك (الأكبر) */
.control-mic {
  width: 74px;
  height: 74px;
  background: linear-gradient(135deg, #5b6ef5, #00e5ff);
  border: none;
  box-shadow:
    0 6px 30px var(--primary-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  position: relative;
}

.control-mic .icon {
  width: 30px;
  height: 30px;
  z-index: 2;
}

.control-mic.muted {
  background: linear-gradient(135deg, #ff4757, #cc0000);
  box-shadow:
    0 6px 30px var(--danger-glow),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* حلقة النبض حول المايك (تظهر عند التحدث) */
.mic-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid transparent;
  pointer-events: none;
  transition: var(--transition);
}

.control-mic.speaking .mic-ring {
  border-color: var(--success);
  box-shadow:
    0 0 20px var(--success-glow),
    inset 0 0 20px rgba(0, 255, 136, 0.2);
  animation: micPulse 1.2s ease-in-out infinite;
}

.control-mic.speaking::after {
  content: '';
  position: absolute;
  inset: -15px;
  border-radius: 50%;
  border: 2px solid var(--success);
  opacity: 0;
  animation: micRipple 1.5s ease-out infinite;
}

/* زر المغادرة */
.control-leave {
  width: 54px;
  height: 54px;
  background: linear-gradient(135deg, #ff4757, #cc0000);
  border-color: transparent;
  box-shadow: 0 4px 20px var(--danger-glow);
}

/* ═══ زر إلغاء مشاركة الشاشة ═══ */
.stop-share-btn {
  position: fixed;
  bottom: 130px;
  right: 20px;
  padding: 10px 18px;
  background: linear-gradient(135deg, #ff4757, #cc0000);
  border-radius: var(--radius-full);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 25px var(--danger-glow);
  z-index: 20;
  cursor: pointer;
  transition: var(--transition);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stop-share-btn:active {
  transform: scale(0.95);
}

.stop-share-btn img {
  filter: brightness(0) invert(1);
}

/* ═══ النوافذ المنبثقة ═══ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.modal-sheet {
  width: 100%;
  max-width: 500px;
  background: linear-gradient(180deg, #141a3a 0%, #0a0e27 100%);
  border-radius: 28px 28px 0 0;
  padding: 12px 16px 24px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--glass-border);
  animation: sheetSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 85vh;
  overflow-y: auto;
}

.modal-handle {
  width: 44px;
  height: 5px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  margin: 0 auto 16px;
}

.modal-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 16px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  text-align: right;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  margin-bottom: 4px;
}

.modal-item:active {
  background: var(--glass-hover);
  transform: scale(0.98);
}

.modal-item svg,
.modal-item img {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

.modal-item-close {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  margin-top: 8px;
  color: var(--danger);
}

.modal-item-close svg,
.modal-item-close img {
  filter: brightness(0) saturate(100%) invert(45%) sepia(80%) saturate(3000%) hue-rotate(330deg);
}

/* ═══ رأس معلومات المستخدم ═══ */
.user-info-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  margin-bottom: 12px;
}

.user-info-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}

.user-info-name {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 3px;
}

.user-info-status {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ═══ نافذة الإدخال ═══ */
.modal-dialog {
  background: linear-gradient(180deg, #141a3a 0%, #0a0e27 100%);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  width: 90%;
  max-width: 380px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg);
  animation: dialogPop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 20vh;
}

.modal-overlay:has(.modal-dialog) {
  align-items: center;
}

.dialog-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
  background: linear-gradient(135deg, #fff, #b0bcff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dialog-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 15px;
  margin-bottom: 16px;
  transition: var(--transition);
}

.dialog-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.dialog-actions {
  display: flex;
  gap: 10px;
}

.dialog-actions-column {
  flex-direction: column;
}

.dialog-btn {
  flex: 1;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  color: #fff;
  font-family: inherit;
}

.dialog-btn:active {
  transform: scale(0.97);
}

.dialog-btn-primary {
  background: linear-gradient(135deg, #5b6ef5, #00e5ff);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.dialog-btn-danger {
  background: linear-gradient(135deg, #ff4757, #cc0000);
  box-shadow: 0 4px 15px var(--danger-glow);
}

.dialog-btn-cancel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
}

.dialog-btn-ok {
  background: linear-gradient(135deg, #5b6ef5, #00e5ff);
  box-shadow: 0 4px 15px var(--primary-glow);
}

/* ═══ حالات خاصة ═══ */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ═══════════════════════════════════════════════
   FIX — منع تراكب الأزرار
   ═══════════════════════════════════════════════ */

.controls {
  pointer-events: none;
}

.controls > * {
  pointer-events: auto;
}

/* الهيدر — فوق العناصر الأخرى */
.header {
  z-index: 25;
}

/* زر القائمة */
.menu-btn {
  z-index: 26;
  position: relative;
}

/* شاشة المشاركة — تحتها */
.screen-share-container {
  z-index: 5;
}

/* شبكة المستخدمين — فوق شاشة المشاركة */
.users-grid {
  position: relative;
  z-index: 10;
}

/* الأزرار السفلية — فوق الكل */
.control-btn {
  z-index: 20;
}
