File size: 12,228 Bytes
59aaeae
 
 
aabc02c
7647e70
 
aabc02c
 
 
42dc069
 
7647e70
 
aabc02c
42dc069
 
aabc02c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7647e70
aabc02c
7647e70
aabc02c
 
 
 
 
 
 
42dc069
 
 
 
 
aabc02c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7647e70
 
aabc02c
 
 
7647e70
 
aabc02c
 
 
7647e70
 
aabc02c
 
7647e70
 
aabc02c
 
 
 
 
 
 
 
7647e70
 
aabc02c
 
 
 
 
 
 
 
 
7647e70
 
aabc02c
 
 
 
 
7647e70
 
aabc02c
 
 
 
 
7647e70
 
aabc02c
 
 
 
 
 
7647e70
 
 
aabc02c
 
 
7647e70
 
aabc02c
 
 
7647e70
 
42dc069
 
 
 
aabc02c
42dc069
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7647e70
 
42dc069
 
 
 
 
 
 
 
 
 
 
aabc02c
 
7647e70
aabc02c
 
 
 
7647e70
 
aabc02c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7647e70
aabc02c
 
 
 
 
 
 
7647e70
 
aabc02c
 
 
 
 
 
 
 
 
7647e70
 
aabc02c
 
 
7647e70
 
aabc02c
 
 
7647e70
 
aabc02c
7647e70
aabc02c
7647e70
 
aabc02c
 
7647e70
 
aabc02c
 
 
7647e70
 
aabc02c
 
 
 
 
7647e70
 
aabc02c
 
 
 
7647e70
 
aabc02c
 
 
 
 
 
7647e70
 
aabc02c
 
 
 
7647e70
 
aabc02c
 
 
 
 
7647e70
59aaeae
aabc02c
 
 
 
7647e70
59aaeae
aabc02c
 
 
 
7647e70
59aaeae
aabc02c
 
 
 
7647e70
59aaeae
aabc02c
 
 
7647e70
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
import streamlit as st

def load_css():
    """Load custom CSS for the application - inspired by mistral-ocr implementations"""
    st.markdown("""
    <style>
    /* Global styles - clean, modern approach with consistent line height */
    :root {
        --standard-line-height: 1.5;
        --standard-font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        --standard-color: #111827;
    }
    
    body {
        font-family: var(--standard-font);
        color: var(--standard-color);
        line-height: var(--standard-line-height);
    }
    
    /* Remove all container backgrounds that cause the white box issue */
    div[data-testid="stMarkdownContainer"],
    div[data-testid="stText"],
    div.stMarkdown,
    .stText > div:first-child,
    .element-container > div,
    div[data-testid="column"] > div > div > div {
        background-color: transparent !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    /* Base text styling with standardized line height */
    div[data-testid="stMarkdownContainer"] > p {
        margin: 0 0 0.3rem 0 !important;
        padding: 0 !important;
        font-size: 0.95rem !important;
        line-height: var(--standard-line-height) !important; 
    }
    
    /* Move content to top of columns with minimal padding */
    [data-testid="column"] {
        align-items: flex-start !important;
        padding: 0 0.5rem !important;
        gap: 0.5rem !important;
    }
    
    /* Clean minimal heading styles with better line height */
    h1, h2, h3, h4, h5, h6 {
        font-family: 'Inter', system-ui, sans-serif;
        font-weight: 600;
        color: #111827;
        margin: 0.4rem 0 0.2rem 0 !important;
        padding: 0 !important;
        background-color: transparent !important;
        line-height: 1.3 !important; /* Slightly increased for headings but still compact */
    }
    
    /* Make h1 headings significantly smaller */
    h1 {
        font-size: 1.3em !important; /* Reduced from default ~2em */
    }
    
    /* Simple section headers with subtle styling */
    .block-container [data-testid="column"] h4 {
        font-size: 0.95rem !important;
        font-weight: 600 !important;
        color: #374151 !important;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 0.15rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* Reduce whitespace between elements */
    .element-container {
        margin-bottom: 0.2rem !important;
    }
    
    /* Custom scrollbar styling */
    .ocr-text-container::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
    
    .ocr-text-container::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }
    
    .ocr-text-container::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }
    
    .ocr-text-container::-webkit-scrollbar-thumb:hover {
        background: #a0a0a0;
    }
    
    /* Styling for all expanders/accordions */
    .st-expander, 
    details.streamlit-expanderHeader {
        border: 1px solid #e5e7eb !important;
        border-radius: 4px !important;
        box-shadow: none !important;
        background-color: transparent !important;
        margin-bottom: 6px !important;
    }
    
    .st-expanderHeader,
    summary.streamlit-expanderHeader {
        font-size: 0.95rem !important;
        font-weight: 600 !important;
        color: #374151 !important;
        padding: 0.4rem 0.6rem !important;
        background-color: rgba(241, 245, 249, 0.5) !important;
        border-bottom: 1px solid #e5e7eb !important;
        border-radius: 3px 3px 0 0 !important;
    }
    
    .st-expanderContent,
    details[open] > div:nth-child(2) {
        border-top: none !important;
        padding: 0.4rem 0.6rem !important;
        background-color: transparent !important;
    }
    
    /* Set expander text to have good contrast */
    .st-expanderContent p, 
    .st-expanderContent li,
    .st-expanderContent span {
        color: #1f2937 !important;
    }
    
    /* Streamlined OCR image display */
    .ocr-image-container {
        border: 1px solid #e2e8f0;
        border-radius: 4px;
        padding: 0;
        background-color: transparent;
        margin-bottom: 5px;
    }
    
    .ocr-image-container img {
        border-radius: 4px;
        width: 100%;
    }
    
    /* Subtle document sections */
    .document-section {
        margin-bottom: 0.4rem !important;
    }
    
    /* Compact tag styling - with higher specificity to override custom.css */
    .document-content .subject-tag,
    div[data-testid="stHorizontalBlock"] .subject-tag,
    div[data-testid="stVerticalBlock"] .subject-tag,
    .subject-tag {
        display: inline-block !important;
        padding: 0.1rem 0.4rem !important;
        border-radius: 3px !important;
        font-size: 0.7rem !important;
        margin: 0 0.2rem 0.2rem 0 !important;
        background-color: #f3f4f6 !important;
        color: #374151 !important;
        border: 1px solid #e5e7eb !important;
        font-family: var(--standard-font) !important;
    }
    
    /* Tag color overrides with higher specificity */
    .document-content .tag-time-period,
    .tag-time-period { color: #1e40af !important; background-color: #eff6ff !important; border-color: #bfdbfe !important; }
    
    .document-content .tag-language,
    .tag-language { color: #065f46 !important; background-color: #ecfdf5 !important; border-color: #a7f3d0 !important; }
    
    .document-content .tag-document-type,
    .tag-document-type { color: #5b21b6 !important; background-color: #f5f3ff !important; border-color: #ddd6fe !important; }
    
    .document-content .tag-subject,
    .tag-subject { color: #166534 !important; background-color: #f0fdf4 !important; border-color: #bbf7d0 !important; }
    
    .document-content .tag-download,
    .tag-download { 
        color: #1e40af !important; 
        background-color: #dbeafe !important; 
        border-color: #93c5fd !important; 
        text-decoration: none !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
    }
    
    .document-content .tag-download:hover,
    .tag-download:hover { 
        background-color: #93c5fd !important; /* Darker blue on hover */
        border-color: #3b82f6 !important; /* Darker border */
        color: #1e3a8a !important; /* Darker text */
        box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important; /* More pronounced shadow */
    }
    
    /* For any default tags that might use the old styling */
    .document-content .tag-default,
    .tag-default { color: #374151 !important; background-color: #f3f4f6 !important; border-color: #e5e7eb !important; }
    
    /* Document content styling to ensure consistency */
    .document-content,
    .document-section {
        font-family: var(--standard-font) !important;
        line-height: var(--standard-line-height) !important;
        color: var(--standard-color) !important;
    }
    
    /* Clean text area */
    .stTextArea textarea {
        font-family: 'Roboto Mono', monospace;
        font-size: 0.9rem;
        line-height: var(--standard-line-height); /* Consistent line height */
        padding: 0.5rem;
    }
    
    /* Button styling - fixed for text overflow issues */
    .stButton > button {
        border-radius: 4px;
        font-weight: 400;
        line-height: var(--standard-line-height);
        padding: 0.4rem 0.75rem !important;
        margin: 0;
        min-width: 150px !important; /* Increased minimum width */
        white-space: normal !important; /* Allow text to wrap if needed */
        overflow: visible !important; /* Ensure text doesn't get cut off */
        height: auto !important; /* Allow height to adjust as needed */
        text-overflow: clip !important; /* Don't clip text */
        display: inline-block !important; /* Better content handling */
        text-align: center !important; /* Center text */
    }
    
    /* Fix button text alignment and prevent truncation */
    .stButton > button > div, 
    .stButton > button span,
    .stButton > button p {
        display: inline-block !important;
        align-items: center;
        white-space: normal !important;
        overflow: visible !important;
        width: auto !important;
        text-overflow: clip !important;
        word-wrap: normal !important;
    }
    
    /* Fix for all action buttons in the application */
    [data-testid="stHorizontalBlock"] button,
    button[key="close_document_btn"],
    button[key="process_document_btn"],
    button[key="load_sample_btn"],
    button[key="view_btn"],
    .stDownloadButton button,
    button[key*="copy_btn"],
    button[key*="download_btn"],
    button[key*="view_"] {
        width: auto !important;
        min-width: 150px !important;
        max-width: none !important;
        display: inline-block !important;
        white-space: normal !important; 
        overflow: visible !important;
        text-align: center !important;
        text-overflow: clip !important;
        word-break: normal !important;
        padding: 0.4rem 0.75rem !important;
    }

    /* Ensure text doesn't wrap awkwardly for buttons */
    button span p {
        margin: 0 !important;
        padding: 0 !important;
        white-space: normal !important;
        overflow: visible !important;
    }
    
    /* Extra button container fixes for all button types */
    .stButton, .stDownloadButton, [data-testid="stDownloadButton"] {
        width: auto !important;
        min-width: 150px !important;
        overflow: visible !important;
        display: block !important;
        background-color: white;
        border: 1px solid #ddd;
        box-shadow: none !important;
    }
    
    /* Ensure consistent spacing in widgets */
    .row-widget {
        padding: 0.15rem 0 !important;
    }
    
    /* Fix spacing in expanders */
    .stExpander > .streamlit-expanderContent > div {
        padding-top: 0.15rem !important;
    }
    
    /* Optimized sidebar */
    .sidebar .block-container {
        padding-top: 0.6rem;
    }
    
    .sidebar .stRadio > div {
        flex-direction: row;
    }
    
    .sidebar .stRadio label {
        margin-right: 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Clean alert styles */
    .stSuccess, .stError, .stInfo, .stWarning {
        border-radius: 4px;
        padding: 0.3rem 0.6rem;
        margin: 0.2rem 0;
    }
    
    /* Fix any remaining spacing issues */
    div.element-container > div > div {
        margin: 0 !important;
        line-height: var(--standard-line-height); /* Ensure consistent line height */
    }
    
    /* Fix column layouts for button containers */
    [data-testid="column"] > div:has(.stButton) {
        display: flex;
        justify-content: flex-start;
        align-items: center;
        min-height: 38px; /* Match standard button height */
    }
    
    /* Fix for tabs being cut off at the top of the page */
    /* Main container adjustments to avoid header overlap */
    .main .block-container {
        padding-top: 3rem !important; /* Increased top padding to make room for Streamlit header */
    }
    
    [data-testid="stTabs"] {
        width: 100%;
        overflow-x: visible !important;
        position: relative;
        z-index: 1; /* Ensure tabs are on the right layer */
    }
    
    [data-testid="stTabs"] > div:first-child {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
        overflow-x: visible !important;
    }
    
    [data-testid="stTabs"] [role="tab"] {
        padding: 0.5rem 1rem;
        min-width: fit-content;
        white-space: nowrap;
    }
    
    [data-testid="stTabs"] [role="tablist"] {
        overflow-x: visible !important;
        flex-wrap: nowrap;
        margin-top: 1rem; /* Add a bit more space at the top */
    }
    
    /* Fix header overlap issues */
    header[data-testid="stHeader"] {
        z-index: 999 !important; /* Keep header on top */
    }
    </style>
    """, unsafe_allow_html=True)