/* ═══════════════════════════════════════════════
   MAIN.CSS — الأساسيات والخلفية والهيدر
   ═══════════════════════════════════════════════ */

/* ───── المتغيرات ───── */
:root {
  /* الألوان الأساسية */
  --bg-deep: #05071a;
  --bg-dark: #0a0e27;
  --bg-mid: #141a3a;
  --bg-light: #1e2650;

  /* الألوان المميزة */
  --primary: #5b6ef5;
  --primary-glow: rgba(91, 110, 245, 0.5);
  --accent: #00e5ff;
  --accent-glow: rgba(0, 229, 255, 0.6);
  --success: #00ff88;
  --success-glow: rgba(0, 255, 136, 0.6);
  --danger: #ff4757;
  --danger-glow: rgba(255, 71, 87, 0.5);
  --warning: #ffa502;
  --crown: #ffd700;

  /* النصوص */
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.7);
  --text-tertiary: rgba(255, 255, 255, 0.45);

  /* الزجاج */
  --glass-bg: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-hover: rgba(255, 255, 255, 0.1);

  /* الظلال */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.6);

  /* الحواف */
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-full: 999px;

  /* الانتقالات */
  --transition-fast: 0.15s ease;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ───── إعادة الضبط ───── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  direction: rtl;
  font-size: 15px;
  line-height: 1.5;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  position: relative;
  display: flex;
  flex-direction: column;
}

/* ───── الخلفية المتحركة ───── */
.bg-blur {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background: radial-gradient(ellipse at top, #0a0e27 0%, #05071a 100%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  will-change: transform;
}

.blob-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #5b6ef5 0%, transparent 70%);
  top: -100px;
  right: -100px;
  animation: blobFloat1 20s ease-in-out infinite;
}

.blob-2 {
  width: 350px;
  height: 350px;
  background: radial-gradient(circle, #00e5ff 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  animation: blobFloat2 25s ease-in-out infinite;
}

.blob-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #a855f7 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: blobFloat3 30s ease-in-out infinite;
}

/* ───── الهيدر ───── */
.header {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 60px 1fr 60px;
  align-items: center;
  padding: 16px 18px;
  padding-top: max(16px, env(safe-area-inset-top));
  background: rgba(10, 14, 39, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
}

.header-right {
  display: flex;
  justify-content: flex-start;
}

.header-center {
  text-align: center;
  min-width: 0;
}

.header-left {
  display: flex;
  justify-content: flex-end;
}

.user-count-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 4px 15px var(--primary-glow);
}

.count-dot {
  width: 7px;
  height: 7px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 8px #fff;
  animation: dotPulse 2s ease-in-out infinite;
}

.room-title {
  font-size: 17px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, #b0bcff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  margin: 0 auto;
}

.room-subtitle {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-btn {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}

.menu-btn:active {
  background: var(--glass-hover);
  transform: scale(0.94);
}

/* ───── شبكة المستخدمين ───── */
.users-grid {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 16px 160px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 16px;
  align-content: start;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--glass-border) transparent;
}

.users-grid::-webkit-scrollbar {
  width: 4px;
}

.users-grid::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 4px;
}

/* ───── شاشة مشاركة الشاشة ───── */
.screen-share-container {
  position: fixed;
  top: 90px;
  left: 12px;
  right: 12px;
  height: 240px;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  z-index: 5;
  box-shadow: var(--shadow-lg), 0 0 0 2px var(--accent);
  animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen-share-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.screen-share-header {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 2;
}

.sharer-name {
  padding: 5px 12px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.live-badge {
  padding: 4px 10px;
  background: var(--danger);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  animation: livePulse 1.5s ease-in-out infinite;
}

/* ───── Toast Notifications ───── */
.toast-container {
  position: fixed;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  background: rgba(20, 26, 58, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.info    { border-color: var(--accent);  color: var(--accent); }

/* ───── منع Zoom و Select ───── */
button, input, video {
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input {
  font-family: inherit;
}
