/* Bootstrap enhancements and overrides */
html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
}

/* Header styling */
.navbar {
    box-shadow: 0 2px 4px rgba(0,0,0,.1);
    background-color: #343a40 !important;
}

.navbar-brand {
    font-weight: 600;
}

/* Main container */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-title {
    margin: 1rem 0;
    color: #343a40;
    font-weight: 600;
}

/* Annotation layout */
.annotation-container {
    display: flex;
    height: calc(100vh - 120px);
    overflow: hidden;
}

/* Sidebar with thumbnails */
.sidebar {
    width: 220px;
    flex-shrink: 0;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    background-color: #f8f9fa;
    padding: 0.75rem;
}

.sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #dee2e6;
    text-align: center;
}

.thumbnails-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.thumbnail-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 0.25rem;
    border: 1px solid #dee2e6;
    cursor: pointer;
    transition: all 0.2s;
    background-color: white;
    position: relative;
}

.thumbnail-item:hover {
    background-color: #e9ecef;
}

.thumbnail-item.active {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.1);
}

.thumbnail-item.annotated {
    border-color: #28a745;
}

.annotated-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background-color: #28a745;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
}

.thumbnail-img {
    width: 2.5rem;
    height: 2.5rem;
    object-fit: cover;
    border-radius: 0.25rem;
    margin-right: 0.5rem;
}

.thumbnail-icon {
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #6c757d;
    margin-right: 0.5rem;
    background-color: #f8f9fa;
    border-radius: 0.25rem;
}

.thumbnail-name {
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* Main content area */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* File display */
.file-panel {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    background-color: white;
    border-right: 1px solid #dee2e6;
    overflow: hidden;
}

.current-file-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* JSON preview */
.json-preview {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.json-content {
    flex: 1;
    overflow: auto;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Form panel */
.form-panel {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background-color: white;
}

/* JSON Editor styling */
#editor-holder {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    padding: 1rem;
    background-color: #f8f9fa;
    margin-bottom: 1rem;
}

/* Make sure JSON Editor elements are visible */
.je-object__container, 
.je-object__title, 
.je-object__controls, 
.je-object__content,
.json-editor-btn-collapse,
.json-editor-btntype-properties,
.json-editor-btn-delete,
.json-editor-btn-add,
.json-editor-btn-moveup,
.json-editor-btn-movedown {
    display: block !important;
}

/* Messages */
.alert {
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
}

/* Upload form */
.upload-form {
    max-width: 600px;
    margin: 0 auto;
    padding: 1.5rem;
    background-color: white;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.075);
}

.file-input-container {
    margin-bottom: 1rem;
}

.file-name {
    margin-left: 0.5rem;
    font-style: italic;
    font-size: 0.875rem;
}

/* Footer */
footer {
    background-color: #343a40;
    color: rgba(255,255,255,.5);
    padding: 1rem 0;
    text-align: center;
    margin-top: auto;
    position: sticky;
    bottom: 0;
    width: 100%;
    z-index: 1000;
}

/* Home page specific styles */
body:has(.upload-form) footer {
    position: fixed;
    bottom: 0;
    width: 100%;
}

/* Responsive adjustments */
@media (max-width: 992px) {
    .annotation-container {
        flex-direction: column;
        height: auto;
    }
    
    .sidebar {
        width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }
    
    .thumbnails-container {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .thumbnail-item {
        width: 80px;
        flex-direction: column;
    }
    
    .thumbnail-img, .thumbnail-icon {
        margin-right: 0;
        margin-bottom: 0.25rem;
    }
    
    .main-content {
        flex-direction: column;
    }
    
    .file-panel, .form-panel {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }
    
    /* Ensure footer stays at bottom on mobile */
    body:has(.upload-form) {
        padding-bottom: 60px; /* Add space for the fixed footer */
    }
}
