/* ============================================
   Help Guide Floating Button & Modal Styles
   دليل المساعدة - الزر العائم والمودال
   متوافق مع ستايل فواتير المشتريات (bill/index)
   ============================================ */

/* الزر العائم الموحد + القائمة المنبثقة */
.help-fab-container {
    position: fixed;
    bottom: 28px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}
[dir="rtl"] .help-fab-container { left: 28px; right: auto; }
[dir="ltr"] .help-fab-container { right: 28px; left: auto; }

.help-guide-fab {
    width: 27px;
    height: 27px;
    border-radius: 50%;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    border: none;
    box-shadow: 0 2px 9px rgba(113, 75, 103, 0.45);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: pulse-help 2.5s infinite;
    position: relative;
}

.help-guide-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 3px 12px rgba(113, 75, 103, 0.55);
}

.help-guide-fab i {
    font-size: 10px;
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fab-menu-open .help-guide-fab {
    animation: none;
    background: linear-gradient(135deg, #5a3a52 0%, #714B67 100%);
    box-shadow: 0 4px 20px rgba(113, 75, 103, 0.5);
}
.fab-menu-open .help-guide-fab i {
    transform: rotate(45deg);
}

/* القائمة المنبثقة */
.help-fab-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    opacity: 0;
    transform: translateY(16px) scale(0.8);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fab-menu-open .help-fab-menu {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

.help-fab-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    flex-direction: row-reverse;
    transition: transform 0.2s ease;
}
[dir="ltr"] .help-fab-menu-item { flex-direction: row; }

.help-fab-menu-item:hover { transform: scale(1.04); }

.help-fab-menu-item:nth-child(1) {
    transition-delay: 0.06s;
}
.help-fab-menu-item:nth-child(2) {
    transition-delay: 0.02s;
}

.help-fab-menu-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 3px 12px rgba(113, 75, 103, 0.35);
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.help-fab-menu-item:hover .help-fab-menu-icon {
    box-shadow: 0 4px 18px rgba(113, 75, 103, 0.5);
    transform: scale(1.06);
}

.help-fab-menu-label {
    padding: 6px 14px;
    background: white;
    color: #333;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    pointer-events: none;
}

@keyframes pulse-help {
    0% { box-shadow: 0 2px 9px rgba(113, 75, 103, 0.45); }
    50% { box-shadow: 0 3px 12px rgba(113, 75, 103, 0.65); }
    100% { box-shadow: 0 2px 9px rgba(113, 75, 103, 0.45); }
}

/* ============================================
   المودال الرئيسي
   ============================================ */
.help-guide-modal .modal-dialog {
    max-width: 1100px;
    margin: 1rem auto;
}

.help-guide-modal .modal-content {
    border: none;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(113, 75, 103, 0.08);
    display: flex;
    flex-direction: column;
    max-height: 88vh;
    overflow: hidden;
    background: white;
}

.help-guide-modal .modal-header {
    background: linear-gradient(135deg, #714B67 0%, #8E6585 50%, #714B67 100%);
    color: white;
    border-radius: 8px 8px 0 0;
    padding: 0.35rem 0.75rem;
    border: none;
    position: relative;
    overflow: hidden;
}

.help-guide-modal .modal-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    pointer-events: none;
}

.help-guide-modal .modal-title {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    position: relative;
    z-index: 1;
}

.help-guide-modal .modal-title i {
    font-size: 0.85rem;
    opacity: 0.9;
}

.help-guide-modal .modal-body {
    padding: 0;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
}

.help-guide-modal .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
    position: relative;
    z-index: 1;
}

.help-guide-modal .btn-close:hover {
    opacity: 1;
}

/* ============================================
   الشريط الجانبي للشجرة
   ============================================ */
.help-guide-sidebar {
    width: 260px;
    min-width: 260px;
    background: #fafbfc;
    border-left: 1px solid #e9ecef;
    overflow-y: auto;
    max-height: 70vh;
}

[dir="rtl"] .help-guide-sidebar { border-left: none; border-right: 1px solid #e9ecef; }

/* شجرة الموديولات */
.help-tree { padding: 10px; }
.help-tree-item { margin-bottom: 3px; }

.help-tree-header {
    display: flex;
    align-items: center;
    padding: 0.2rem 0.4rem;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(113, 75, 103, 0.12);
}

.help-tree-header:hover {
    background: rgba(113, 75, 103, 0.04);
    border-color: rgba(113, 75, 103, 0.2);
}

.help-tree-header.active {
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    border-color: #714B67;
}

.help-tree-header .tree-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    background: rgba(113, 75, 103, 0.08);
    color: #714B67;
    font-size: 0.75rem;
}

[dir="ltr"] .help-tree-header .tree-icon { margin-left: 0; margin-right: 8px; }

.help-tree-header.active .tree-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.help-tree-header .tree-label {
    flex: 1;
    font-weight: 500;
    font-size: 0.75rem;
}

.help-tree-header .tree-arrow {
    transition: transform 0.2s ease;
    font-size: 0.65rem;
    color: #714B67;
}

.help-tree-header.active .tree-arrow { color: white; }
.help-tree-header.expanded .tree-arrow { transform: rotate(90deg); }
[dir="rtl"] .help-tree-header.expanded .tree-arrow { transform: rotate(-90deg); }

/* الصفحات الفرعية */
.help-tree-children {
    display: none;
    padding-right: 16px;
    margin-top: 2px;
}

[dir="ltr"] .help-tree-children { padding-right: 0; padding-left: 16px; }
.help-tree-children.show { display: block; }

.help-tree-page {
    display: flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    margin-bottom: 2px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.72rem;
    color: #5a6169;
    border: 1px solid transparent;
}

.help-tree-page:hover {
    background: rgba(113, 75, 103, 0.06);
    border-color: rgba(113, 75, 103, 0.12);
}

.help-tree-page.active {
    background: #714B67;
    color: white;
    border-color: #714B67;
}

.help-tree-page i {
    margin-left: 6px;
    font-size: 0.68rem;
    color: #714B67;
}

[dir="ltr"] .help-tree-page i { margin-left: 0; margin-right: 6px; }
.help-tree-page.active i { color: white; }

/* ============================================
   محتوى المساعدة
   ============================================ */
.help-guide-content {
    flex: 1;
    padding: 0.6rem 0.8rem;
    overflow-y: auto;
    max-height: 70vh;
}

.help-content-header {
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e9ecef;
}

.help-content-header h4 {
    color: #714B67;
    font-weight: 600;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
}

.help-content-header h4 i { font-size: 0.9rem; opacity: 0.9; }

.help-content-header p {
    color: #5a6169;
    margin: 0;
    font-size: 0.75rem;
}

/* ============================================
   خطوات العمل
   ============================================ */
.help-steps { counter-reset: step-counter; }

.help-step {
    position: relative;
    padding: 0.4rem 0.7rem;
    padding-right: 3.5rem;
    margin-bottom: 0.3rem;
    background: #fafbfc;
    border-radius: 6px;
    border-right: 3px solid #714B67;
    transition: all 0.2s ease;
    border-top: 1px solid rgba(113, 75, 103, 0.08);
    border-bottom: 1px solid rgba(113, 75, 103, 0.08);
}

[dir="ltr"] .help-step {
    padding-right: 1rem;
    padding-left: 3.5rem;
    border-right: none;
    border-left: 3px solid #714B67;
}

.help-step:hover {
    background: rgba(113, 75, 103, 0.04);
    box-shadow: 0 2px 8px rgba(113, 75, 103, 0.08);
}

.help-step::before {
    counter-increment: step-counter;
    content: counter(step-counter);
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #714B67 0%, #9B7A91 100%);
    color: white;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    font-size: 0.75rem;
}

[dir="ltr"] .help-step::before { right: auto; left: 10px; }

.help-step-title {
    font-weight: 600;
    color: #714B67;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.help-step-desc {
    color: #5a6169;
    font-size: 0.75rem;
    margin: 0;
    line-height: 1.3;
}

/* ============================================
   نصائح
   ============================================ */
.help-tips {
    margin-top: 0.5rem;
    padding: 0.4rem 0.7rem;
    background: linear-gradient(135deg, #fff8e1 0%, #fff3cd 100%);
    border-radius: 6px;
    border-right: 3px solid #f59e0b;
}

[dir="ltr"] .help-tips { border-right: none; border-left: 3px solid #f59e0b; }

.help-tips-title {
    font-weight: 600;
    color: #92400e;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
}

.help-tips ul { margin: 0; padding-right: 16px; color: #92400e; }
[dir="ltr"] .help-tips ul { padding-right: 0; padding-left: 16px; }
.help-tips li { margin-bottom: 3px; font-size: 0.75rem; }

/* ============================================
   رسالة الترحيب
   ============================================ */
.help-welcome {
    text-align: center;
    padding: 1rem 0.75rem;
}

.help-welcome-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.help-welcome-icon i { font-size: 22px; color: white; }

.help-welcome h4 {
    color: #714B67;
    margin-bottom: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.help-welcome p {
    color: #5a6169;
    max-width: 400px;
    margin: 0 auto;
    font-size: 0.78rem;
}

/* ============================================
   البحث
   ============================================ */
.help-search {
    padding: 10px;
    background: white;
    border-bottom: 1px solid #e9ecef;
}

.help-search input {
    width: 100%;
    padding: 0.3rem 0.6rem;
    border: 1px solid #714B67;
    border-radius: 4px;
    font-size: 0.75rem;
    height: 30px;
}

.help-search input:focus {
    outline: none;
    border-color: #8E6585;
    box-shadow: 0 0 0 0.1rem rgba(113, 75, 103, 0.2);
}

/* ============================================
   زر فتح الصفحة مباشرة
   ============================================ */
.help-open-page-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 0.2rem 0.6rem;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-open-page-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(113, 75, 103, 0.3);
}

/* خطوة قابلة للتنقل */
.help-step-navigable { border-right-color: #16a34a; }
[dir="ltr"] .help-step-navigable { border-left-color: #16a34a; }
.help-step-navigable::before { background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%); }

.help-step-goto {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 0.15rem 0.5rem;
    background: rgba(34, 197, 94, 0.08);
    color: #16a34a;
    border: 1px solid rgba(34, 197, 94, 0.12);
    border-radius: 4px;
    font-size: 0.68rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-step-goto:hover {
    background: #22c55e;
    color: white;
    border-color: #22c55e;
}

.help-step-goto i { font-size: 0.62rem; }

/* ============================================
   مسار العمل (Workflow)
   ============================================ */
.help-workflow {
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.7rem;
    background: linear-gradient(135deg, #e8f5e9 0%, #f1f8e9 100%);
    border-radius: 6px;
    border-right: 3px solid #4caf50;
}

[dir="ltr"] .help-workflow { border-right: none; border-left: 3px solid #4caf50; }

.help-workflow-title {
    font-weight: 600;
    color: #2e7d32;
    margin-bottom: 4px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-workflow-desc {
    color: #558b2f;
    font-size: 0.72rem;
    margin-bottom: 10px;
}

.help-workflow-flow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}

.wf-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.25rem 0.4rem;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(113, 75, 103, 0.12);
    min-width: 70px;
    text-align: center;
}

.wf-item:hover {
    border-color: #714B67;
    box-shadow: 0 2px 8px rgba(113, 75, 103, 0.15);
    transform: translateY(-2px);
}

.wf-icon {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #714B67 0%, #9B7A91 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
}

.wf-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: #5a6169;
    line-height: 1.2;
}

.wf-arrow {
    color: #714B67;
    font-size: 1rem;
    display: flex;
    align-items: center;
}

/* حالة التحميل والخطأ */
.help-loading, .help-error {
    text-align: center;
    padding: 1.5rem 1rem;
    color: #5a6169;
    font-size: 0.78rem;
}

.help-loading i, .help-error i {
    font-size: 1.2rem;
    margin-bottom: 8px;
    display: block;
    color: #714B67;
}

.help-error { color: #dc3545; }
.help-error i { color: #dc3545; }

/* ============================================
   حالات المستند (Document Statuses)
   ============================================ */
.help-statuses {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.7rem;
    background: #fafbfc;
    border-radius: 6px;
    border-right: 3px solid #714B67;
    border-top: 1px solid rgba(113, 75, 103, 0.08);
    border-bottom: 1px solid rgba(113, 75, 103, 0.08);
}

[dir="ltr"] .help-statuses { border-right: none; border-left: 3px solid #714B67; }

.help-statuses-title {
    font-weight: 600;
    color: #714B67;
    margin-bottom: 4px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-statuses-desc {
    color: #5a6169;
    font-size: 0.72rem;
    margin-bottom: 10px;
}

.help-statuses-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.help-status-item {
    background: white;
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    transition: all 0.2s ease;
    border: 1px solid rgba(113, 75, 103, 0.12);
}

.help-status-item:hover {
    box-shadow: 0 2px 8px rgba(113, 75, 103, 0.1);
}

.help-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    color: white;
    font-size: 0.72rem;
    font-weight: 500;
    margin-bottom: 6px;
}

.help-status-badge i { font-size: 0.68rem; }

.help-status-desc {
    color: #5a6169;
    font-size: 0.75rem;
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.help-status-constraints {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(113, 75, 103, 0.15);
}

.help-status-constraints .constraints-label {
    font-weight: 600;
    font-size: 0.68rem;
    color: #714B67;
    display: block;
    margin-bottom: 3px;
}

.help-status-constraints ul { margin: 0; padding-right: 16px; padding-left: 0; }
[dir="ltr"] .help-status-constraints ul { padding-right: 0; padding-left: 16px; }

.help-status-constraints li {
    font-size: 0.7rem;
    color: #5a6169;
    margin-bottom: 2px;
    line-height: 1.25;
}

.help-status-constraints li::marker { color: #714B67; }

/* ============================================
   إشارة الإعدادات المرتبطة (Settings Reference)
   ============================================ */
.help-status-settings {
    margin-top: 8px;
    padding: 0.5rem 0.75rem;
    background: rgba(113, 75, 103, 0.04);
    border-radius: 4px;
    border: 1px solid rgba(113, 75, 103, 0.12);
    border-right: 3px solid #714B67;
}

[dir="ltr"] .help-status-settings { border-right: 1px solid rgba(113, 75, 103, 0.12); border-left: 3px solid #714B67; }

.settings-ref-header {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: #714B67;
    margin-bottom: 3px;
    flex-wrap: wrap;
}

.settings-ref-header i { font-size: 0.68rem; color: #714B67; }
.settings-ref-label { font-weight: 600; }

.settings-ref-desc {
    font-size: 0.68rem;
    color: #5a6169;
    margin: 0 0 6px 0;
    line-height: 1.25;
}

.help-settings-goto {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.15rem 0.5rem;
    background: rgba(113, 75, 103, 0.08);
    color: #714B67;
    border: 1px solid rgba(113, 75, 103, 0.12);
    border-radius: 4px;
    font-size: 0.68rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.help-settings-goto:hover {
    background: #714B67;
    color: white;
    border-color: #714B67;
}

.help-settings-goto i { font-size: 0.62rem; }

/* ============================================
   نظام الحوار الذكي (Smart Chat System)
   ============================================ */
.help-chat-panel {
    border-top: 1px solid #e9ecef;
    background: #fafbfc;
    display: flex;
    flex-direction: column;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.3s ease;
}

.help-chat-panel.open {
    max-height: 350px;
    padding: 0;
}

.help-chat-toggle {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 0.4rem;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 50%, #714B67 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 500;
    transition: all 0.2s ease;
    z-index: 5;
}

.help-chat-toggle:hover { filter: brightness(1.1); }
.help-chat-toggle i { font-size: 0.85rem; }

.help-chat-toggle .chat-badge {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    font-weight: 600;
}

.help-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.75rem;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 50%, #714B67 100%);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
}

.help-chat-header-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.help-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0 4px;
}

.help-chat-close:hover { opacity: 1; }

.help-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 120px;
    max-height: 200px;
    background: white;
}

.help-chat-msg {
    max-width: 85%;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    line-height: 1.3;
    word-wrap: break-word;
    animation: chatMsgIn 0.3s ease;
}

@keyframes chatMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.help-chat-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 2px;
}

[dir="rtl"] .help-chat-msg-user { border-bottom-left-radius: 2px; border-bottom-right-radius: 6px; }

.help-chat-msg-bot {
    align-self: flex-start;
    background: rgba(113, 75, 103, 0.06);
    color: #333;
    border: 1px solid rgba(113, 75, 103, 0.1);
    border-bottom-right-radius: 6px;
    border-bottom-left-radius: 2px;
}

[dir="rtl"] .help-chat-msg-bot { border-bottom-right-radius: 2px; border-bottom-left-radius: 6px; }

.help-chat-msg-bot .chat-bot-icon {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-weight: 600;
    color: #714B67;
    margin-bottom: 3px;
    font-size: 0.68rem;
}

.help-chat-msg-bot .chat-answer { margin: 0; }
.help-chat-msg-bot .chat-answer ul { margin: 4px 0 0 0; padding-right: 14px; padding-left: 0; }
[dir="ltr"] .help-chat-msg-bot .chat-answer ul { padding-right: 0; padding-left: 14px; }
.help-chat-msg-bot .chat-answer li { margin-bottom: 2px; }

.help-chat-msg-bot .chat-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin-top: 4px;
    padding: 0.1rem 0.4rem;
    background: rgba(113, 75, 103, 0.08);
    color: #714B67;
    border: 1px solid rgba(113, 75, 103, 0.12);
    border-radius: 4px;
    font-size: 0.68rem;
    cursor: pointer;
    transition: all 0.2s;
}

.help-chat-msg-bot .chat-link:hover { background: #714B67; color: white; border-color: #714B67; }

.help-chat-welcome {
    text-align: center;
    color: #999;
    font-size: 0.72rem;
    padding: 1rem 0.5rem;
}

.help-chat-welcome i {
    font-size: 1.2rem;
    color: #714B67;
    opacity: 0.4;
    display: block;
    margin-bottom: 6px;
}

.help-chat-input-area {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.4rem 0.75rem;
    background: #fafbfc;
    border-top: 1px solid #e9ecef;
}

.help-chat-input {
    flex: 1;
    padding: 0.3rem 0.6rem;
    border: 1px solid #714B67;
    border-radius: 4px;
    font-size: 0.75rem;
    outline: none;
    transition: border-color 0.2s;
    height: 30px;
}

.help-chat-input:focus {
    border-color: #8E6585;
    box-shadow: 0 0 0 0.1rem rgba(113, 75, 103, 0.2);
}

.help-chat-send {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.help-chat-send:hover {
    box-shadow: 0 2px 8px rgba(113, 75, 103, 0.3);
}

.help-chat-send i { font-size: 0.75rem; }
[dir="rtl"] .help-chat-send i { transform: scaleX(-1); }

/* ============================================
   استكشاف الأخطاء - Troubleshooting Section
   ============================================ */
.help-troubleshooting {
    margin-top: 0.5rem;
    padding: 0.4rem 0.7rem;
    background: #fff8e1;
    border-radius: 6px;
    border-right: 3px solid #e65100;
}

[dir="ltr"] .help-troubleshooting { border-right: none; border-left: 3px solid #e65100; }

.help-troubleshooting-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: #e65100;
    margin-bottom: 10px;
}

.help-troubleshooting-title i { margin-left: 5px; color: #e65100; }
[dir="ltr"] .help-troubleshooting-title i { margin-left: 0; margin-right: 5px; }

.help-trouble-item {
    margin-bottom: 6px;
    background: white;
    border-radius: 6px;
    padding: 0.3rem 0.5rem;
    border: 1px solid rgba(230, 81, 0, 0.1);
}

.help-trouble-item:last-child { margin-bottom: 0; }

.help-trouble-problem {
    font-weight: 600;
    font-size: 0.75rem;
    color: #c62828;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #ffcdd2;
}

.help-trouble-problem i { margin-left: 3px; color: #c62828; }
[dir="ltr"] .help-trouble-problem i { margin-left: 0; margin-right: 3px; }

.help-trouble-causes {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.help-trouble-cause {
    padding: 0.4rem 0.6rem;
    background: #fafafa;
    border-radius: 4px;
    border-right: 2px solid #e0e0e0;
    transition: border-color 0.2s;
}

[dir="ltr"] .help-trouble-cause { border-right: none; border-left: 2px solid #e0e0e0; }
.help-trouble-cause:hover { border-color: #714B67; }
.help-trouble-cause:first-child { border-color: #c62828; }

.help-trouble-cause-title { font-weight: 600; font-size: 0.72rem; color: #333; margin-bottom: 3px; }
.help-trouble-cause-desc { font-size: 0.68rem; color: #666; margin-bottom: 3px; }

.help-trouble-cause-fix { font-size: 0.68rem; color: #2e7d32; font-weight: 500; }
.help-trouble-cause-fix i { margin-left: 2px; color: #2e7d32; }
[dir="ltr"] .help-trouble-cause-fix i { margin-left: 0; margin-right: 2px; }

/* ============================================
   تجاوب الموبايل
   ============================================ */
@media (max-width: 768px) {
    .help-fab-container {
        bottom: 20px;
    }
    [dir="rtl"] .help-fab-container { left: 20px; }
    [dir="ltr"] .help-fab-container { right: 20px; }

    .help-guide-fab {
        width: 24px;
        height: 24px;
    }
    .help-guide-fab i { font-size: 9px; }

    .help-fab-menu-icon { width: 40px; height: 40px; font-size: 14px; }
    .help-fab-menu-label { font-size: 0.72rem; padding: 5px 10px; }

    .help-guide-modal .modal-body { flex-direction: column; }

    .help-guide-sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 180px;
        border-left: none;
        border-bottom: 1px solid #e9ecef;
    }

    [dir="rtl"] .help-guide-sidebar { border-right: none; }

    .help-guide-content { max-height: calc(70vh - 180px); padding: 0.75rem; }

    .help-step { padding-right: 3rem; }
    [dir="ltr"] .help-step { padding-right: 0.75rem; padding-left: 3rem; }
    .help-step::before { width: 24px; height: 24px; font-size: 0.68rem; }

    .help-workflow-flow { gap: 4px; }
    .wf-item { padding: 0.3rem 0.5rem; min-width: 60px; }
    .wf-icon { width: 28px; height: 28px; font-size: 0.72rem; }
    .wf-label { font-size: 0.6rem; }
    .wf-arrow { font-size: 0.85rem; }

    .help-chat-panel.open { max-height: 280px; }
    .help-chat-messages { min-height: 100px; max-height: 140px; }
    .help-chat-msg { max-width: 90%; font-size: 0.72rem; }
    .help-chat-input { font-size: 0.72rem; }
    .help-chat-send { width: 28px; height: 28px; }

    .help-statuses { padding: 0.5rem 0.75rem; }
    .help-status-item { padding: 0.4rem 0.6rem; }
    .help-status-badge { font-size: 0.68rem; padding: 0.1rem 0.4rem; }
    .help-status-desc { font-size: 0.7rem; }
    .help-status-constraints li { font-size: 0.65rem; }

    .help-status-settings { padding: 0.4rem 0.6rem; }
    .settings-ref-header { font-size: 0.68rem; }
    .settings-ref-desc { font-size: 0.65rem; }
    .help-settings-goto { font-size: 0.62rem; padding: 0.1rem 0.4rem; }

    .help-step-goto { font-size: 0.62rem; padding: 0.1rem 0.4rem; }
}


/* ============================================
   نافذة المساعد الذكي المستقلة (Standalone Window)
   ============================================ */
.sa-window {
    position: fixed;
    bottom: 20px;
    width: 420px;
    height: 620px;
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 48px rgba(113, 75, 103, 0.25), 0 0 0 1px rgba(113, 75, 103, 0.08);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(30px) scale(0.95);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
[dir="rtl"] .sa-window { left: 20px; right: auto; }
[dir="ltr"] .sa-window { right: 20px; left: auto; }

.sa-window.sa-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ============================================
   رأس النافذة
   ============================================ */
.sa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 50%, #6B3F5E 100%);
    color: white;
    position: relative;
    overflow: hidden;
}
.sa-header::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -30%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    pointer-events: none;
}
.sa-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    z-index: 1;
}
.sa-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255,255,255,0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    backdrop-filter: blur(4px);
}
.sa-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sa-header-title {
    font-weight: 600;
    font-size: 0.88rem;
    letter-spacing: -0.2px;
}
.sa-header-status {
    font-size: 0.7rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}
.sa-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: sa-pulse-dot 2s infinite;
}
@keyframes sa-pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.sa-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
    z-index: 1;
}
.sa-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.12);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}
.sa-header-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.05);
}
.sa-btn-close:hover { background: rgba(220, 53, 69, 0.5); }

/* ============================================
   شارة السياق (الصفحة الحالية)
   ============================================ */
.sa-context-badge {
    padding: 6px 18px;
    background: linear-gradient(90deg, rgba(113, 75, 103, 0.06) 0%, rgba(113, 75, 103, 0.02) 100%);
    border-bottom: 1px solid rgba(113, 75, 103, 0.08);
    font-size: 0.7rem;
    color: #714B67;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sa-context-badge i { font-size: 0.65rem; opacity: 0.7; }

/* ============================================
   منطقة الرسائل
   ============================================ */
.sa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(180deg, #faf9fb 0%, #f5f3f6 100%);
    scroll-behavior: smooth;
}
.sa-messages::-webkit-scrollbar { width: 5px; }
.sa-messages::-webkit-scrollbar-track { background: transparent; }
.sa-messages::-webkit-scrollbar-thumb { background: rgba(113, 75, 103, 0.15); border-radius: 10px; }
.sa-messages::-webkit-scrollbar-thumb:hover { background: rgba(113, 75, 103, 0.3); }

/* ============================================
   رسالة الترحيب
   ============================================ */
.sa-welcome {
    text-align: center;
    padding: 20px 10px 10px;
}
.sa-welcome-avatar {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin: 0 auto 12px;
    box-shadow: 0 4px 16px rgba(113, 75, 103, 0.25);
}
.sa-welcome h5 {
    color: #333;
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}
.sa-welcome p {
    color: #888;
    font-size: 0.78rem;
    margin: 0;
}

/* ============================================
   الأسئلة المقترحة
   ============================================ */
.sa-suggestions {
    padding: 4px 0;
}
.sa-suggestions-title {
    font-size: 0.72rem;
    color: #999;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.sa-suggestions-title i { color: #f59e0b; font-size: 0.75rem; }
.sa-suggestions-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.sa-suggestion-chip {
    padding: 7px 12px;
    background: white;
    border: 1px solid rgba(113, 75, 103, 0.12);
    border-radius: 20px;
    font-size: 0.72rem;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.sa-suggestion-chip i { color: #714B67; font-size: 0.68rem; }
.sa-suggestion-chip:hover {
    background: #714B67;
    color: white;
    border-color: #714B67;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(113, 75, 103, 0.2);
}
.sa-suggestion-chip:hover i { color: white; }

/* ============================================
   فقاعات الرسائل
   ============================================ */
.sa-msg {
    display: flex;
    gap: 8px;
    animation: sa-msg-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes sa-msg-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.sa-msg-user {
    flex-direction: row-reverse;
}
.sa-msg-avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 10px;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    margin-top: 2px;
}
.sa-msg-content {
    display: flex;
    flex-direction: column;
    max-width: 82%;
}
.sa-msg-user .sa-msg-content { align-items: flex-end; }
[dir="rtl"] .sa-msg-user .sa-msg-content { align-items: flex-start; }

.sa-msg-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.8rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.sa-msg-bubble-user {
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    border-bottom-right-radius: 4px;
}
[dir="rtl"] .sa-msg-bubble-user { border-bottom-right-radius: 16px; border-bottom-left-radius: 4px; }

.sa-msg-bubble-bot {
    background: white;
    color: #333;
    border: 1px solid rgba(113, 75, 103, 0.08);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
[dir="rtl"] .sa-msg-bubble-bot { border-bottom-left-radius: 16px; border-bottom-right-radius: 4px; }

.sa-msg-bubble-bot strong { color: #714B67; }
.sa-msg-bubble-bot ul { margin: 6px 0 0; padding-right: 16px; padding-left: 0; }
[dir="ltr"] .sa-msg-bubble-bot ul { padding-right: 0; padding-left: 16px; }
.sa-msg-bubble-bot li { margin-bottom: 3px; font-size: 0.78rem; }

.sa-msg-bubble-bot .chat-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 4px 10px;
    background: rgba(113, 75, 103, 0.06);
    color: #714B67;
    border: 1px solid rgba(113, 75, 103, 0.12);
    border-radius: 8px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.sa-msg-bubble-bot .chat-link:hover {
    background: #714B67;
    color: white;
    border-color: #714B67;
}

.sa-msg-time {
    font-size: 0.62rem;
    color: #bbb;
    margin-top: 3px;
    padding: 0 4px;
}

/* ============================================
   مؤشر الكتابة (Typing Indicator)
   ============================================ */
.sa-typing-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px !important;
    min-width: 60px;
}
.sa-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #714B67;
    opacity: 0.4;
    animation: sa-typing-bounce 1.4s infinite;
}
.sa-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.sa-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes sa-typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================
   منطقة الإدخال
   ============================================ */
.sa-input-area {
    padding: 12px 16px 10px;
    background: white;
    border-top: 1px solid rgba(113, 75, 103, 0.06);
}
.sa-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f3f6;
    border-radius: 14px;
    padding: 4px 4px 4px 12px;
    border: 1.5px solid transparent;
    transition: all 0.2s ease;
}
[dir="ltr"] .sa-input-wrapper { padding: 4px 12px 4px 4px; }
.sa-input-wrapper:focus-within {
    border-color: rgba(113, 75, 103, 0.3);
    background: white;
    box-shadow: 0 0 0 3px rgba(113, 75, 103, 0.06);
}
.sa-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.82rem;
    color: #333;
    outline: none;
    padding: 8px 0;
}
.sa-input::placeholder { color: #aaa; }
.sa-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #714B67 0%, #8E6585 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.sa-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 12px rgba(113, 75, 103, 0.3);
}
[dir="rtl"] .sa-send-btn i { transform: scaleX(-1); }

.sa-powered {
    text-align: center;
    font-size: 0.6rem;
    color: #ccc;
    margin-top: 6px;
}

/* ============================================
   تجاوب الموبايل - النافذة المستقلة
   ============================================ */
@media (max-width: 480px) {
    .sa-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 16px);
        max-height: calc(100vh - 16px);
        bottom: 8px;
        border-radius: 16px;
    }
    [dir="rtl"] .sa-window { left: 8px; }
    [dir="ltr"] .sa-window { right: 8px; }
    .sa-header { padding: 12px 14px; }
    .sa-messages { padding: 12px; }
    .sa-suggestion-chip { font-size: 0.68rem; padding: 6px 10px; }
    .sa-msg-bubble { font-size: 0.78rem; }
    .sa-input { font-size: 0.8rem; }
}

@media (min-width: 481px) and (max-width: 768px) {
    .sa-window { width: 380px; height: 560px; }
}
