/* ==================== category_items.css (ألوان جديدة) ==================== */

/* === 1. المتغيرات (Variables) === */
:root {
  /* الوضع النهاري */
  --primary-color: #8B4513;       /* بني متوسط */
  --gold-dark: #5C4033;           /* بني غامق */
  --gold-light: #D2B48C;          /* بيج فاتح */
  --light-bg: #ffffff;            /* خلفية النهار أبيض */
  --light-item-bg: #f5f5dc;       /* بيج فاتح جداً */
  --light-border: #e6ddc4;        /* حدود بيج فاتح */
  --light-text: #3E2723;          /* بني غامق للنص */


  /* الوضع الليلي */
  --black: #3E2723;               /* بني غامق جداً */
  --black-light: #5C4033;         /* بني أفتح شوي */
  --dark-bg: #3E2723;             /* خلفية الوضع الليلي */
  --dark-item-bg: #4E342E;        /* بني متوسط غامق */
  --dark-border: #6D4C41;         /* بني متوسط للحدود */
  --dark-text: #F5EBDD;           /* نص فاتح */

  /* ثابتة */
  --white: #FFFFFF;               /* أبيض للنص أو للخلفية */
  --success: #28a745;             /* أخضر */
  --danger: #dc3545;              /* أحمر */
  --warning: #ffc107;             /* أصفر */
}


/* === 2. القواعد العامة === */
* {
    /* الشرح: إزالة الهوامش والبادينغ */
    margin: 0;
    padding: 0;
    /* الشرح: يجعل الحدود جزءًا من العرض */
    box-sizing: border-box;
}

/* === 3. تنسيق الجسم === */
body {
    /* الشرح: خط عربي */
    font-family: 'Tajawal', sans-serif;
    /* الشرح: خلفية فاتحة */
    background: var(--light-bg);
    /* الشرح: لون النص */
    color: var(--text-color-light);
    /* الشرح: انتقال ناعم عند التغيير */
    transition: all 0.3s;
    /* الشرح: ارتفاع كامل الشاشة */
    min-height: 100vh;
    /* الشرح: ترتيب عمودي */
    display: flex;
    flex-direction: column;
}

/* === 4. الوضع الليلي === */
body.dark-mode {
    /* الشرح: تغيير الخلفية إلى داكنة */
    background: var(--dark-bg);
    /* الشرح: تغيير لون النص */
    color: var(--text-color-dark);
}

/* === 5. شريط البحث === */
.search-container {
    /* الشرح: هامش داخلي */
    padding: 20px;
    /* الشرح: توسيط النص */
    text-align: center;
    /* الشرح: تأثير ظهور */
    animation: fadeIn 0.6s ease-in-out;
}

/* الشرح: مربع إدخال البحث */
.search-container input {
    /* الشرح: عرض 90% من الحاوية */
    width: 90%;
    /* الشرح: أقصى عرض 500 بكسل */
    max-width: 500px;
    /* الشرح: هامش داخلي */
    padding: 14px 20px;
    /* الشرح: حجم الخط */
    font-size: 15px;
    /* الشرح: حد فاتح */
    border: 1px solid var(--light-border);
    /* الشرح: زوايا مستديرة */
    border-radius: 50px;
    /* الشرح: لا حدود عند التركيز */
    outline: none;
    /* الشرح: خلفية بيضاء */
    background-color: #fff;
    /* الشرح: لون النص */
    color: var(--text-color-light);
    /* الشرح: ظل خفيف */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    /* الشرح: انتقال ناعم */
    transition: all 0.3s ease;
}

/* الشرح: عند التركيز على مربع البحث */
.search-container input:focus {
    /* الشرح: تغيير لون الحد */
    border-color: var(--primary-color);
    /* الشرح: تأثير ظل داخلي */
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.2);
    /* الشرح: تكبير طفيف */
    transform: scale(1.02);
}

/* === 6. تأثير الظهور التدريجي === */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* شريط البحث في الوضع الليلي */
body.dark-mode .search-container input {
    background-color: var(--dark-item-bg);
    border: 1px solid var(--dark-border);
    color: var(--dark-text);
}
body.dark-mode .search-container input::placeholder {
    color: rgba(255, 255, 255, 0.7); /* لون نص البحث */
}


/* الشرح: شبكة العناصر داخل القسم */
.items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 7px;
    padding: 0 5px;
    min-height: 0px;
}
.item {
  background: var(--light-item-bg);
  border-radius: 32px;
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(92, 64, 51, 0.2);  /* gold-dark */
  transition: 0.4s;
  border: 1px solid var(--light-border);
  cursor: pointer;
  color: var(--light-text);
}
.item:hover {
  transform: translateY(-12px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
  border-color: var(--primary-color);
}

.item-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
}

.item-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.item:hover .item-overlay {
  opacity: 1;
}

.item-overlay i {
  font-size: 3.5rem;
  text-shadow: 0 3px 8px rgba(0, 0, 0, 0.7);
  animation: 1.5s infinite pulse;
  color: var(--primary-color);
}
.item-title {
  height: 25px;
  padding: 1px;
  text-align: center;
  font-size: 1.1rem;
  color: #c77510;
  border-top: 1px solid rgba(212, 175, 55, 0.3);
  font-weight: 700;
}
/* وضع الليل - تفعيل عند وجود class "dark-mode" على body */
body.dark-mode {
  background-color: var(--dark-bg);
  color: var(--dark-text);
}

body.dark-mode .item {
  background: var(--dark-item-bg);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.6);
  border: 1px solid var(--dark-border);
  color: var(--dark-text);
}
body.dark-mode .item:hover {
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7);
  border-color: var(--primary-color);
}
body.dark-mode .item-overlay {
  background: rgba(0, 0, 0, 0.6);
}
body.dark-mode .item-overlay i {
  color: var(--gold-light);
}


/* === 7. حاوية عرض الأقسام === */
.sections-container {
    /* الشرح: تحويل الحاوية إلى شبكة */
    display: grid;
    /* الشرح: أعمدة تتكيف تلقائيًا */
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    /* الشرح: فجوة بين البطاقات */
    gap: 20px;
    /* الشرح: هامش داخلي */
    padding: 20px;
    /* الشرح: تمديد لملء المساحة */
    flex-grow: 1;
}

/* === 8. بطاقة القسم (مطابقة 100% لتصميم العنصر) === */
.section {
    /* الشرح: نفس تصميم item-card من items.css */
    border: 1px solid var(--light-border);
    /* الشرح: زوايا مستديرة (32px) */
    border-radius: 10px;
    /* الشرح: اقتصاص الصورة والنص الزائد */
    overflow: hidden;
    /* الشرح: موقع نسبي للعناصر الداخلية */
    position: relative;
    /* الشرح: انتقال ناعم عند التفاعل */
    transition: transform 0.4s, box-shadow 0.4s, border-color 0.4s;
    /* الشرح: مؤشر يد عند التحويم */
    cursor: pointer;
    /* الشرح: خلفية فاتحة */
    background-color: var(--light-bg);
    /* الشرح: ترتيب عمودي */
    display: flex;
    flex-direction: column;
    height: 250px;
}

/* الشرح: في الوضع الداكن، تغيير مظهر البطاقة */
body.dark-mode .section {
    /* الشرح: خلفية داكنة */
    background-color: var(--dark-card);
    /* الشرح: حد داكن */
    border-color: var(--dark-border);
    /* الشرح: لون نص أبيض */
    color: var(--text-color-dark);
}

/* الشرح: عند التحويم على القسم */
.section:hover {
    /* الشرح: ارتفاع طفيف */
    transform: translateY(-12px);
    /* الشرح: ظل سماوي قوي */
    box-shadow: 0 15px 35px rgba(210, 180, 140, 0.5); /* gold-light */
    /* الشرح: تغيير لون الحد */
    border-color: var(--primary-color);
}

/* === 9. صورة القسم === */
.section-image {
    /* الشرح: عرض كامل */
    width: 100%;
    /* الشرح: ارتفاع 220 بكسل (مثل items.css) */
    height: 220px;
    /* الشرح: تغطية الصورة للمساحة */
    object-fit: cover;
    /* الشرح: عرض ككتلة */
    display: block;
}

/* === 10. تفاصيل القسم (النص تحت الصورة) === */
.section-details {
    height: 30px;
    /* الشرح: خلفية سماوية فاتحة */
    background-color: var(--light-item-bg);
    /* الشرح: هامش داخلي */
    padding: 1px;
}

/* الشرح: في الوضع الداكن، تغيير لون الخلفية */
body.dark-mode .section-details {
    /* الشرح: خلفية داكنة */
    background-color: var(--dark-bg);
}

/* === 11. عنوان القسم === */
.section-details h3 {
    /* الشرح: لون السماوي */
    color: var(--gold-dark);
    /* الشرح: حجم الخط */
    font-size: 16px;
    /* الشرح: هامش سفلي */
    margin-bottom: 2px;
    /* الشرح: لا تفاف للنص */
    white-space: nowrap;
    /* الشرح: اقتصاص النص الطويل */
    overflow: hidden;
    /* الشرح: توسيط النص */
    text-align: center;
    /* الشرح: ... عند الاقتطاع */
    text-overflow: ellipsis;
}

body.dark-mode .section-details h3{
    /* الشرح: خلفية داكنة */
    color: var(--dark-text);
}


/* === 12. زر المفضلة (إذا أردت إضافته لاحقًا) === */
.favorite-btn {
    /* الشرح: موقع مطلق */
    position: absolute;
    /* الشرح: 10 بكسل من الأعلى */
    top: 10px;
    /* الشرح: 10 بكسل من اليسار */
    left: 10px;
    /* الشرح: خلفية شفافة سماوية */
    background: rgba(0, 188, 212, 0.8);
    /* الشرح: لا حدود */
    border: none;
    /* الشرح: لون النص أبيض */
    color: white;
    /* الشرح: عرض 32 بكسل */
    width: 32px;
    /* الشرح: ارتفاع 32 بكسل */
    height: 32px;
    /* الشرح: دائري */
    border-radius: 50%;
    /* الشرح: مؤشر يد */
    cursor: pointer;
    /* الشرح: محاذاة داخلية */
    display: flex;
    align-items: center;
    justify-content: center;
    /* الشرح: مستوى عالٍ */
    z-index: 2;
    /* الشرح: انتقال ناعم */
    transition: all 0.3s ease;
    /* الشرح: ظل خفيف */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* الشرح: عند التحويم على زر المفضلة */
.favorite-btn:hover {
    /* الشرح: لون أكثر تشبعًا */
    background: rgba(0, 188, 212, 1);
    /* الشرح: تكبير طفيف */
    transform: scale(1.1);
}

/* الشرح: أيقونة النجمة */
.favorite-btn i {
    /* الشرح: حجم الخط */
    font-size: 16px;
}

/* الشرح: حاوية العنصر (لدعم الزر) */
.item-wrapper {
    /* الشرح: موقع نسبي */
    position: relative;
}

/* === 18. تأثير الرمادي عند عدم التوفر === */
.grayscale {
    /* الشرح: تحويل الصورة إلى رمادي */
    filter: grayscale(100%);
    /* الشرح: تقليل الشفافية */
    opacity: 0.6;
}

/* === 19. شارة "غير متاح" === */
.ribbon {
    /* الشرح: عرض 120 بكسل */
    width: 120px;
    /* الشرح: ارتفاع 120 بكسل */
    height: 120px;
    /* الشرح: اقتصاص الزائد */
    overflow: hidden;
    /* الشرح: موقع مطلق */
    position: absolute;
    /* الشرح: 5 بكسل من الأعلى */
    top: -5px;
    /* الشرح: 5 بكسل من اليمين */
    right: -5px;
    /* الشرح: مستوى عالٍ */
    z-index: 2;
}

/* الشرح: النص داخل الشارة */
.ribbon span {
    /* الشرح: موقع مطلق */
    position: absolute;
    /* الشرح: عرض 160 بكسل */
    display: block;
    width: 160px;
    /* الشرح: هامش داخلي */
    padding: 8px 0;
    /* الشرح: خلفية حمراء */
    background: #e53935;
    /* الشرح: نص أبيض */
    color: white;
    /* الشرح: توسيط */
    text-align: center;
    /* الشرح: حجم الخط */
    font-size: 14px;
    /* الشرح: غامق */
    font-weight: bold;
    /* الشرح: دوران 45 درجة */
    transform: rotate(45deg);
    /* الشرح: مواضع النص */
    top: 30px;
    right: -40px;
    /* الشرح: ظل خفيف */
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* === 14. رسائل الإشعار (Toast) === */
.toast {
  position: fixed;
  top: 25px;
  right: 25px;
  background: var(--primary-color);
  color: var(--black);
  padding: 18px 30px;
  border-radius: 8px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  z-index: 1000;
  transform: translateX(150%);
  transition: transform 0.4s;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast.show {
  transform: translateX(0);
}
.toast.success {
  background: var(--success);
  color: #fff;
}
.toast.error {
  background: var(--danger);
  color: #fff;
}
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}
.loader {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: 1s ease-in-out infinite spin;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
  appearance: none;
}

#itemsContainer:empty {
    display: none;
}

/* === 13. التكيف مع الشاشات الصغيرة === */
@media (max-width: 768px) {
  .sections-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    grid-auto-rows: min-content; /* يسمح للصفوف بأن يكون ارتفاعها حسب محتوى البطاقات */
    gap: 8px; /* تقليل المسافة بين البطاقات */
    padding: 5px;
  }

  .section {
    display: flex;
    flex-direction: column;
    height: auto; /* البطاقة تحدد حسب محتوى الصورة + النص */
    overflow: hidden;
  }

  .section-image {
    height: 140px;
    object-fit: cover;
  }

  .section-details {
    height: auto; /* ارتفاع النص حسب حجمه */
    padding: 0 5px;
  }

  .section-details h3 {
    font-size: 14px;
    line-height: 18px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

    /* الشرح: تصغير مربع البحث */
    .search-container input {
        max-width: 95%;
        font-size: 14px;
    }
    
    /* الشرح: 2-3 أعمدة على الموبايل */
    .items-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 15px;
        padding: 15px;
    }
    /* الشرح: تقليل ارتفاع الصورة */
    .item-image {
        height: 160px;
    }
    /* الشرح: تقليل حجم النص */
    .item-details h3 {
        font-size: 8px;
    }
}