/* Grid for category cards and client cards */
.cards-grid, .category-cards-wrapper {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 24px;
    margin-bottom: 32px;
}

@media (max-width: 1200px) {
    .cards-grid, .category-cards-wrapper {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (max-width: 900px) {
    .cards-grid, .category-cards-wrapper {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (max-width: 600px) {
    .cards-grid, .category-cards-wrapper {
        grid-template-columns: 1fr;
    }
}
/* ====================================
   Bitrix V3 Tabs Layout CSS
   تنسيق خاص بالتبويبات في Bitrix Portal V3
   ==================================== */

/* ✅ Wrapper الرئيسي */
.bitrix-portal-wrapper {
    position: relative;
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden; /* ✅ منع التمرير الأفقي للصفحة */
}

/* Main Content Area */
.bitrix-main-content {
    position: relative; /* ✅ لضمان عدم التداخل */
    z-index: 1; /* ✅ أقل من Sidebar (z-index: 900) لكن فوق الخلفية */
    margin-right: 260px; /* ✅ يجب أن يطابق var(--bitrix-sidebar-width) */
    margin-top: 60px;
    margin-bottom: 50px;
    padding: 20px;
    min-height: calc(100vh - 110px);
    background: #f8f9fa;
    transition: margin-right 0.3s ease;
    width: auto; /* ✅ عرض تلقائي */
    max-width: calc(100vw - 260px); /* ✅ لا يتجاوز العرض المتاح */
    box-sizing: border-box; /* ✅ padding داخل العرض */
}

/* Sidebar collapsed state */
.bitrix-sidebar.collapsed ~ .bitrix-main-content {
    margin-right: 70px; /* ✅ يجب أن يطابق var(--bitrix-sidebar-collapsed) */
    max-width: calc(100vw - 70px); /* ✅ تحديث العرض الأقصى */
    transition: all 0.3s ease; /* ✅ smooth transition */
}

/* Content Sections (Tabs) */
.content-section {
    display: none;
    animation: fadeInUp 0.3s ease-in-out;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: relative; /* ✅ لضمان عدم التداخل */
    z-index: 1; /* ✅ نفس مستوى المحتوى */
    max-width: 100%; /* ✅ لا يتجاوز عرض الحاوية */
    overflow-x: auto; /* ✅ scroll أفقي إذا كان المحتوى عريض */
}

.content-section.active {
    display: block;
}

/* ✅ ضمان أن الجداول والعناصر الكبيرة لا تتجاوز الحدود */
.content-section table,
.content-section .dataTables_wrapper {
    max-width: 100%;
    overflow-x: auto;
}

/* Fade In Animation */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Override old tab styles */
.content-section .tabcontent {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Section Headers */
.content-section .section-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e5e7eb;
}

.content-section .section-header h1 {
    font-size: 24px;
    color: #1f2937;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.content-section .section-header h1 i {
    color: #667eea;
}

.content-section .section-subtitle {
    color: #6b7280;
    font-size: 14px;
    margin-top: 5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .bitrix-main-content {
        margin-right: 0;
        margin-top: 60px;
        padding: 15px;
    }
    
    /* في الموبايل، Sidebar يصبح overlay ولا نحتاج margin */
    .bitrix-sidebar.collapsed ~ .bitrix-main-content {
        margin-right: 0;
    }
    
    [dir="rtl"] .bitrix-main-content {
        margin-left: 0;
    }
    
    [dir="rtl"] .bitrix-sidebar.collapsed ~ .bitrix-main-content {
        margin-left: 0;
    }
    
    .content-section {
        padding: 15px;
    }
    
    .content-section .section-header h1 {
        font-size: 20px;
    }
}

/* Loading State */
.content-section.loading {
    position: relative;
    min-height: 400px;
}

.content-section.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Activity Heatmap Styles */
.activity-heatmap-loader {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.activity-load-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.2);
}

.activity-load-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.activity-load-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.activity-heatmap-empty {
    color: #94a3b8;
    font-size: 12px;
    font-style: italic;
}

.activity-heatmap {
    display: inline-block;
    padding: 4px;
}

/* AI Assistant Button Styles */
.ai-assistant-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.ai-assistant-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

/* AI Assistant Modal Styles */
.ai-assistant-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent !important;
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.ai-assistant-modal.show {
    display: flex;
}

.ai-assistant-modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.ai-assistant-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
}

.ai-assistant-modal-title {
    margin: 0;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-assistant-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.ai-assistant-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ai-assistant-modal-body {
    padding: 20px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.ai-assistant-welcome {
    margin-bottom: 16px;
    padding: 12px;
    background: #f0fdf4;
    border-radius: 8px;
    color: #166534;
    font-size: 14px;
}

.ai-assistant-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 12px;
}

.ai-assistant-input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.ai-assistant-send {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.ai-assistant-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.ai-assistant-chat {
    margin-top: 16px;
    max-height: 300px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-assistant-msg {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
}

.ai-assistant-msg.user-msg {
    background: #667eea;
    color: #fff;
    align-self: flex-end;
    max-width: 80%;
}

.ai-assistant-msg.ai-msg {
    background: #f3f4f6;
    color: #1f2937;
    align-self: flex-start;
    max-width: 80%;
}

/* Trust Score Badge Styles */
.trust-score-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: help;
}

.trust-score-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.trust-score-badge i {
    font-size: 16px;
}

.trust-score-value {
    font-size: 16px;
    font-weight: 700;
}

.trust-score-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
}


/* RTL Support */

/* ✅ إصلاح مهم: Sidebar في RTL يجب أن يكون على اليسار */
