/**
 * Unified Suggestions System CSS - Production Ready
 * עיצוב נקי ללא התנגשויות למערכת ההצעות המאוחדת
 */

/* =================================================================
   PANEL LAYOUT - הפאנל הראשי
================================================================= */

.unified-suggestions-panel {
    position: fixed;
    top: 20px;
    left: 20px;
    width: 450px;
    max-height: 80vh;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 9999;
    font-family: 'Heebo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    direction: rtl;
    overflow: hidden;
    backdrop-filter: blur(10px);
    transform: translateY(0);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.unified-suggestions-panel.hidden {
    transform: translateY(-20px);
    opacity: 0;
    visibility: hidden;
}

/* =================================================================
   PANEL HEADER - כותרת הפאנל
================================================================= */

.unified-panel-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.unified-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.unified-panel-header h3 i {
    font-size: 18px;
    color: #fff;
}

.unified-panel-controls {
    display: flex;
    gap: 8px;
}

.unified-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    color: white;
    cursor: pointer;
    transition: background 0.2s ease;
}

.unified-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* =================================================================
   PANEL CONTENT - תוכן הפאנל
================================================================= */

.unified-panel-content {
    max-height: calc(80vh - 70px);
    overflow-y: auto;
    padding: 0;
}

.unified-suggestions-list {
    padding: 12px;
}

.unified-loading {
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
    font-size: 14px;
}

.unified-loading i {
    font-size: 20px;
    margin-left: 8px;
    color: #1e3a5f;
}

.unified-no-suggestions {
    text-align: center;
    padding: 40px 20px;
    color: #22c55e;
    font-size: 14px;
    font-weight: 600;
}

.unified-no-suggestions i {
    font-size: 24px;
    margin-left: 8px;
}

/* =================================================================
   SUGGESTION ITEMS - פריטי הצעות
================================================================= */

.unified-suggestion-item {
    border: 2px solid #f3f4f6;
    border-radius: 12px;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    transition: all 0.3s ease;
    overflow: hidden;
}

.unified-suggestion-item:hover {
    border-color: #e5e7eb;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.unified-suggestion-item:last-child {
    margin-bottom: 0;
}

/* =================================================================
   MINIMAL DESIGN - עיצוב מינימליסטי חדש
================================================================= */

.unified-suggestion-minimal {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    cursor: pointer; /* 🔄 סמן יד כדי להראות שניתן ללחוץ */
    transition: all 0.2s ease;
    font-family: 'Heebo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* הכרטיסיות בפונט Heebo כמו העורך */
    letter-spacing: normal; /* Reset - ללא ריווח נוסף */
}

.unified-suggestion-minimal:hover {
    border-color: #1e3a5f;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.15);
    transform: translateY(-1px);
    background: linear-gradient(135deg, #ffffff 0%, #f8faff 100%);
}

/* 🔄 הצעה מודגשת (כשהעכבר מעליה בעורך) - רקע לבן עם מסגרת אפורה */
.unified-suggestion-minimal.highlighted-in-panel {
    border-color: #9ca3af !important;
    border-width: 1px !important;
    background: white !important;
    box-shadow: 0 2px 8px rgba(156, 163, 175, 0.15) !important;
    transform: none;
}

.unified-suggestion-minimal .unified-suggestion-content {
    padding: 12px 16px;
}

.unified-suggestion-change-minimal {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* שורה ראשונה - טקסט מקור עם קו אדום מתחת (כמו הטולטיפ רק באדום) */
.unified-original-text-minimal {
    background: transparent;
    color: #9ca3af; /* אפור - להבדיל מהטקסט המשופר */
    font-size: 16px;
    font-weight: 400;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    text-align: right;
    direction: rtl;
    padding-bottom: 4px;
    border-bottom: 2px solid #ef4444; /* קו אדום מתחת */
    font-family: 'Heebo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* פונט Heebo כמו העורך */
    letter-spacing: normal; /* Reset - ללא ריווח נוסף */
}

/* שורה שנייה - תיקון עם רקע כחול בהיר */
.unified-suggested-text-wrapper-minimal {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* הצעה לשיפור - כמו בטולטיפ: רקע לבן עם קו כחול מתחת */
.unified-suggested-text-minimal {
    background: transparent;
    color: #1f2937;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    text-align: right;
    direction: rtl;
    padding-bottom: 4px;
    border-bottom: 2px solid #1e3a5f; /* קו כחול כמו הלוגו */
    font-family: 'Heebo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* פונט Heebo כמו העורך */
    letter-spacing: normal; /* Reset - ללא ריווח נוסף */
}

/* כפתורי פעולה - מתחת למסגרות */
.unified-suggestion-actions-minimal {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.unified-action-btn-minimal {
    background: white;
    border: 1px solid;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    min-width: 60px;
}

.accept-btn-minimal {
    color: #1e3a5f; /* כחול כמו הלוגו */
    border-color: #1e3a5f;
}

.accept-btn-minimal:hover {
    background: #eff6ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
}

.reject-btn-minimal {
    color: #ef4444;
    border-color: #ef4444;
}

.reject-btn-minimal:hover {
    background: #fef2f2;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* =================================================================
   DIFF VISUALIZATION - תצוגת השוואה בסגנון הפרויקט (כחול + אדום)
================================================================= */

/* טקסט שנמחק - קו חוצה + רקע אדום בהיר */
.diff-removed {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
    text-decoration: line-through;
    text-decoration-color: #ef4444;
    padding: 0 2px;
    border-radius: 2px;
    margin: 0 1px;
}

/* טקסט שנוסף - מודגש + רקע כחול בהיר עם קו תחתון */
.diff-added {
    background: rgba(30, 58, 95, 0.12);
    color: #1e3a5f;
    font-weight: 500;
    padding: 0 2px;
    border-radius: 2px;
    border-bottom: 2px solid #1e3a5f;
    margin: 0 1px;
}

/* אנימציה עדינה בהופעה */
.diff-removed,
.diff-added {
    animation: diffHighlight 0.3s ease-out;
}

@keyframes diffHighlight {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* התאמה לטקסט עברי RTL */
.unified-original-text-minimal .diff-removed,
.unified-suggested-text-minimal .diff-added {
    unicode-bidi: embed;
    direction: rtl;
}

/* =================================================================
   PARTIAL ACCEPTANCE - קבלה חלקית של שינויים
   🆕 גרסה משופרת: לחיצה ישירה על השינוי + כפתור overlay
================================================================= */

/* עטיפה לשינוי - position: relative לאפשר overlay */
.diff-change-wrapper {
    display: inline;
    position: relative;
    cursor: pointer;
}

/* 🆕 השינוי עצמו - ניתן ללחיצה */
.diff-change-wrapper .diff-removed,
.diff-change-wrapper .diff-added {
    cursor: pointer;
    transition: all 0.15s ease;
}

/* 🆕 אפקט hover על השינוי - מראה שניתן ללחוץ */
.diff-change-wrapper:hover .diff-removed:not(.rejected) {
    background-color: rgba(239, 68, 68, 0.25);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
}

.diff-change-wrapper:hover .diff-added:not(.rejected) {
    background-color: rgba(30, 58, 95, 0.2);
    box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.3);
}

/* כפתור Toggle - overlay ממורכז על השינוי */
.change-unit-toggle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    /* 🆕 מוסתר כברירת מחדל */
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    pointer-events: none; /* 🆕 לא תופס לחיצות - הלחיצה על הטקסט */
}

/* 🆕 הצגה בהובר על העטיפה */
.diff-change-wrapper:hover .change-unit-toggle {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* כפתור X (דחייה) - בטקסט המוצע */
.toggle-reject {
    background: #fee2e2;
    color: #b91c1c;
    border: 2px solid #fca5a5;
}

/* כפתור V (שמירת מקור) - בטקסט המקורי */
.toggle-keep {
    background: #dcfce7;
    color: #15803d;
    border: 2px solid #86efac;
}

/* 🆕 כשהשינוי נדחה - הכפתור מתחלף */
.toggle-reject.is-rejected {
    background: #dcfce7;
    color: #15803d;
    border: 2px solid #86efac;
}

.toggle-keep.is-rejected {
    background: #fee2e2;
    color: #b91c1c;
    border: 2px solid #fca5a5;
}

/* 🆕 אפקט hover על שינוי שנדחה */
.diff-change-wrapper:hover .diff-removed.rejected {
    background-color: #fef9c3 !important;
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.3);
}

.diff-change-wrapper:hover .diff-added.rejected {
    background-color: #e5e7eb !important;
    box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.2);
}

/* שינוי שנדחה - diff-added */
.diff-added.rejected {
    background-color: #f3f4f6 !important;
    color: #9ca3af !important;
    text-decoration: line-through;
    opacity: 0.6;
    font-weight: 400;
}

/* שינוי שנדחה - diff-removed (המקור נשאר - מודגש!) */
.diff-removed.rejected {
    background-color: #fef3c7 !important;
    color: #92400e !important;
    text-decoration: none !important;
    font-weight: 600;
    opacity: 1;
}

/* אנימציה להופעת כפתור */
@keyframes buttonFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* =================================================================
   SUGGESTION HEADER - כותרת ההצעה
================================================================= */

.unified-suggestion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    background: rgba(249, 250, 251, 0.5);
}

.unified-suggestion-categories {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.unified-category-tag {
    padding: 4px 8px;
    border-radius: 12px;
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.unified-suggestion-priority {
    font-size: 16px;
    display: flex;
    align-items: center;
}

.unified-suggestion-priority.priority-high {
    color: #ef4444;
}

.unified-suggestion-priority.priority-medium {
    color: #f59e0b;
}

.unified-suggestion-priority.priority-low {
    color: #6b7280;
}

/* =================================================================
   TEXT COMPARISON - השוואת טקסט
================================================================= */

.unified-suggestion-content {
    padding: 0;
}

.unified-text-comparison {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #e5e7eb;
}

.unified-original-text,
.unified-improved-text {
    padding: 16px;
    background: white;
}

.unified-original-text {
    border-left: 4px solid #ef4444;
}

.unified-improved-text {
    border-left: 4px solid #22c55e;
}

.unified-text-comparison label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: normal;
}

.unified-text-preview {
    padding: 12px;
    border-radius: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    font-family: 'Heebo', sans-serif;
    line-height: 1.6;
    min-height: 50px;
    font-size: 14px;
    color: #1f2937;
}

.unified-text-preview.improved {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

/* =================================================================
   CHANGES LIST - רשימת שינויים
================================================================= */

.unified-changes-list {
    padding: 16px;
    border-top: 1px solid #f3f4f6;
    background: #fafbfc;
}

.unified-changes-list > label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 12px;
    display: block;
    font-size: 13px;
}

.unified-change-item {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    transition: border-color 0.2s ease;
}

.unified-change-item:hover {
    border-color: #d1d5db;
}

.unified-change-item:last-child {
    margin-bottom: 0;
}

.unified-change-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 8px;
    font-size: 13px;
}

.unified-change-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #1e3a5f;
    cursor: pointer;
}

.unified-change-type {
    padding: 3px 8px;
    background: #e5e7eb;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: #4b5563;
    white-space: nowrap;
}

.unified-change-description {
    flex-grow: 1;
    color: #4b5563;
    font-size: 13px;
}

.unified-change-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-right: 24px;
    padding: 8px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #f3f4f6;
}

.unified-change-from {
    background: #fef2f2;
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: line-through;
    color: #991b1b;
    border: 1px solid #fecaca;
    font-family: monospace;
}

.unified-change-to {
    background: #f0fdf4;
    padding: 4px 8px;
    border-radius: 4px;
    color: #166534;
    font-weight: 600;
    border: 1px solid #bbf7d0;
    font-family: monospace;
}

.unified-change-preview i {
    color: #6b7280;
    font-size: 10px;
}

/* =================================================================
   SUGGESTION EXPLANATION - הסבר ההצעה
================================================================= */

.unified-suggestion-explanation {
    padding: 12px 16px;
    background: #fffbeb;
    border-top: 1px solid #fef3c7;
    color: #92400e;
    font-size: 13px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.unified-suggestion-explanation i {
    color: #d97706;
    margin-top: 2px;
    flex-shrink: 0;
}

/* =================================================================
   ACTION BUTTONS - כפתורי פעולה
================================================================= */

.unified-suggestion-actions {
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.unified-action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 80px;
    justify-content: center;
}

.accept-selected-btn {
    background: linear-gradient(135deg, #1e3a5f 0%, #162d4a 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(30, 58, 95, 0.2);
}

.accept-selected-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.accept-all-btn {
    background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(34, 197, 94, 0.2);
}

.accept-all-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.reject-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
}

.reject-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.unified-action-btn:active {
    transform: translateY(0);
}

.unified-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

/* =================================================================
   ANIMATIONS - אנימציות
================================================================= */

.unified-suggestion-item {
    animation: unified-slideInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes unified-slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.unified-category-tag {
    animation: unified-fadeIn 0.6s ease-out;
}

@keyframes unified-fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* =================================================================
   MOBILE RESPONSIVENESS - תגובה למובייל
================================================================= */

@media (max-width: 768px) {
    .unified-suggestions-panel {
        position: fixed;
        top: 10px;
        left: 10px;
        right: 10px;
        width: auto;
        max-height: 85vh;
    }

    .unified-text-comparison {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .unified-suggestion-actions {
        flex-direction: column;
    }

    .unified-action-btn {
        width: 100%;
    }

    .unified-change-preview {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin-right: 0;
    }

    .unified-panel-header h3 {
        font-size: 14px;
    }

    .unified-category-tag {
        font-size: 10px;
        padding: 3px 6px;
    }
}

@media (max-width: 480px) {
    .unified-suggestions-panel {
        top: 5px;
        left: 5px;
        right: 5px;
    }

    .unified-panel-header {
        padding: 12px 16px;
    }

    .unified-text-preview {
        min-height: 40px;
        font-size: 13px;
    }

    .unified-change-checkbox {
        font-size: 12px;
    }
}

/* =================================================================
   SCROLLBAR STYLING - עיצוב פס הגלילה
================================================================= */

.unified-panel-content::-webkit-scrollbar {
    width: 6px;
}

.unified-panel-content::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.unified-panel-content::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.unified-panel-content::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* =================================================================
   ACCESSIBILITY - נגישות
================================================================= */

.unified-action-btn:focus {
    outline: 1px solid #9ca3af;
    outline-offset: 2px;
}

.unified-change-checkbox input[type="checkbox"]:focus {
    outline: 1px solid #9ca3af;
    outline-offset: 2px;
}

.unified-close-btn:focus {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* =================================================================
   HIGH CONTRAST MODE - מצב ניגודיות גבוהה
================================================================= */

@media (prefers-contrast: high) {
    .unified-suggestions-panel {
        border: 2px solid #000;
    }

    .unified-category-tag {
        border: 1px solid rgba(255, 255, 255, 0.3);
    }

    .unified-text-preview {
        border: 2px solid #666;
    }

    .unified-action-btn {
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
}

/* =================================================================
   ENHANCED LOADING INDICATORS - אינדיקטורי טעינה משופרים
================================================================= */

.unified-loading-content {
    text-align: center;
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.unified-loading-content i.fa-spinner {
    font-size: 28px;
    color: #1e3a5f;
    margin: 0;
}

.loading-text {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.loading-subtext {
    font-size: 13px;
    color: #6b7280;
    margin: 0;
}

.loading-progress {
    width: 100%;
    max-width: 300px;
    height: 8px;
    background: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #1e3a5f 0%, #162d4a 100%);
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
    overflow: hidden;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* אנימציית pulse לטקסט */
.loading-text {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* סטייל מיוחד לכאשר הטעינה ארוכה */
.unified-loading-content.long-loading .loading-subtext {
    color: #ef4444;
    font-weight: 500;
}

.unified-loading-content.long-loading .loading-text {
    animation: urgentPulse 1s infinite;
}

@keyframes urgentPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.02);
    }
}

/* =================================================================
   PRINT STYLES - סגנונות הדפסה
================================================================= */

@media print {
    .unified-suggestions-panel {
        display: none !important;
    }
}

/* =================================================================
   DARK MODE SUPPORT - תמיכה במצב כהה
================================================================= */

@media (prefers-color-scheme: dark) {
    .unified-suggestions-panel {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }

    .unified-panel-header {
        background: linear-gradient(135deg, #4338ca 0%, #6366f1 100%);
    }

    .unified-suggestion-item {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
        border-color: #374151;
    }

    .unified-text-preview {
        background: #111827;
        border-color: #374151;
        color: #f9fafb;
    }

    .unified-text-preview.improved {
        background: #064e3b;
        border-color: #10b981;
        color: #d1fae5;
    }

    .unified-changes-list {
        background: #111827;
    }

    .unified-change-item {
        background: #1f2937;
        border-color: #374151;
    }

    .unified-suggestion-explanation {
        background: #1e293b;
        border-color: #64748b;
        color: #fbbf24;
    }

    .unified-suggestion-actions {
        background: #111827;
    }

    /* עיצוב טקסט מקורי והצעה במצב כהה */
    .unified-original-text-minimal {
        color: #6b7280; /* אפור כהה יותר במצב כהה */
        border-bottom-color: #f87171; /* אדום בהיר יותר במצב כהה */
    }

    .unified-suggested-text-minimal {
        color: #f3f4f6;
        border-bottom-color: #60a5fa; /* כחול בהיר יותר במצב כהה */
    }
}

/* =================================================================
   CSS HIGHLIGHT API - V3 הדגשות עם CSS Highlight API
================================================================= */

/* הדגשה בסיסית לכל ההצעות */
::highlight(grammar-errors) {
    background-color: rgba(255, 230, 0, 0.2);
    text-decoration: underline solid #e74c3c 2px;
    cursor: pointer;
}

/* 🔴 היילייט למחיקות - מוצג בעת hover על הצעה */
::highlight(grammar-deletions) {
    background-color: rgba(239, 68, 68, 0.25);
    text-decoration: line-through solid #ef4444 2px;
    color: #b91c1c;
}

/* תמיכה במצב כהה */
@media (prefers-color-scheme: dark) {
    ::highlight(grammar-errors) {
        background-color: rgba(251, 191, 36, 0.15);
        text-decoration: underline solid #f87171 2px;
    }
    ::highlight(grammar-deletions) {
        background-color: rgba(239, 68, 68, 0.2);
        text-decoration: line-through solid #f87171 2px;
        color: #fca5a5;
    }
}

/* ניגודיות גבוהה */
@media (prefers-contrast: high) {
    ::highlight(grammar-errors) {
        background-color: rgba(255, 230, 0, 0.4);
        text-decoration: underline solid #dc2626 3px;
    }
}

/* =================================================================
   GRAMMARLY-STYLE TEXT HIGHLIGHTING - הדגשות טקסט בסגנון Grammarly
   (נשמר לתאימות לאחור - DOM-based highlights)
================================================================= */

/* הדגשות בסיסיות לפי סוג */
.grammarly-highlight {
    position: relative;
    cursor: pointer;
    border-radius: 2px;
    transition: all 0.2s ease;
    display: inline;
    font-style: inherit;
    font-weight: inherit;
    line-height: inherit;
}

/* אפקט hover כללי */
.grammarly-highlight:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(-0.5px);
}

/* הדגשות לפי קטגוריות - עדינות ומינימליסטיות */
.grammarly-grammar {
    background: linear-gradient(180deg, transparent 70%, rgba(239, 68, 68, 0.15) 70%);
    border-bottom: 2px solid rgba(239, 68, 68, 0.35);
}

.grammarly-spelling {
    background: linear-gradient(180deg, transparent 70%, rgba(239, 68, 68, 0.18) 70%);
    border-bottom: 2px solid rgba(239, 68, 68, 0.4);
}

.grammarly-punctuation {
    background: linear-gradient(180deg, transparent 70%, rgba(245, 158, 11, 0.15) 70%);
    border-bottom: 2px solid rgba(245, 158, 11, 0.4);
}

.grammarly-style {
    background: linear-gradient(180deg, transparent 70%, rgba(34, 197, 94, 0.12) 70%);
    border-bottom: 2px solid rgba(34, 197, 94, 0.35);
}

.grammarly-clarity {
    background: linear-gradient(180deg, transparent 70%, rgba(99, 102, 241, 0.12) 70%);
    border-bottom: 2px solid rgba(99, 102, 241, 0.35);
}

.grammarly-headers {
    background: linear-gradient(180deg, transparent 70%, rgba(139, 92, 246, 0.12) 70%);
    border-bottom: 2px solid rgba(139, 92, 246, 0.35);
}

.grammarly-sources {
    background: linear-gradient(180deg, transparent 70%, rgba(6, 182, 212, 0.12) 70%);
    border-bottom: 2px solid rgba(6, 182, 212, 0.35);
}

/* רמות עדיפות - ללא אנימציות מיותרות */
.grammarly-highlight.priority-high {
    border-bottom-width: 2.5px; /* קו מעט יותר עבה לעדיפות גבוהה */
}

.grammarly-highlight.priority-high:hover {
    background-color: rgba(239, 68, 68, 0.08);
}

.grammarly-highlight.priority-medium:hover {
    background-color: rgba(245, 158, 11, 0.06);
}

.grammarly-highlight.priority-low:hover {
    background-color: rgba(107, 114, 128, 0.04);
}

/* אפקט כשלוחצים על הדגשה */
.grammarly-highlight:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* הדגשה בפאנל כשלוחצים על טקסט מודגש - רקע לבן עם מסגרת אפורה */
.highlighted-in-panel {
    background: white !important;
    transform: none;
    transition: all 0.2s ease;
    border: 1px solid #9ca3af !important;
    box-shadow: 0 2px 8px rgba(156, 163, 175, 0.15) !important;
}

/* תאימות למובייל */
@media (max-width: 768px) {
    .grammarly-highlight {
        border-bottom-width: 1.5px;
    }

    .grammarly-highlight:hover {
        transform: none;
        box-shadow: none;
    }

    /* הגדלת אזור המגע בנייד */
    .grammarly-highlight {
        padding: 2px 0;
        margin: -2px 0;
    }
}

/* מצב ניגודיות גבוהה */
@media (prefers-contrast: high) {
    .grammarly-highlight {
        border-bottom-width: 3px;
    }

    .grammarly-grammar {
        border-bottom-color: #dc2626;
        background: rgba(239, 68, 68, 0.4);
    }

    .grammarly-spelling {
        border-bottom-color: #dc2626;
        background: rgba(239, 68, 68, 0.5);
    }

    .grammarly-punctuation {
        border-bottom-color: #d97706;
        background: rgba(245, 158, 11, 0.4);
    }

    .grammarly-style {
        border-bottom-color: #059669;
        background: rgba(34, 197, 94, 0.35);
    }
}

/* מצב כהה */
@media (prefers-color-scheme: dark) {
    .grammarly-grammar {
        background: linear-gradient(180deg, transparent 65%, rgba(248, 113, 113, 0.2) 65%);
        border-bottom-color: rgba(248, 113, 113, 0.5);
    }

    .grammarly-spelling {
        background: linear-gradient(180deg, transparent 65%, rgba(248, 113, 113, 0.25) 65%);
        border-bottom-color: rgba(248, 113, 113, 0.6);
    }

    .grammarly-punctuation {
        background: linear-gradient(180deg, transparent 65%, rgba(251, 191, 36, 0.2) 65%);
        border-bottom-color: rgba(251, 191, 36, 0.5);
    }

    .grammarly-style {
        background: linear-gradient(180deg, transparent 65%, rgba(74, 222, 128, 0.2) 65%);
        border-bottom-color: rgba(74, 222, 128, 0.5);
    }

    .grammarly-clarity {
        background: linear-gradient(180deg, transparent 65%, rgba(129, 140, 248, 0.2) 65%);
        border-bottom-color: rgba(129, 140, 248, 0.5);
    }

    .grammarly-headers {
        background: linear-gradient(180deg, transparent 65%, rgba(168, 85, 247, 0.2) 65%);
        border-bottom-color: rgba(168, 85, 247, 0.5);
    }

    .grammarly-sources {
        background: linear-gradient(180deg, transparent 65%, rgba(34, 211, 238, 0.2) 65%);
        border-bottom-color: rgba(34, 211, 238, 0.5);
    }
}

/* =================================================================
   POPUP TOOLTIPS - עיצוב חדש בסגנון הפאנל עם חץ למטה
================================================================= */

.grammarly-popup-tooltip {
    position: fixed;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    font-family: 'Heebo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    letter-spacing: normal;
    direction: rtl;
    text-align: right;
    max-width: 350px;
    width: fit-content;
    padding: 8px 12px; /* סגנון סורק */
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    animation: popupSlideIn 0.15s ease-out;
}

/* חץ (משולש) כלפי מטה - כשהטולטיפ מעל המילה */
.grammarly-popup-tooltip.arrow-below::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #ffffff;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.08));
}

/* מסגרת לחץ */
.grammarly-popup-tooltip.arrow-below::before {
    content: '';
    position: absolute;
    bottom: -9px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 9px solid #e5e7eb;
}

/* חץ כלפי מעלה - כשהטולטיפ מתחת למילה */
.grammarly-popup-tooltip.arrow-above::after {
    content: '';
    position: absolute;
    top: -8px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #ffffff;
    filter: drop-shadow(0 -2px 2px rgba(0, 0, 0, 0.08));
}

.grammarly-popup-tooltip.arrow-above::before {
    content: '';
    position: absolute;
    top: -9px;
    left: var(--arrow-left, 50%);
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-bottom: 9px solid #e5e7eb;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* כותרת - מוסרים לחלוטין, לא נחוץ בעיצוב החדש */
.popup-header {
    display: none !important;
}

.popup-title {
    display: none !important;
}

.popup-close-btn {
    display: none !important;
}

/* תוכן אופקי מינימליסטי - רק הטקסט המשופר */
.popup-changes-list {
    display: none !important; /* מסתירים את הרשימה הישנה */
}

.popup-change-item {
    display: none !important;
}

/* תוכן - טקסט מימין */
.popup-content-inline {
    flex: 1;
    display: flex;
    align-items: flex-start;
}

/* טקסט מוצע - רקע לבן נקי, קו כחול למטה */
.popup-suggested-text-inline {
    font-size: 16px;
    font-weight: 400; /* רגיל, כדי שהדגשות יבלטו */
    color: #1f2937;
    line-height: 1.4;
    word-wrap: break-word;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    text-align: right;
    direction: rtl;
    padding-bottom: 4px;
    border-bottom: 2px solid #1e3a5f; /* קו כחול כמו הלוגו */
    font-family: 'Heebo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; /* פונט Heebo כמו העורך */
    letter-spacing: normal; /* Reset - ללא ריווח נוסף */
}

/* הדגשות בתוך הטולטיפ */
.popup-suggested-text-inline strong {
    font-weight: 700;
    color: #111827;
}

.popup-suggested-text-inline em {
    font-style: italic;
}

.popup-category-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    color: white;
    text-transform: uppercase;
    letter-spacing: normal;
    white-space: nowrap;
}

/* =================================================================
   POPUP DIFF UNIFIED - תצוגת טולטיפ בסגנון הסורק (קו כחול תחתון)
================================================================= */
.popup-diff-unified {
    font-size: 16px;
    line-height: 1.4;
    color: #1f2937;
    direction: rtl;
    text-align: right;
    max-width: 350px;
    padding-bottom: 4px;
    border-bottom: 2px solid #1e3a5f;
    font-family: 'Heebo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-weight: 400;
}

/* diff בתוך הטולטיפ - סגנון סורק (טקסט נקי, בלי רקע) */
.popup-diff-unified .diff-removed {
    /* לא מוצג בטולטיפ - המחיקות מוצגות בהייליט בעורך */
    display: none;
}

.popup-diff-unified .diff-added {
    color: #1e3a5f;
    font-weight: 500;
    /* ללא רקע - טקסט נקי כמו הסורק */
}

/* =================================================================
   🆕 POPUP TOGGLE - קבלה/דחייה של שינויים בודדים בטולטיפ
   עיצוב זהה לפאנל - עם V/X על הטקסט
================================================================= */

/* כשיש מספר שינויים - הטקסט זורם inline */
.popup-diff-unified.has-toggles {
    display: block;
    border-bottom: none;
    padding-bottom: 0;
}

/* wrapper לשינוי בודד עם toggle - כמו בכרטיסיות הפאנל */
.popup-diff-unified .diff-change-wrapper {
    display: inline;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
}

.popup-diff-unified .diff-change-wrapper:hover {
    background: rgba(30, 58, 95, 0.15);
    border-radius: 3px;
}

/* הסגנון של diff-added בטולטיפ - diff-removed מוסתר (מוצג בהייליט בעורך) */
.popup-diff-unified .diff-added {
    color: #1e3a5f;
    font-weight: 500;
    display: inline;
    background: transparent;
}

/* כפתור Toggle - כמו בפאנל: overlay ממורכז על המילה */
.popup-diff-unified .change-unit-toggle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    /* מוסתר כברירת מחדל */
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

/* הצגה בהובר על העטיפה */
.popup-diff-unified .diff-change-wrapper:hover .change-unit-toggle {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* כפתור X (דחייה) - רקע אדום בהיר */
.popup-diff-unified .toggle-reject {
    background: #fee2e2;
    color: #b91c1c;
    border: 2px solid #fca5a5;
}

/* כפתור V (שמירת מקור) - רקע ירוק בהיר */
.popup-diff-unified .toggle-keep {
    background: #dcfce7;
    color: #15803d;
    border: 2px solid #86efac;
}

/* מצב kept - המשתמש בחר לשמור את המקור */
.popup-diff-unified .diff-change-wrapper.kept .diff-removed {
    text-decoration: none;
    color: #10b981;
    font-weight: 500;
}

.popup-diff-unified .diff-change-wrapper.kept .toggle-keep {
    opacity: 1;
    visibility: visible;
}

/* מצב rejected - המשתמש דחה את השינוי */
.popup-diff-unified .diff-change-wrapper.rejected .diff-added {
    text-decoration: line-through;
    color: #9ca3af;
    opacity: 0.5;
}

.popup-diff-unified .diff-change-wrapper.rejected .toggle-reject {
    opacity: 1;
    visibility: visible;
}

/* =================================================================
   LEGACY - רשימת תיקונים מינימליסטית (לא בשימוש בטולטיפ)
================================================================= */

/* רשימת תיקונים מינימליסטית - שורה נוספת */
.popup-changes-mini {
    flex-basis: 100%;
    display: flex;
    gap: 4px;
    padding: 6px 0 0 0;
    border-top: 1px solid #f3f4f6;
    margin-top: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.popup-change-mini {
    font-size: 11px;
    padding: 2px 6px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.popup-change-mini i {
    font-size: 9px;
    color: #9ca3af;
}

.popup-change-mini .change-from {
    color: #dc2626;
    font-weight: 500;
}

.popup-change-mini .change-to {
    color: #16a34a;
    font-weight: 600;
}

/* כפתורים מינימליסטיים לכל תיקון */
.popup-change-mini-actions {
    display: flex;
    gap: 2px;
    margin-right: 3px;
}

.popup-change-mini-btn {
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    transition: all 0.1s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.popup-change-mini-btn:hover {
    transform: scale(1.15);
}

.popup-change-mini-btn:active {
    transform: scale(0.9);
}

.popup-change-mini-accept {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
}

.popup-change-mini-reject {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
}

/* הסבר - מוסתר בעיצוב המינימליסטי */
.popup-explanation {
    display: none !important;
}

/* כפתורי פעולה - ריבועים באותה שורה */
.popup-actions {
    display: flex;
    flex-direction: row; /* V ו-X באותה שורה */
    gap: 6px;
    align-items: center;
}

.popup-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    background: white;
    border: 1px solid;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.popup-btn:hover {
    transform: translateY(-1px);
}

.popup-btn:active {
    transform: translateY(0);
}

/* כפתור קבלה - כחול כמו בפאנל */
.popup-apply-selected,
.popup-apply-all {
    color: #1e3a5f;
    border-color: #1e3a5f;
}

.popup-apply-selected:hover,
.popup-apply-all:hover {
    background: #eff6ff;
    box-shadow: 0 2px 8px rgba(30, 58, 95, 0.3);
}

/* כפתור דחייה - אדום כמו בפאנל */
.popup-reject {
    color: #ef4444;
    border-color: #ef4444;
}

.popup-reject:hover {
    background: #fef2f2;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

/* התאמה למובייל */
@media (max-width: 768px) {
    .grammarly-popup-tooltip {
        max-width: calc(100vw - 40px);
        padding: 5px 8px;
        gap: 8px;
    }

    .popup-suggested-text-inline {
        font-size: 14px;
    }

    .popup-btn {
        width: 26px;
        height: 26px;
        font-size: 11px;
    }
}

/* מצב כהה לpopup */
@media (prefers-color-scheme: dark) {
    .grammarly-popup-tooltip {
        background: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }

    .grammarly-popup-tooltip.arrow-below::after {
        border-top-color: #1f2937;
    }

    .grammarly-popup-tooltip.arrow-below::before {
        border-top-color: #374151;
    }

    .grammarly-popup-tooltip.arrow-above::after {
        border-bottom-color: #1f2937;
    }

    .grammarly-popup-tooltip.arrow-above::before {
        border-bottom-color: #374151;
    }

    .popup-suggested-text-inline {
        color: #f3f4f6;
        border-bottom-color: #60a5fa; /* כחול בהיר יותר במצב כהה */
    }

    .popup-btn {
        background: #1f2937;
    }

    .popup-apply-all {
        color: #60a5fa;
        border-color: #60a5fa;
    }

    .popup-reject {
        color: #f87171;
        border-color: #f87171;
    }
}

/* =================================================================
   REFERENCE PANEL SYSTEM - פאנל מידע עזר
   מקורות, ניתוח והפניות
================================================================= */

/* רשימת references */
.references-list {
    padding: 12px;
}

/* פריט reference בודד */
.reference-item {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    padding: 14px;
    transition: all 0.3s ease;
    cursor: default;
}

.reference-item:hover {
    border-color: #4a90d9;
    box-shadow: 0 4px 16px rgba(74, 144, 217, 0.12);
}

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

/* כותרת reference - מספר וקטגוריה */
.reference-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.reference-number {
    font-size: 14px;
    font-weight: 700;
    color: #1e3a5f;
    background: #e8f4fd;
    padding: 2px 8px;
    border-radius: 6px;
}

.reference-category-badge {
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.reference-category-badge i {
    font-size: 11px;
}

/* כפתור הסרה */
.reference-remove-btn {
    margin-right: auto;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    opacity: 0;
}

.reference-item:hover .reference-remove-btn {
    opacity: 1;
}

.reference-remove-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* הדגשת reference בפאנל */
.reference-item.reference-highlighted {
    border-color: #4a90d9;
    background: #e8f4fd;
    box-shadow: 0 0 20px rgba(74, 144, 217, 0.3);
    animation: reference-highlight-pulse 0.5s ease;
}

@keyframes reference-highlight-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

/* טקסט מקושר - לחיץ */
.reference-linked-text {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-family: 'Heebo', sans-serif;
    font-size: 14px;
    color: #475569;
    line-height: 1.6;
}

.reference-linked-text:hover {
    background: #e8f4fd;
    border-color: #4a90d9;
}

.reference-link-icon {
    color: #4a90d9;
    font-size: 12px;
    margin-top: 3px;
    flex-shrink: 0;
}

/* תוכן המידע */
.reference-content {
    font-family: 'Heebo', sans-serif;
    font-size: 14px;
    color: #1e293b;
    line-height: 1.7;
    margin-bottom: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
}

/* הסבר */
.reference-explanation {
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 10px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.reference-explanation i {
    color: #94a3b8;
    margin-top: 2px;
    flex-shrink: 0;
}

/* כפתורי פעולה */
.reference-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: wrap;
    padding-top: 8px;
    align-items: center;
}

.reference-copy-btn,
.reference-insert-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid;
}

.reference-copy-btn {
    background: #f8fafc;
    color: #475569;
    border-color: #e2e8f0;
}

.reference-copy-btn:hover {
    background: #e8f4fd;
    color: #1e3a5f;
    border-color: #4a90d9;
}

.reference-insert-btn {
    background: linear-gradient(135deg, #4a90d9 0%, #3b7dc4 100%);
    color: white;
    border-color: transparent;
}

.reference-insert-btn:hover {
    background: linear-gradient(135deg, #3b7dc4 0%, #2d6aaf 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 144, 217, 0.3);
}

/* =================================================================
   REFERENCE NUMBER MARKERS - מספורים בעורך
================================================================= */

.reference-number-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #9333ea;
    background: #f3e8ff;
    border: 1px solid #9333ea;
    border-radius: 4px;
    padding: 1px 5px;
    margin: 0 3px;
    cursor: pointer;
    vertical-align: super;
    line-height: 1;
    transition: all 0.2s ease;
}

.reference-number-marker:hover {
    background: #9333ea;
    color: white;
    transform: scale(1.1);
}

/* אנימציית הבהוב */
.reference-number-marker.marker-flash {
    animation: marker-flash 1.5s ease;
}

@keyframes marker-flash {
    0%, 100% {
        background: #f3e8ff;
        color: #9333ea;
    }
    25%, 75% {
        background: #9333ea;
        color: white;
        transform: scale(1.2);
    }
}

/* =================================================================
   REFERENCE PANEL NEW BUTTONS
================================================================= */

.reference-insert-after-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #16a34a40;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reference-insert-after-btn:hover {
    background: #16a34a;
    color: white;
    border-color: #16a34a;
}

.reference-dismiss-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #dc262640;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.reference-dismiss-btn:hover {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

/* Fade out animation for dismissed items */
.reference-item.fade-out {
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.2s ease;
}

/* =================================================================
   REFERENCE PANEL BULK ACTION BUTTONS
================================================================= */

/* קונטיינר לכפתורי "הכנס הכל" ו"התעלם מהכל" */
.references-list + .inline-control-bar .inline-action-btns,
.panel-inline-results .inline-action-btns {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

/* כפתור "הכנס הכל" */
.inline-accept-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #16a34a40;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.inline-accept-all-btn:hover {
    background: #16a34a;
    color: white;
    border-color: #16a34a;
}

.inline-accept-all-btn img,
.inline-accept-all-btn i {
    width: 12px;
    height: 12px;
    font-size: 10px;
}

/* כפתור "התעלם מהכל" */
.inline-reject-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #dc262640;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.inline-reject-all-btn:hover {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.inline-reject-all-btn img {
    width: 12px;
    height: 12px;
}

/* עיצוב ה-control bar בתוך reference panel */
.panel-inline-results .inline-control-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8fafc;
    border-radius: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.panel-inline-results .inline-nav-controls {
    flex: 1;
    min-width: 0;
}

.panel-inline-results .inline-status-text {
    font-size: 12px;
    color: #64748b;
}

/* Dark mode for bulk action buttons */
@media (prefers-color-scheme: dark) {
    .inline-accept-all-btn {
        background: #14532d;
        color: #4ade80;
        border-color: #4ade8040;
    }

    .inline-accept-all-btn:hover {
        background: #4ade80;
        color: #0f172a;
    }

    .inline-reject-all-btn {
        background: #450a0a;
        color: #f87171;
        border-color: #f8717140;
    }

    .inline-reject-all-btn:hover {
        background: #f87171;
        color: #0f172a;
    }

    .panel-inline-results .inline-control-bar {
        background: #1e293b;
    }

    .panel-inline-results .inline-status-text {
        color: #94a3b8;
    }
}

/* הדגשת reference בפאנל */
.reference-item.reference-flash {
    animation: reference-item-flash 1.5s ease;
}

@keyframes reference-item-flash {
    0%, 100% {
        border-color: #e5e7eb;
        background: linear-gradient(135deg, #ffffff 0%, #fafbfc 100%);
    }
    25%, 75% {
        border-color: #4a90d9;
        background: #e8f4fd;
        box-shadow: 0 0 20px rgba(74, 144, 217, 0.3);
    }
}

/* =================================================================
   REFERENCE TOAST - הודעות
================================================================= */

.reference-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    padding: 12px 24px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    animation: toast-in 0.3s ease;
}

.reference-toast-success i {
    color: #10b981;
}

.reference-toast-error i {
    color: #ef4444;
}

.reference-toast.fade-out {
    animation: toast-out 0.3s ease forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
    to {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
}

/* =================================================================
   DARK MODE - מצב כהה ל-references
================================================================= */

@media (prefers-color-scheme: dark) {
    .reference-item {
        background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
        border-color: #374151;
    }

    .reference-item:hover {
        border-color: #60a5fa;
    }

    .reference-item.reference-highlighted {
        background: #1e3a5f;
        border-color: #60a5fa;
    }

    .reference-remove-btn {
        color: #6b7280;
    }

    .reference-remove-btn:hover {
        background: #7f1d1d;
        color: #fca5a5;
    }

    .reference-number {
        background: #1e3a5f;
        color: #60a5fa;
    }

    .reference-linked-text {
        background: #111827;
        border-color: #374151;
        color: #94a3b8;
    }

    .reference-linked-text:hover {
        background: #1e3a5f;
        border-color: #60a5fa;
    }

    .reference-content {
        color: #e2e8f0;
        border-bottom-color: #374151;
    }

    .reference-explanation {
        color: #94a3b8;
    }

    .reference-copy-btn {
        background: #1f2937;
        color: #94a3b8;
        border-color: #374151;
    }

    .reference-copy-btn:hover {
        background: #1e3a5f;
        color: #60a5fa;
        border-color: #60a5fa;
    }

    .reference-number-marker {
        background: #2d1b4e;
        color: #c084fc;
        border-color: #c084fc;
    }

    .reference-number-marker:hover {
        background: #c084fc;
        color: #0f172a;
    }

    .reference-insert-after-btn {
        background: #14532d;
        color: #4ade80;
        border-color: #4ade8040;
    }

    .reference-insert-after-btn:hover {
        background: #4ade80;
        color: #0f172a;
    }

    .reference-dismiss-btn {
        background: #450a0a;
        color: #f87171;
        border-color: #f8717140;
    }

    .reference-dismiss-btn:hover {
        background: #f87171;
        color: #0f172a;
    }

    .reference-inserted-text {
        color: #c084fc;
        background: #2d1b4e40;
    }
}

/* =================================================================
   REFERENCE NUMBER MARKER - לא ניתן לעריכה
================================================================= */

/* המספורים לא ניתנים לעריכה - נעים עם הטקסט */
.reference-number-marker[contenteditable="false"] {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    cursor: pointer;
    outline: none;
}

/* מניעת הבחירה של המספורים */
.reference-number-marker::selection {
    background: transparent;
}

.reference-number-marker::-moz-selection {
    background: transparent;
}

/* =================================================================
   FOOTNOTES SYSTEM - מערכת הערות שוליים
================================================================= */

/* =================================================================
   FOOTNOTES RESIZE HANDLE - ידית לגרירה לשינוי גובה
================================================================= */

.footnotes-resize-handle {
    /* מרווחים תואמים ל-footnotes-section */
    margin-right: 142px;
    margin-left: 110px;
    height: 12px;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: background 0.2s ease;
    position: relative;
    z-index: 10;
}

.footnotes-resize-handle:hover {
    background: rgba(74, 144, 217, 0.1);
}

.footnotes-resize-handle.resizing {
    background: rgba(74, 144, 217, 0.2);
}

.footnotes-resize-line {
    width: 60px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.footnotes-resize-handle:hover .footnotes-resize-line {
    background: #4a90d9;
    width: 80px;
}

.footnotes-resize-handle.resizing .footnotes-resize-line {
    background: #4a90d9;
    width: 100px;
    height: 5px;
}

/* קונטיינר הערות שוליים - תואם לרוחב העורך */
.footnotes-section {
    /* 🆕 מרווחים תואמים ל-text-editor — מקור-אמת יחיד (var על body ב-main.css) */
    margin-right: var(--editor-space-right, 142px);
    margin-left: var(--editor-space-left, 110px);
    margin-top: 8px;
    margin-bottom: 2px;
    padding: 16px 1cm;
    /* סגנון תואם לעורך */
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    /* מעבר חלק כמו העורך — margin (כולל שמאל, שהיה בחוקי-state שאוחדו) */
    transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    direction: rtl;
    text-align: right;
}

.footnotes-separator {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 0 0 12px 0;
}

/* header עם כותרת וכפתור סגירה */
.footnotes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

/* כותרת הערות שוליים */
.footnotes-title {
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
}

/* כפתור סגירה קטן - רק X */
.footnotes-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
}

.footnotes-close-btn:hover {
    background: #f3f4f6;
    color: #4b5563;
}

.footnotes-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 25vh;
    overflow-y: auto;
}

/* Scrollbar styling for footnotes */
.footnotes-container::-webkit-scrollbar {
    width: 6px;
}

.footnotes-container::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 3px;
}

.footnotes-container::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.footnotes-container::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* הערה בודדת */
.footnote {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 12px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
    position: relative;
    transition: all 0.2s ease;
}

.footnote:hover {
    background: #f9fafb;
}

.footnote-back {
    color: #4a90d9;
    text-decoration: none;
    font-weight: 600;
    flex-shrink: 0;
    cursor: pointer;
}

.footnote-back:hover {
    text-decoration: underline;
}

.footnote-content {
    flex: 1;
    color: #374151;
    min-width: 100px;
    outline: none;
    padding: 2px 4px;
    border-radius: 4px;
    /* ירושת פונט מהעורך */
    font-family: inherit;
    font-size: inherit;
    line-height: 1.6;
}

/* Editable footnote content - ללא רקע ומסגרת */
.footnote-content[contenteditable="true"]:focus {
    /* ללא שינוי בפוקוס */
}

/* Placeholder for empty footnote */
.footnote-content[contenteditable="true"]:empty::before {
    content: attr(placeholder);
    color: #9ca3af;
    font-style: italic;
}

.footnote-hide-btn,
.footnote-delete-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    background: transparent;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    opacity: 0;
    transition: all 0.2s ease;
}

.footnote:hover .footnote-hide-btn,
.footnote:hover .footnote-delete-btn {
    opacity: 1;
}

.footnote-hide-btn:hover {
    background: #e0e7ff;
    color: #4f46e5;
}

.footnote-delete-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

/* הדגשת הערה */
.footnote-highlight {
    background: #dbeafe !important;
    box-shadow: 0 0 0 2px #3b82f6;
}

/* Reference בטקסט */
.footnote-ref {
    color: #4a90d9;
    text-decoration: none;
    cursor: pointer;
    user-select: none;
}

.footnote-ref sup {
    font-size: 11px;
    font-weight: 600;
    vertical-align: super;
    margin: 0 1px;
}

.footnote-ref:hover {
    color: #2563eb;
    text-decoration: underline;
}

.footnote-ref-highlight {
    background: #dbeafe;
    border-radius: 3px;
    animation: footnote-pulse 0.5s ease 2;
}

@keyframes footnote-pulse {
    0%, 100% { background: #dbeafe; }
    50% { background: #93c5fd; }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    .footnotes-resize-handle:hover {
        background: rgba(96, 165, 250, 0.15);
    }

    .footnotes-resize-handle.resizing {
        background: rgba(96, 165, 250, 0.25);
    }

    .footnotes-resize-line {
        background: #4b5563;
    }

    .footnotes-resize-handle:hover .footnotes-resize-line,
    .footnotes-resize-handle.resizing .footnotes-resize-line {
        background: #60a5fa;
    }

    .footnotes-section {
        border-top-color: #374151;
    }

    .footnotes-separator {
        border-top-color: #374151;
    }

    .footnotes-header {
        color: #9ca3af;
    }

    .footnotes-title {
        color: #9ca3af;
    }

    .footnotes-close-btn {
        color: #6b7280;
    }

    .footnotes-close-btn:hover {
        background: #374151;
        color: #d1d5db;
    }

    .footnotes-container::-webkit-scrollbar-track {
        background: #1f2937;
    }

    .footnotes-container::-webkit-scrollbar-thumb {
        background: #4b5563;
    }

    .footnotes-container::-webkit-scrollbar-thumb:hover {
        background: #6b7280;
    }

    .footnote {
        background: #1f2937;
    }

    .footnote:hover {
        background: #374151;
    }

    .footnote-content {
        color: #e5e7eb;
    }

    .footnote-content[contenteditable="true"]:focus {
        /* ללא שינוי בפוקוס */
    }

    .footnote-content[contenteditable="true"]:empty::before {
        color: #6b7280;
    }

    .footnote-highlight {
        background: #1e3a5f !important;
        box-shadow: 0 0 0 2px #60a5fa;
    }

    .footnote-ref {
        color: #60a5fa;
    }

    .footnote-ref:hover {
        color: #93c5fd;
    }
}

/* =================================================================
   🆕 DELETION SUGGESTIONS - הצעות מחיקה
================================================================= */

/* פריט מחיקה - מסגרת אדומה */
.unified-deletion-item {
    border-color: #fecaca !important;
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%) !important;
}

.unified-deletion-item:hover {
    border-color: #f87171 !important;
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.15) !important;
}

/* תג מחיקה */
.unified-deletion-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #fee2e2;
    color: #dc2626;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.unified-deletion-badge i {
    font-size: 11px;
}

/* טקסט למחיקה - קו חוצה אדום */
.unified-deletion-text {
    border-bottom-color: #ef4444 !important;
}

.unified-deletion-text .diff-removed {
    background: rgba(239, 68, 68, 0.15);
    color: #b91c1c;
    text-decoration: line-through;
    text-decoration-color: #ef4444;
}

/* כפתור מחיקה */
.delete-btn-minimal {
    color: #dc2626 !important;
    border-color: #dc2626 !important;
    background: #fef2f2;
}

.delete-btn-minimal:hover {
    background: #fee2e2 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.3) !important;
}

.delete-btn-minimal i {
    font-size: 12px;
}

/* מצב כהה */
@media (prefers-color-scheme: dark) {
    .unified-deletion-item {
        border-color: #7f1d1d !important;
        background: linear-gradient(135deg, #1f2937 0%, #2d1515 100%) !important;
    }

    .unified-deletion-item:hover {
        border-color: #f87171 !important;
    }

    .unified-deletion-badge {
        background: #7f1d1d;
        color: #fca5a5;
    }

    .unified-deletion-text .diff-removed {
        background: rgba(239, 68, 68, 0.2);
        color: #fca5a5;
    }

    .delete-btn-minimal {
        color: #f87171 !important;
        border-color: #f87171 !important;
        background: #2d1515;
    }

    .delete-btn-minimal:hover {
        background: #7f1d1d !important;
    }
}