@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&display=swap');

/* ============================================================
   GameBuzzer User Guide — Isolated Styles (Cards version)
   جميع الأنماط معزولة تحت .gm- / .guide- / .help-fab
   ============================================================ */

:root {
  --gm-bg: #ffffff;
  --gm-text: #0f172a;
  --gm-text-muted: #64748b;
  --gm-border: #e2e8f0;
  --gm-soft: #f8fafc;
  --gm-purple: #7c3aed;
  --gm-purple-dark: #6d28d9;
  --gm-purple-light: #ede9fe;
  --gm-red: #ef4444;
  --gm-radius: 16px;
  --gm-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  --gm-font: 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* ----------------------------------------------------------------
   الزر العائم "كيف يعمل؟"
   ---------------------------------------------------------------- */
.help-fab {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 999px;
  background: var(--gm-purple);
  color: #fff;
  font-family: var(--gm-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px -4px rgba(124, 58, 237, 0.5);
  transition: background 0.2s ease, transform 0.2s ease;
}
.help-fab:hover,
.help-fab:focus-visible {
  background: var(--gm-purple-dark);
  transform: translateY(-1px);
  outline: none;
}
.help-fab__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 700;
  font-size: 13px;
}

/* نسخة inline داخل التخطيط (بدون floating) — أيقونة + نص */
.help-fab--inline {
  position: static;
  top: auto;
  left: auto;
  z-index: auto;
  padding: 6px 12px 6px 6px;
  height: 32px;
  border-radius: 999px;
  font-size: 13px;
  gap: 6px;
  box-shadow: 0 4px 12px -2px rgba(124, 58, 237, 0.4);
}
.help-fab--inline .help-fab__icon {
  width: 22px;
  height: 22px;
  background: rgba(255, 255, 255, 0.22);
  font-size: 13px;
}

/* للزاوية داخل بطاقة (مثل player join header) */
.help-fab--corner {
  position: absolute;
  top: 14px;
  left: 14px;
}
.player-join-header { position: relative; }

/* ----------------------------------------------------------------
   الرابط المدمج داخل بطاقة الصفحة الرئيسية
   ---------------------------------------------------------------- */
.guide-inline-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px dashed var(--gm-purple);
  border-radius: 12px;
  background: var(--gm-purple-light);
  color: var(--gm-purple-dark);
  font-family: var(--gm-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background 0.2s ease;
}
.guide-inline-link:hover,
.guide-inline-link:focus-visible {
  background: #ddd6fe;
  outline: none;
}
.guide-inline-link__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gm-purple);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* ----------------------------------------------------------------
   طبقة التعتيم والمودال
   ---------------------------------------------------------------- */
.gm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.6);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  font-family: var(--gm-font);
  color: var(--gm-text);
  direction: rtl;
}
.gm-overlay.gm-open {
  display: flex;
  animation: gm-fade-in 0.2s ease both;
}
@keyframes gm-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gm-modal {
  width: 100%;
  max-width: 820px;
  max-height: 92vh;
  background: var(--gm-bg);
  border-radius: var(--gm-radius);
  box-shadow: var(--gm-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: gm-pop-in 0.25s ease both;
}
@keyframes gm-pop-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ----------------------------------------------------------------
   الرأس
   ---------------------------------------------------------------- */
.gm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--gm-border);
  background: var(--gm-soft);
}
.gm-header__title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}
.gm-header__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--gm-purple);
  color: #fff;
  font-weight: 700;
  font-size: 18px;
}
.gm-header__text h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--gm-text);
}
.gm-header__text p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--gm-text-muted);
}
.gm-header__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--gm-border);
  border-radius: 10px;
  background: #fff;
  color: var(--gm-text);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}
.gm-header__close svg {
  width: 18px;
  height: 18px;
}
.gm-header__close:hover,
.gm-header__close:focus-visible {
  background: var(--gm-red);
  color: #fff;
  border-color: var(--gm-red);
  outline: none;
}

/* ----------------------------------------------------------------
   شريط التابات
   ---------------------------------------------------------------- */
.gm-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gm-border);
  overflow-x: auto;
}
.gm-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--gm-border);
  border-radius: 10px;
  background: #fff;
  color: var(--gm-text);
  font-family: var(--gm-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.gm-tab__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--gm-purple-light);
  color: var(--gm-purple-dark);
  font-size: 12px;
  font-weight: 700;
}
.gm-tab:hover {
  border-color: var(--gm-purple);
  color: var(--gm-purple-dark);
}
.gm-tab.gm-tab--active {
  background: var(--gm-purple);
  border-color: var(--gm-purple);
  color: #fff;
}
.gm-tab.gm-tab--active .gm-tab__num {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

/* ----------------------------------------------------------------
   جسم المودال
   ---------------------------------------------------------------- */
.gm-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* ترويسة الشاشة الحالية */
.gm-screen-header { margin-bottom: 16px; }
.gm-screen-step {
  font-size: 13px;
  color: var(--gm-text-muted);
  margin-bottom: 4px;
}
.gm-screen-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--gm-text);
  margin: 0 0 4px;
}
.gm-screen-desc {
  font-size: 13px;
  color: var(--gm-text-muted);
  margin: 0;
  line-height: 1.6;
}

/* قائمة البطاقات */
.gm-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 8px;
}

.gm-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--gm-soft);
  border: 1px solid var(--gm-border);
  border-radius: 12px;
  transition: border-color 0.15s, background 0.15s;
}
.gm-card:hover {
  border-color: var(--gm-purple);
  background: var(--gm-purple-light);
}

.gm-card__img-wrap {
  flex-shrink: 0;
  width: 160px;
  height: 100px;
  background: #fff;
  border: 1px solid var(--gm-border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.gm-card__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.gm-card__body { min-width: 0; flex: 1; }
.gm-card__title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gm-text);
  margin: 0 0 4px;
}
.gm-card__desc {
  font-size: 13px;
  color: var(--gm-text-muted);
  margin: 0;
  line-height: 1.6;
}

/* ----------------------------------------------------------------
   الفوتر
   ---------------------------------------------------------------- */
.gm-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--gm-border);
  background: var(--gm-soft);
  flex-wrap: wrap;
}
.gm-footer__left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.gm-btn {
  padding: 9px 18px;
  border: 1px solid var(--gm-border);
  border-radius: 10px;
  background: #fff;
  color: var(--gm-text);
  font-family: var(--gm-font);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.gm-btn:hover:not(:disabled) {
  border-color: var(--gm-purple);
  color: var(--gm-purple-dark);
}
.gm-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.gm-btn--primary {
  background: var(--gm-purple);
  color: #fff;
  border-color: var(--gm-purple);
}
.gm-btn--primary:hover:not(:disabled) {
  background: var(--gm-purple-dark);
  border-color: var(--gm-purple-dark);
  color: #fff;
}
.gm-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gm-text-muted);
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.gm-checkbox input {
  accent-color: var(--gm-purple);
  width: 16px;
  height: 16px;
}
.gm-dots {
  display: inline-flex;
  gap: 6px;
}
.gm-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gm-border);
  transition: background 0.2s ease, transform 0.2s ease;
}
.gm-dot.gm-dot--active {
  background: var(--gm-purple);
  transform: scale(1.25);
}

/* ----------------------------------------------------------------
   Responsive ≤ 640px
   ---------------------------------------------------------------- */
@media (max-width: 640px) {
  .gm-modal { max-height: 95vh; }
  .gm-header { padding: 14px 16px; }
  .gm-header__icon { width: 36px; height: 36px; font-size: 17px; }
  .gm-header__text h2 { font-size: 15px; }
  .gm-header__text p { font-size: 11px; }

  .gm-tabs { padding: 0 12px; }
  .gm-tab { padding: 12px 10px; font-size: 12px; }

  .gm-body { padding: 14px; }
  .gm-screen-title { font-size: 18px; }

  /* البطاقة تبقى أفقية لكن الصورة أصغر */
  .gm-card { padding: 10px; gap: 10px; }
  .gm-card__img-wrap { width: 110px; height: 76px; padding: 3px; }
  .gm-card__title { font-size: 13px; }
  .gm-card__desc { font-size: 12px; }

  .gm-footer {
    padding: 12px 14px;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 10px;
  }
  .gm-footer__left,
  .gm-footer__right {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .help-fab { padding: 8px 12px; font-size: 12px; }
  .help-fab__text { display: none; }
}

/* ----------------------------------------------------------------
   prefers-reduced-motion
   ---------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .gm-overlay,
  .gm-modal,
  .gm-card,
  .gm-btn,
  .gm-dot { transition: none !important; }
}
