*,
*::before,
*::after {
    box-sizing: border-box;
}
       
       
       body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background: #f0f2f5;
        }

        .main-layout {
            display: flex;
            min-height: 100vh;
        }

        .bookmarks-sidebar {
            width: 320px;
            background: white;
            border-right: 2px solid #e9ecef;
            overflow-y: auto;
            position: fixed;
            left: 0;
            top: 0;
            bottom: 0;
            box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
        }

        .sidebar-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            text-align: center;
            position: sticky;
            top: 0;
            z-index: 10;
        }

        .sidebar-header h2 {
            margin: 0;
            font-size: 1.3em;
        }

        .sidebar-content {
            padding: 15px;
        }

        .sidebar-section {
            border-top: 2px solid #e9ecef;
            background: #f8f9fa;
        }

        .sidebar-section-header {
            background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
            color: white;
            padding: 12px 15px;
            position: sticky;
            top: 0;
            z-index: 9;
            height: 50px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .sidebar-section-header h3 {
            margin: 0;
            font-size: 1.1em;
        }

        .sidebar-keywords {
            padding: 15px;
        }

        .container {
            flex: 1;
            margin-left: 320px;
            background: white;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        }

        .header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 25px;
            text-align: center;
        }

        .header h1 {
            margin: 0 0 10px 0;
            font-size: 2em;
        }

        .controls {
            padding: 25px;
            background: #f8f9fa;
            border-bottom: 2px solid #e9ecef;
        }

        .section {
            margin-bottom: 25px;
            padding: 20px;
            border: 2px solid #e9ecef;
            border-radius: 8px;
        }

        .section.ocr {
            border-color: #28a745;
            background: #f8fff9;
        }

        .section.search {
            border-color: #ffc107;
            background: #fffef8;
        }

        .section-title {
            font-size: 1.2em;
            font-weight: bold;
            margin-bottom: 15px;
            color: #495057;
        }

        .dev-only {
            display: none;
        }
        

        .input-field {
            display: flex;
            flex-direction: column;
        }

        /* API URL row */
        .api-row {
            display: grid;
            grid-template-columns: minmax(300px, 700px) auto;
            gap: 20px;
            align-items: end;
            margin-bottom: 25px;
        }

.dev-only {
    display: none !important;
}

        

/* Search row */
.search-row {
    display: grid;
    grid-template-columns: minmax(240px, 420px) minmax(240px, 420px) auto;
    gap: 20px;
    align-items: end;
}



button {
    height: 46px;
    white-space: nowrap;
}

        
        
        

        label {
            display: block;
            font-weight: bold;
            margin-bottom: 5px;
            color: #495057;
        }

        input {
            width: 100%;
            padding: 12px;
            border: 2px solid #ced4da;
            border-radius: 6px;
            font-size: 14px;
            transition: border-color 0.3s;
        }

        input:focus {
            outline: none;
            border-color: #667eea;
            box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        }

        button {
            padding: 12px 24px;
            border: none;
            border-radius: 6px;
            font-weight: bold;
            cursor: pointer;
            transition: all 0.3s;
            font-size: 14px;
        }
        

        .btn-ocr {
            background: #28a745;
            color: white;
        }

        .btn-search {
            background: #ffc107;
            color: #212529;
        }

        .btn-health {
            background: #17a2b8;
            color: white;
        }

        button:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        button:disabled {
            opacity: 0.6;
            cursor: not-allowed;
            transform: none;
        }

        .keywords {
            margin-top: 15px;
        }

        .keyword-btn {
            background: #e9ecef;
            color: #495057;
            padding: 6px 12px;
            border: none;
            border-radius: 15px;
            margin: 3px;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.3s;
        }

        .keyword-btn:hover {
            background: #667eea;
            color: white;
            transform: none;
            box-shadow: none;
        }

        .loading {
            display: none;
            padding: 30px;
            text-align: center;
        }

        .spinner {
            border: 4px solid #f3f3f3;
            border-top: 4px solid #667eea;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            animation: spin 1s linear infinite;
            margin: 0 auto 15px;
        }

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

            100% {
                transform: rotate(360deg);
            }
        }

        .results {
            padding: 25px;
        }

        .summary {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
            color: white;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 25px;
        }

        .summary.ocr-summary {
            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
        }

        .summary.search-summary {
            background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
            color: #212529;
        }

        .summary h2 {
            margin: 0 0 10px 0;
            font-size: 1.5em;
        }

        .document {
            background: white;
            border: 2px solid #e9ecef;
            border-radius: 10px;
            margin-bottom: 25px;
            overflow: hidden;
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        }

        .doc-header {
            background: #f8f9fa;
            padding: 15px 20px;
            border-bottom: 1px solid #e9ecef;
        }

        .doc-title {
            font-size: 1.2em;
            font-weight: bold;
            color: #495057;
            margin-bottom: 5px;
        }

        .doc-stats {
            color: #6c757d;
            font-size: 14px;
        }

        .page {
            padding: 20px;
            border-bottom: 1px solid #f8f9fa;
        }

        .page:last-child {
            border-bottom: none;
        }

        .page-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .page-title {
            font-weight: bold;
            color: #495057;
        }

        .matches {
            background: #ffd700;
            color: #856404;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 12px;
            font-weight: bold;
        }

        .context {
            background: #fff3cd;
            border-left: 4px solid #ffd700;
            padding: 12px;
            border-radius: 6px;
            margin-bottom: 15px;
            font-style: italic;
        }

        .preview {
            text-align: center;
            margin-top: 15px;
        }

        .preview img {
            max-width: 100%;
            height: auto;
            border: 3px solid #667eea;
            border-radius: 8px;
            cursor: pointer;
            transition: transform 0.3s;
        }

        .preview img:hover {
            transform: scale(1.02);
        }

        .preview-caption {
            margin-top: 10px;
            font-size: 12px;
            color: #6c757d;
        }

        .error {
            background: #f8d7da;
            color: #721c24;
            padding: 20px;
            border-radius: 8px;
            border: 1px solid #f5c6cb;
            margin: 20px;
        }

        .status {
            padding: 20px;
            text-align: center;
            font-size: 16px;
            color: #6c757d;
        }

        /* Saved Keywords Styles */
        .saved-keywords-box {
            margin-top: 15px;
            padding: 15px;
            background: white;
            border: 2px solid #e9ecef;
            border-radius: 8px;
        }

        .saved-keywords-title {
            font-weight: bold;
            margin-bottom: 10px;
            color: #495057;
        }

        .keyword-checkbox-item {
            display: flex;
            align-items: center;
            padding: 8px;
            margin: 5px 0;
            background: #f8f9fa;
            border-radius: 6px;
            transition: background 0.3s;
        }

        .keyword-checkbox-item:hover {
            background: #e9ecef;
        }

        .keyword-checkbox-item input[type="checkbox"] {
            width: 20px;
            height: 20px;
            margin-right: 10px;
            cursor: pointer;
        }

        .keyword-checkbox-item label {
            margin: 0;
            cursor: pointer;
            flex: 1;
            font-weight: normal;
        }

        .keyword-checkbox-item.saved {
            background: #d4edda;
            border: 1px solid #c3e6cb;
        }

        .saved-keyword-btn {
            display: block;
            width: 100%;
            background: #667eea;
            color: white;
            padding: 10px 12px;
            margin-bottom: 8px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s;
            border: none;
            font-size: 13px;
            font-weight: 500;
            text-align: left;
            position: relative;
            line-height: 1.4;
            word-wrap: break-word;
        }

        .saved-keyword-btn:hover {
            background: #5568d3;
            transform: translateX(3px);
            box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
        }

        .saved-keyword-btn:active {
            transform: translateX(0);
        }



        /* Bookmark Styles */
        .section.bookmarks {
            border-color: #667eea;
            background: #f8f9ff;
        }

        .btn-bookmark {
            background: #667eea;
            color: white;
        }

        .btn-save-bookmark {
            background: #28a745;
            color: white;
            margin-top: 15px;
        }

        .bookmark-item {
            background: #f8f9fa;
            border: 2px solid #e9ecef;
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 12px;
            transition: all 0.3s;
            cursor: pointer;
        }

        .bookmark-item:hover {
            border-color: #667eea;
            background: white;
            box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
        }

        .bookmark-header {
            margin-bottom: 8px;
        }

        .bookmark-title {
            font-size: 0.95em;
            font-weight: bold;
            color: #495057;
            margin-bottom: 5px;
            word-wrap: break-word;
        }

        .bookmark-actions {
            display: flex;
            gap: 5px;
            margin-top: 8px;
        }

        .bookmark-actions button {
            padding: 5px 10px;
            font-size: 11px;
            margin: 0;
            width: 100%;
        }

        .bookmark-info {
            color: #6c757d;
            font-size: 12px;
        }

        .bookmark-info p {
            margin: 4px 0;
            word-wrap: break-word;
        }

        .badge {
            display: inline-block;
            padding: 2px 8px;
            background: #667eea;
            color: white;
            border-radius: 10px;
            font-size: 10px;
            margin-right: 5px;
        }

        .btn-view {
            background: #17a2b8;
            color: white;
        }

        .btn-delete {
            background: #dc3545;
            color: white;
        }

        .bookmark-list {
            margin-top: 20px;
        }

        /* Highlight Image Styles */
        .highlight-container {
            margin-top: 15px;
        }

        .highlight-image-wrapper {
            position: relative;
            cursor: pointer;
            border: 2px solid #e9ecef;
            border-radius: 8px;
            overflow: hidden;
            transition: all 0.3s;
        }

        .highlight-image-wrapper:hover {
            border-color: #667eea;
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
        }

        .highlight-image {
            width: 100%;
            height: auto;
            display: block;
        }

        /* Results toolbar above pages */
        .results-toolbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin: 15px 0 20px;
            gap: 10px;
        }

        .results-toolbar-left {
            font-size: 14px;
            color: #495057;
        }

        .select-all-label input {
            margin-right: 6px;
        }

        .results-toolbar-right {
            display: flex;
            justify-content: flex-end;
        }

        .btn-save {
            background: #28a745;
            color: #fff;
        }

        .image-overlay {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            background: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 10px;
            text-align: center;
            opacity: 0;
            transition: opacity 0.3s;
        }

        .highlight-image-wrapper:hover .image-overlay {
            opacity: 1;
        }


        @media (max-width: 900px) {
            .search-row,
            .api-row {
                grid-template-columns: 1fr;
            }
        
            button {
                width: 100%;
            }
        }
        


.api-row {
    display: none !important;
}

/* ===============================
   CleveDoc UI Theme Override
   =============================== */

:root {
    --cd-primary: #0b1f5b;
    --cd-primary-light: #1f3a8a;
    --cd-accent: #fbbf24;
    --cd-bg: #f5f7fb;
    --cd-card: #ffffff;
    --cd-border: #e5e7eb;
    --cd-text: #1f2937;
}

/* Page background */
body {
    background: var(--cd-bg);
}

/* Header */
.header {
    background: var(--cd-primary);
}

/* Sidebar */
.bookmarks-sidebar {
    background: var(--cd-primary);
    border-right: none;
}

.sidebar-header {
    background: var(--cd-primary);
}

.sidebar-section-header {
    background: var(--cd-primary-light);
}

/* Sidebar keyword buttons */
.saved-keyword-btn {
    background: #1f3a8a;
    border-radius: 10px;
}

.saved-keyword-btn:hover {
    background: #162f6a;
}

/* Main container */
.container {
    background: transparent;
    box-shadow: none;
}

/* Cards */
.section,
.document,
.summary {
    border-radius: 14px;
    border: 1px solid var(--cd-border);
    box-shadow: 0 6px 18px rgba(0,0,0,0.06);
}

/* Search card */
.section.search {
    background: var(--cd-card);
    border-left: 4px solid var(--cd-accent);
}

/* Summary bar */
.summary.search-summary {
    background: var(--cd-primary);
    color: #ffffff;
}

/* Buttons */
.btn-search {
    background: var(--cd-accent);
    color: #111827;
    font-weight: 600;
}

.btn-save-bookmark {
    background: var(--cd-primary);
}

/* Match badges */
.matches {
    background: var(--cd-accent);
    color: #111827;
}

/* Highlight image */
.highlight-image-wrapper {
    border-radius: 14px;
    border: 1px solid var(--cd-border);
}


/* Simplify API health check UI */
.summary.ocr-summary,
.summary.search-summary {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 10px 0 !important;
}

/* Hide technical details */
.summary h2,
.summary p,
.summary div {
    display: none !important;
}

/* Show a single friendly line */
.summary::after {
    content: "OCR processing is ready. You can search documents.";
    display: block;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    color: #1f3a8a;
    padding: 16px;
}


/* CleveDoc Search button */
.btn-search {
    background: #1f3a8a !important;
    color: #ffffff !important;
    border-radius: 8px;
    font-weight: 600;
}

.btn-search:hover {
    background: #162f6a !important;
}

/* Hide Flask technical status text permanently */
.status,
.status p {
    display: none !important;
}


/* System status message */
.system-status {
    margin: 20px;
    padding: 16px 20px;
    border-radius: 12px;
    text-align: center;
    font-size: 15px;
    font-weight: 500;
}

/* Success */
.system-status.success {
    background: #e6f4ea;
    color: #1e7e34;
}

/* Error */
.system-status.error {
    background: #fdecea;
    color: #b02a37;
}

/* Hidden */
.system-status.hidden {
    display: none;
}
