@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&family=Outfit:wght@400;700&display=swap");
/* ================================================================
   BOX SIZING & UTILITIES
   ================================================================ */
* {
    box-sizing: border-box;
}

/* Utility Classes */
.flex { display: flex !important; }
.flex-col { flex-direction: column !important; }
.items-center { align-items: center !important; }
.items-baseline { align-items: baseline !important; }
.justify-between { justify-content: space-between !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.px-1 { padding-left: 4px !important; padding-right: 4px !important; }
.pr-1 { padding-right: 4px !important; }
.pl-2 { padding-left: 8px !important; }
.truncate { white-space: nowrap !important; overflow: hidden !important; text-overflow: ellipsis !important; }
.w-16 { width: 4rem !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.overflow-hidden { overflow: hidden !important; }
.min-w-0 { min-width: 0 !important; }
.uppercase { text-transform: uppercase !important; }
.text-sm { font-size: 0.875rem !important; }
.text-xs { font-size: 0.75rem !important; }
.text-slate-400 { color: #94a3b8 !important; }
.text-slate-500 { color: #64748b !important; }
.text-blue-600 { color: #2563eb !important; }
.font-semibold { font-weight: 600 !important; }
.font-bold { font-weight: 700 !important; }

/* ================================================================
   CSS VARIABLES
   ================================================================ */
:root {
    --bg-color: #f3f4f6;
    --sidebar-bg: #ffffff;
    --text-main: #1e293b;
    --text-dim: #64748b;
    --accent: #2563eb;
    --accent-glow: rgba(37, 99, 235, 0.1);
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #d97706;
    --error: #dc2626;
}

/* Utility Classes */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.w-16 { width: 4rem; }
.flex-shrink-0 { flex-shrink: 0; }
.overflow-hidden { overflow: hidden; }
.min-w-0 { min-width: 0; }
.pr-1 { padding-right: 4px; }
.pl-2 { padding-left: 8px; }
.uppercase { text-transform: uppercase; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-slate-400 { color: #94a3b8; }
.text-blue-600 { color: #2563eb; }
.mb-2 { margin-bottom: 0.5rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ================================================================
   INSPECTOR PAGE: Hide ALL Drupal chrome and take over viewport
   Triggered by body class 'daos-inspector-page' set in module preprocess.
   ================================================================ */

/* Hide everything that isn't the inspector */
body.daos-inspector-page .site-header,
body.daos-inspector-page .region-header,
body.daos-inspector-page .region-primary-menu,
body.daos-inspector-page .region-secondary-menu,
body.daos-inspector-page .region-breadcrumb,
body.daos-inspector-page .region-highlighted,
body.daos-inspector-page .page-title,
body.daos-inspector-page .site-footer,
body.daos-inspector-page .region-footer,
/* Reset all Drupal layout containers to be transparent pass-throughs */
html.daos-inspector-page {
    overflow: hidden !important;
    height: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

body.daos-inspector-page {
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    height: 100% !important;
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    background: #1e293b !important;
    box-sizing: border-box !important;
}

/* ================================================================
   1. LAYOUT STRETCH - Ensure full height for RDA
   ================================================================ */

body.daos-inspector-page .dialog-off-canvas-main-canvas,
body.daos-inspector-page .page-wrapper,
body.daos-inspector-page #page,
body.daos-inspector-page .layout-container,
body.daos-inspector-page #main-wrapper,
body.daos-inspector-page .layout-main,
body.daos-inspector-page #main,
body.daos-inspector-page .main-content,
body.daos-inspector-page div.main-content,
body.daos-inspector-page main[role="main"],
body.daos-inspector-page .main-content__container,
body.daos-inspector-page .region--content,
body.daos-inspector-page .region-content,
body.daos-inspector-page .block-system-main-block,
body.daos-inspector-page .block--system-main-block,
body.daos-inspector-page .block-content,
body.daos-inspector-page .block__content,
body.daos-inspector-page [class*="block__content"] {
    all: unset !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    height: 100% !important;
    min-height: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    inset: unset !important;
}

body.daos-inspector-page [class*="region--content"],
body.daos-inspector-page [class*="layout--pass"] {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
}

/* ================================================================
   2. HIDE DRUPAL CHROME - MUST come after stretch to win display:none
   ================================================================ */

body.daos-inspector-page #toolbar-administration,
body.daos-inspector-page header.site-header,
body.daos-inspector-page .breadcrumb,
body.daos-inspector-page .region-sidebar,
body.daos-inspector-page .social-bar,
body.daos-inspector-page .layout-sidebar-first,
body.daos-inspector-page .layout-sidebar-second,
body.daos-inspector-page .region--highlighted,
body.daos-inspector-page .region--breadcrumb,
body.daos-inspector-page .region--secondary-menu,
body.daos-inspector-page .region--hero,
body.daos-inspector-page .region--content-above,
body.daos-inspector-page .region-content-above,
body.daos-inspector-page .region-highlighted,
body.daos-inspector-page .region-breadcrumb,
body.daos-inspector-page .region-hero,
body.daos-inspector-page .region-secondary-menu,
body.daos-inspector-page #block-olivero-messages,
body.daos-inspector-page .messages-wrapper,
body.daos-inspector-page footer,
body.daos-inspector-page .page-title,
body.daos-inspector-page aside:not(.sidebar),
body.daos-inspector-page .site-header,
body.daos-inspector-page .region-header,
body.daos-inspector-page .region-primary-menu,
body.daos-inspector-page .site-footer,
body.daos-inspector-page .region-footer,
body.daos-inspector-page .toolbar,
body.daos-inspector-page #block-olivero-page-title,
body.daos-inspector-page .block-page-title-block,
body.daos-inspector-page #block-olivero-breadcrumbs,
body.daos-inspector-page .tabs,
body.daos-inspector-page .site-header__inner {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 0 0 0 !important;
    overflow: hidden !important;
    visibility: hidden !important;
}

/* Also hide any Drupal layout aside elements (sidebars from theme) */
body.daos-inspector-page .layout-main>aside {
    display: none !important;
}

/* Ensure our inspector's own sidebar remains visible */
body.daos-inspector-page .inspector-wrapper .sidebar {
    display: flex !important;
    width: 380px !important;
    min-width: 380px !important;
    max-width: 380px !important;
    flex: 0 0 380px !important;
    overflow-x: hidden !important;
}

#sidebar-metadata-container {
    flex: 1;
    min-height: 0;
    width: 100% !important;
    min-width: 0 !important;
    overflow-y: auto;
    overflow-x: hidden !important;
}

/* Olivero theme-specific container overrides - only when they wrap our content */
body.daos-inspector-page .dialog-off-canvas-main-canvas .container,
body.daos-inspector-page [class*="region--content"],
body.daos-inspector-page [class*="layout--pass"] {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    margin-inline: 0 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 0 !important;
    padding-inline: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
}

/* Create a slim 2rem Drupal header via CSS pseudo-element */
body.daos-inspector-page .dialog-off-canvas-main-canvas::before {
    content: 'Drupal  |  RDA Management';
    display: flex;
    align-items: center;
    height: 2rem;
    flex-shrink: 0;
    background: #1e293b;
    color: #94a3b8;
    padding: 0 1rem;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-sizing: border-box;
}

/* ================================================================
   INSPECTOR WRAPPER – fills remaining space below pseudo-header
   ================================================================ */
.inspector-wrapper {
    display: flex;
    flex-direction: column;
    width: 100%;
    flex: 1;
    height: 100%;
    min-height: 0;
    background: var(--bg-color);
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}

/* ================================================================
   INSPECTOR HEADER (the RDA header bar)
   ================================================================ */
.inspector-header {
    height: 3rem;
    flex-shrink: 0;
    background: #ffffff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    font-family: 'Inter', sans-serif;
    z-index: 100;
}

.header-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.header-title svg {
    color: var(--accent);
    flex-shrink: 0;
}

.header-title .version-tag {
    background: #eff6ff;
    color: var(--accent);
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    border: 1px solid #dbeafe;
}

.header-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--accent);
    color: white !important;
    border: none;
    padding: 5px 15px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.1), 0 2px 4px -1px rgba(37, 99, 235, 0.06);
    margin-left: 20px;
    height: 32px;
}

.header-select-btn:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.2), 0 4px 6px -2px rgba(37, 99, 235, 0.1);
}

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

.header-select-btn svg {
    color: white !important;
    margin: 0;
}

/* Recent-Docs Dropdown am "Dokument auswählen" Button */
.doc-selector-wrap {
    position: relative;
    display: inline-block;
    margin-left: 20px;
}

.doc-selector-wrap .header-select-btn {
    margin-left: 0;
}

.doc-selector-wrap:hover .header-select-btn {
    border-radius: 8px 8px 0 0;
}

.recent-docs-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 300px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,.12), 0 8px 10px -5px rgba(0,0,0,.06);
    padding: 2px 6px 6px;
    z-index: 2000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
}

.doc-selector-wrap:hover .recent-docs-dropdown {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

.recent-docs-header {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 4px 10px 6px;
}

.recent-doc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-main);
    transition: background 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
}

.recent-doc-item:hover {
    background: #f1f5f9;
    color: var(--accent);
}

.recent-doc-item svg {
    flex-shrink: 0;
    color: #94a3b8;
}

.recent-doc-item:hover svg {
    color: var(--accent);
}

.recent-doc-item span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-docs-empty {
    font-size: 12px;
    color: #94a3b8;
    padding: 6px 10px 4px;
    font-style: italic;
}

/* Navigation links in the header */
.nav-link {
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    transition: color 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--accent);
}

/* Fullscreen / back buttons in the header */
.fullscreen-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
    background: #f1f5f9;
    border: 1px solid var(--border);
    white-space: nowrap;
}

.fullscreen-btn:hover {
    background: var(--border);
    color: var(--text-main);
}

/* ================================================================
   APP CONTAINER – holds sidebar + main side by side
   ================================================================ */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: row-reverse;
    /* sidebar on right */
    min-height: 0;
    /* critical for nested flex scrolling */
    overflow: hidden;
}

/* ================================================================
   SIDEBAR – fixed width, scrollable
   ================================================================ */
.sidebar {
    width: 380px !important;
    min-width: 380px !important;
    max-width: 380px !important;
    flex-shrink: 0 !important;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.logo span {
    color: var(--accent);
}

.sidebar-header h1 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
}

/* ================================================================
   DOCUMENT LIST in sidebar
   ================================================================ */
.document-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.doc-item {
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.doc-item:hover {
    background: rgba(0, 0, 0, 0.03);
    border-color: var(--border);
}

.doc-item.active {
    background: var(--accent-glow);
    border-color: var(--accent);
}

.doc-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.doc-filename {
    font-weight: 600;
    font-size: 14px;
}

.doc-meta {
    font-size: 12px;
    color: var(--text-dim);
}

.status-badge {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-badge.CONFIRMED {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.status-badge.RETRY {
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
}

.status-badge.ERROR {
    background: var(--error);
    box-shadow: 0 0 8px var(--error);
}

/* ================================================================
   MAIN CONTENT – PDF viewer area, takes remaining space
   ================================================================ */
.inspector-main {
    flex: 1;
    min-width: 0;
    /* allows flex child to shrink below intrinsic size */
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    overflow: hidden;
}

.detail-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #64748b;
}

.empty-state .icon {
    font-size: 56px;
    margin-bottom: 12px;
}

.header-analysis-timer {
    display: none;
    align-items: center;
    gap: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    padding: 3px 10px;
    margin-left: 8px;
}

.header-analysis-timer svg {
    color: #3b82f6;
    flex-shrink: 0;
}

.header-timer-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #93c5fd;
}

.header-timer-value {
    font-size: 13px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: #3b82f6;
    min-width: 3ch;
}

.header-timer-value.timer-stopped {
    color: #64748b;
}

.header-analysis-timer:has(.timer-stopped) {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.header-analysis-timer:has(.timer-stopped) svg {
    color: #94a3b8;
}

/* ================================================================
   PDF VIEWER
   ================================================================ */
.pdf-viewer-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.page-nav-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 12px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
}

.page-nav-btn {
    background: #334155;
    border: 1px solid #475569;
    color: #cbd5e1;
    font-size: 16px;
    line-height: 1;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}
.page-nav-btn:hover:not(:disabled) {
    background: #475569;
    color: #f1f5f9;
}
.page-nav-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.page-delete-btn {
    margin-left: 12px;
    background: #7f1d1d !important;
    border-color: #991b1b !important;
    color: #fca5a5 !important;
    font-size: 11px !important;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px !important;
}
.page-delete-btn:hover:not(:disabled) {
    background: #991b1b !important;
    color: #fee2e2 !important;
}
.page-delete-btn svg {
    flex-shrink: 0;
}

.page-nav-indicator {
    font-size: 11px;
    color: #94a3b8;
    min-width: 80px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.view-header {
    background: var(--sidebar-bg);
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.view-header h2 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    margin: 0;
}

.pdf-viewer-overlay-container {
    flex: 1;
    position: relative;
    overflow: auto;
    background: #334155;
    display: flex;
    justify-content: center;
    min-height: 0;
}

.document-wrapper {
    position: relative;
    background: white;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    width: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    cursor: default;
    user-select: none;
    -webkit-user-drag: none;
}

iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

#pdf-image {
    width: 100%;
    height: auto;
    border: none;
    display: block;
    object-fit: contain;
}

/* ================================================================
   HIGHLIGHT LAYER (OCR overlays)
   ================================================================ */
.highlight-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.2s ease-in-out;
}

.doc-box {
    position: absolute;
    border: 2px solid var(--accent);
    background: rgba(56, 189, 248, 0.15);
    box-shadow: 0 0 6px var(--accent);
    border-radius: 2px;
    z-index: 10;
    transition: all 0.2s ease;
    pointer-events: auto;
    /* Enable hover/clicks on boxes */
}

.doc-box:hover {
    background: rgba(56, 189, 248, 0.4);
    z-index: 100;
}

.doc-box::after {
    content: attr(data-label);
    position: absolute;
    bottom: calc(100% + 8px);
    /* Position above the box with clear gap */
    left: 0;
    background: rgba(37, 99, 235, 0.9);
    /* Slight transparency */
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 101;
    pointer-events: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Small arrow for the label */
.doc-box::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 10px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid rgba(37, 99, 235, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 101;
}

.doc-box:hover::after,
.doc-box:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateY(-2px);
}

/* Anchor checkmark on hover */
.anchor-checkbox-container {
    position: absolute;
    top: -12px;
    right: -10px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 4px;
    display: none;
    align-items: center;
    gap: 4px;
    z-index: 101;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.anchor-checkbox-container input {
    width: 12px;
    height: 12px;
    accent-color: var(--accent);
    cursor: pointer;
}

.doc-box:hover .anchor-checkbox-container {
    display: flex;
    pointer-events: auto;
}

/* Anchor fields keep their original marking visible, pin is shown on top */

/* Labels for anchors: hidden by default to avoid clutter, show on hover */
.is-anchor-field::after {
    opacity: 0 !important;
}

.is-anchor-field:hover::after {
    opacity: 1 !important;
}

/* Pin for anchors */
.pin-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    background: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 102;
    pointer-events: none;
}

/* Marker-Styles nach Typ */
.entity-box {
    border-color: #a855f7; /* Purple */
    background: rgba(168, 85, 247, 0.1);
}

.validated-box {
    border-color: #3b82f6; /* Blue */
    background: rgba(59, 130, 246, 0.1);
}

.learned-box {
    border-color: #f59e0b; /* Amber */
    background: rgba(245, 158, 11, 0.1);
}

.impressum-cluster-box {
    border: 2px solid #2563eb !important; /* Solid Blue outer frame */
    background: transparent !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

.impressum-cluster-box::after {
    background: #2563eb !important;
    font-size: 9px !important;
    padding: 1px 4px !important;
}

.impressum-sub-box {
    border: 2px solid #16a34a !important; /* Solid Green for the 4 columns */
    background: rgba(22, 163, 74, 0.05) !important;
}

.impressum-sub-box::after {
    background: #16a34a !important;
    font-size: 8px !important;
    padding: 1px 4px !important;
}

.impressum-sub-box::before {
    border-top-color: rgba(16, 185, 129, 0.9) !important;
}

.technical-box {
    border: 2px dashed #64748b !important; /* Slate grey dashed for technical IDs */
    background: rgba(100, 116, 139, 0.08) !important;
}

.technical-box::after {
    background: rgba(71, 85, 105, 0.9) !important;
}

.technical-box::before {
    border-top-color: rgba(71, 85, 105, 0.9) !important;
}

/* OCR Blocks (Tesseract) – teal dashed */
.ocr-block-box {
    border: 2px dashed #0d9488 !important;
    background: rgba(13, 148, 136, 0.06) !important;
    box-shadow: none !important;
}
.ocr-block-box::after {
    background: rgba(13, 148, 136, 0.92) !important;
    font-size: 9px !important;
}
.ocr-block-box::before {
    border-top-color: rgba(13, 148, 136, 0.92) !important;
}

/* AI Blocks (KI-Modell) – rose solid */
.ai-block-box {
    border: 2px solid #e11d48 !important;
    background: rgba(225, 29, 72, 0.06) !important;
    box-shadow: none !important;
}
.ai-block-box::after {
    background: rgba(225, 29, 72, 0.92) !important;
    font-size: 9px !important;
}
.ai-block-box::before {
    border-top-color: rgba(225, 29, 72, 0.92) !important;
}

/* Surya Blocks – rot solid (wie bisher ai-block-box) */
.surya-block-box {
    border: 2px solid #e11d48 !important;
    background: rgba(225, 29, 72, 0.06) !important;
    box-shadow: none !important;
}
.surya-block-box::after {
    background: rgba(225, 29, 72, 0.92) !important;
    font-size: 9px !important;
}
.surya-block-box::before {
    border-top-color: rgba(225, 29, 72, 0.92) !important;
}

/* minicpm-v Blocks – orange */
.minicpm-block-box {
    border: 2px solid #d97706 !important;
    background: rgba(217, 119, 6, 0.06) !important;
    box-shadow: none !important;
}
.minicpm-block-box::after {
    background: rgba(217, 119, 6, 0.92) !important;
    font-size: 9px !important;
}
.minicpm-block-box::before {
    border-top-color: rgba(217, 119, 6, 0.92) !important;
}

/* LayoutLMv3 Entities – violett */
.layoutlm-block-box {
    border: 2px dashed #7c3aed !important;
    background: rgba(124, 58, 237, 0.06) !important;
    box-shadow: none !important;
}
.layoutlm-block-box::after {
    background: rgba(124, 58, 237, 0.92) !important;
    font-size: 9px !important;
}
.layoutlm-block-box::before {
    border-top-color: rgba(124, 58, 237, 0.92) !important;
}

/* Barcode / QR-Code Blocks – grün solid */
.barcode-block-box {
    border: 3px solid #15803d !important;
    background: rgba(21, 128, 61, 0.08) !important;
    box-shadow: 0 0 0 1px rgba(21, 128, 61, 0.4) !important;
}
.barcode-block-box::after {
    background: rgba(21, 128, 61, 0.95) !important;
    font-size: 9px !important;
    font-weight: 700 !important;
}
.barcode-block-box::before {
    border-top-color: rgba(21, 128, 61, 0.95) !important;
}

/* Table Blocks – amber solid (Tabellenerkennung) */
.table-block-box {
    border: 2px solid #d97706 !important;
    background: rgba(217, 119, 6, 0.07) !important;
    box-shadow: 0 0 0 1px rgba(217, 119, 6, 0.35) !important;
}
.table-block-box::after {
    background: rgba(217, 119, 6, 0.93) !important;
    font-size: 9px !important;
    font-weight: 700 !important;
}
.table-block-box::before {
    border-top-color: rgba(217, 119, 6, 0.93) !important;
}

/* Visual Region Blocks – cyan solid (Rahmen / Hintergrundfarbe) */
.visual-region-box {
    border: 2px solid #0891b2 !important;
    background: rgba(8, 145, 178, 0.08) !important;
    box-shadow: 0 0 0 1px rgba(8, 145, 178, 0.3) !important;
}
.visual-region-box::after {
    background: rgba(8, 145, 178, 0.92) !important;
    font-size: 9px !important;
}
.visual-region-box::before {
    border-top-color: rgba(8, 145, 178, 0.92) !important;
}

/* Column-Split Blocks – orange dashed */
.column-split-block-box {
    border: 2px dashed #ea580c !important;
    background: rgba(234, 88, 12, 0.06) !important;
    box-shadow: none !important;
}
.column-split-block-box::after {
    background: rgba(234, 88, 12, 0.92) !important;
    font-size: 9px !important;
}
.column-split-block-box::before {
    border-top-color: rgba(234, 88, 12, 0.92) !important;
}
.impressum-block-box {
    border: 2px solid #16a34a !important;
    background: rgba(22, 163, 74, 0.07) !important;
}
.impressum-block-box::after {
    background: rgba(22, 163, 74, 0.92) !important;
}
.impressum-block-box::before {
    border-top-color: rgba(22, 163, 74, 0.92) !important;
}
.formularindex-block-box {
    border: 2px solid #7c3aed !important;
    background: rgba(124, 58, 237, 0.07) !important;
}
.formularindex-block-box::after {
    background: rgba(124, 58, 237, 0.92) !important;
}
.formularindex-block-box::before {
    border-top-color: rgba(124, 58, 237, 0.92) !important;
}
.left-text-margin-line {
    position: absolute;
    top: 0;
    height: 100%;
    width: 0;
    border-left: 2px dashed rgba(99, 102, 241, 0.70);
    pointer-events: none;
    z-index: 12;
}

/* Block Quality Panel */
.block-quality-panel {
    background: linear-gradient(135deg, #f0fdfa 0%, #fdf2f8 100%);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 6px;
}
.bqp-metric {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 5px;
}
.bqp-score-bar {
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 4px;
}
.bqp-score-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.learned-box::after {
    background: var(--warning);
    color: #fff;
}

.validated-box {
    border-color: var(--success);
    background: rgba(22, 163, 74, 0.15);
    /* #16a34a is var(--success) */
    box-shadow: 0 0 6px var(--success);
}

.validated-box:hover {
    background: rgba(22, 163, 74, 0.4);
    z-index: 100;
}

.validated-box::before {
    border-top-color: rgba(22, 163, 74, 0.9);
}

.validated-box::after {
    background: rgba(22, 163, 74, 0.9);
    color: #fff;
}

@keyframes validated-addr-flash {
    0%   { background: rgba(22, 163, 74, 0.15); box-shadow: 0 0 6px var(--success); }
    20%  { background: rgba(22, 163, 74, 0.65); box-shadow: 0 0 20px 6px var(--success); border-width: 3px; }
    60%  { background: rgba(22, 163, 74, 0.35); box-shadow: 0 0 12px 3px var(--success); border-width: 2px; }
    100% { background: rgba(22, 163, 74, 0.15); box-shadow: 0 0 6px var(--success); }
}

.validated-addr-flash {
    animation: validated-addr-flash 2s ease-out forwards;
    z-index: 200 !important;
}

/* Entities from document_entities (non-manual) - Purple/Indigo theme */
.entity-box {
    border-color: #6366f1;
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 6px #6366f1;
}

.entity-box:hover {
    background: rgba(99, 102, 241, 0.4);
    z-index: 100;
}

.entity-box::before {
    border-top-color: rgba(99, 102, 241, 0.9);
}

.entity-box::after {
    background: rgba(99, 102, 241, 0.9);
    color: #fff;
}

/* ================================================================
   METADATA CONTAINER (in sidebar)
   ================================================================ */
.metadata-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    overflow-x: hidden !important;
    width: 100% !important;
    min-width: 0 !important;
    padding: 20px;
    background: #fff;
}

.meta-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

.section-content {
    width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
}

.meta-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.meta-header-row h3 {
    margin: 0;
    font-size: 14px;
}

.select-all-container {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.select-all-container input {
    accent-color: var(--accent);
    cursor: pointer;
}

/* Zeile: Modellname + Analyse-Toggle + Anzeige-Toggle */
.model-toggle-row {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: 9px;
    min-height: 14px;
}
.model-toggle-row .model-name {
    flex: 1;
    font-weight: 700;
    text-transform: uppercase;
}
.model-toggle-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 0px 4px;
    border-radius: 3px;
    font-size: 9px;
    font-weight: 600;
    margin-left: 3px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}
.model-toggle-chip input[type="checkbox"] {
    cursor: pointer;
    margin: 0;
    width: 9px;
    height: 9px;
}

/* Crosshair aktiv: Cursor auf Bild-Bereich ändern */
body.crosshair-active .image-wrapper,
body.crosshair-active #pdf-image,
body.crosshair-active .highlight-layer-wrapper {
    cursor: crosshair !important;
}

#crosshair-toggle-btn.active {
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
    box-shadow: 0 0 0 2px rgba(239,68,68,0.25);
}

.fields-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    width: 100% !important;
}

.field-row {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    width: 100% !important;
    overflow: hidden !important;
    box-sizing: border-box;
}

.field-row.with-checkbox {
    gap: 10px;
}

.highlight-toggle {
    margin-top: 16px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent);
}

.field-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.field-value {
    font-size: 13px;
    background: rgba(0, 0, 0, 0.02);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

/* ================================================================
   TABLES
   ================================================================ */
.table-wrapper {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

th {
    background: rgba(0, 0, 0, 0.04);
    text-align: left;
    padding: 8px 10px;
    color: var(--text-dim);
}

td {
    padding: 8px 10px;
    border-top: 1px solid var(--border);
}

/* ================================================================
   WORD CLOUD
   ================================================================ */
.word-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.word-tag {
    background: rgba(37, 99, 235, 0.08);
    color: var(--accent);
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 12px;
    border: 1px solid rgba(37, 99, 235, 0.15);
}

.hint {
    font-style: italic;
    color: var(--text-dim);
    font-size: 13px;
}

/* ================================================================
   SELECTION BOX (Learning Mode)
   ================================================================ */
.selection-rect {
    position: absolute;
    border: 2px dashed var(--accent);
    background: rgba(56, 189, 248, 0.25);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
    pointer-events: none;
    z-index: 1000;
}

/* ================================================================
   LERN-MODUS UI
   ================================================================ */
.lern-section {
    border-color: var(--warning);
}

.correction-row {
    background: #ffffff;
    border: 1.5px solid var(--warning);
    padding: 14px;
    border-radius: 12px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.1);
    transition: all 0.3s ease;
    margin-bottom: 12px;
}

.correction-row:hover {
    box-shadow: 0 8px 16px rgba(217, 119, 6, 0.15);
    background: #fff;
}

.new-entry-glow {
    animation: glow-pulse 2s ease;
    border-color: var(--accent) !important;
}

@keyframes glow-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 0 20px 5px rgba(37, 99, 235, 0.2);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(217, 119, 6, 0.1);
    }
}

.field-select {
    background: var(--sidebar-bg);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 5px;
    border-radius: 4px;
    font-size: 12px;
}

.custom-field-name {
    background: var(--bg-color);
    color: var(--accent);
    border: 1px solid var(--accent);
    padding: 5px 8px;
    border-radius: 4px;
    font-size: 12px;
    outline: none;
}

.field-value-input {
    background: #ffffff;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 6px;
    border-radius: 4px;
    font-size: 13px;
    width: 100%;
    resize: vertical;
    box-sizing: border-box;
}

.btn-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-save {
    background: var(--success);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.btn-save:hover {
    background: #16a34a;
    transform: translateY(-1px);
}

.btn-save:disabled {
    background: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* ================================================================
   SCROLLBARS
   ================================================================ */
/* ================================================================
   UTILITIES (for tree nodes)
   ================================================================ */
/* Explorer Tree Compactness */
#explorer-modal .tree-item-content {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    min-height: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    margin-bottom: 0 !important;
}

#explorer-modal .tree-item-content span {
    line-height: 1 !important;
    font-size: 11px !important;
}

#explorer-modal .tree-item-content svg {
    width: 12px !important;
    height: 12px !important;
}

.p-small {
    padding: 4px !important;
}

.mb-none {
    margin-bottom: 0 !important;
}

.gap-small {
    gap: 6px !important;
}

.rounded {
    border-radius: 4px !important;
}

/* ================================================================
   LEARNED GROUP WRAPPER (Pulldown)
   ================================================================ */
.learned-group-wrapper {
    margin-bottom: 20px;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.learned-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f8fafc;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}

.learned-group-header:hover {
    background: #f1f5f9;
}

.learned-group-header .chevron-icon {
    width: 14px;
    height: 14px;
    color: var(--text-dim);
    transition: transform 0.3s ease;
}

.learned-group-header .label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-main);
}

.learned-group-header .badge {
    background: var(--accent);
    color: white;
    font-size: 9px;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 99px;
}

.learned-group-content {
    padding: 12px;
}

.learned-group-content.hidden {
    display: none;
}

.learned-meta-row {
    padding: 4px 0;
}

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:checked+.slider:before {
    transform: translateX(16px);
}

/* ================================================================
   Phase A++ & Address Tree Styles
   ================================================================ */
.section-collapsible .section-header:hover {
    background: #f8fafc;
    border-radius: 8px;
}

.section-collapsible .badge {
    transition: all 0.3s ease;
}

.address-tree-node {
    transition: all 0.2s ease;
    border: 1px solid #e2e8f0;
}

.address-tree-node:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.address-basics {
    margin-top: 8px;
}

.address-basics > div {
    padding: 2px 0;
}

.address-basics span.text-slate-400 {
    font-size: 10px;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.05em;
}

.hidden {
    display: none !important;
}

/* Confidence Badges */
.conf-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px !important;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 4px;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    white-space: nowrap;
    margin-left: auto;
    line-height: normal;
    flex-shrink: 0;
}

.address-tree-node .conf-badge {
    background: #eff6ff !important;
    color: #2563eb !important;
    border-color: #dbeafe !important;
}

.field-info {
    display: flex !important;
    flex: 1 !important;
    min-width: 0 !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    overflow: hidden !important;
}

.field-info-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex-grow: 1;
    overflow: hidden;
}

.field-value {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    width: 100% !important;
    display: block !important;
}

/* Fix for address block specifically */
.address-basics .field-info {
    width: 100%;
}

/* ================================================================
   DROPDOWN MENU (Navigation)
   ================================================================ */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dropdown-trigger:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.dropdown-trigger svg {
    color: var(--text-dim);
}

.dropdown-trigger .chevron {
    transition: transform 0.2s ease;
    color: #94a3b8;
}

.nav-dropdown:hover .dropdown-trigger .chevron {
    transform: rotate(180deg);
}

.dropdown-content {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    padding: 8px;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transform: translateY(12px);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.nav-dropdown:hover .dropdown-content {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none !important;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-main) !important;
    border-radius: 10px;
    transition: all 0.15s ease;
}

.dropdown-item:hover {
    background: #f1f5f9;
    color: var(--accent) !important;
    transform: translateX(4px);
}

.dropdown-item-icon {
    font-size: 16px;
    width: 20px;
    display: flex;
    justify-content: center;
}

/* ================================================================
   HDB FILE EXPLORER – Reset Drupal/Theme input overrides
   ================================================================ */
.fe-window input,
.fe-window select,
.fe-window textarea {
    height: auto !important;
    min-height: unset !important;
    padding: 0.375rem 0.75rem !important;
    box-sizing: border-box !important;
    line-height: 1.5 !important;
}

.fe-search {
    height: 26px !important;
    padding: 0 10px 0 28px !important;
    line-height: 26px !important;
}