/* quiz_select.css — أنماط خاصة بتحدي الأسئلة
  */

body.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.footer { margin-top: auto; }

/* Header */
.site-header {
  display: flex;
  justify-content: center;
  align-items: center;
  max-width: 1200px;
  margin: 20px auto;
  padding: 20px;
  background: rgba(0,0,0,0.25);
  border-radius: 12px;
  text-align: center;
}
.logo {
  margin-left: 12px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: var(--primary);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
}
.logo img { width: 100%; height: 100%; object-fit: cover; }

.brand h1 { margin: 0; font-size: 1.6rem; color: var(--secondary); }
.brand .subtitle { margin: 6px 0 0; color: var(--muted); font-size: 1rem; }

/* Back button */
.back-home {
  position: absolute;
  top: 15px;
  right: 20px;
  background: var(--primary);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
}
.back-home:hover { background: #8c2502; }

/* فرق + زر البدء */
.teams-section { max-width: 800px; margin: 20px auto; text-align: center; }
.teams-inputs { display: flex; gap: 20px; justify-content: center; margin-bottom: 16px; flex-wrap: wrap; }
.team-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
  min-width: 220px;
  background: rgba(255,255,255,0.08);
  padding: 14px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.team-field label {
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}
.team-field input {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--secondary);
  background: #fff;
  color: #000;
  width: 100%;
  font-size: 1rem;
}

/* Start button */
#startBtn {
  font-size: 1.2rem;
  padding: 14px 28px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  transition: transform .2s, box-shadow .2s;
}
#startBtn:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  background: #811f00;
}

/* Picker */
.picker { text-align: center; margin-top: 30px; }
.categories-list { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; margin: 20px 0; }

/* أقسام التصنيفات */
.category-group {
  background: var(--card);
  padding: 20px;
  border-radius: 16px;
  width: 100%;                 /* ياخذ عرض الشاشة */
  margin-bottom: 30px;         /* مسافة بين كل مجموعة */
  box-shadow: 0 6px 18px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  align-items: flex-start;     /* العنوان والبطاقات بمحاذاة اليمين */
}
.category-group:hover {
  transform: translateY(-6px);
  box-shadow: 0 10px 26px rgba(0,0,0,0.35);
}
.category-group h4 {
  margin: 0 0 16px;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
  width: 100%;
}


/* زر التصنيف الفرعي */
.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  width: 100%;
}
.cat-item {
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--secondary);
  border: none;
  font-weight: 700;
  cursor: pointer;
  color: #000;
  transition: all .2s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.cat-item:hover {
  background: #f7e3b3;
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.25);
}
.cat-item.selected {
  background: var(--primary);
  color: #fff;
  transform: translateY(-3px) scale(1.07);
  box-shadow: 0 6px 16px rgba(0,0,0,0.3);
}

/* Toasts */
#toastHost {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
#toastHost .toast {
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0,0,0,.4);
  transition: all .35s;
}

/* ✨ تأثير فوز الفريق */
.team-score-value.glow { animation: glowFlash 1.2s ease-out; }
@keyframes glowFlash {
  0%   { text-shadow: 0 0 0px gold, 0 0 0px gold; color: var(--secondary); }
  40%  { text-shadow: 0 0 12px gold, 0 0 24px gold; color: #FFD700; }
  100% { text-shadow: 0 0 0px gold, 0 0 0px gold; color: var(--secondary); }
}

.cat-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.sub-card {
  position: relative;
  flex: 0 1 calc(25% - 16px);  /* أربع بطاقات بالصف تقريبًا */
  aspect-ratio: 1 / 1;         /* يحافظ على التربيع */
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  transition: transform 0.2s ease;
  max-width: 200px;            /* ما يتجاوز 200px */
  min-width: 120px;            /* أصغر شي على الموبايل */
}
.sub-card:hover {
  transform: scale(1.05);
}
.sub-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sub-card .sub-name {
  position: absolute;
  bottom: 0;
  width: 100%;
  background: rgba(0,0,0,0.6);
  color: #fff;
  text-align: center;
  font-size: 16px;
  padding: 5px;
}
.sub-card.disabled {
  opacity: 0.4;
  pointer-events: none;
}
.sub-card.selected {
  outline: 4px solid #AD3103; /* لون الثيم */
}
/* شارة عدد المرّات فوق بطاقة التصنيف */
.sub-card .sub-badge {
  position: absolute;
  top: 8px;
  right: 8px;           /* RTL: يمين */
  background: #AD3103;  /* لون الثيم */
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
  pointer-events: none; /* ما تمنع الضغط على البطاقة */
}
/* ============================================= */
/* 📱 تحسينات مظهر التطبيق على الجوال والتابلت */
/* ============================================= */

/* 🧠 القاعدة العامة للجوال */
@media (max-width: 767px) {
  body.layout {
    background: var(--background);
    padding: 0;
  }

  /* 🔹 زر العودة يصبح دائري داخل شريط علوي */
  .back-home {
    top: 10px;
    right: 10px;
    padding: 10px 12px;
    font-size: 0.9rem;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
  }

  /* 🔹 الهيدر */
  .site-header {
    flex-direction: column;
    background: transparent;
    box-shadow: none;
    padding: 10px 0;
    margin: 60px 0 10px;
  }

  .logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 10px;
  }

  .brand h1 {
    font-size: 1.3rem;
  }
  .brand .subtitle {
    font-size: 0.9rem;
  }

  /* 🔹 قسم الفرق */
  .teams-section {
    margin: 10px auto;
    padding: 0 12px;
  }
  .teams-inputs {
    flex-direction: column;
    gap: 12px;
  }
  .team-field {
    width: 100%;
    padding: 12px;
  }
  .team-field input {
    font-size: 1rem;
  }

  /* زر البدء */
  #startBtn {
    width: 100%;
    font-size: 1.1rem;
    padding: 14px 0;
    border-radius: 10px;
  }

  /* 🔹 التصنيفات */
  .category-group {
    padding: 16px;
    border-radius: 12px;
  }
  .category-group h4 {
    font-size: 1.2rem;
  }
  .category-list {
    justify-content: center;
  }
  .sub-card {
    flex: 0 1 calc(45% - 10px);  /* بطاقتين بالصف */
    max-width: none;
    min-width: 120px;
  }
  .sub-card .sub-name {
    font-size: 14px;
    padding: 4px;
  }

  /* 🔹 Toasts */
  #toastHost .toast {
    font-size: 0.9rem;
    padding: 8px 10px;
  }

  /* 🔹 الفوتر */
  .footer {
    font-size: 0.8rem;
    padding: 10px 0;
    background: rgba(0,0,0,0.3);
  }
}

/* 💻 التابلت */
@media (min-width: 768px) and (max-width: 1024px) {
  .site-header {
    flex-direction: row;
    justify-content: center;
    gap: 20px;
    padding: 14px;
  }
  .logo {
    width: 100px;
    height: 100px;
  }
  .brand h1 { font-size: 1.5rem; }
  .brand .subtitle { font-size: 1rem; }

  .teams-section {
    max-width: 600px;
  }

  .category-list {
    justify-content: center;
  }
  .sub-card {
    flex: 0 1 calc(30% - 14px); /* ثلاث بطاقات في الصف */
  }
}
/* ============================
   Modal إدخال الكود — إضافة جديدة
   لا تغيّر أي عناصر قائمة
   ============================ */
.modal.is-hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.modal-dialog {
  position: relative;
  width: min(520px, 92vw);
  background: var(--card, #FFF5E1);
  color: var(--text, #000);
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(0,0,0,.35);
  padding: 18px 18px 14px;
  z-index: 1;
}
.modal-close {
  position: absolute;
  top: 6px;
  left: 8px; /* RTL */
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,0.08);
  font-size: 20px;
  line-height: 36px;
  cursor: pointer;
}
.modal-header h3 {
  margin: 0 0 6px;
  color: var(--primary, #AD3103);
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
}
.modal-sub {
  margin: 0 0 10px;
  color: var(--dark, #2b0a00);
  opacity: .85;
  text-align: center;
  font-size: .95rem;
}
.modal-body { margin-top: 6px; }
.redeem-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 14px;
}
.redeem-field label {
  font-size: .9rem;
  font-weight: 700;
  color: var(--primary, #AD3103);
}
#redeemInput {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--secondary, #EBCE8F);
  background: #fff;
  color: #000;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-align: center;
}
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}
.btn.ghost {
  background: transparent;
  color: var(--primary, #AD3103);
  border: 1px solid rgba(0,0,0,.15);
}
.modal-footer-hint {
  margin-top: 10px;
  text-align: center;
  font-size: .95rem;
  color: var(--dark, #2b0a00);
}
.modal-footer-hint a {
  font-weight: 800;
  text-decoration: none;
}
.redeem-feedback {
  margin-top: 10px;
  text-align: center;
  min-height: 22px;
  font-weight: 700;
}
@media (max-width: 767px) {
  .modal-dialog { padding: 16px 14px 12px; border-radius: 14px; }
  .modal-header h3 { font-size: 1.05rem; }
  .modal-sub { font-size: .9rem; }
  #redeemInput { font-size: 1rem; }
}
/* 🎨 تحسين تباين ألوان المودال */
.modal-dialog {
  background: #FFF2C6; /* أدفأ قليلاً وأغمق من الأبيض السابق */
  color: #2b0a00;      /* نص غامق واضح */
}

.modal-header h3,
.modal-sub,
.redeem-field label,
.modal-footer-hint,
.redeem-feedback {
  color: #2b0a00 !important; /* توحيد لون النصوص للوضوح */
}

/* النص السفلي "❌ الكود غير صالح" */
.redeem-feedback {
  font-weight: 700;
  color: #B00020 !important; /* أحمر واضح */
  text-shadow: 0 0 2px rgba(255,255,255,0.5);
}

/* النص "ما عندك كود؟ اشترِ كودًا الآن 🔑" */
.modal-footer-hint a {
  color: #5a2c00 !important;
  text-decoration: underline;
}

/* الزر الرئيسي */
.modal-actions .btn.primary {
  background: var(--primary, #AD3103);
  color: #fff;
}
.modal-actions .btn.primary:hover {
  background: #8c2502;
}
