/* LocalDMS - Professionelles, kompaktes Design */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #34495e;
    --accent-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --bg-color: #f5f6fa;
    --card-bg: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --border-color: #dfe6e9;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 8px rgba(0,0,0,0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

body {
    overflow-y: auto;
    padding-top: 0;
}

html {
    scroll-padding-top: 0;
}

/* Header */
.app-header {
    background: var(--primary-color);
    color: white;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    left: 0;
    right: 0;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    background: var(--secondary-color);
    color: white;
    min-height: 40px; /* Fingerfreundlich */
    min-width: 40px;
}

.btn:hover {
    background: var(--accent-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

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

.btn-primary {
    background: var(--accent-color);
}

.btn-icon {
    padding: 8px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-search {
    padding: 8px 12px;
}

/* Toolbar */
.toolbar {
    background: var(--card-bg);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    position: sticky;
    top: 56px; /* Höhe des Headers (12px padding top + 12px padding bottom + ~32px content) */
    z-index: 999;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.search-container {
    display: flex;
    flex: 1;
    min-width: 200px;
    gap: 4px;
    align-items: center;
    position: relative;
}

.search-input {
    flex: 1;
    padding: 10px 12px;
    padding-right: 40px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    min-height: 40px;
}

.btn-clear-search {
    position: absolute;
    right: 50px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.btn-clear-search:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.filters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    min-width: 0;
    width: 100%;
}

.sort-bar {
    background: var(--card-bg);
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky;
    top: 108px; /* Header (56px) + Toolbar (~52px) */
    z-index: 998;
}

.sort-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.sort-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none;
}

.sort-option:hover {
    background-color: var(--bg-color);
}

.sort-option[data-sort] {
    font-weight: 500;
}

.sort-option.sort-direction-toggle {
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
    padding-top: 12px;
    cursor: default;
}

.sort-option.sort-direction-toggle:hover {
    background-color: transparent;
}

.sort-direction-indicator {
    color: var(--accent-color);
    font-weight: 600;
    margin-left: 8px;
}

.sort-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 0;
}

.sort-option .btn-sm {
    padding: 4px 8px;
    font-size: 12px;
    min-height: 28px;
    margin-left: auto;
}

.filter-select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: white;
    min-height: 40px;
    cursor: pointer;
}

/* Multi-Select Dropdown */
.multi-select-wrapper {
    position: relative;
    min-width: 150px;
}

.multi-select-button {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    background: white;
    min-height: 40px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.multi-select-button:hover {
    border-color: var(--accent-color);
}

.multi-select-arrow {
    font-size: 10px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.multi-select-wrapper.active .multi-select-arrow {
    transform: rotate(180deg);
}

.multi-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1001; /* Höher als Toolbar, damit Dropdowns sichtbar bleiben */
    box-shadow: var(--shadow-hover);
}

.multi-select-wrapper.active .multi-select-dropdown {
    display: block;
}

.multi-select-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.multi-select-option:hover {
    background-color: var(--bg-color);
}

.multi-select-option input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    min-width: 18px;
}

.multi-select-option span {
    flex: 1;
    user-select: none;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 16px;
}

.stats-bar {
    background: var(--card-bg);
    padding: 10px 16px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
}

/* Documents Grid */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

/* Documents List */
.documents-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

/* Documents Explorer */
.documents-explorer {
    margin-bottom: 24px;
}

.explorer-container {
    background: var(--card-bg);
    border-radius: 4px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.explorer-breadcrumb {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 4px;
}

.explorer-breadcrumb-item {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--accent-color);
    font-size: 14px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.explorer-breadcrumb-item:hover {
    background: var(--card-bg);
}

.explorer-breadcrumb-separator {
    color: var(--text-secondary);
    padding: 0 4px;
}

.explorer-content {
    padding: 8px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
    overflow-x: hidden;
}

.explorer-item {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
    gap: 12px;
}

.explorer-item:hover {
    background: var(--bg-color);
}

.explorer-folder {
    font-weight: 500;
}

.explorer-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.explorer-name {
    flex: 1;
    word-break: break-word;
    color: var(--text-primary);
}

.explorer-file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.explorer-path {
    font-size: 11px;
    color: var(--text-secondary);
    font-style: italic;
}

.explorer-search-info {
    flex: 1;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 4px 8px;
}

.explorer-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: auto;
}

.explorer-count {
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-color);
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
}

.explorer-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

.document-list-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 70px;
}

.document-list-item:hover {
    box-shadow: var(--shadow-hover);
    transform: translateX(4px);
    border-color: var(--accent-color);
}

.list-item-icon {
    font-size: 32px;
    flex-shrink: 0;
    width: 40px;
    text-align: center;
}

.list-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.list-item-name {
    font-weight: 600;
    font-size: 15px;
    margin: 0;
    word-break: break-word;
    color: var(--text-primary);
}

.list-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.list-item-type {
    font-weight: 500;
    color: var(--accent-color);
}

.list-item-separator {
    color: var(--border-color);
}

.list-item-size,
.list-item-date {
    color: var(--text-secondary);
}

.list-item-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.document-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    min-height: 100px;
}

.document-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
    border-color: var(--accent-color);
}

.document-icon {
    font-size: 36px;
    text-align: center;
    margin-bottom: 8px;
}

.document-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    word-break: break-word;
    color: var(--text-primary);
}

.document-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.document-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.tag {
    background: var(--accent-color);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 4px;
    box-shadow: var(--shadow);
}

#page-info {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000; /* Höher als Header und Toolbar */
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 8px;
    max-width: 95vw;
    width: 100%;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* Größere Modals für große Bildschirme */
@media (min-width: 768px) {
    .modal-content {
        max-width: 90vw;
    }
}

@media (min-width: 1200px) {
    .modal-content {
        max-width: 85vw;
    }
}

@media (min-width: 1600px) {
    .modal-content {
        max-width: 80vw;
    }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 10;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.btn-close:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

@media (min-width: 1200px) {
    .modal-body {
        padding: 24px;
    }
}

/* Form Elements */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    min-height: 40px;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

/* Document Detail */
.document-detail {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-section {
    padding: 12px;
    background: var(--bg-color);
    border-radius: 4px;
}

.detail-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.detail-section p {
    font-size: 13px;
    color: var(--text-secondary);
    word-break: break-word;
}

.detail-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Preview */
.preview-section {
    position: relative;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 5;
    padding: 8px 0;
    margin-top: -8px;
    margin-left: -20px;
    margin-right: -20px;
    padding-left: 20px;
    padding-right: 20px;
}

.document-metadata {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.preview-header h3 {
    margin: 0;
    font-size: 16px;
}

.btn-fullscreen {
    padding: 6px 12px;
    font-size: 18px;
    min-width: 40px;
    min-height: 40px;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
}

.preview-container {
    margin-top: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-color);
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    touch-action: pan-y pinch-zoom;
}

.preview-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 3000;
    border: none;
    border-radius: 0;
    margin: 0;
}

.modal.preview-fullscreen {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    margin: 0;
}

.modal.preview-fullscreen .modal-content {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal.preview-fullscreen .modal-header {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--card-bg);
}

.modal.preview-fullscreen .modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.modal.preview-fullscreen .preview-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal.preview-fullscreen .preview-header {
    position: sticky;
    top: 0;
    z-index: 15;
    background: var(--card-bg);
}

.modal.preview-fullscreen .preview-container {
    flex: 1;
    margin: 0;
    border: none;
    border-radius: 0;
}

.preview-iframe {
    width: 100%;
    min-height: 60vh;
    max-height: 85vh;
    border: none;
}

@media (min-width: 768px) {
    .preview-iframe {
        min-height: 70vh;
        max-height: 80vh;
    }
}

@media (min-width: 1200px) {
    .preview-iframe {
        min-height: 75vh;
        max-height: 75vh;
    }
}

/* PDF.js Viewer für Office-Dokumente */
.pdf-viewer-container {
    width: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    position: relative;
    max-height: 100%;
    overflow: hidden;
}

.pdf-viewer-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 15;
    flex-shrink: 0;
    width: 100%;
}

.pdf-controls-divider {
    color: var(--border-color);
    font-size: 14px;
    user-select: none;
}

.pdf-canvas-wrapper {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
    position: relative;
}

.pdf-viewer-container .pdf-canvas-wrapper {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

@media (max-width: 768px) {
    .pdf-viewer-controls {
        padding: 6px;
        gap: 4px;
    }
    
    .pdf-viewer-controls .btn-sm {
        padding: 8px 12px;
        font-size: 14px;
        min-height: 36px;
        min-width: 44px;
        -webkit-tap-highlight-color: rgba(0,0,0,0.1);
    }
    
    .pdf-viewer-controls span {
        font-size: 12px;
        padding: 0 4px;
    }
    
    .pdf-canvas {
        max-height: 60vh;
    }
}

.pdf-viewer-controls .btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    min-height: 32px;
    min-width: 40px;
}

.pdf-viewer-controls span {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 0 8px;
}

.pdf-canvas {
    width: auto;
    height: auto;
    display: block;
    margin: 0 auto;
    min-width: 0;
    min-height: 0;
    touch-action: pan-x pan-y pinch-zoom;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: grab;
    object-fit: contain;
    flex-shrink: 0;
}

/* Canvas kann größer als Container werden beim Zoom */
.pdf-viewer-container:not(.fullscreen) .pdf-canvas {
    max-width: none;
    max-height: none;
}

.pdf-canvas:active {
    cursor: grabbing;
}

.pdf-viewer-container {
    overflow: hidden;
    position: relative;
}

.pdf-viewer-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    z-index: 3000;
    background: var(--card-bg);
    display: flex;
    flex-direction: column;
}

.pdf-viewer-container.fullscreen .pdf-viewer-controls {
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 20;
}

.pdf-viewer-container.fullscreen .pdf-canvas-wrapper {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.pdf-viewer-container.fullscreen .pdf-canvas-wrapper {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.pdf-viewer-container.fullscreen .pdf-canvas {
    max-height: none;
}

@media (max-width: 768px) {
    .pdf-viewer-container {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .pdf-canvas {
        max-height: none;
        min-height: 50vh;
    }
    
    .pdf-viewer-controls {
        padding: 10px;
        gap: 6px;
    }
    
    .pdf-viewer-controls .btn-sm {
        padding: 10px 16px;
        font-size: 16px;
        min-height: 44px;
        min-width: 50px;
    }
    
    .pdf-viewer-controls span {
        font-size: 14px;
        padding: 0 6px;
    }
}

@media (min-width: 768px) {
    .pdf-viewer-container:not(.fullscreen) .pdf-canvas {
        max-height: none;
    }
}

@media (min-width: 1200px) {
    .pdf-viewer-container:not(.fullscreen) .pdf-canvas {
        max-height: none;
    }
}

.pdf-loading {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Mobile Optimierung für PDF-Viewer */
@media (max-width: 768px) {
    .pdf-viewer-controls {
        padding: 6px;
        gap: 4px;
    }
    
    .pdf-viewer-controls .btn-sm {
        padding: 8px 10px;
        font-size: 12px;
        min-width: 36px;
    }
    
    .pdf-viewer-controls span {
        font-size: 12px;
        padding: 0 4px;
    }
    
    .pdf-canvas {
        max-height: 60vh;
    }
}

.preview-image {
    width: 100%;
    max-height: 70vh;
    min-height: 400px;
    object-fit: contain;
    display: block;
}

@media (min-width: 768px) {
    .preview-image {
        max-height: 75vh;
        min-height: 500px;
    }
}

@media (min-width: 1200px) {
    .preview-image {
        max-height: 80vh;
        min-height: 600px;
    }
}

.ocr-text {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    padding: 8px;
    background: var(--bg-color);
    border-radius: 4px;
}

/* Tags */
.document-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag {
    display: inline-block;
    padding: 4px 8px;
    background: var(--accent-color);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.tag-remove {
    cursor: pointer;
    margin-left: 4px;
    font-weight: bold;
    opacity: 0.8;
}

.tag-remove:hover {
    opacity: 1;
}

.preview-text {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    padding: 12px;
    background: var(--bg-color);
    border-radius: 4px;
    margin: 0;
    max-height: 400px;
    overflow-y: auto;
    color: var(--text-primary);
}

/* Responsive */
@media (max-width: 768px) {
    .documents-grid {
        grid-template-columns: 1fr;
    }
    
    .document-list-item {
        padding: 10px 12px;
        gap: 12px;
    }
    
    .list-item-icon {
        font-size: 28px;
        width: 36px;
    }
    
    .list-item-name {
        font-size: 14px;
    }
    
    .list-item-meta {
        font-size: 11px;
        gap: 6px;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 8px 12px;
        gap: 8px;
    }
    
    .search-container {
        width: 100%;
        min-width: 0;
    }
    
    .filters {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        overflow-x: visible;
        justify-content: flex-start;
    }
    
    .view-select-wrapper {
        min-width: 0;
        flex: 1 1 calc(33.333% - 4px);
        max-width: calc(33.333% - 4px);
    }
    
    .view-select-wrapper select {
        min-width: 0;
        width: 100%;
        font-size: 13px;
        padding: 8px 10px;
    }
    
    .multi-select-wrapper {
        min-width: 0;
        flex: 1 1 calc(33.333% - 4px);
        max-width: calc(33.333% - 4px);
    }
    
    .multi-select-button {
        min-width: 0;
        width: 100%;
        font-size: 13px;
        padding: 8px 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    #btn-toggle-tag-search {
        min-width: 44px;
        width: 44px;
        height: 44px;
        flex-shrink: 0;
        padding: 0;
        font-size: 20px;
        order: 999; /* Zeige als letztes Element */
        margin-left: auto; /* Drücke nach rechts */
    }
    
    .filter-select {
        flex: 1;
    }
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* Status Modal */
.status-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.status-section {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 16px;
}

.status-section h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    color: var(--text-primary);
}

.status-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.status-item:last-child {
    border-bottom: none;
}

.status-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.status-value {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 12px;
}

.progress-fill {
    height: 100%;
    background: var(--accent-color);
    transition: width 0.3s ease;
}

/* ==================== TAG-SUCHE MIT LIVE-TREFFERZÄHLER ==================== */

.tag-search-container {
    background: var(--card-bg);
    padding: 16px;
    margin: 12px 16px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    animation: slideDown 0.3s ease-out;
}

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

.tag-selector-section {
    margin-bottom: 16px;
}

.tag-selector-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.tag-chips-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    min-height: 32px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1976D2;
    color: #FFFFFF;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    max-width: 200px;
}

.tag-chip:hover {
    background: #1565C0;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.tag-chip:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.tag-chip-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-chip-remove {
    background: none;
    border: none;
    color: #FFFFFF;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
    border-radius: 50%;
}

.tag-chip-remove:hover {
    opacity: 1;
    background: rgba(255,255,255,0.2);
}

.tag-autocomplete-wrapper {
    position: relative;
    max-width: 300px;
}

.tag-autocomplete-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.tag-autocomplete-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.tag-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: var(--shadow-hover);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10000;
    margin-top: 4px;
    min-width: 200px;
}

.tag-autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

.tag-autocomplete-item:hover {
    background: var(--bg-color);
}

.operator-section {
    margin-bottom: 16px;
}

.operator-toggle {
    display: flex;
    gap: 24px;
    align-items: center;
}

.operator-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    user-select: none;
}

.operator-option input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-color);
}

.operator-option span {
    cursor: pointer;
}

.result-counter {
    padding: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
}

.result-counter:hover {
    opacity: 0.8;
}

.result-counter-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.result-counter-text {
    font-size: 16px;
    font-weight: 600;
}

/* Zustände für Trefferzähler */
.result-counter-normal {
    background: #E8F5E9;
    color: #2E7D32;
}

.result-counter-many {
    background: #FFF3E0;
    color: #E65100;
}

.result-counter-none {
    background: #FFEBEE;
    color: #C62828;
}

.result-counter-loading {
    background: #F5F5F5;
    color: #757575;
}

.result-counter-loading .result-counter-icon {
    animation: spin 1s linear infinite;
}

.result-counter-error {
    background: #FFF9C4;
    color: #F57F17;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .tag-search-container {
        margin: 8px;
        padding: 12px;
    }
    
    .tag-chips-container {
        gap: 6px;
    }
    
    .tag-chip {
        font-size: 13px;
        padding: 6px 10px;
        min-height: 44px; /* Touch-freundlich */
    }
    
    .operator-toggle {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    
    .operator-option {
        min-height: 44px; /* Touch-freundlich */
        padding: 8px;
    }
    
    .result-counter {
        padding: 12px;
        font-size: 14px;
    }
    
    .result-counter-text {
        font-size: 14px;
    }
}

/* ==========================================
   MONITORING DASHBOARD STYLES
   ========================================== */

.modal-large {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
}

.modal-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Tabs */
.monitoring-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.monitoring-tab {
    padding: 12px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s ease;
}

.monitoring-tab:hover {
    color: var(--primary-color);
    background: rgba(52, 152, 219, 0.1);
}

.monitoring-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    font-weight: 600;
}

/* Panels */
.monitoring-content {
    overflow-y: auto;
    max-height: calc(90vh - 200px);
}

.monitoring-panel {
    display: none;
    animation: fadeIn 0.3s ease;
}

.monitoring-panel.active {
    display: block;
}

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

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.stat-icon {
    font-size: 32px;
    line-height: 1;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 8px;
}

.stat-bar {
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #2ecc71);
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

.stat-bar-fill.warning {
    background: linear-gradient(90deg, #f39c12, #e74c3c);
}

.stat-bar-fill.critical {
    background: #e74c3c;
}

/* Service Status */
.service-status-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.service-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.service-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.service-indicator.running {
    background: #2ecc71;
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.5);
}

.service-indicator.stopped {
    background: #e74c3c;
    animation: none;
}

.service-indicator.warning {
    background: #f39c12;
}

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

.service-name {
    font-weight: 500;
}

.service-port {
    color: var(--text-secondary);
    font-family: monospace;
    font-size: 12px;
}

/* Quick Stats */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 16px;
}

.quick-stat {
    text-align: center;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.quick-stat-value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
}

.quick-stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-top: 4px;
}

/* Document Stats */
.doc-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.doc-stat-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.doc-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.doc-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-color);
}

/* File Type Chart */
.file-type-chart {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.file-type-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.file-type-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 16px;
}

.file-type-icon.pdf { background: #fee2e2; color: #dc2626; }
.file-type-icon.doc { background: #dbeafe; color: #2563eb; }
.file-type-icon.xls { background: #dcfce7; color: #16a34a; }
.file-type-icon.img { background: #fef3c7; color: #d97706; }
.file-type-icon.txt { background: #f3f4f6; color: #6b7280; }
.file-type-icon.other { background: #e5e7eb; color: #4b5563; }

.file-type-name {
    font-weight: 500;
    min-width: 60px;
}

.file-type-count {
    color: var(--text-secondary);
    font-family: monospace;
}

/* Indexing Stats */
.indexing-stats {
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.indexing-progress {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
}

.indexing-bar {
    flex: 1;
    height: 12px;
    background: var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.indexing-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #2ecc71);
    border-radius: 6px;
    transition: width 0.5s ease;
}

.indexing-details {
    display: flex;
    gap: 24px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Storage */
.storage-overview {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.storage-item {
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.storage-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.storage-icon {
    font-size: 20px;
}

.storage-name {
    font-weight: 600;
}

.storage-path {
    font-family: monospace;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    word-break: break-all;
}

.storage-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.storage-bar-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.storage-details {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Logs */
.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.log-header h3 {
    margin: 0;
}

.log-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.log-controls select {
    padding: 6px 12px;
    border-radius: 4px;
    min-width: 120px;
}

.log-summary {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.log-stat {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.log-stat.errors {
    background: #fee2e2;
    color: #dc2626;
}

.log-stat.warnings {
    background: #fef3c7;
    color: #d97706;
}

.log-stat.total {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.log-viewer {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.5;
    max-height: 400px;
    overflow-y: auto;
    color: #d4d4d4;
}

.log-line {
    padding: 2px 0;
    border-bottom: 1px solid #333;
}

.log-line:last-child {
    border-bottom: none;
}

.log-line.error {
    color: #f87171;
    background: rgba(239, 68, 68, 0.1);
}

.log-line.warning {
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
}

.log-line.info {
    color: #60a5fa;
}

.log-timestamp {
    color: #6b7280;
    margin-right: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-large {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .monitoring-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .monitoring-tab {
        padding: 10px 14px;
        font-size: 13px;
        white-space: nowrap;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .quick-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .log-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .log-controls {
        width: 100%;
    }
    
    .log-controls select {
        flex: 1;
    }
}

/* ==========================================
   INDIZIERUNG TAB STYLES
   ========================================== */

.indexing-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.action-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.action-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.action-icon {
    font-size: 32px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    border-radius: 10px;
    flex-shrink: 0;
}

.action-info {
    flex: 1;
}

.action-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 4px;
}

.action-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.action-status {
    font-size: 12px;
    color: var(--primary-color);
    margin-top: 4px;
    font-weight: 500;
}

.action-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-controls select {
    padding: 8px 12px;
    border-radius: 6px;
    min-width: 140px;
}

.action-card .btn {
    white-space: nowrap;
}

.action-card .btn.running {
    background: var(--warning-color, #f39c12);
}

/* Processing Stats */
.processing-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.processing-item {
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.processing-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.processing-icon {
    font-size: 18px;
}

.processing-title {
    font-weight: 500;
}

.processing-bar {
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 6px;
}

.processing-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #2ecc71);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

.processing-values {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-secondary);
}

.processing-percent {
    font-weight: 600;
    color: var(--primary-color);
}

/* Indexing Log */
.indexing-log {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 12px;
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.log-entry {
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 4px;
}

.log-entry:last-child {
    margin-bottom: 0;
}

.log-entry.info {
    color: #60a5fa;
}

.log-entry.success {
    color: #34d399;
    background: rgba(52, 211, 153, 0.1);
}

.log-entry.error {
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.log-entry.warning {
    color: #fbbf24;
}

.log-entry .timestamp {
    color: #6b7280;
    margin-right: 8px;
}

/* Responsive Indexing */
@media (max-width: 768px) {
    .action-card {
        flex-direction: column;
        text-align: center;
    }
    
    .action-info {
        width: 100%;
    }
    
    .action-controls {
        width: 100%;
        flex-direction: column;
    }
    
    .action-controls select {
        width: 100%;
    }
    
    .action-card .btn {
        width: 100%;
    }
}

