/* ==========================================================
   style.css - النسخة المنسقة الكاملة مع تثبيت الهيدر في الموبايل
   - لا تغير في وظائف الكود، فقط تنظيم وتعليقات وصياغة الموباعة
   - إذا أردت تعديل ارتفاع الهيدر في الموبايل عدّل قيمة padding-top في الـ media query
   ========================================================== */

/* ==========================================================
   🔹 استيراد الخطوط (Google Fonts)
   ========================================================== */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;700;900&display=swap');


/* ==========================================================
   🔹 القواعد العامة للموقع (أساسيات)
   ========================================================== */
body {
  font-family: 'Cairo', sans-serif;
  background: #0f0f0f;
  color: #fff;
  margin: 0;
  padding: 0;
  overflow-x: hidden; /* يمنع تمدد الصفحة أفقيًا */
}

/* ==========================================================
   🔹 الهيدر (Header)
   - يحتوي على العنوان والقوائم وأزرار التحكم
   - مبدئياً يستخدم position: sticky (يُلغى على الموبايل عبر media query)
   ========================================================== */
.main-header {
  background: #009691;
  padding: 0.5rem 0; /* مسافة رأسية داخل الهيدر */
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);

  /* سلوك الهيدر على الشاشات الكبيرة: يبقى عند الوصول له (sticky) */
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* توزيع المحتوى داخل الهيدر */
.header-left,
.header-right {
  flex: 1;
}

.header-center {
  flex: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* محاذاة الجانبين */
.header-left {
  display: flex;
  justify-content: flex-start;
  padding-right: 1rem;
}

.header-right {
  display: flex;
  justify-content: flex-end;
  padding-left: 1rem;
}

/* عنوان الموقع */
.header-title {
  margin: 0;
  font-size: 1.6em;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(45deg, #ffd700, #ff8c00, #fff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-animation 5s ease infinite;
  line-height: 1.3;
}

/* حركة تدرج الألوان في العنوان */
@keyframes gradient-animation {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* روابط صغيرة تحت العنوان (الروابط الفرعية) */
.header-sub-links {
  display: flex;
  gap: 15px;
  margin-top: 2px;
}

.header-sub-links a {
  color: white;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.9em;
  transition: color 0.3s;
}

.header-sub-links a:hover {
  color: #ffd700;
}

/* خانة اختيار اللغة أو أي select في اليسار */
.header-left select {
  background: #1a1a1a;
  color: white;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 4px;
  font-weight: bold;
}

/* زر القائمة (hamburger) للموبايل */
.menu-toggle {
  background: transparent;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 0.5rem;
}


/* ==========================================================
   🔹 القائمة المنسدلة (Mobile Navigation)
   - تظهر فقط في الموبايل عند إضافة الكلاس .is-open
   ========================================================== */
#mobile-nav {
  display: none;
  flex-direction: column;
  position: absolute;
  top: calc(100% + 5px); /* أسفل الهيدر مباشرة */
  left: 0.5rem;            /* محاذاة مع حافة الهيدر اليسرى */
  right: auto;
  width: max-content;
  min-width: 150px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: #009691;
  border: 1px solid rgba(255,255,255,0.3);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 0.5rem 0;
  box-shadow: 0 8px 15px rgba(0,0,0,0.4);
  z-index: 999;
}

#mobile-nav.is-open { display: flex; }

#mobile-nav a {
  color: white;
  text-decoration: none;
  padding: 0.9rem 1.5rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  transition: background 0.3s;
}

#mobile-nav a:last-child { border-bottom: none; }
#mobile-nav a:hover { background: rgba(0, 0, 0, 0.2); }


/* ==========================================================
   🔹 الفوتر (Footer)
   ========================================================== */
.main-footer {
  background: #009691;
  color: white;
  text-align: center;
  padding: 1.5rem 1rem;
  margin-top: 3rem;
}

.footer-links a {
  color: white;
  text-decoration: none;
  margin: 0 10px;
  font-weight: bold;
}

.footer-copyright {
  margin-top: 1rem;
  padding-top: 1rem;
  font-size: 0.9em;
  opacity: 0.8;
  border-top: 1px solid rgba(255, 255, 255, 0.3);
}


/* ==========================================================
   🔹 الصفحات الداخلية (أقسام عامة)
   ========================================================== */

/* صفحة تسجيل الدخول / التسجيل */
.auth {
  max-width: 400px;
  margin: 2rem auto;
  padding: 1rem;
  background: #1a1a1a;
  border-radius: 30px;
}

.auth-box input {
  width: 93%;
  padding: 0.8rem;
  margin: 0.5rem 0;
  border: 1px solid #444;
  border-radius: 15px;
  background: #333;
  color: white;
}

.auth-box button {
  width: 100%;
  padding: 0.8rem;
  margin: 1rem 0;
  background: #ff6600;
  color: white;
  border: none;
  border-radius: 15px;
  cursor: pointer;
  transition: opacity 0.3s;
}
.auth-box button:hover { opacity: 0.9; }
.auth-box a { color: #ff6600; }


/* صفحة المتجر */
.store {
  max-width: 100%;
  padding: 1rem;
}

.items-scroll {
  overflow-y: auto;
  height: 500px;
  padding: 1rem 0;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  padding-bottom: 1rem;
}

.item-card {
  background: #2a2a2a;
  border-radius: 20px;
  padding: 1rem;
  text-align: center;
  transition: transform 0.3s;
}
.item-card:hover { transform: translateY(-5px); }

.token-img { width: 80px; height: 80px; margin: 0 auto; }

.buy-btn {
  background: #ff6600;
  color: white;
  border: none;
  padding: 0.8rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  margin-top: 0.5rem;
}


/* صفحة الدفع */
.payment {
  max-width: 800px;
  margin: 2rem auto;
  padding: 1rem;
  background: #1a1a1a;
  border-radius: 50px;
}

.payment-methods {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
  margin: 2rem 0;
}

.payment-methods button {
  background: #333;
  padding: 1rem 2rem;
  border-radius: 15px;
  border: none;
  color: white;
  cursor: pointer;
  transition: background 0.3s;
}
.payment-methods button:hover { background: #444; }


/* الدعم والتحميل */
.support a { color: #00ff00; }

.support, .download {
  max-width: 800px;
  margin: 2rem auto;
  padding: 1rem;
  background: #1a1a1a;
  border-radius: 50px;
  text-align: center;
}

.download-btn {
  background: #ff6600;
  color: #ffffff;
  padding: 0.8rem 1.5rem;
  border-radius: 15px;
  text-decoration: none;
  display: inline-block;
  margin-top: 1rem;
}


/* قسم اللعبة / الأيقونة */
.game-section { padding: 20px; background-color: transparent; }

.game-icon { text-align: center; margin-bottom: 30px; }

/* أيقونة رئيسية: القيمة الافتراضية لسطح المكتب والموبايل (مرن) */
.icon-style {
  width: 200px;
  height: auto;
  animation: pulse 2s infinite;
}

/* بانر وصورة */
.banner-block { margin-bottom: 40px; text-align: center; }

.banner-img {
  width: 75%;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 1s ease forwards;
  animation-delay: 0.3s;
}

.banner-desc {
  margin-top: 10px;
  font-size: 20px;
  color: #f1eeee;
  line-height: 1.6;
  opacity: 0;
  animation: fadeIn 1s ease forwards;
  animation-delay: 0.8s;
}


/* لوحة التحكم (Admin Panel) */
.admin-header h1 { margin: 0; font-size: 1.5em; }
.admin-main { padding: 20px; max-width: 960px; margin: auto; }

#posts-section h2, #gameplay-section h2 { margin-bottom: 12px; color: #ff6600; }
#newPostBtn, #newGameplayBtn { padding: 8px 14px; background: #28a745; color: #fff; border: none; border-radius: 4px; cursor: pointer; }

#postsTable, #gameplayTable { width: 100%; border-collapse: collapse; margin-top: 12px; }

#postsTable th, #postsTable td,
#gameplayTable th, #gameplayTable td {
  padding: 10px;
  border: 1px solid #444;
  text-align: right;
}

.edit-btn, .delete-btn { padding: 6px 10px; border: none; border-radius: 4px; cursor: pointer; margin: 0 4px; }
.edit-btn { background: #ffc107; color: #212529; }
.delete-btn { background: #dc3545; color: #fff; }

#postForm, #gameplayForm { margin-top: 15px; padding: 15px; background-color: #222; border-radius: 8px; }
#postForm input, #postForm textarea,
#gameplayForm input, #gameplayForm textarea {
  width: calc(100% - 20px);
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 5px;
  border: 1px solid #555;
  background-color: #333;
  color: #fff;
}

.form-actions { margin-top: 10px; }
.hidden { display: none !important; }


/* ==========================================================
   🔹 الحركات (Animations)
   ========================================================== */
[data-aos] {
  transition-property: opacity, transform;
  transition-duration: 0.6s;
  transition-timing-function: ease;
}

@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { to { opacity: 1; } }
@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}


/* ==========================================================
   🔹 تنسيق المشاركات والأقسام
   ========================================================== */
#postsContainer, #gameplay-content-container {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.post-item {
  background: #1a1a1a;
  border-radius: 15px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
}

.post-image { width: 100%; height: 350px; object-fit: cover; display: block; }

.post-text-content {
  background: linear-gradient(to bottom, #ffffff, #e9e9e9);
  padding: 20px;
  margin-top: -10px;
  position: relative;
}

.post-item h2 {
  font-size: 1.8em;
  font-weight: 700;
  color: #111;
  margin: 0 0 15px 0;
  line-height: 1.3;
}
.post-item p { font-size: 1.1em; color: #333; line-height: 1.7; margin: 0; }


/* ==========================================================
   🔹 Media Queries (تصميم الهاتف)
   - هنا نُعدل سلوك الهيدر على الموبايل إلى position: fixed
   - ونُضيف padding أعلى للـ body حتى لا يختبئ المحتوى تحت الهيدر
   ========================================================== */
@media (max-width: 768px) {

  /* تعديل حجم وتباعد عناصر الهيدر على الهاتف */
  .header-title { font-size: 1.2em; }
  .header-sub-links a {
    font-size: 0.8em;
    white-space: nowrap;
    gap: 10px;
  }

  .store, .payment, .support, .download {
    margin: 1rem auto;
    padding: 0.5rem;
  }

  .items-scroll { height: auto; }

  .items-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .payment-methods { flex-direction: column; gap: 1rem; }
  .banner-desc { font-size: 16px; padding: 0 10px; }
  .banner-img { width: 100%; height: auto; }
  .footer-links a { font-size: 0.85em; margin: 5px; }
  .footer-copyright { font-size: 0.75em; }

  /* ==========================================================
     🔹 التعديل الرئيسي: تثبيت الهيدر في الموبايل
     - نستخدم position: fixed هنا فقط للهواتف
     - نضيف padding-top في body بقيمة مساوٍ لارتفاع الهيدر حتى لا تختفي المحتويات تحته
     - عدّل القيمة 72px إذا كان ارتفاع الهيدر الفعلي مختلفًا
     ========================================================== */
  .main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
  }

  /* مهمة: تأكد أن padding-top أكبر أو يساوي ارتفاع .main-header لتجنب اختفاء المحتوى */
  body {
    padding-top: 72px; /* <-- عدّل هذه القيمة حسب ارتفاع الهيدر الفعلي لديك */
  }

  /* تصغير أيقونة اللعبة قليلاً على الموبايل بدون تغيير موقعها المركزي */
  .icon-style { width: 150px; }

  /* إذا أردت أن تبقي الأيقونة في منتصف الشاشة على الموبايل: */
  .game-icon { text-align: center; }

  /* في حال ظهور أي تمدد أفقى على الموبايل، تأكد overflow-x hidden مفعّل (قمنا بتفعيله في أعلى الملف) */
}

/* ==========================================================
   --- نهاية الملف ---
   - ملاحظات:
// 1) إذا شعرت أن الهيدر يغطي جزءًا من عناصر الصفحة عدّل قيمة body padding-top.
// 2) للحفاظ على سلوك سطح المكتب تمامًا، لم نغيّر أي قواعد أخرى خارج media query.
   ========================================================== */
