/* VLAMy OCR Application Styles */

:root {
    --primary-color: #0066cc;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-bg: #f8f9fa;
    --dark-bg: #343a40;
    --border-color: #dee2e6;
    --text-muted: #6c757d;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

.container-fluid {
    padding: 0;
}

/* Navigation */
.navbar-brand {
    font-weight: bold;
}

/* Sidebar */
.sidebar {
    height: calc(100vh - 56px);
    overflow-y: auto;
    background-color: #ffffff;
}

/* Tree View Styles */
.tree-view {
    max-height: 500px;
    overflow-y: auto;
}

.tree-item {
    margin: 0;
    user-select: none;
}

.tree-item-content {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    position: relative;
}

.tree-item-content:hover {
    background-color: #f8f9fa;
}

.tree-item.active > .tree-item-content {
    background-color: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.tree-toggle {
    width: 16px;
    margin-right: 8px;
    font-size: 12px;
    color: #666;
    transition: transform 0.2s ease;
}

.tree-toggle.fa-caret-down {
    transform: rotate(90deg);
}

.tree-icon {
    margin-right: 8px;
    width: 16px;
    text-align: center;
    color: #666;
}

.tree-text {
    flex-grow: 1;
    font-size: 14px;
    color: #333;
    margin-right: 8px;
}

.tree-item-content:hover .tree-actions {
    opacity: 1;
}

.tree-status {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.tree-children {
    margin-left: 0;
}

/* Project Items */
.project-item .tree-icon {
    color: #ff9800;
}

.project-item .tree-text {
    font-weight: 500;
}

/* Document Items */
.document-item {
    margin-left: 20px;
}

.document-item .tree-icon {
    color: #2196f3;
}

/* Image Items */
.image-item {
    margin-left: 40px;
}

.image-item .tree-icon {
    color: #4caf50;
}

.image-item .tree-text {
    font-size: 13px;
}

/* Main Content */
.main-content {
    padding: 0;
    height: calc(100vh - 56px);
}

/* Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px; /* Increased gap between button groups */
    padding: 15px; /* Added more padding */
}

.toolbar .btn-group {
    flex-shrink: 0;
    margin-right: 10px; /* Add margin between button groups */
}

/* Add more distinct separation between different action groups */
.toolbar .btn-group + .btn-group {
    margin-left: 15px;
    padding-left: 15px;
    border-left: 1px solid #dee2e6;
}

/* Make individual buttons in toolbar more distinct */
.toolbar .btn {
    margin: 0 3px; /* Add small margin between individual buttons */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1); /* Add subtle shadow for depth */
    border: 1px solid rgba(0,0,0,0.1);
}

.toolbar .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Tree Actions - Make buttons more distinct */
.tree-actions {
    display: flex;
    gap: 8px; /* Increase gap between action buttons */
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tree-actions .btn {
    padding: 4px 8px; /* Increase padding */
    font-size: 11px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid rgba(0,0,0,0.1);
}

.tree-actions .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Project and Document Level Action Buttons */
.level-actions {
    display: flex;
    gap: 6px;
    margin-left: auto;
    align-items: center;
}

.level-actions .btn {
    padding: 3px 8px;
    font-size: 10px;
    border-radius: 3px;
    min-width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.level-actions .btn i {
    font-size: 10px;
}

/* Detection and Transcription Action Buttons */
.btn-detect {
    background-color: #17a2b8 !important;
    border-color: #17a2b8 !important;
    color: white !important;
}

.btn-detect:hover {
    background-color: #138496 !important;
    border-color: #117a8b !important;
    color: white !important;
}

.btn-transcribe {
    background-color: #28a745 !important;
    border-color: #28a745 !important;
    color: white !important;
}

.btn-transcribe:hover {
    background-color: #218838 !important;
    border-color: #1e7e34 !important;
    color: white !important;
}

/* Dropdown menus for level actions */
.level-action-dropdown {
    position: relative;
    display: inline-block;
}

.level-action-menu {
    position: fixed;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    z-index: 9999;
    min-width: 280px;
    max-width: 320px;
    padding: 8px 0;
    display: none;
}

/* Fixed positioning means we'll set coordinates directly via JavaScript */

.level-action-menu.show {
    display: block;
}

.level-action-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.2s;
}

.level-action-menu-item:hover {
    background-color: #f8f9fa;
}

.level-action-menu-item:last-child {
    border-bottom: none;
}

.level-action-menu-item h6 {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
}

.level-action-menu-item p {
    margin: 0;
    font-size: 11px;
    color: #6c757d;
    line-height: 1.3;
}

.level-action-menu-item.warning {
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.level-action-menu-item.warning h6 {
    color: #856404;
}

/* Canvas Container */
.viewer-container {
    height: calc(100vh - 120px);
}

.canvas-container {
    position: relative;
    overflow: auto; /* Allow scrolling for large images */
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
}

#fabricCanvas {
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    background-color: white;
}

/* Transcription Panel */
.transcription-panel {
    border-left: 1px solid #ddd;
    background-color: #ffffff;
    position: relative;
    transition: width 0.3s ease;
}

/* Panel Resize Functionality */
.resize-handle {
    width: 4px;
    background-color: #dee2e6;
    cursor: col-resize;
    transition: background-color 0.2s ease;
    position: relative;
    z-index: 10;
    user-select: none;
}

.resize-handle:hover {
    background-color: #0066cc;
}

.resize-handle.left-resize {
    border-right: 1px solid #ccc;
}

.resize-handle.right-resize {
    border-left: 1px solid #ccc;
}

/* Smooth resizing performance */
.resizing {
    cursor: col-resize !important;
}

.resizing * {
    cursor: col-resize !important;
    pointer-events: none;
}

.no-select {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

/* Panel Collapse Buttons */
.panel-collapse-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 50px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0 8px 8px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.panel-collapse-btn:hover {
    background-color: #e9ecef;
    border-color: #0066cc;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-50%) scale(1.05);
}

.panel-collapse-btn i {
    font-size: 14px;
    color: #6c757d;
    transition: all 0.3s ease;
}

.panel-collapse-btn:hover i {
    color: #0066cc;
    transform: scale(1.1);
}

.left-panel-btn {
    right: -24px;
    border-radius: 0 8px 8px 0;
}

.right-panel-btn {
    left: -24px;
    border-radius: 8px 0 0 8px;
}

/* Panel States */
#leftSidebar {
    transition: width 0.3s ease;
    overflow: hidden;
}

#leftSidebar.collapsed {
    width: 0 !important;
    min-width: 0 !important;
}

#transcriptionPanel {
    transition: width 0.3s ease;
    overflow: hidden;
}

#transcriptionPanel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
}

/* Hide resize handles when panels are collapsed */
#leftSidebar.collapsed + .left-resize {
    display: none !important;
}

.transcription-panel.collapsed + .right-resize {
    display: none !important;
}

/* Main content adjustments for panel resizing */
#mainContent {
    flex: 1;
    min-width: 300px;
}

/* Transcription Content */
.transcription-content {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
    border: 1px solid #e9ecef;
}

.transcription-section {
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
}

.transcription-section h6 {
    margin-bottom: 10px;
    color: #495057;
    font-weight: 600;
}

/* Transcription Text Styles - Preserve Line Breaks */
.transcription-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 10px;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
}

.annotation-transcriptions .border {
    background-color: #fafafa;
    border-color: #e0e0e0 !important;
}

.annotation-transcriptions .badge {
    font-size: 10px;
}

/* Collapsible Sections */
.collapsible-section {
    transition: all 0.3s ease;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 8px;
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    transition: all 0.2s ease;
}

.section-header:hover {
    background-color: #e9ecef;
}

.section-header h6 {
    margin: 0;
    display: flex;
    align-items: center;
}

.toggle-icon {
    font-size: 12px;
    color: #6c757d;
    transition: transform 0.2s ease;
}

.section-content {
    transition: all 0.3s ease;
    overflow: hidden;
}

/* Transcription Items Drag and Drop */
.transcription-item {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0 !important;
    background-color: #fafafa;
    position: relative;
}

.transcription-item:hover {
    background-color: #f0f0f0;
    border-color: #2196f3 !important;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.1);
    transform: translateY(-1px);
}

.transcription-item.selected {
    background-color: #e3f2fd !important;
    border-color: #2196f3 !important;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
}

.transcription-item.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #2196f3;
    border-radius: 2px 0 0 2px;
}

.transcription-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg) scale(1.02);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

/* Drag and drop visual feedback */
.transcription-item.drag-over {
    background-color: #e3f2fd !important;
    border-color: #2196f3 !important;
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.transcription-item.drag-insert-above::before {
    content: '';
    position: absolute;
    top: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4caf50, #2196f3);
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.5);
    z-index: 10;
}

.transcription-item.drag-insert-below::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4caf50, #2196f3);
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.5);
    z-index: 10;
}

.transcription-item .fa-grip-vertical {
    opacity: 0.4;
    transition: all 0.2s ease;
    cursor: grab;
    padding: 2px;
    border-radius: 2px;
}

.transcription-item:hover .fa-grip-vertical {
    opacity: 0.8;
    background-color: rgba(33, 150, 243, 0.1);
}

.transcription-item .fa-grip-vertical:hover {
    opacity: 1 !important;
    background-color: rgba(33, 150, 243, 0.2) !important;
    color: #2196f3 !important;
}

.transcription-item .fa-grip-vertical:active {
    cursor: grabbing;
}

.transcription-text-item {
    padding-left: 8px;
    border-left: 3px solid #e9ecef;
    margin-top: 8px;
    font-family: 'Courier New', monospace;
    background-color: #ffffff;
    padding: 8px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

.transcription-item .btn-outline-danger {
    padding: 2px 6px;
    font-size: 10px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.transcription-item:hover .btn-outline-danger {
    opacity: 1;
}

.transcription-item .btn-group .btn {
    padding: 2px 6px;
    font-size: 10px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.transcription-item:hover .btn-group .btn {
    opacity: 1;
}

/* Metadata Display */
.metadata-display {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 6px 8px;
    margin: 4px 0;
}

.metadata-content {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.metadata-item {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    padding: 2px 6px;
    font-size: 11px;
    color: #495057;
}

.metadata-item strong {
    color: #343a40;
}

.classification-badge {
    cursor: pointer !important;
    transition: all 0.2s ease;
}

.classification-badge:hover {
    background-color: #6c757d !important;
    color: white !important;
    transform: scale(1.05);
}

/* Inline Editing Styles */
.inline-edit-form {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 10px;
    margin: 8px 0;
}

.inline-edit-form .form-label {
    font-weight: 600;
    margin-bottom: 3px;
}

.inline-edit-form .form-control-sm,
.inline-edit-form .form-select-sm {
    font-size: 11px;
    padding: 3px 6px;
}

.inline-edit-form .btn-sm {
    padding: 3px 8px;
    font-size: 11px;
}

.transcription-edit-form {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 8px;
    margin-top: 8px;
}

.transcription-edit-form textarea {
    min-height: 150px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
}

/* Expandable text areas for metadata */
.expandable-text {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

.expandable-text:focus {
    border-color: #4caf50;
    box-shadow: 0 0 0 0.2rem rgba(76, 175, 80, 0.25);
}

.expandable-text::placeholder {
    font-style: italic;
    color: #6c757d;
}

/* Edit button states */
.btn-outline-warning {
    border-color: #ffc107;
    color: #ffc107;
}

.btn-outline-warning:hover {
    background-color: #ffc107;
    color: #212529;
}

/* Ensure textarea preserves line breaks during editing */
.transcription-edit-form textarea {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    min-height: 60px;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

/* Combined transcription text */
.transcription-text.border {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.4;
}

/* Hide button groups by default, show on hover */
.transcription-item .btn-group {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.transcription-item:hover .btn-group,
.transcription-item.selected .btn-group {
    opacity: 1;
}

/* Not transcribed state */
.not-transcribed {
    padding: 8px;
    background-color: #fff8e1;
    border: 1px dashed #ffb74d;
    border-radius: 4px;
    text-align: center;
    font-style: italic;
}

.transcription-item:not(.selected) .not-transcribed {
    opacity: 0.8;
}

/* Annotations List */
.annotation-item {
    padding: 10px;
    margin-bottom: 8px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.annotation-item:hover {
    background-color: #e3f2fd;
    border-color: #2196f3;
}

.annotation-item.selected {
    background-color: #e3f2fd;
    border-color: #2196f3;
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.2);
}

.annotation-item[draggable="true"] {
    cursor: grab;
}

.annotation-item[draggable="true"]:active {
    cursor: grabbing;
}

.annotation-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.reading-order-badge {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 50%;
    min-width: 20px;
    text-align: center;
}

.annotation-item .fa-grip-vertical {
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.annotation-item:hover .fa-grip-vertical {
    opacity: 1;
}

.annotation-type-badge {
    font-size: 10px;
    padding: 2px 6px;
}

.annotation-transcription {
    margin-top: 5px;
    font-size: 12px;
    font-style: italic;
    color: #666;
    white-space: pre-wrap;
}

/* Credentials Status */
.credentials-card {
    border: 1px solid #e9ecef;
}

.credentials-card .badge {
    font-size: 10px;
}

/* Loading States */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Upload Progress */
.upload-progress {
    margin-top: 15px;
}

.upload-progress .progress {
    height: 20px;
}

.upload-status {
    font-size: 14px;
    color: #666;
    margin-top: 10px;
}

/* Alert Styles */
.alert {
    margin-bottom: 10px;
    font-size: 14px;
}

.alert-info {
    background-color: #e3f2fd;
    color: #0277bd;
}

.alert-success {
    background-color: #e8f5e8;
    color: #2e7d32;
}

.alert-warning {
    background-color: #fff3cd;
    color: #f57c00;
}

.alert-danger {
    background-color: #ffebee;
    color: #c62828;
}

/* Modal Improvements */
.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.modal-title {
    display: flex;
    align-items: center;
}

.modal-title i {
    margin-right: 8px;
}

/* Form Styling */
.form-label {
    font-weight: 500;
    margin-bottom: 5px;
}

.form-control:focus {
    border-color: #2196f3;
    box-shadow: 0 0 0 0.2rem rgba(33, 150, 243, 0.25);
}

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

.btn-primary:hover {
    background-color: #0052a3;
    border-color: #0052a3;
}

/* Button Groups */
.btn-group .btn {
    border-radius: 0;
}

.btn-group .btn:first-child {
    border-top-left-radius: 4px;
    border-bottom-left-radius: 4px;
}

.btn-group .btn:last-child {
    border-top-right-radius: 4px;
    border-bottom-right-radius: 4px;
}

/* Canvas Tools */
.canvas-tools {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
}

/* Status Badges */
.status-badge {
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 12px;
}

.status-pending {
    background-color: #fff3cd;
    color: #856404;
}

.status-processing {
    background-color: #cce7ff;
    color: #004085;
}

.status-completed {
    background-color: #d4edda;
    color: #155724;
}

.status-failed {
    background-color: #f8d7da;
    color: #721c24;
}

/* Image Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    background-color: var(--light-bg);
    transition: all 0.2s;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: #f8f9ff;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: #e3f2fd;
}

/* Progress Bar */
.progress {
    height: 8px;
    border-radius: 4px;
    margin-top: 8px;
}

.progress-bar {
    background-color: var(--primary-color);
}

/* Bootstrap Dropdown Positioning Fix */
.navbar-nav .dropdown-menu {
    position: absolute !important;
    transform: none !important;
}

/* For dropdowns near the right edge, align them to the right */
.navbar-nav .nav-item:last-child .dropdown-menu,
.navbar-nav .nav-item:nth-last-child(1) .dropdown-menu,
.navbar-nav .nav-item:nth-last-child(2) .dropdown-menu {
    left: auto !important;
    right: 0 !important;
}

/* Ensure dropdowns don't go off-screen */
.dropdown-menu {
    max-width: 90vw;
    word-wrap: break-word;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        height: auto;
        max-height: 300px;
    }
    
    .transcription-panel {
        width: 100% !important;
        min-height: 200px !important;
    }
    
    .viewer-container {
        flex-direction: column;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 10px;
    }
    
    .toolbar .btn-group {
        justify-content: center;
        margin-bottom: 10px;
    }
    
    .toolbar .btn-group + .btn-group {
        margin-left: 10px;
        padding-left: 10px;
    }
    
    .level-action-menu {
        min-width: 250px;
        right: 0;
        left: auto;
    }
    
    /* On mobile, always align dropdowns to the right */
    .navbar-nav .dropdown-menu {
        left: auto !important;
        right: 0 !important;
        min-width: 200px;
    }
}

@media (max-width: 576px) {
    .toolbar .btn {
        padding: 6px 8px;
        font-size: 0.875rem;
    }
    
    .toolbar .btn i {
        margin-right: 0;
    }
    
    .toolbar .btn span {
        display: none;
    }
}

/* Accessibility */
.btn:focus,
.form-control:focus,
.tree-item:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Fabric.js Customizations */
.upper-canvas {
    cursor: crosshair;
}

.canvas-container .upper-canvas {
    outline: none;
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1050;
    min-width: 150px;
}

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

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

.context-menu-item:hover {
    background-color: var(--light-bg);
}

/* Export Panel */
.export-options {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.export-btn {
    flex: 1;
    text-align: center;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background-color: white;
}

.export-btn:hover {
    border-color: var(--primary-color);
    background-color: #f8f9ff;
}

.export-btn i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 8px;
    color: var(--primary-color);
}

/* Version History */
.version-item {
    padding: 8px 12px;
    border-left: 3px solid var(--border-color);
    margin-bottom: 8px;
    background-color: var(--light-bg);
    border-radius: 0 6px 6px 0;
}

.version-item.current {
    border-left-color: var(--success-color);
    background-color: #e8f5e8;
}

.version-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Image Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    padding: 16px;
}

.image-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    background-color: white;
}

.image-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.image-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 102, 204, 0.3);
}

.image-thumbnail {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background-color: var(--light-bg);
}

.image-info {
    padding: 12px;
}

.image-name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.9rem;
}

.image-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
} 

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.tree-children {
    animation: slideIn 0.2s ease;
}

.annotation-item {
    animation: fadeIn 0.3s ease;
}

/* Custom Scrollbars */
.tree-view::-webkit-scrollbar,
.transcription-panel::-webkit-scrollbar {
    width: 6px;
}

.tree-view::-webkit-scrollbar-track,
.transcription-panel::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.tree-view::-webkit-scrollbar-thumb,
.transcription-panel::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.tree-view::-webkit-scrollbar-thumb:hover,
.transcription-panel::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Welcome Screen */
.welcome-screen {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feature-card {
    transition: transform 0.2s ease;
}

.feature-card:hover {
    transform: translateY(-5px);
}

/* Status Indicators */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 5px;
}

.status-indicator.success {
    background-color: #4caf50;
}

.status-indicator.warning {
    background-color: #ff9800;
}

.status-indicator.error {
    background-color: #f44336;
}

.status-indicator.info {
    background-color: #2196f3;
}

/* Utility Classes */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cursor-pointer {
    cursor: pointer;
}

.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Print Styles */
@media print {
    .sidebar,
    .toolbar,
    .btn,
    .modal {
        display: none !important;
    }
    
    .main-content {
        width: 100% !important;
        margin: 0 !important;
    }
} 

/* Cursor changes during resize */
body.resizing {
    cursor: col-resize !important;
}

body.resizing * {
    cursor: col-resize !important;
}

/* Annotation Classification Styles */
.annotation-classification {
    display: flex;
    align-items: center;
}

.annotation-classification label {
    white-space: nowrap;
    line-height: 1.5;
}

.annotation-classification select {
    min-width: 150px;
}

.annotation-types-checkboxes {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.75rem;
}

.annotation-types-checkboxes .form-check {
    margin-bottom: 0.5rem;
}

.annotation-types-checkboxes .form-check:last-child {
    margin-bottom: 0;
}

/* Annotation Types Configuration */
.annotation-types-config {
    padding: 0.5rem 0;
}

.config-checklist {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    max-height: none; /* Remove height restriction */
    overflow-y: visible; /* Remove scrolling */
}

.annotation-type-column {
    flex: 1;
    min-width: 150px; /* Reduced from 200px */
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.75rem;
    background-color: var(--card-bg, #ffffff);
    min-height: 100px;
}

.annotation-type-column:empty::after {
    content: "No items available";
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.875rem;
}

.annotation-type-column h6 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.75rem 0;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.annotation-type-column .form-check {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.annotation-type-column .form-check:last-child {
    margin-bottom: 0;
}

.annotation-type-column .form-check-input {
    margin-top: 0.125rem;
}

.annotation-type-column .form-check-label {
    color: #495057;
    cursor: pointer;
    flex: 1;
    word-wrap: break-word; /* Allow text wrapping */
    hyphens: auto; /* Enable hyphenation for better wrapping */
}

.annotation-type-column .form-check-input:checked + .form-check-label {
    color: #212529;
    font-weight: 500;
}

/* Custom zones toggle */
.custom-zones-toggle {
    margin-bottom: 1rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    border: 1px solid #e9ecef;
}

.custom-zones-toggle .form-check {
    margin-bottom: 0;
}

.custom-zones-toggle .form-check-label {
    font-weight: 500;
    color: #495057;
}

/* Responsive design for smaller screens */
@media (max-width: 1200px) {
    .config-checklist {
        flex-direction: column;
    }
    
    .annotation-type-column {
        min-width: auto;
    }
}

/* Responsive for very small screens */
@media (max-width: 800px) {
    .annotation-type-column {
        min-width: 120px; /* Even smaller on mobile */
    }
}

/* Zone type items with color pickers */
.zone-type-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.zone-type-item .form-check-input {
    margin-top: 0;
}

.zone-type-item .form-check-label {
    flex: 1;
    margin-bottom: 0;
}

.zone-color-picker {
    width: 30px !important;
    height: 24px !important;
    border: 1px solid #dee2e6 !important;
    border-radius: 3px !important;
    padding: 0 !important;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.zone-color-picker:hover {
    border-color: #adb5bd !important;
}

.zone-color-picker:focus {
    border-color: #86b7fe !important;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

.zone-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
    border-radius: 2px;
}

.zone-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.custom-zone-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.custom-zone-controls .btn {
    width: 24px;
    height: 24px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Legacy config-checklist styles (keeping for backward compatibility) */

/* Classification badge in transcription items */
.classification-badge {
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

/* Sidebar Sections */
.sidebar-section {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

.sidebar-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-section-title.text-center {
    justify-content: center;
    position: relative;
}

.sidebar-section-title.text-center .btn {
    position: absolute;
    right: 0;
}

.btn-xs {
    padding: 0.125rem 0.375rem;
    font-size: 0.75rem;
    line-height: 1.2;
}

/* Prompts List */
.prompts-list {
    max-height: 300px;
    overflow-y: auto;
}

.prompt-item {
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    background: white;
    transition: all 0.2s ease;
}

.prompt-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0,102,204,0.1);
}

.prompt-item.active {
    border-color: var(--primary-color);
    background-color: rgba(0,102,204,0.05);
}

.prompt-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.prompt-item-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: #333;
    margin: 0;
}

.prompt-item-actions {
    display: flex;
    gap: 0.25rem;
}

.prompt-item-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.prompt-item-zones {
    margin-top: 0.5rem;
}

.prompt-zone-badge {
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

/* Metadata Fields Editor */
.metadata-field {
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: #f8f9fa;
}

.metadata-field-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.metadata-field-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin: 0;
}

.metadata-field-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr auto;
    gap: 0.5rem;
    align-items: end;
}

/* Edit annotation metadata */
.annotation-metadata-field {
    margin-bottom: 0.75rem;
}

.annotation-metadata-field label {
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

/* Classification Badge Colors */
.classification-badge {
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    font-weight: 500;
}

/* Transcription Item Border Colors */
.transcription-item {
    border-left-width: 4px !important;
    transition: all 0.2s ease;
}

.transcription-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.transcription-item.selected {
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2) !important;
}

/* Button utilities */
.btn-xs {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.2;
    border-radius: 0.2rem;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --light-bg: #2c3e50;
        --border-color: #34495e;
        --text-muted: #bdc3c7;
    }
    
    body {
        background-color: var(--dark-bg);
        color: #ecf0f1;
    }
    
    .sidebar {
        background-color: #34495e;
    }
    
    .card {
        background-color: #34495e;
        border-color: var(--border-color);
    }
    
    .main-content {
        background-color: var(--dark-bg);
    }
}

/* Zone/Line Detection Modal Styles */
.detection-type-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    padding: 0.5rem;
    background-color: #f8f9fa;
}

.detection-type-list .form-check {
    margin-bottom: 0.5rem;
}

.detection-type-list .form-check:last-child {
    margin-bottom: 0;
}

.detection-type-list .form-check-label {
    font-size: 0.875rem;
    color: var(--bs-body-color);
}

#detectZonesLinesModal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

#detectionProgress .progress {
    height: 0.5rem;
}

#detectionResults .alert {
    margin-bottom: 0;
}

/* Responsive adjustments for detection modal */
@media (max-width: 768px) {
    .detection-type-list {
        max-height: 150px;
    }
    
    #detectZonesLinesModal .modal-body {
        max-height: 60vh;
    }
}

/* Detection Mapper Styles */
#detectionMapperContent {
    background-color: #fafafa;
    font-size: 11px;
}

#detectionMappingsList {
    max-height: 120px;
    overflow-y: auto;
}

#detectionMappingsList .btn-xs {
    padding: 0.125rem 0.25rem;
    font-size: 9px;
    line-height: 1;
    border-radius: 0.2rem;
}

#newDetectionClass,
#newMappingTarget {
    font-size: 11px !important;
}

.cursor-pointer {
    cursor: pointer;
}

#detectionMapperContent .input-group-sm .form-control,
#detectionMapperContent .input-group-sm .form-select {
    padding: 0.125rem 0.375rem;
    font-size: 11px;
    line-height: 1.5;
}

#detectionMapperContent .btn-sm {
    padding: 0.125rem 0.375rem;
    font-size: 11px;
}

/* Zone Selection Modal Styles */
.zone-selection-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 0.75rem;
    background-color: #f8f9fa;
}

.zone-selection-list .form-check {
    margin-bottom: 0.5rem;
    padding: 0.25rem 0;
}

.zone-selection-list .form-check:last-child {
    margin-bottom: 0;
}

.zone-selection-list .form-check-label {
    font-size: 0.875rem;
    cursor: pointer;
    padding-left: 0.5rem;
}

.zone-selection-list .form-check-input {
    margin-top: 0.2rem;
    margin-right: 0.5rem;
    width: 16px;
    height: 16px;
}

.zone-selection-list .form-check-input:checked + .form-check-label {
    font-weight: 500;
    color: #0d6efd;
}

.zone-detection-mode {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    background-color: #f8f9fa;
}

.zone-detection-mode.selected {
    border-color: #0d6efd;
    background-color: #e3f2fd;
}

.detection-mode-radio {
    margin-right: 0.75rem;
    width: 18px;
    height: 18px;
}

.detection-mode-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.detection-mode-description {
    font-size: 0.875rem;
    color: #6c757d;
    margin-left: 2rem;
}

/* Progress Modal Styles */
#progressDetails {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
}

.progress-item {
    padding: 4px 8px;
    margin: 2px 0;
    border-radius: 3px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.progress-item.success {
    background-color: #d4edda;
    color: #155724;
    border-left: 3px solid #28a745;
}

.progress-item.error {
    background-color: #f8d7da;
    color: #721c24;
    border-left: 3px solid #dc3545;
}

.progress-item.processing {
    background-color: #cce7ff;
    color: #004085;
    border-left: 3px solid #0066cc;
}

.progress-item.skipped {
    background-color: #fff3cd;
    color: #856404;
    border-left: 3px solid #ffc107;
}

.progress-item-icon {
    margin-right: 8px;
    min-width: 16px;
}

.progress-item-text {
    flex-grow: 1;
}

.progress-item-count {
    font-size: 11px;
    opacity: 0.8;
}

/* Document Status Icons */
.document-status-icons {
    display: flex;
    gap: 4px;
    margin-left: 8px;
}

.status-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: white;
    position: relative;
}

.status-icon.zones-detected {
    background-color: #17a2b8;
}

.status-icon.transcribed {
    background-color: #28a745;
}

.status-icon.partial {
    background: linear-gradient(45deg, #ffc107 50%, #28a745 50%);
}

/* Tooltip for status icons */
.status-icon::before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
    margin-bottom: 4px;
}

.status-icon:hover::before {
    opacity: 1;
}

/* Professional Tree Interface */
.edit-structure-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6 !important;
    margin-bottom: 0.5rem;
}

.edit-structure-header .btn {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.edit-structure-header .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Editable Text Styling */
.editable-text {
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    transition: all 0.2s ease;
    position: relative;
}

.editable-text:hover {
    background-color: rgba(0, 102, 204, 0.1);
    color: #0066cc;
}

.editable-text:hover::after {
    content: '✏️';
    position: absolute;
    right: -15px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    opacity: 0.7;
}

.tree-rename-input {
    border: 2px solid #0066cc !important;
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.25) !important;
    border-radius: 3px !important;
    font-size: 14px !important;
    min-width: 120px;
}

/* Tree Reorder Controls */
.tree-reorder-controls {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
    margin-left: auto;
    margin-right: 8px;
}

.tree-item-content:hover .tree-reorder-controls {
    opacity: 1;
}

.tree-reorder-controls .btn {
    padding: 2px 4px;
    font-size: 10px;
    line-height: 1;
    border-radius: 2px;
    min-width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
    background-color: white;
    color: #6c757d;
    transition: all 0.2s ease;
}

.tree-reorder-controls .btn:hover {
    background-color: #f8f9fa;
    border-color: #0066cc;
    color: #0066cc;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.tree-reorder-controls .btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Structure Modal Styling */
.structure-section {
    height: 400px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    background-color: white;
}

.section-title {
    background-color: #f8f9fa;
    padding: 12px 16px;
    margin: 0;
    border-bottom: 1px solid #dee2e6;
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 8px;
}

.structure-list {
    height: calc(100% - 50px);
    overflow-y: auto;
    padding: 8px;
}

.structure-item {
    margin-bottom: 4px;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.structure-item:hover {
    border-color: #0066cc;
    background-color: #f8f9ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.structure-item.selected {
    border-color: #0066cc;
    background-color: #e3f2fd;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.15);
}

.structure-item-content {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    gap: 8px;
}

.structure-icon {
    width: 16px;
    text-align: center;
    font-size: 12px;
}

.structure-text {
    flex: 1;
    font-size: 13px;
    color: #495057;
    font-weight: 500;
}

.structure-controls {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.structure-item:hover .structure-controls {
    opacity: 1;
}

.structure-controls .btn {
    padding: 1px 4px;
    font-size: 9px;
    line-height: 1;
    border-radius: 2px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Enhanced Tree Item Layout */
.tree-item-content {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    position: relative;
    gap: 6px;
}

.tree-text {
    flex: 1;
    font-size: 14px;
    color: #333;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Disable old drag and drop */
.tree-item[draggable="true"] {
    cursor: default;
    pointer-events: auto;
}

.tree-item.dragging,
.tree-item.tree-drag-insert-above::before,
.tree-item.tree-drag-insert-below::after {
    display: none !important;
}

body.tree-dragging {
    cursor: default !important;
}

body.tree-dragging * {
    cursor: default !important;
    pointer-events: auto !important;
}

/* Professional animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tree-item {
    animation: slideIn 0.3s ease-out;
}

.structure-item {
    animation: slideIn 0.2s ease-out;
}

/* Success feedback animation */
@keyframes successPulse {
    0% {
        background-color: #d4edda;
        transform: scale(1);
    }
    50% {
        background-color: #c3e6cb;
        transform: scale(1.02);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.tree-item.success-feedback {
    animation: successPulse 0.6s ease-out;
}

/* Tree Drag and Drop Styles */
.tree-item[draggable="true"] {
    cursor: grab;
    transition: all 0.2s ease;
}

.tree-item[draggable="true"]:active {
    cursor: grabbing;
}

.tree-item.dragging {
    opacity: 0.5;
    transform: rotate(2deg) scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 2px dashed #0066cc;
}

/* Tree drag visual indicators */
.tree-item.tree-drag-insert-above::before {
    content: '';
    position: absolute;
    top: -3px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4caf50, #2196f3);
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.5);
    z-index: 10;
    animation: dropIndicatorPulse 1s ease-in-out infinite alternate;
}

.tree-item.tree-drag-insert-below::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #4caf50, #2196f3);
    border-radius: 2px;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.5);
    z-index: 10;
    animation: dropIndicatorPulse 1s ease-in-out infinite alternate;
}

@keyframes dropIndicatorPulse {
    from {
        opacity: 0.6;
        transform: scaleY(0.8);
    }
    to {
        opacity: 1;
        transform: scaleY(1.2);
    }
}

/* Drag hover effects for different item types */
.project-item:hover[draggable="true"] .tree-item-content {
    background-color: #fff3e0;
    border-left: 3px solid #ff9800;
}

.document-item:hover[draggable="true"] .tree-item-content {
    background-color: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.image-item:hover[draggable="true"] .tree-item-content {
    background-color: #e8f5e8;
    border-left: 3px solid #4caf50;
}

/* Enhanced visual feedback for valid drop targets */
.tree-item[draggable="true"]:not(.dragging):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Disable pointer events on child elements during drag */
.tree-item.dragging * {
    pointer-events: none;
}

/* Add a subtle grip indicator */
.tree-item[draggable="true"] .tree-item-content::after {
    content: '⋮⋮';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    font-size: 12px;
    color: #dee2e6;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.tree-item[draggable="true"]:hover .tree-item-content::after {
    opacity: 0.6;
}

.tree-item[draggable="true"].dragging .tree-item-content::after {
    opacity: 0;
}

/* Cross-project/document move indicators */
.tree-item.tree-drag-cross-move {
    background-color: #fff8e1 !important;
    border: 2px dashed #ffc107 !important;
    border-radius: 6px;
}

.tree-item.tree-drag-cross-move::before {
    content: '↗ Move to different container';
    position: absolute;
    top: -24px;
    left: 0;
    font-size: 11px;
    color: #856404;
    background-color: #fff3cd;
    padding: 2px 6px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 15;
}

/* Responsive adjustments for drag and drop */
@media (max-width: 768px) {
    .tree-item[draggable="true"] .tree-item-content::after {
        opacity: 0.4; /* Make grip more visible on mobile */
    }
    
    .tree-item.tree-drag-insert-above::before,
    .tree-item.tree-drag-insert-below::after {
        height: 6px; /* Larger drop indicators for touch */
    }
}

/* Improved accessibility for drag and drop */
.tree-item[draggable="true"]:focus {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

.tree-item[draggable="true"]:focus-visible {
    outline: 2px solid #0066cc;
    outline-offset: 2px;
}

/* Animation for successful move */
@keyframes moveSuccess {
    0% {
        background-color: #d4edda;
        transform: scale(1.02);
    }
    100% {
        background-color: transparent;
        transform: scale(1);
    }
}

.tree-item.move-success {
    animation: moveSuccess 0.6s ease-out;
}

/* Global dragging state */
body.tree-dragging {
    cursor: grabbing !important;
    user-select: none;
}

body.tree-dragging * {
    cursor: grabbing !important;
    pointer-events: none;
}

/* Allow drop targets to receive events during drag */
body.tree-dragging .tree-item {
    pointer-events: auto;
}

/* Remove persistent highlighting/selection */
.tree-item.active > .tree-item-content {
    background-color: transparent !important;
    border-left: none !important;
}

.tree-item-content {
    background-color: transparent !important;
}

.tree-item-content:hover {
    background-color: #f8f9fa !important;
}

/* Smoother drag animations */
.tree-item {
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.tree-item.dragging {
    opacity: 0.8;
    transform: rotate(1deg) scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    z-index: 1000;
    background-color: #ffffff;
    border-radius: 6px;
    border: 1px solid #0066cc;
}

/* Removed dragPulse animation for cleaner look */

/* Slide animation for reordering */
.tree-item.sliding {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

/* Smooth sliding during drag */
.tree-item:not(.dragging):not(.sliding) {
    transition: transform 0.2s ease;
}

/* Ensure dragged item stays on top */
.tree-item.dragging {
    z-index: 1000;
}

/* Enhanced drop indicators with animations */
.tree-item.tree-drag-insert-above::before {
    animation: dropIndicatorSlide 0.2s ease-out;
}

.tree-item.tree-drag-insert-below::after {
    animation: dropIndicatorSlide 0.2s ease-out;
}

@keyframes dropIndicatorSlide {
    from {
        opacity: 0;
        transform: scaleX(0);
    }
    to {
        opacity: 1;
        transform: scaleX(1);
    }
}

/* Better hover feedback during drag */
body.tree-dragging .tree-item:hover:not(.dragging) {
    background-color: rgba(0, 102, 204, 0.05);
    border-radius: 4px;
}

/* Prevent text selection during drag */
body.tree-dragging .tree-text,
body.tree-dragging .tree-item-content {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}