/* Main Editor Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Galil', -apple-system, BlinkMacSystemFont, sans-serif;
    letter-spacing: normal;
    background: #e2e8f0; /* Darker unified background */
    color: #2c3e50;
    direction: rtl;
    overflow: hidden;

    /* 🆕 ===== Editor spacing — מקור-אמת יחיד למרווחי-העורך =====
       כל האלמנטים שמתיישרים לרוחב-העורך (.text-editor, .tc-editor-bar, .footnotes-section,
       .editor-placeholder-overlay) משתמשים בשני המשתנים האלו במקום לשכפל את אותו חישוב.
       מצב-הפאנלים משנה את המשתנים פעם אחת כאן — וכולם מתעדכנים יחד. */
    --editor-space-right: 74px; /* 🆕 task3b: ריווח לרצועה המכווצת (edge 18 + rail 48 + gap 8) */
    --editor-space-left: 110px;  /* צד שמאל: סוף הבר העליון (איזור האווטאר) */
}

/* 🆕 task3b: פאנל נעוץ/מורחב (panel-open = pinned): ימין = edge(18)+panel(280)+gap(8) */
body.panel-open {
    --editor-space-right: calc(18px + var(--panel-width, 160px) + 8px);
    --editor-space-left: 20px;
}
/* מצב פאנל-שמאלי פתוח: שמאל = gap(8)+leftPanel+gap(8) ; ימין נשאר בסיס */
body.left-panel-open {
    --editor-space-left: calc(8px + var(--left-panel-width, 320px) + 8px);
}
/* שני הפאנלים יחד (ספציפיות גבוהה — גובר על שני הבודדים) */
body.panel-open.left-panel-open {
    --editor-space-right: calc(18px + var(--panel-width, 160px) + 8px);
    --editor-space-left: calc(8px + var(--left-panel-width, 320px) + 8px);
}
/* מצב Track-Changes-שמאל: הטקסט מתרחב ימינה עד הרצועה המכווצת */
body.tc-left-active {
    --editor-space-right: 74px !important;
}

/* Main Layout */
.editor-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px); /* גובה קבוע - הבר העליון כעת 60px בלבד */
    margin-top: 0;
    background: #e2e8f0; /* רקע אפור - ממשיך מהבר העליון */
    position: relative;
    overflow: hidden; /* מונע גלילה ברמת הקונטיינר */
}

/* כבר לא צריך מצב סגור/פתוח של סרגל העיצוב */
body:not(.formatting-toolbar-open) .editor-container {
    margin-top: 0;
}

/* Layout adjustments for A4 document view */
.editor-container.document-layout {
    background: #f5f5f5;
}

/* Central Text Editor */
.main-editor {
    flex: 1;
    background: #e2e8f0 !important; /* Darker unified color */
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 0; /* חשוב ל-flexbox כדי לאפשר גלילה פנימית */
    box-sizing: border-box;
}

/* 🆕 כפתור העתקה בעורך — מוסתר; מתגלה בריחוף על אזור-העריכה (פינה שמאלית-עליונה) */
.editor-copy-btn {
    position: absolute; top: 16px; z-index: 25;
    /* נצמד לפינה השמאלית-העליונה של כרטיס-הטקסט עצמו (עוקב אחר margin-left שלו) */
    left: calc(var(--editor-space-left, 110px) + 14px);
    width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.92); border: 1px solid var(--border-light, #e2e8f0); border-radius: 8px;
    color: var(--text-muted, #64748b); cursor: pointer; font-size: 13px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, left 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 0 2px 8px rgba(15,23,42,0.10);
}
.main-editor:hover .editor-copy-btn { opacity: 1; pointer-events: auto; }
.editor-copy-btn:hover { background: #fff; color: var(--accent-primary, #1e3a5f); border-color: #c9d6e8; }
.editor-copy-btn.copied { color: var(--accent-success, #10b981); border-color: #bfe3cc; }

/* ======================================== */
/* Editor Placeholder Overlay - Drag & Drop */
/* ======================================== */

.editor-placeholder-overlay {
    position: absolute;
    /* מיושר לתוך מסגרת הטקסט: margin-top(2px) + padding(1cm) */
    top: calc(2px + 1cm);
    /* מיושר לתוך מסגרת הטקסט: editor-space-right + padding(1cm) — מקור-אמת יחיד */
    right: calc(var(--editor-space-right, 142px) + 1cm);
    z-index: 5;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease, right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: right;
    direction: rtl;
}

/* Hide when editor has content */
.text-editor:not(.empty) ~ .editor-placeholder-overlay,
.main-editor:has(.text-editor:not(.empty)) .editor-placeholder-overlay {
    opacity: 0;
    pointer-events: none;
}

/* Ensure drop hint is also disabled when editor has content */
.text-editor:not(.empty) ~ .editor-placeholder-overlay .placeholder-drop-hint,
.main-editor:has(.text-editor:not(.empty)) .editor-placeholder-overlay .placeholder-drop-hint {
    pointer-events: none;
}

/* Show only when editor is empty */
.main-editor:has(.text-editor.empty) .editor-placeholder-overlay {
    opacity: 1;
}

.placeholder-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

.placeholder-text {
    color: #9ca3af;
    font-size: 16px;
    font-style: italic;
    font-family: 'Heebo', Tahoma, Arial, sans-serif;
    letter-spacing: normal;
}

.placeholder-divider {
    color: #d1d5db;
    font-size: 14px;
}

.placeholder-drop-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #93c5fd;
    font-size: 14px;
    padding: 4px 10px;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.placeholder-drop-hint:hover {
    background: rgba(30, 58, 95, 0.05);
    border-color: #93c5fd;
    color: #1e3a5f;
}

.placeholder-drop-hint i {
    font-size: 14px;
}

/* Audio hint - same style as drop hint */
.placeholder-audio-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #93c5fd;
    font-size: 14px;
    padding: 4px 10px;
    border: 1px dashed #cbd5e1;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s ease;
}

.placeholder-audio-hint:hover {
    background: rgba(30, 58, 95, 0.05);
    border-color: #93c5fd;
    color: #1e3a5f;
}

.placeholder-audio-hint i {
    font-size: 14px;
}

/* Drag over state */
.text-editor.drag-over {
    border-color: #1e3a5f !important;
    border-style: dashed !important;
    background: rgba(30, 58, 95, 0.05) !important;
}

.text-editor.drag-over ~ .editor-placeholder-overlay .placeholder-drop-hint {
    background: rgba(30, 58, 95, 0.1);
    border-color: #1e3a5f;
    color: #1e3a5f;
}

/* Import button highlight animation - subtle version */
@keyframes importButtonPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(30, 58, 95, 0.2);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(30, 58, 95, 0);
    }
}

.nav-btn.highlight-import {
    animation: importButtonPulse 1.2s ease-in-out 2;
    background: rgba(30, 58, 95, 0.08);
    color: #1e3a5f;
}

.editor-header {
    padding: 15px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: #2c3e50;
}

.document-name-title {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.document-name-title:hover {
    background: rgba(30, 58, 95, 0.08);
    border-color: rgba(30, 58, 95, 0.2);
    color: #1e3a5f;
}

.document-name-title .fas.fa-file-alt {
    color: #1e3a5f;
    font-size: 1rem;
}

.edit-icon {
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    color: #6b7280;
}

.document-name-title:hover .edit-icon {
    opacity: 1;
}

.save-status-indicator {
    font-size: 0.8rem;
    margin-left: 8px;
    transition: all 0.3s ease;
}

.save-status-indicator.saved {
    color: #10b981; /* ירוק - נשמר */
}

.save-status-indicator.unsaved {
    color: #f59e0b; /* כתום - יש שינויים */
}

.save-status-indicator.saving {
    color: #1e3a5f; /* כחול - בתהליך שמירה */
    animation: pulse 1s infinite;
}

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

#currentDocumentTitle {
    max-width: 300px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.word-count {
    font-size: 0.85rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 12px;
}

.text-editor {
    /* רווח שווה של ס"מ מכל הכיוונים */
    padding: 1cm;
    /* גובה וזהה לבר האייקונים: calc(100vh - 112px) */
    height: calc(100vh - 112px);
    /* מרווח עליון מיושר עם בר האייקונים */
    margin-top: 2px;
    /* 🆕 מקור-אמת יחיד (מוגדר על body לפי מצב-הפאנלים) */
    margin-right: var(--editor-space-right, 142px);
    margin-left: var(--editor-space-left, 110px);
    margin-bottom: 0;
    border: 1px solid rgba(209, 213, 219, 0.7);
    border-radius: 12px;
    outline: none;
    font-family: 'Heebo', serif;
    font-size: 16px;
    line-height: 1.8;
    letter-spacing: normal; /* Reset - העורך נשאר עם Heebo ללא ריווח נוסף */
    color: #2c3e50;
    resize: none;
    background: white;
    direction: rtl;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    position: relative;
    box-sizing: border-box;
    /* 🆕 margin (לא רק margin-right) — כדי ש-margin-left יונפש גם הוא חלק (היה במצב-state שאוחד) */
    transition: margin 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* סרגל גלילה מותאם אישית - בתוך המסגרת */
.text-editor::-webkit-scrollbar {
    width: 10px;
}

.text-editor::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0; /* מרווח למעלה ולמטה */
}

.text-editor::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
    border: 2px solid white; /* מרווח מהצדדים */
}

.text-editor::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.text-editor:focus {
    box-shadow: inset 0 0 0 1px #9ca3af;
}

/* Selection Indicator */
.selection-info {
    background: #fbbf24;
    color: #92400e;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    display: none;
    align-items: center;
    gap: 8px;
}

.selection-info.active {
    display: flex;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #1e3a5f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Zoom Control */
.zoom-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.zoom-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #475569;
}

.zoom-btn:hover {
    background: rgba(30, 58, 95, 0.1);
    color: #1e3a5f;
}

.zoom-indicator {
    font-size: 0.85rem;
    color: #475569;
    font-weight: 500;
    min-width: 45px;
    text-align: center;
}

/* View Mode Selector */
.view-mode-selector {
    position: relative;
    display: inline-block;
}

.view-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
}

.view-arrow {
    font-size: 0.7rem;
    opacity: 0.7;
    transition: transform 0.2s ease;
}

.view-dropdown {
    position: absolute;
    bottom: 45px;
    right: 0;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 180px;
    display: none;
    z-index: 1000;
    direction: rtl;
}

.view-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.9rem;
    border-bottom: 1px solid #f1f5f9;
}

.view-option:last-child {
    border-bottom: none;
}

.view-option:hover {
    background: #f8fafc;
}

.view-option.active {
    background: #eff6ff;
    color: #2563eb;
}

.view-option i {
    width: 16px;
    text-align: center;
    font-size: 0.9rem;
}

.view-option .checkmark {
    margin-right: auto;
    display: none;
    color: #16a34a;
    font-weight: bold;
}

.view-option.active .checkmark {
    display: block;
}

/* 🔔 מצב תצוגה מושבת זמנית ("בקרוב") — לא-לחיץ + באדג' */
.view-option.disabled {
    cursor: not-allowed;
    color: #94a3b8;
}
.view-option.disabled i {
    opacity: 0.6;
}
.view-option.disabled:hover {
    background: transparent;
}
.view-option .coming-soon-badge {
    margin-right: auto;
    font-size: 0.72rem;
    font-weight: 600;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 999px;
    padding: 1px 8px;
    white-space: nowrap;
}

/* Document View (Multi-page Mode) */
.main-editor.document-view {
    background: #f5f5f5;
    padding: 20px 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100%;
    width: 100%;
    position: relative;
    box-sizing: border-box;
}

/* Simple Flowing Document Editor with CSS-only page appearance */
.flowing-document-editor-simple {
    width: 21cm;
    min-height: 29.7cm;
    margin: 20px auto;
    padding: 2cm 2cm 3cm 2cm;
    outline: none;
    direction: rtl;
    text-align: right;
    font-family: 'Times New Roman', 'Noto Serif Hebrew', serif;
    font-size: 12pt;
    line-height: 1.6;
    position: relative;
    transform-origin: center top;
    transition: transform 0.2s ease;

    /* Create page-like appearance with CSS */
    background:
        /* Page background pattern */
        repeating-linear-gradient(
            transparent 0,
            transparent 29.7cm,
            #f5f5f5 29.7cm,
            #f5f5f5 calc(29.7cm + 20px)
        ),
        /* Main white background */
        white;

    /* Page shadows and borders */
    box-shadow:
        0 0 0 1px #e5e7eb,
        0 4px 20px rgba(0,0,0,0.15);

    /* Add page numbers using CSS counter */
    counter-reset: page-counter;
}

/* Page break simulation every 29.7cm */
.flowing-document-editor-simple::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        /* Create visual page separations */
        repeating-linear-gradient(
            transparent 0,
            transparent calc(29.7cm - 1px),
            rgba(0,0,0,0.1) calc(29.7cm - 1px),
            rgba(0,0,0,0.1) calc(29.7cm + 1px),
            transparent calc(29.7cm + 1px),
            transparent calc(29.7cm + 20px)
        );
    pointer-events: none;
    z-index: -1;
}

/* Placeholder for empty editor */
.flowing-document-editor-simple:empty:before {
    content: attr(data-placeholder);
    color: #9ca3af;
    pointer-events: none;
    position: absolute;
    top: 2cm;
    right: 2cm;
    font-style: italic;
}

/* Legacy placeholder - keep for compatibility */
.flowing-document-editor:empty:before {
    content: attr(data-placeholder);
    color: #9ca3af;
    pointer-events: none;
    position: absolute;
    top: 2cm;
    right: 2cm;
    font-style: italic;
}

/* Page Break Markers - Updated for margin-aware breaking */
.page-break-marker {
    width: 100%;
    height: 3cm; /* Bottom margin space */
    display: block;
    margin: 0;
    padding: 0;
    page-break-before: always;
    break-before: page;
    position: relative;
    pointer-events: none;
    user-select: none;

    /* Subtle visual separator */
    background: linear-gradient(to bottom,
        transparent 0%,
        transparent 85%,
        rgba(0,0,0,0.02) 90%,
        rgba(0,0,0,0.05) 95%,
        transparent 100%
    );
}

/* Optional page transition indicator */
.page-break-marker::after {
    content: '';
    position: absolute;
    bottom: 1.5cm;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 1px;
    background: rgba(0,0,0,0.1);
    opacity: 0.3;
}

/* Legacy page break styles - kept for compatibility */
.page-break-line {
    width: 100%;
    height: 1px;
    background: #d1d5db;
    position: relative;
}

.page-break-line:before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 100px;
    height: 1px;
    background: #6b7280;
}

.page-number-indicator {
    font-size: 10pt;
    color: #6b7280;
    font-family: 'Galil', sans-serif;
    letter-spacing: normal;
    margin-top: 8px;
    background: white;
    padding: 4px 12px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    direction: rtl;
}

/* Container for all pages */
.document-pages-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px; /* מרווח בין עמודים */
    width: 100%;
    max-width: 1200px;
    position: relative;
    transform-origin: center top;
    transition: transform 0.2s ease;
}

/* Individual page styling */
.document-page {
    width: 21cm;
    height: 29.7cm;
    min-height: 29.7cm;
    max-height: 29.7cm;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border: 1px solid #e5e7eb;
    position: relative;
    display: flex;
    flex-direction: column;
    page-break-after: always;
}

/* Page content area */
.document-page-content {
    flex: 1;
    padding: 1cm 2cm 2cm 2cm; /* More space at bottom for page number */
    outline: none;
    direction: rtl;
    text-align: right;
    font-family: 'Times New Roman', 'Noto Serif Hebrew', serif;
    font-size: 12pt;
    line-height: 1.6;
    overflow: hidden;
    position: relative;
    min-height: 0; /* Allow flex shrinking */
    max-height: calc(100% - 3cm); /* Ensure content doesn't overlap with page number */
}

/* Page number */
.page-number {
    position: absolute;
    bottom: 1cm; /* Moved closer to bottom edge */
    left: 50%;
    transform: translateX(-50%);
    font-size: 10pt;
    color: #6b7280;
    font-family: 'Galil', sans-serif;
    letter-spacing: normal;
    direction: ltr;
    z-index: 10; /* Ensure it's above content */
}

/* Hidden text editor for content management */
.text-editor.document-editor {
    display: none;
}

/* Document toolbar inside A4 page */
.document-toolbar {
    width: 100%;
    padding: 8px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    min-height: 40px;
    flex-shrink: 0;
}

.document-toolbar .toolbar-btn {
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 6px 8px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.85rem;
    min-width: 32px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.document-toolbar .toolbar-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.document-toolbar .toolbar-btn:active {
    background: #e5e7eb;
}

.document-toolbar .toolbar-separator {
    width: 1px;
    height: 20px;
    background: #d1d5db;
    margin: 0 4px;
}

/* Document content area */
.document-content {
    flex: 1;
    padding: 2.5cm 3cm 2.5cm 3cm; /* מרווחי מסמך טבעיים כמו וורד */
    overflow-y: auto;
    outline: none;
    direction: rtl;
    text-align: right;
    min-height: 800px; /* גובה מינימלי */
}

.text-editor.document-editor:before {
    content: "";
    position: absolute;
    top: 1cm;
    left: 2cm;
    right: 2cm;
    height: 1px;
    background: #e5e7eb;
    opacity: 0.5;
}

.text-editor.document-editor:after {
    content: "עמוד 1";
    position: absolute;
    bottom: 1cm;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10pt;
    color: #6b7280;
    font-family: 'Galil', sans-serif;
    letter-spacing: normal;
}

/* Maintain normal view styles */
.main-editor:not(.document-view) {
    background: white;
    padding: 0;
}

.text-editor:not(.document-editor) {
    /* רווח שווה של ס"מ מכל הכיוונים */
    padding: 1cm;
    font-family: 'Heebo', serif;
    font-size: 16px;
    line-height: 1.8;
    letter-spacing: normal; /* Reset - העורך נשאר עם Heebo ללא ריווח נוסף */
}

/* Global Selection Feedback */
.global-selection-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(16, 185, 129, 0.95);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    direction: rtl;
    font-family: 'Galil', sans-serif;
    letter-spacing: normal;
    animation: slideInFeedback 0.3s ease-out, slideOutFeedback 0.3s ease-in 1.7s;
}

@keyframes slideInFeedback {
    from {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes slideOutFeedback {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }
}

/* Enhanced page content highlighting */
.document-page-content.global-selected {
    background: rgba(30, 58, 95, 0.15) !important;
    outline: 2px solid rgba(30, 58, 95, 0.3) !important;
    transition: all 0.2s ease;
}

/* Page navigation indicator */
.page-navigation-indicator {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 40px;
    background: #1e3a5f;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.page-navigation-indicator.left {
    left: -10px;
}

.page-navigation-indicator.right {
    right: -10px;
}

.document-page:hover .page-navigation-indicator {
    opacity: 0.6;
}

/* Document Pages Container - Real pages for print/PDF */
.document-pages-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100%;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
    transform-origin: top center;
    transition: transform 0.2s ease;
}

/* Individual Page Wrapper */
.document-page-wrapper {
    display: block;
    margin-bottom: 2cm;
    page-break-after: always;
    break-after: page;
}

/* Real Document Page with A4 dimensions */
.document-page-real {
    width: 21cm;
    height: 29.7cm;
    background: white;
    margin: 1cm auto;
    box-shadow: 0 0 0 1px #e5e7eb, 0 4px 20px rgba(0,0,0,0.15);
    position: relative;
    box-sizing: border-box;
    page-break-after: always;
    break-after: page;
}

/* Page Content Area */
.page-content-area {
    width: 100%;
    height: 100%;
    padding: 2cm 2cm 3cm 2cm;
    box-sizing: border-box;
    outline: none;
    direction: rtl;
    text-align: right;
    font-family: 'Times New Roman', 'Noto Serif Hebrew', serif;
    font-size: 12pt;
    line-height: 1.6;
    overflow-wrap: break-word;
    word-wrap: break-word;
    min-height: calc(29.7cm - 5cm);
    max-height: calc(29.7cm - 5cm);
    overflow: hidden;
}

/* Placeholder for empty content area */
.page-content-area:empty:before {
    content: 'הקלד או הדבק את הטקסט שלך כאן...';
    color: #9ca3af;
    pointer-events: none;
    position: absolute;
    top: 2cm;
    right: 2cm;
    font-style: italic;
}

/* Page Number Display */
.page-number-display {
    position: absolute;
    bottom: 1cm;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10pt;
    color: #6b7280;
    font-family: 'Galil', sans-serif;
    letter-spacing: normal;
    pointer-events: none;
    user-select: none;
    z-index: 10;
}

/* Print support */
@media print {
    .document-page-wrapper {
        page-break-after: always;
        break-after: page;
        margin: 0;
        box-shadow: none;
    }

    .document-page-real {
        margin: 0;
        box-shadow: none;
        width: 100%;
        height: 100vh;
    }

    .page-content-area {
        padding: 2cm;
        max-height: none;
        overflow: visible;
    }
}

/* ========================================
   Sequential Chunking Progress Indicator
   ======================================== */

.chunking-progress {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    min-width: 300px;
    font-family: 'Galil', Arial, sans-serif;
    letter-spacing: normal;
}

.progress-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.progress-text {
    font-size: 14px;
    color: #333;
    text-align: center;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #45a049);
    transition: width 0.3s ease;
}

.fa-cog {
    color: #4CAF50;
    font-size: 20px;
}

/* ===================================
   Truncation Warning (Chunking Limit)
   =================================== */
.truncation-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffe69c 100%);
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    color: #856404;
    font-size: 14px;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.15);
    animation: slideDown 0.3s ease-out;
}

.truncation-warning i {
    color: #ffc107;
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.truncation-warning .warning-content {
    flex: 1;
    line-height: 1.5;
}

.truncation-warning strong {
    display: block;
    margin-bottom: 4px;
    font-size: 15px;
    color: #664d03;
}

.truncation-warning p {
    margin: 0;
    font-size: 13px;
}

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

/* ===================================
   Panel Status Bar - Container
   =================================== */
#panelStatusBar {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

/* ===================================
   Chunking Status Inline (Inside Panel)
   =================================== */
.chunking-status-inline {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #0ea5e9;
    border-radius: 8px;
    padding: 8px 12px;
    animation: slideDown 0.3s ease-out;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.chunking-status-inline .status-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chunking-spinner {
    color: #0ea5e9;
    font-size: 14px;
    animation: fa-spin 1s infinite linear;
}

.chunk-counter {
    font-size: 13px;
    font-weight: 600;
    color: #0369a1;
    font-family: 'Courier New', monospace;
}

/* ===================================
   Global Stop Button (Separate from progress)
   =================================== */
.global-stop-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.2);
    display: none; /* מוסתר כברירת מחדל */
}

.global-stop-btn:hover {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

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

/* Suggestions Counter */
.suggestions-counter {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #22c55e;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #15803d;
    text-align: center;
    animation: slideDown 0.3s ease-out;
    display: inline-flex;
    align-items: center;
}

/* ===================================
   Dark Theme Background Toggle
   =================================== */

/* Dark theme button */
.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.75rem;
    color: #475569;
    font-family: 'Galil', sans-serif;
    letter-spacing: normal;
    height: 24px;
    line-height: 1;
}

.theme-toggle-btn i {
    font-size: 12px;
}

.theme-toggle-btn span {
    white-space: nowrap;
}

.theme-toggle-btn:hover {
    background: rgba(30, 58, 95, 0.1);
    border-color: #1e3a5f;
    color: #1e3a5f;
}

.theme-toggle-btn.active {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: white;
    border-color: #1e293b;
}

.theme-toggle-btn.active:hover {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
}

/* Dark theme mode - background only */
body.dark-theme-bg {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

body.dark-theme-bg .editor-container {
    background: transparent;
}

body.dark-theme-bg .main-editor {
    background: transparent !important;
}

/* Top navigation bar - transparent in dark theme */
body.dark-theme-bg .top-nav {
    background: transparent;
}

/* Formatting toolbar - transparent in dark theme */
body.dark-theme-bg .formatting-toolbar,
body.dark-theme-bg .formatting-toolbar.light {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Logo turns white in dark theme */
body.dark-theme-bg .nav-logo-img,
body.dark-theme-bg #navLogoStatic {
    filter: brightness(0) invert(1);
}

/* Logo text "מילה" turns white in dark theme */
body.dark-theme-bg .nav-logo span {
    color: white;
}

body.dark-theme-bg .nav-logo-animated .logo-full {
    filter: brightness(0) invert(1);
}

/* Smooth transition for theme changes */
body {
    transition: background 0.3s ease;
}

.nav-logo-img,
#navLogoStatic {
    transition: filter 0.3s ease;
}