/**
 * شجرة أحكام الصيام - CSS متوافق مع إسلام ويب
 * ============================================
 */

/* المتغيرات */
:root {
    --iw-primary: #1a6b8a;
    --iw-primary-dark: #0f4c63;
    --iw-primary-light: #2a8db3;
    --iw-gold: #c9a227;
    --iw-bg: #f5f7f9;
    --iw-bg-card: #ffffff;
    --iw-text: #333333;
    --iw-text-muted: #666666;
    --iw-border: #dde3e8;
    --iw-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* الحاوية الرئيسية */
.fasting-tree {
  /*  font-family: 'Tajawal', Arial, sans-serif;*/
    direction: rtl;
}

.fasting-tree * {
    box-sizing: border-box;
}

/* قائمة التصنيفات */
.fasting-tree .categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--iw-bg-card);
    /*border: 1px solid var(--iw-border);*/
    border-radius: 8px;
    overflow: hidden;
}

/* التصنيف الرئيسي */
.fasting-tree .category-item {
    border-bottom: 1px solid var(--iw-border);
}

.fasting-tree .category-item:last-child {
    border-bottom: none;
}

/* رأس التصنيف */
.fasting-tree .category-header {
    display: flex;
    align-items: center;
    padding: 14px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafbfc;
    border-right: 4px solid transparent;
}

.fasting-tree .category-header:hover {
    background: #f0f4f7;
}

.fasting-tree .category-item.active .category-header {
    background: linear-gradient(to left, rgba(26, 107, 138, 0.08), transparent);
    border-right-color: var(--iw-primary);
}

/* أيقونة المجلد */
.fasting-tree .folder-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 12px;
    flex-shrink: 0;
    color: white;
    font-size: 1em;
}

/* ألوان الأيقونات حسب التصنيف */
.fasting-tree .folder-icon.intro { background: #0d6efd; }
.fasting-tree .folder-icon.excuses { background: #198754; }
.fasting-tree .folder-icon.invalidators { background: #dc3545; }
.fasting-tree .folder-icon.itikaf { background: #6f42c1; }
.fasting-tree .folder-icon.taraweeh { background: #fd7e14; }
.fasting-tree .folder-icon.zakat { background: #20c997; }

/* عنوان التصنيف */
.fasting-tree .category-title {
    flex: 1;
    font-size: 1.05em;
    font-weight: 700;
    color: var(--iw-primary-dark);
    margin: 0;
}

/* عداد المواضيع */
.fasting-tree .category-count {
    background: var(--iw-bg);
    color: var(--iw-text-muted);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 500;
    margin-left: 10px;
}

/* سهم التوسيع */
.fasting-tree .expand-arrow {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--iw-text-muted);
    transition: transform 0.3s ease;
}

.fasting-tree .category-item.active .expand-arrow {
    transform: rotate(-90deg);
    color: var(--iw-primary);
}

/* القائمة الفرعية */
.fasting-tree .sub-items-list {
    display: none;
    list-style: none;
    margin: 0;
    padding: 8px 0;
    background: #f8f9fa;
    border-top: 1px solid var(--iw-border);
}

.fasting-tree .category-item.active .sub-items-list {
    display: block;
    animation: ftSlideIn 0.25s ease;
}

@keyframes ftSlideIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* العنصر الفرعي */
.fasting-tree .sub-item {
    margin: 0;
}

.fasting-tree .sub-item a {
    display: flex;
    align-items: center;
    padding: 10px 20px 10px 15px;
    margin: 2px 15px;
    text-decoration: none;
    color: var(--iw-text);
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 0.95em;
}

.fasting-tree .sub-item a:hover {
    background: var(--iw-bg-card);
    color: var(--iw-primary);
    box-shadow: var(--iw-shadow);
}

/* أيقونة العنصر الفرعي */
.fasting-tree .sub-icon {
    width: 26px;
    height: 26px;
    background: var(--iw-primary);
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    flex-shrink: 0;
    color: white;
    font-size: 0.7em;
    transition: transform 0.2s ease;
}

.fasting-tree .sub-item a:hover .sub-icon {
    transform: scale(1.1);
}

/* عنوان العنصر الفرعي */
.fasting-tree .sub-title {
    flex: 1;
}

/* رقم الفتوى */
.fasting-tree .sub-id {
    font-size: 0.75em;
    color: #999;
    background: #eee;
    padding: 2px 8px;
    border-radius: 10px;
    direction: ltr;
}

.fasting-tree .sub-item a:hover .sub-id {
    background: rgba(26, 107, 138, 0.1);
    color: var(--iw-primary);
}

/* أزرار التحكم */
.fasting-tree .tree-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.fasting-tree .tree-controls button {
    padding: 8px 16px;
    border: 1px solid var(--iw-border);
    background: white;
    color: var(--iw-primary);
    font-family: 'Tajawal', sans-serif;
    font-size: 0.9em;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.fasting-tree .tree-controls button:hover {
    background: var(--iw-primary);
    color: white;
    border-color: var(--iw-primary);
}

/* ============================================
   نسخة بديلة: تصميم البطاقات
   ============================================ */

.fasting-tree.cards-style .categories-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    background: transparent;
    border: none;
}

.fasting-tree.cards-style .category-item {
    border: 1px solid var(--iw-border);
    border-radius: 10px;
    overflow: hidden;
    background: white;
}

.fasting-tree.cards-style .category-header {
    border-right: none;
    border-bottom: 3px solid transparent;
}

.fasting-tree.cards-style .category-item.active .category-header {
    border-bottom-color: var(--iw-primary);
    border-right: none;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 768px) {
    .fasting-tree .category-header {
        padding: 12px 15px;
    }
    
    .fasting-tree .folder-icon {
        width: 34px;
        height: 34px;
        font-size: 0.9em;
    }
    
    .fasting-tree .category-title {
        font-size: 0.95em;
    }
    
    .fasting-tree .sub-item a {
        padding: 8px 15px;
        margin: 2px 10px;
        font-size: 0.9em;
    }
    
    .fasting-tree .tree-controls {
        flex-wrap: wrap;
    }
}