/**
 * Exact Sources System - CSS
 * סגנונות למערכת מראי מקומות מדויקים
 */

/* ===========================================
   Source Context Tooltip
   =========================================== */
.source-context-tooltip {
    position: fixed;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    max-width: 450px;
    min-width: 300px;
    z-index: 10000;
    font-family: 'Heebo', 'Tahoma', sans-serif;
    direction: rtl;
    overflow: hidden;
    animation: tooltipFadeIn 0.2s ease-out;
}

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

.context-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--accent-gradient, linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%));
    color: white;
}

.context-reference {
    font-weight: 600;
    font-size: 14px;
}

.context-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    color: white;
}

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

.context-body {
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.context-verse {
    padding: 8px 12px;
    margin: 4px 0;
    border-radius: 6px;
    line-height: 1.7;
    font-size: 14px;
}

.context-verse.muted {
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-muted, #64748b);
    font-size: 13px;
}

.context-verse.current {
    background: var(--accent-light, #eef2ff);
    border-right: 3px solid var(--accent-color, #4f46e5);
    font-weight: 500;
    color: var(--text-primary, #1e293b);
}

.context-before,
.context-after {
    opacity: 0.8;
}

.context-main {
    margin: 8px 0;
}

/* ===========================================
   Exact Sources Button Styles
   =========================================== */
.exact-sources-btn {
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.exact-sources-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

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

.exact-sources-btn i {
    font-size: 12px;
}

/* ===========================================
   Verification Badge
   =========================================== */
.verification-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.verification-badge.verified {
    background: #dcfce7;
    color: #166534;
}

.verification-badge.error {
    background: #fef2f2;
    color: #dc2626;
}

.verification-badge.warning {
    background: #fefce8;
    color: #ca8a04;
}

/* ===========================================
   Source Type Icons
   =========================================== */
.source-type-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.source-type-icon.tanach {
    background: #dbeafe;
    color: #1d4ed8;
}

.source-type-icon.talmud {
    background: #fef3c7;
    color: #b45309;
}

.source-type-icon.mishna {
    background: #dcfce7;
    color: #166534;
}

.source-type-icon.midrash {
    background: #f3e8ff;
    color: #7c3aed;
}

.source-type-icon.halacha {
    background: #fce7f3;
    color: #be185d;
}

.source-type-icon.commentary {
    background: #e0e7ff;
    color: #4f46e5;
}

/* ===========================================
   Suggestion Card for Sources
   =========================================== */
.suggestion-card[data-type="exact_source"] {
    border-right-color: #059669;
}

.suggestion-card[data-type="exact_source"] .suggestion-type-badge {
    background: #dcfce7;
    color: #166534;
}

.suggestion-card[data-type="verification_error"] {
    border-right-color: #dc2626;
}

.suggestion-card[data-type="verification_error"] .suggestion-type-badge {
    background: #fef2f2;
    color: #dc2626;
}

/* ===========================================
   Context Button in Suggestion Card
   =========================================== */
.context-btn {
    background: var(--bg-secondary, #f1f5f9);
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.context-btn:hover {
    background: var(--accent-light, #eef2ff);
    color: var(--accent-color, #4f46e5);
}

.context-btn i {
    font-size: 10px;
}

/* ===========================================
   Dark Theme Support
   =========================================== */
.dark-theme .source-context-tooltip {
    background: var(--bg-primary-dark, #1e293b);
    border-color: var(--border-color-dark, #334155);
}

.dark-theme .context-verse.muted {
    background: var(--bg-secondary-dark, #334155);
    color: var(--text-muted-dark, #94a3b8);
}

.dark-theme .context-verse.current {
    background: rgba(79, 70, 229, 0.2);
    color: var(--text-primary-dark, #f1f5f9);
}

.dark-theme .source-type-icon {
    filter: brightness(0.9);
}

/* ===========================================
   Split Button for Sources Menu
   =========================================== */
.sources-split-btn {
    display: flex;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color, #e2e8f0);
}

.sources-split-btn .main-btn {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-primary, #ffffff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary, #1e293b);
    transition: background 0.2s;
}

.sources-split-btn .main-btn:hover {
    background: var(--bg-hover, #f8fafc);
}

.sources-split-btn .dropdown-btn {
    padding: 10px 12px;
    background: var(--bg-secondary, #f1f5f9);
    border: none;
    border-right: 1px solid var(--border-color, #e2e8f0);
    cursor: pointer;
    color: var(--text-secondary, #64748b);
    transition: background 0.2s;
}

.sources-split-btn .dropdown-btn:hover {
    background: var(--bg-hover, #e2e8f0);
}

/* ===========================================
   Dropdown Menu for Sources
   =========================================== */
.sources-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 100;
    display: none;
    margin-top: 4px;
}

.sources-dropdown-menu.show {
    display: block;
    animation: dropdownFadeIn 0.15s ease-out;
}

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

.sources-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: right;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary, #1e293b);
}

.sources-dropdown-item:hover {
    background: var(--bg-hover, #f8fafc);
}

.sources-dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.sources-dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.sources-dropdown-item i {
    width: 18px;
    text-align: center;
    color: var(--text-muted, #64748b);
}

.sources-dropdown-item .item-badge {
    margin-right: auto;
    padding: 2px 8px;
    background: var(--accent-light, #eef2ff);
    color: var(--accent-color, #4f46e5);
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
}

.sources-dropdown-divider {
    height: 1px;
    background: var(--border-color, #e2e8f0);
    margin: 4px 0;
}

/* ===========================================
   Dropdown Badge (for sidebar menu)
   =========================================== */
.dropdown-badge {
    margin-right: auto;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    background: var(--accent-light, #eef2ff);
    color: var(--accent-color, #4f46e5);
}

.dropdown-divider {
    height: 1px;
    background: var(--border-color, #e2e8f0);
    margin: 6px 8px;
}

/* Tool Badge in panel buttons */
.tool-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
}

/* ===========================================
   Exact Source Suggestion Card Enhancement
   =========================================== */
.suggestion-card[data-type="exact_source"] .suggestion-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color, #e2e8f0);
}

.suggestion-card[data-type="exact_source"] .source-info {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted, #64748b);
}

.suggestion-card[data-type="exact_source"] .source-name {
    font-weight: 500;
}

.suggestion-card[data-type="exact_source"] .match-score {
    background: var(--accent-light, #eef2ff);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    color: var(--accent-color, #4f46e5);
}

/* Context Button inside suggestion card */
.suggestion-card .show-context-btn {
    margin-right: auto;
    background: transparent;
    border: 1px solid var(--border-color, #e2e8f0);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    color: var(--text-secondary, #64748b);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.15s;
}

.suggestion-card .show-context-btn:hover {
    background: var(--bg-hover, #f8fafc);
    border-color: var(--accent-color, #4f46e5);
    color: var(--accent-color, #4f46e5);
}

.suggestion-card .show-context-btn i {
    font-size: 10px;
}

/* ===========================================
   Left Panel Sources Mode
   =========================================== */

/* Container */
.left-panel-sources-content {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: 'Heebo', 'Tahoma', sans-serif;
}

/* Empty state */
.left-panel-empty.sources-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted, #64748b);
}

.left-panel-empty.sources-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.left-panel-empty.sources-empty p {
    margin: 8px 0;
}

.left-panel-empty.sources-empty .empty-hint {
    font-size: 12px;
    opacity: 0.8;
}

/* Control bar */
.sources-control-bar {
    background: var(--bg-secondary, #f8fafc);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
    font-family: 'Heebo', 'Tahoma', sans-serif;
    direction: rtl;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* כפתור עצור משתמש ב-minimalist-stop-btn מ-new-sidebar.css */

/* Source Card */
.source-card {
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    overflow: hidden;
    transition: all 0.2s ease;
    font-family: 'Heebo', 'Tahoma', sans-serif;
    direction: rtl;
}

.source-card:hover {
    border-color: var(--accent-color, #4f46e5);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.1);
}

.source-card.inserted {
    border-color: #10b981;
    background: linear-gradient(to left, rgba(16, 185, 129, 0.05), transparent);
}

/* Card Header */
.source-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-secondary, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    flex-direction: row-reverse;
}

.source-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.source-type-badge.tanach {
    background: #dbeafe;
    color: #1d4ed8;
}

.source-type-badge.talmud {
    background: #fef3c7;
    color: #b45309;
}

.source-type-badge.mishna {
    background: #dcfce7;
    color: #166534;
}

.source-type-badge.midrash {
    background: #f3e8ff;
    color: #7c3aed;
}

.source-type-badge.halacha {
    background: #fce7f3;
    color: #be185d;
}

.source-type-badge.commentary {
    background: #e0e7ff;
    color: #4f46e5;
}

.source-type-badge.default {
    background: #f1f5f9;
    color: #64748b;
}

.source-type-badge i {
    font-size: 10px;
}

.source-reference {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary, #1e293b);
    flex: 1;
    text-align: right;
    font-family: 'Heebo', 'Tahoma', sans-serif;
}

/* Card Body */
.source-card-body {
    padding: 12px 14px;
}

.source-text {
    font-size: 15px;
    line-height: 1.9;
    color: var(--text-primary, #1e293b);
    font-family: 'Heebo', 'Tahoma', sans-serif;
    text-align: right;
}

/* הדגשת הטקסט שנמצא - בצבע הלוגו של מילה (כחול כהה) */
.source-text .source-highlight {
    color: #1e3a5f;
    font-weight: 600;
    background: linear-gradient(to bottom, transparent 70%, rgba(30, 58, 95, 0.15) 70%);
    padding: 0 2px;
    border-radius: 2px;
}

/* התאמה מקורבת (trigram / דילוג מילה) - צבע רך/קרוב, לא מודגש כמו מדויק */
.source-text .source-highlight.source-highlight-soft {
    color: #3b6ea5;
    font-weight: 500;
    background: linear-gradient(to bottom, transparent 70%, rgba(59, 110, 165, 0.18) 70%);
}

.dark-theme .source-text .source-highlight.source-highlight-soft {
    color: #93c5fd;
    background: linear-gradient(to bottom, transparent 70%, rgba(147, 197, 253, 0.22) 70%);
}

.source-text mark.source-match {
    background: linear-gradient(to bottom, transparent 60%, rgba(30, 58, 95, 0.2) 60%);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

/* תצוגה מקדימה */
.source-preview {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* טקסט מלא */
.source-full-text {
    animation: expandFadeIn 0.3s ease-out;
}

@keyframes expandFadeIn {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 1000px;
    }
}

/* כפתור הרחבה */
.source-expand-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px;
    margin-top: 8px;
    background: transparent;
    border: 1px dashed var(--border-color, #e2e8f0);
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Heebo', 'Tahoma', sans-serif;
    color: var(--text-muted, #64748b);
    cursor: pointer;
    transition: all 0.2s;
}

.source-expand-btn:hover {
    background: var(--bg-secondary, #f8fafc);
    border-color: #1e3a5f;
    color: #1e3a5f;
}

.source-expand-btn i {
    font-size: 10px;
    transition: transform 0.2s;
}

.source-name {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted, #64748b);
}

/* Card Actions */
.source-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-secondary, #f8fafc);
    flex-direction: row-reverse;
}

.source-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
}

.source-action-btn.primary-btn {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    color: white;
}

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

.source-action-btn.secondary-btn {
    background: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #64748b);
    border: 1px solid var(--border-color, #e2e8f0);
}

.source-action-btn.secondary-btn:hover {
    border-color: #1e3a5f;
    color: #1e3a5f;
    background: rgba(30, 58, 95, 0.05);
}

.source-action-btn.insert-btn:disabled {
    background: #10b981;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.source-action-btn.context-btn {
    background: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #64748b);
    border: 1px solid var(--border-color, #e2e8f0);
    padding: 8px;
}

.source-action-btn.context-btn:hover {
    border-color: var(--accent-color, #4f46e5);
    color: var(--accent-color, #4f46e5);
}

.source-action-btn.context-btn.loading {
    pointer-events: none;
}

/* Expanded Context */
.source-context-expanded {
    padding: 12px 14px;
    background: var(--bg-tertiary, #f1f5f9);
    border-top: 1px dashed var(--border-color, #e2e8f0);
    animation: contextExpandIn 0.25s ease-out;
    overflow: hidden;
}

@keyframes contextExpandIn {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
        padding-top: 12px;
        padding-bottom: 12px;
    }
}

/* אייקון מסתובב בכפתור הרחבה */
.source-expand-btn i {
    transition: transform 0.2s ease;
}

.source-expand-btn.context-btn i.fa-chevron-up {
    transform: rotate(180deg);
}

.source-context-expanded .context-verses {
    margin: 8px 0;
}

.source-context-expanded .context-verse {
    padding: 6px 10px;
    margin: 4px 0;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.7;
}

.source-context-expanded .context-verse.muted {
    background: var(--bg-secondary, #f8fafc);
    color: var(--text-muted, #64748b);
}

.source-context-expanded .context-verse.current {
    background: var(--accent-light, #eef2ff);
    border-right: 3px solid var(--accent-color, #4f46e5);
    font-weight: 500;
}

/* Loading state for buttons */
button.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

button.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    right: 50%;
    top: 50%;
    margin-right: -8px;
    margin-top: -8px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Dark Theme */
.dark-theme .source-card {
    background: var(--bg-primary-dark, #1e293b);
    border-color: var(--border-color-dark, #334155);
}

.dark-theme .source-card-header {
    background: var(--bg-secondary-dark, #334155);
    border-color: var(--border-color-dark, #475569);
}

.dark-theme .source-reference {
    color: var(--text-primary-dark, #f1f5f9);
}

.dark-theme .source-text {
    color: var(--text-primary-dark, #f1f5f9);
}

.dark-theme .source-card-actions {
    background: var(--bg-secondary-dark, #334155);
    border-color: var(--border-color-dark, #475569);
}

.dark-theme .source-context-expanded {
    background: var(--bg-tertiary-dark, #1e293b);
}

.dark-theme .source-text .source-highlight {
    color: #60a5fa;
    background: linear-gradient(to bottom, transparent 70%, rgba(96, 165, 250, 0.2) 70%);
}

.dark-theme .source-expand-btn {
    border-color: var(--border-color-dark, #475569);
    color: var(--text-muted-dark, #94a3b8);
}

.dark-theme .source-expand-btn:hover {
    background: var(--bg-secondary-dark, #334155);
    border-color: #60a5fa;
    color: #60a5fa;
}

/* ===========================================
   Source Card Actions - Three Buttons Layout
   =========================================== */
.source-card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-secondary, #f8fafc);
    flex-wrap: wrap;
}

.source-card-actions .actions-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    justify-content: stretch;
}

/* כפתורים בגודל שווה */
.source-card-actions .actions-row > button {
    flex: 1;
    justify-content: center;
    min-width: 0;
}

.source-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-family: inherit;
    white-space: nowrap;
}

.source-action-btn i {
    font-size: 11px;
}

.source-action-btn.copy-btn {
    background: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #64748b);
    border: 1px solid var(--border-color, #e2e8f0);
}

.source-action-btn.copy-btn:hover {
    border-color: #1e3a5f;
    color: #1e3a5f;
}

.source-action-btn.footnote-btn {
    background: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #64748b);
    border: 1px solid var(--border-color, #e2e8f0);
}

.source-action-btn.footnote-btn:hover {
    border-color: #1e3a5f;
    color: #1e3a5f;
}

.source-action-btn.insert-after-btn {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    color: white;
}

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

.source-action-btn:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none !important;
    box-shadow: none !important;
}

.source-action-btn.success {
    background: #10b981 !important;
    color: white !important;
    border-color: #10b981 !important;
}

/* Editor Highlight for source match */
.editor-source-highlight {
    background: rgba(30, 58, 95, 0.15);
    border-radius: 2px;
    transition: background 0.3s ease;
}

.editor-source-highlight.active {
    background: rgba(30, 58, 95, 0.3);
    box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.25);
}

/* Source card clickable for highlight */
.source-card.clickable {
    cursor: pointer;
}

.source-card.clickable:hover {
    border-color: #1e3a5f;
}

/* Selected source card */
.source-card.selected {
    border-color: #1e3a5f;
    box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.15);
}

/* ===========================================
   Verse Number Styling
   מספר פסוק בסוגריים לפני הטקסט
   =========================================== */
.verse-number {
    font-weight: 700;
    color: #1e3a5f;
    margin-left: 4px;
    font-size: 0.95em;
}

.dark-theme .verse-number {
    color: #60a5fa;
}

/* Tanach source card special styling */
.source-card[data-source-type="tanach"] .source-text {
    font-family: 'David Libre', 'Frank Ruhl Libre', 'Heebo', serif;
    line-height: 2;
}

/* ===========================================
   AI Extract Streaming Styles
   =========================================== */
.ai-extract-streaming {
    padding: 16px;
    direction: rtl;
    font-family: 'Heebo', 'Tahoma', sans-serif;
}

.ai-extract-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-secondary, #f8fafc);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    color: var(--text-secondary, #64748b);
}

.ai-extract-status i {
    font-size: 16px;
    color: var(--accent-color, #4f46e5);
}

.ai-extract-status.complete {
    background: #dcfce7;
    color: #166534;
}

.ai-extract-status.complete i {
    color: #166534;
}

.ai-extract-status.error {
    background: #fef2f2;
    color: #dc2626;
}

.ai-extract-status.error i {
    color: #dc2626;
}

.ai-extract-results {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

.ai-extract-result {
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 10px;
    overflow: hidden;
    animation: slideIn 0.3s ease-out;
}

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

.ai-extract-result.no-source {
    border-color: #fef3c7;
    background: #fffbeb;
}

.ai-extract-quote {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px 14px;
    background: var(--bg-secondary, #f8fafc);
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.quote-number {
    background: var(--accent-color, #4f46e5);
    color: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.quote-text {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary, #1e293b);
    font-style: italic;
}

.ai-extract-sources {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-extract-source-item {
    padding: 10px 12px;
    background: var(--bg-tertiary, #f1f5f9);
    border-radius: 8px;
    border-right: 3px solid var(--accent-color, #4f46e5);
}

.ai-extract-source-item .source-reference {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 13px;
    color: var(--accent-color, #4f46e5);
    margin-bottom: 6px;
}

.ai-extract-source-item .source-reference i {
    font-size: 11px;
}

.ai-extract-source-item .source-text {
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-secondary, #64748b);
    margin-bottom: 10px;
}

.ai-extract-source-item .source-actions {
    display: flex;
    gap: 8px;
}

.ai-extract-source-item .btn-small {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border-color, #e2e8f0);
    background: var(--bg-primary, #ffffff);
    color: var(--text-secondary, #64748b);
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: inherit;
}

.ai-extract-source-item .btn-small:hover {
    border-color: var(--accent-color, #4f46e5);
    color: var(--accent-color, #4f46e5);
}

.ai-extract-source-item .btn-small i {
    font-size: 10px;
}

.ai-extract-no-source {
    padding: 16px;
    text-align: center;
    color: #ca8a04;
    font-size: 13px;
}

.ai-extract-no-source i {
    margin-left: 6px;
}

/* Dark Theme for AI Extract */
.dark-theme .ai-extract-streaming {
    color: var(--text-primary-dark, #f1f5f9);
}

.dark-theme .ai-extract-status {
    background: var(--bg-secondary-dark, #334155);
    color: var(--text-secondary-dark, #94a3b8);
}

.dark-theme .ai-extract-result {
    background: var(--bg-primary-dark, #1e293b);
    border-color: var(--border-color-dark, #334155);
}

.dark-theme .ai-extract-result.no-source {
    background: rgba(202, 138, 4, 0.1);
    border-color: rgba(202, 138, 4, 0.3);
}

.dark-theme .ai-extract-quote {
    background: var(--bg-secondary-dark, #334155);
    border-color: var(--border-color-dark, #475569);
}

.dark-theme .quote-text {
    color: var(--text-primary-dark, #f1f5f9);
}

.dark-theme .ai-extract-source-item {
    background: var(--bg-tertiary-dark, #1e293b);
}

.dark-theme .ai-extract-source-item .source-text {
    color: var(--text-secondary-dark, #94a3b8);
}

.dark-theme .ai-extract-source-item .btn-small {
    background: var(--bg-secondary-dark, #334155);
    border-color: var(--border-color-dark, #475569);
    color: var(--text-secondary-dark, #94a3b8);
}

/* Progress Bar for AI Extract */
.ai-extract-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    margin-bottom: 12px;
}

.ai-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary, #e2e8f0);
    border-radius: 3px;
    overflow: hidden;
}

.ai-progress-fill {
    height: 100%;
    background: var(--accent-color, #4f46e5);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.ai-progress-text {
    font-size: 12px;
    color: var(--text-secondary, #64748b);
    min-width: 50px;
    text-align: left;
}

.dark-theme .ai-progress-bar {
    background: var(--bg-tertiary-dark, #475569);
}

.dark-theme .ai-progress-text {
    color: var(--text-secondary-dark, #94a3b8);
}

/* ===========================================
   Grouped Citations - כותרות ציטוטים בתצוגה מקובצת
   משתמש באותו סגנון כרטיסים כמו renderSourcesContent
   =========================================== */

/* מארז לתצוגה מקובצת */
.left-panel-sources-content.grouped-sources {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* כותרת קבוצת ציטוט */
.citation-group-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    margin-top: 16px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    border-radius: 10px 10px 0 0;
    direction: rtl;
}

.citation-group-header:first-child {
    margin-top: 0;
}

.citation-group-number {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    min-width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.citation-group-text {
    font-size: 14px;
    line-height: 1.7;
    color: white;
    font-style: italic;
    flex: 1;
    font-family: 'Heebo', 'Tahoma', sans-serif;
}

/* הודעה - לא נמצא מקור לציטוט */
.citation-no-source {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 16px;
    margin-bottom: 8px;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 0 0 10px 10px;
    color: #ca8a04;
    font-size: 13px;
    font-family: 'Heebo', 'Tahoma', sans-serif;
}

.citation-no-source i {
    font-size: 14px;
}

/* הכרטיסים שמופיעים אחרי כותרת ציטוט */
.citation-group-header + .source-card {
    border-radius: 0;
    margin-top: 0;
}

.citation-group-header + .source-card:last-of-type,
.citation-group-header + .source-card + .citation-group-header ~ .source-card:last-of-type {
    border-radius: 0 0 10px 10px;
}

/* כרטיס לפני כותרת חדשה */
.source-card:has(+ .citation-group-header) {
    border-radius: 0 0 10px 10px;
    margin-bottom: 0;
}

/* Dark Theme */
.dark-theme .citation-group-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
}

.dark-theme .citation-no-source {
    background: rgba(202, 138, 4, 0.1);
    border-color: rgba(202, 138, 4, 0.3);
    color: #fbbf24;
}

/* ===========================================
   Accordion - פתיחה/סגירה לכל ציטוט (יוני 2026)
   כל משפט מכווץ עם מונה מקורות; נפתח בלחיצה.
   =========================================== */
.citation-accordion {
    margin-top: 16px;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.citation-accordion:first-child {
    margin-top: 0;
}

/* הכותרת כפתור לחיצה - יורשת את עיצוב .citation-group-header (רקע כחול) */
.citation-accordion .citation-group-header {
    width: 100%;
    border: none;
    cursor: pointer;
    margin-top: 0;
    border-radius: 0;
    align-items: center;
    text-align: right;
    direction: rtl;
    font-family: 'Heebo', 'Tahoma', sans-serif;
    transition: filter 0.15s ease;
}

.citation-accordion .citation-group-header:hover {
    filter: brightness(1.08);
}

/* תג מונה מקורות */
.citation-source-count {
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}

.citation-source-count.empty {
    background: rgba(255, 255, 255, 0.12);
}

/* חץ פתיחה/סגירה */
.citation-accordion-chevron {
    color: rgba(255, 255, 255, 0.85);
    font-size: 13px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.citation-accordion.open .citation-accordion-chevron {
    transform: rotate(180deg);
}

/* גוף האקורדיון - מכווץ כברירת מחדל */
.citation-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease;
}

.citation-accordion.open .citation-accordion-body {
    max-height: 100000px;
}

/* כרטיסים בתוך האקורדיון - בלי רדיוס/שוליים כפולים */
.citation-accordion-body .source-card {
    border-radius: 0;
    margin: 0;
}

.citation-accordion-body .source-card + .source-card {
    border-top: 1px solid #eef2f7;
}

.citation-accordion-body .citation-no-source {
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
}

/* Dark Theme */
.dark-theme .citation-accordion {
    border-color: #334155;
}

.dark-theme .citation-accordion-body .source-card + .source-card {
    border-top-color: #334155;
}

/* כפתור "הצג עוד N מקורות" בתוך קבוצת ציטוט */
.citation-show-more-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border: none;
    border-top: 1px dashed #d7dee8;
    background: #f1f5f9;
    color: #1e3a5f;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Heebo', 'Tahoma', sans-serif;
    transition: background 0.15s ease;
}

.citation-show-more-btn:hover {
    background: #e2e8f0;
}

.citation-more-cards .source-card {
    border-radius: 0;
    margin: 0;
}

.citation-more-cards .source-card + .source-card,
.citation-show-more-btn {
    border-top: 1px solid #eef2f7;
}

.dark-theme .citation-show-more-btn {
    background: #1e293b;
    color: #93c5fd;
    border-top-color: #334155;
}

.dark-theme .citation-show-more-btn:hover {
    background: #283548;
}

/* ===========================================
   Verify cards - אימות מראי מקומות
   =========================================== */
.verify-card {
    border-radius: 10px;
    padding: 12px 14px;
    margin: 8px 0;
    border-right: 4px solid #cbd5e1;
    background: #f8fafc;
    direction: rtl;
    font-family: 'Heebo', 'Tahoma', sans-serif;
}
/* בכרטיסי אימות - להסתיר את 3 כפתורי הפעולה הגנריים (העתק/הכנס אחרי/הערה);
   נשארים רק "הצג עוד" והכפתורים המותאמים (תקן מ"מ / הצג נוסח שצוין) */
.verify-card .source-card-actions { display: none !important; }

.verify-card.verify-ok    { border-right-color: #16a34a; background: #f0fdf4; }
.verify-card.verify-warn  { border-right-color: #d97706; background: #fffbeb; }
.verify-card.verify-err   { border-right-color: #dc2626; background: #fef2f2; }
.verify-card.verify-muted { border-right-color: #94a3b8; background: #f8fafc; }

.verify-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.verify-status { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.verify-ok .verify-status    { color: #16a34a; }
.verify-warn .verify-status  { color: #d97706; }
.verify-err .verify-status   { color: #dc2626; }
.verify-muted .verify-status { color: #64748b; }
.verify-ref { font-size: 13px; color: #1e3a5f; font-weight: 600; }

.verify-suggest { margin-top: 8px; font-size: 13px; color: #334155; line-height: 1.7; }
.verify-correct-text { font-weight: 600; color: #1e3a5f; }

/* "בטקסט:" - הציטוט והמ"מ כפי שנכתבו במסמך */
.verify-written {
    margin-top: 8px;
    font-size: 13px;
    line-height: 1.7;
    color: #334155;
}
.verify-written-label { font-weight: 700; color: #64748b; margin-left: 4px; }
.verify-written-text { font-family: 'Heebo', 'Tahoma', sans-serif; }
.verify-written-text.verify-wrong {
    text-decoration: line-through;
    text-decoration-color: rgba(220, 38, 38, 0.5);
    color: #991b1b;
}
.verify-ref-inline { font-weight: 600; color: #1e3a5f; white-space: nowrap; }

/* "חיפשנו:" - המ"מ אחרי הפענוח (מוצג רק כשהוא שונה מהכתוב בטקסט) */
.verify-searched {
    margin-top: 2px;
    font-size: 12.5px;
    opacity: 0.85;
}

/* כרטיס אימות לחיץ - קליק מדגיש וגולל לציטוט/למ"מ בעורך */
.verify-card.verify-clickable { cursor: pointer; }
.verify-card.verify-clickable:hover { filter: brightness(0.98); }

/* שורת הכותרת בכרטיס אימות: סטטוס מימין, X משמאל */
.verify-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.verify-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 13px;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 4px;
    flex-shrink: 0;
}
.verify-close-btn:hover { color: #dc2626; background: rgba(220, 38, 38, 0.08); }
.dark-theme .verify-close-btn { color: #64748b; }
.dark-theme .verify-close-btn:hover { color: #f87171; background: rgba(248, 113, 113, 0.12); }

/* "לא נמצא עדיין במאגר" - הערת קורפוס בכרטיס אימות */
.verify-not-in-corpus {
    margin-top: 8px;
    font-size: 12.5px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 6px;
}
.dark-theme .verify-not-in-corpus { color: #94a3b8; }

/* חלופות מ"מ ותוצאות חיפוש-משפט בתוך כרטיס אימות */
.verify-alternatives { margin-top: 8px; }
.verify-qsearch-results { margin-top: 8px; }
.verify-search-btn { background: #1e3a5f; }

/* כפתור "תקן מראה מקום" בכרטיס מקור (הקשר אימות) - בולט מול שאר הפעולות */
.source-action-btn.fix-ref-btn {
    background: #1e3a5f;
    color: #fff;
    border-color: #1e3a5f;
}
.source-action-btn.fix-ref-btn:hover { filter: brightness(1.15); }
.dark-theme .source-action-btn.fix-ref-btn { background: #3b82f6; border-color: #3b82f6; }

/* תווית "המקור הנכון" מעל כרטיס הפסוק */
.verify-correct-label {
    margin-top: 10px;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #16a34a;
    display: flex;
    align-items: center;
    gap: 6px;
}

.dark-theme .verify-written { color: #cbd5e1; }
.dark-theme .verify-written-text.verify-wrong { color: #fca5a5; }
.dark-theme .verify-ref-inline { color: #93c5fd; }

/* הצגת נוסח המ"מ שצוין (מכווץ) - מ"מ שגוי */
.verify-show-written-btn {
    margin-top: 8px;
    padding: 5px 10px;
    border: 1px dashed #cbd5e1;
    background: transparent;
    color: #64748b;
    font-size: 12px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Heebo', 'Tahoma', sans-serif;
}
.verify-show-written-btn:hover { background: #f1f5f9; color: #1e3a5f; }
.verify-written-source {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    direction: rtl;
}
.verify-written-source-ref { font-size: 12px; font-weight: 700; color: #64748b; margin-bottom: 4px; }
.verify-written-source-text { font-size: 14px; line-height: 1.8; color: #334155; font-family: 'Heebo', 'Tahoma', sans-serif; }

.dark-theme .verify-show-written-btn { border-color: #475569; color: #94a3b8; }
.dark-theme .verify-show-written-btn:hover { background: #283548; color: #cbd5e1; }
.dark-theme .verify-written-source { background: #1e293b; border-color: #334155; }
.dark-theme .verify-written-source-text { color: #cbd5e1; }

.verify-fix-btn {
    margin-top: 10px;
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    background: #1e3a5f;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    gap: 6px;
    align-items: center;
    font-family: 'Heebo', 'Tahoma', sans-serif;
    transition: filter 0.15s ease;
}
.verify-fix-btn:hover { filter: brightness(1.12); }

.dark-theme .verify-card { background: #1e293b; border-right-color: #475569; }
.dark-theme .verify-card.verify-ok   { background: rgba(22, 163, 74, 0.12); }
.dark-theme .verify-card.verify-warn { background: rgba(217, 119, 6, 0.12); }
.dark-theme .verify-card.verify-err  { background: rgba(220, 38, 38, 0.12); }
.dark-theme .verify-suggest { color: #cbd5e1; }
.dark-theme .verify-ref, .dark-theme .verify-correct-text { color: #93c5fd; }

/* ===========================================
   Realtime Status - סטטוס בזמן אמת
   =========================================== */
.realtime-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px;
    margin: 12px;
    background: var(--bg-secondary, #f8fafc);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-secondary, #64748b);
    font-family: 'Heebo', 'Tahoma', sans-serif;
    animation: pulse 2s infinite;
}

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

.realtime-status i {
    font-size: 18px;
    color: var(--accent-color, #4f46e5);
}

.dark-theme .realtime-status {
    background: var(--bg-secondary-dark, #334155);
    color: var(--text-secondary-dark, #94a3b8);
}

/* ===== בורר פורמט מראה מקום (reference-formatter.js) ===== */
.mm-format-gear {
    background: none; border: none; color: #64748b; cursor: pointer;
    font-size: 15px; padding: 6px 8px; border-radius: 6px; margin-inline-start: auto;
    transition: background .15s, color .15s;
}
.mm-format-gear:hover { background: rgba(30,58,95,.08); color: #1e3a5f; }
.dark-theme .mm-format-gear { color: #94a3b8; }
.dark-theme .mm-format-gear:hover { background: rgba(148,163,184,.15); color: #e2e8f0; }

.mmf-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 100000;
    display: flex; align-items: center; justify-content: center; direction: rtl;
}
.mmf-box {
    background: #fff; border-radius: 14px; width: min(460px, 92vw); max-height: 88vh;
    overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); font-family: 'Heebo','Tahoma',sans-serif;
}
.mmf-head {
    display: flex; align-items: center; gap: 8px; padding: 14px 18px; font-weight: 700;
    font-size: 16px; color: #1e3a5f; border-bottom: 1px solid #e5e7eb;
}
.mmf-x { margin-inline-start: auto; background: none; border: none; font-size: 22px; color: #94a3b8; cursor: pointer; line-height: 1; }
.mmf-x:hover { color: #dc2626; }
.mmf-live { padding: 10px 18px; font-size: 13px; color: #334155; background: #f8fafc; border-bottom: 1px solid #eef2f7; }
.mmf-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 16px 18px; }
.mmf-group { display: flex; flex-direction: column; gap: 6px; }
.mmf-title { font-weight: 700; font-size: 13px; color: #64748b; margin-bottom: 2px; }
.mmf-opt { display: flex; align-items: center; gap: 7px; font-size: 14px; color: #334155; cursor: pointer; padding: 2px 0; }
.mmf-opt input { accent-color: #1e3a5f; cursor: pointer; }
.mmf-foot { padding: 12px 18px 16px; border-top: 1px solid #e5e7eb; text-align: left; }
.mmf-done {
    background: #1e3a5f; color: #fff; border: none; border-radius: 8px; padding: 9px 20px;
    font-size: 14px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.mmf-done:hover { filter: brightness(1.15); }
.dark-theme .mmf-box { background: #1e293b; color: #e2e8f0; }
.dark-theme .mmf-head { color: #e2e8f0; border-color: #334155; }
.dark-theme .mmf-live { background: #0f172a; color: #cbd5e1; border-color: #334155; }
.dark-theme .mmf-opt { color: #cbd5e1; }
.dark-theme .mmf-foot { border-color: #334155; }
