/* Verdalsbilder.no Styles */

/* Theme Variables */
:root {
    /* Dark Theme (Default) */
    --bg-color: #1a1a1a;
    --text-color: #ffffff;
    --text-secondary: rgba(255,255,255,0.8);
    --border-color: rgba(255,255,255,0.1);
    --card-bg: rgba(0,0,0,0.85);
    --input-bg: rgba(255,255,255,0.1);
    --input-border: #ddd;
    --button-primary: #007bff;
    --button-secondary: #6c757d;
    --button-light: #f8f9fa;
    --modal-backdrop: rgba(0, 0, 0, 0.9);
    --modal-content: rgba(0, 0, 0, 0.95);
}

[data-theme="light"] {
    /* Light Theme */
    --bg-color: #ffffff;
    --text-color: #000000;
    --text-secondary: rgba(0,0,0,0.7);
    --border-color: rgba(0,0,0,0.1);
    --card-bg: rgba(255,255,255,0.95);
    --input-bg: #ffffff;
    --input-border: #ddd;
    --button-primary: #007bff;
    --button-secondary: #6c757d;
    --button-light: #e9ecef;
    --modal-backdrop: rgba(0, 0, 0, 0.5);
    --modal-content: rgba(255, 255, 255, 0.98);
}

/* Global Theme Application */
body {
    background-color: var(--bg-color) !important;
    color: var(--text-color) !important;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Text Muted - Theme Compatible */
.text-muted {
    color: var(--text-secondary) !important;
}

/* 
Z-INDEX LAYERING SYSTEM:
- z-index: 1000+ = Modal navigation and close buttons
- z-index: 100-199 = Face overlays and tags (always on top)
  - 105: Selected face name tags (highest)
  - 102: Face tags and name tags
  - 101: Selected face overlay boxes
  - 100: Regular face overlay boxes
- z-index: 10-99 = UI panels and controls
  - 50: Side panels in modal layout
  - 10: Table headers and other sticky elements
- z-index: 2-9 = Thumbnails and secondary images
  - 2: Version thumbnails, gallery thumbnails, person thumbnails
- z-index: 1 = Main images and content
  - 1: Modal images, image containers, main content
- z-index: 0 (default) = Background elements
*/

/* Gallery and Image Styles */
.gallery-thumbnail {
    width: 140px;
    height: 105px;
    object-fit: cover;
    object-position: top; /* Prioritize top part for people photos */
    margin: 8px;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    z-index: 2; /* Above main images but below face overlays */
    position: relative;
}

.gallery-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    justify-items: center;
    max-width: 100%;
    margin-bottom: 20px;
}

/* Modal and Lightbox Styles */
.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 24px;
    cursor: pointer;
    z-index: 1000;
}

.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 28px;
    cursor: pointer;
    z-index: 1000;
}

.modal-nav-btn.prev {
    left: 20px;
}

.modal-nav-btn.next {
    right: 20px;
}

.modal-image-container {
    text-align: center;
    max-height: 75vh;  /* Increased from 70vh to allow more space for higher positioning */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5px;
    margin-top: 20px;  /* Reduced from 40px to move image higher */
    margin-bottom: 5px;
}

/* Adjust image container margin when version navigation is present */
#version-navigation + .modal-image-container,
#version-navigation ~ .modal-image-container {
    margin-top: 20px;  /* Increased from 5px to maintain higher positioning with version nav */
}

.modal-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 100%;
    z-index: 1; /* Ensure images are below face overlays */
}

.modal-main-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1; /* Ensure content is below face overlays */
}

.modal-image {
    max-width: 100%;
    max-height: 75vh;  /* Increased from 70vh to match container and allow larger images */
    height: auto;
    width: auto;
    display: block;
    margin: auto;
    object-fit: contain;
    z-index: 1; /* Ensure main image is below face overlays */
    position: relative;
}

/* Modal Styling */
.modal-backdrop {
    background-color: var(--modal-backdrop) !important;
}

.modal-content {
    background-color: var(--modal-content) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-color) !important;
}

.modal-header {
    background-color: var(--modal-content) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.modal-body {
    background-color: var(--modal-content) !important;
    color: var(--text-color) !important;
}

.modal-footer {
    background-color: var(--modal-content) !important;
    border-top: 1px solid var(--border-color) !important;
}

/* Face Names Display */
.face-names-container {
    text-align: center;
    color: var(--text-color);
    font-size: 13px;
    margin-bottom: 20px;  /* Increased from 15px for better spacing */
    margin-top: 30px;     /* Increased from 10px to make room for version navigation */
    min-height: 20px;
}

.face-name-button {
    text-decoration: none;
    padding: 2px 4px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 3px;
    background: transparent;
}

.face-name-button.selected {
    background: rgba(0, 255, 0, 0.2);
    border: 1px solid #00ff00;
    color: #00ff00;
}

/* Light mode face name button colors */

/* Light mode unselected face name button - darker cyan/blue for better visibility */
[data-theme="light"] .face-name-button.unselected {
    color: #003399 !important ;  /* Dark blue instead of cyan */
}


/* General override for unselected face names in light mode (lower specificity) */
[data-theme="light"] .face-name-button:not(.selected) {
    color: #003399 !important;  /* Dark blue for unselected only */
}


[data-theme="light"] .face-name-button.selected {
    background: rgba(0, 128, 0, 0.2);
    border: 1px solid #004400 !important;
    color: #004400 !important;
}


/* Light mode selected face name button - dark green for better contrast */
[data-theme="light"] .face-name-button.selected {
    background: rgba(0, 128, 0, 0.2) !important;
    border: 1px solid #004400 !important;
    color: #004400 !important; /* Dark green for selected */
}

.face-name-button.unselected {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
}

/* Control Buttons */
.modal-control-buttons {
    text-align: center;
    margin-bottom: 15px;
}

.control-btn {
    font-size: 12px;
}

/* Side Panels */
.side-panel {
    background-color: var(--card-bg);
    border-left: 1px solid var(--border-color);
    position: fixed;
    right: 0;
    top: 0;
    height: 100vh;
    width: 300px;
    z-index: 1050;
    padding: 10px;
    overflow-y: auto;
    color: var(--text-color);
}

/* Light mode side panel styling */
[data-theme="light"] .side-panel {
    background-color: #ffffff;
    color: #333333;
}

/* Light mode side panel content improvements */
[data-theme="light"] .side-panel * {
    color: #333333 !important;
}

/* Year badge styling - preserve original appearance in all themes with higher specificity */
.year-badge {
    color: #00ff00 !important;
    background-color: rgba(0, 0, 0, 0.6) !important;
    border: 1px solid #00ff00 !important;
}

/* Year badge in light mode - maintain green color with higher specificity */
[data-theme="light"] .side-panel .year-badge {
    color: #00ff00 !important;
    background-color: rgba(0, 0, 0, 0.6) !important;
    border: 1px solid #00ff00 !important;
}

[data-theme="light"] .side-panel .person-name {
    color: #000000 !important;
    font-weight: bold;
}

[data-theme="light"] .side-panel .person-detail {
    color: #444444 !important;
}

[data-theme="light"] .side-panel .face-info-label {
    color: #555555 !important;
    font-weight: 600;
}

[data-theme="light"] .side-panel .face-info-item {
    color: #333333 !important;
}

[data-theme="light"] .side-panel h1,
[data-theme="light"] .side-panel h2,
[data-theme="light"] .side-panel h3,
[data-theme="light"] .side-panel h4,
[data-theme="light"] .side-panel h5,
[data-theme="light"] .side-panel h6 {
    color: #000000 !important;
}

[data-theme="light"] .side-panel p,
[data-theme="light"] .side-panel div,
[data-theme="light"] .side-panel span {
    color: #333333 !important;
}

[data-theme="light"] .side-panel .text-muted {
    color: #666666 !important;
}

/* Light mode button color fixes for better visibility */
[data-theme="light"] .btn-info {
    background-color: #0c5460 !important;
    border-color: #0c5460 !important;
    color: #ffffff !important;
}

[data-theme="light"] .btn-info:hover {
    background-color: #024c57 !important;
    border-color: #024c57 !important;
}

[data-theme="light"] .btn-primary {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: #ffffff !important;
}

[data-theme="light"] .btn-primary:hover {
    background-color: #0b5ed7 !important;
    border-color: #0b5ed7 !important;
}

.side-panel-content {
    padding: 15px;
    height: 95vh;
    overflow-y: auto;
}

.edit-panel-hidden {
    display: none;
}

.person-panel-hidden {
    display: none;
}

/* Compact input and textarea for edit mode */
.side-panel input[type="text"],
.side-panel input[type="number"],
.side-panel textarea {
    padding: 4px 6px !important;
    font-size: 12px;
}

/* Metadata Fields */
.metadata-container {
    max-width: 800px;
    margin: 0 auto;
    margin-bottom: 15px;
}

.metadata-field-label {
    font-size: 12px;
}

/* Light mode metadata field labels */
[data-theme="light"] .metadata-field-label {
    color: #333333 !important;
    font-weight: 600;
}

.metadata-readonly-display {
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    padding: 8px;
    background-color: var(--input-bg);
    border-radius: 5px;
}

/* Light mode metadata readonly display */
[data-theme="light"] .metadata-readonly-display {
    color: #444444 !important;
    background-color: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
}

/* Extract Buttons */
.extract-button {
    font-size: 11px;
    padding: 2px 8px;
    background-color: black;
    color: #00ff00;
    border: 1px solid #00ff00;
}

.extract-button-label {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    margin-top: 3px;
    margin-bottom: 2px;
}

/* Light mode extract button labels */
[data-theme="light"] .extract-button-label {
    color: #666666 !important;
}

/* Light mode extract buttons */
[data-theme="light"] .extract-button {
    background-color: #f8f9fa !important;
    color: #0066cc !important;
    border: 1px solid #0066cc !important;
}

.extract-buttons-container {
    display: flex;
    flex-wrap: wrap;
}

/* Image Description */
.image-description {
    text-align: center;
    color: var(--text-color);
    font-size: 14px;
    margin-bottom: 10px;
    padding: 10px;
    background-color: var(--input-bg);
    border-radius: 5px;
    border: 1px solid var(--border-color);
}

/* Light mode specific styling for image description */
[data-theme="light"] .image-description {
    background-color: rgba(0,0,0,0.05);
    color: #333333;
    border: 1px solid rgba(0,0,0,0.2);
}

/* Person Information Panel */
.person-info-header {
    font-size: 14px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.2);
    padding-bottom: 8px;
}

/* Light mode person panel styling */
[data-theme="light"] .person-info-header {
    border-bottom: 1px solid rgba(0,0,0,0.2);
}

[data-theme="light"] .person-lifespan {
    color: #666666;
}

[data-theme="light"] .person-description {
    background-color: rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.1);
    color: #333333;
}

[data-theme="light"] .person-thumbnails-container {
    border: 1px solid rgba(0,0,0,0.1);
    background-color: #f8f9fa;
}

.person-name {
    font-size: 16px;
    font-weight: bold;
}

.person-lifespan {
    font-size: 13px;
    color: #e6e6e6;
    font-weight: 500;
}

.person-detail {
    font-size: 12px;
    margin-right: 5px;
}

.person-description {
    background-color: rgba(255,255,255,0.1);
    padding: 8px;
    border-radius: 4px;
    margin-bottom: 15px;
    border: 1px solid rgba(255,255,255,0.2);
    font-size: 12px;
    line-height: 1.4;
}

.person-stats {
    font-size: 11px;
    text-align: center;
    font-style: italic;
    color: var(--text-secondary);
}

.person-thumbnails-container {
    max-height: calc(100vh);
    min-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 8px;
    scroll-behavior: smooth;
}

.person-image-item {
    margin-bottom: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.person-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: center;
    border-radius: 8px;
    margin-bottom: 8px;
    z-index: 2; /* Above main images but below face overlays */
    position: relative;
}

.person-image-item {
    margin-bottom: 15px;
}

.person-thumbnail-caption {
    padding: 5px 0;
}

.person-thumbnail-filename {
    font-size: 11px;
    line-height: 1.2;
}

.person-thumbnail-year {
    font-size: 10px;
    line-height: 1.1;
}

/* Face Information Panel */
.face-info-item {
    border-bottom: 1px solid #6c757d;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.face-info-label {
    font-size: 12px;
    margin-bottom: 4px;
}

.face-tag-input {
    font-size: 11px;
    height: 30px;
    cursor: pointer;
    margin-bottom: 4px;
}

.face-tag-input.selected {
    background-color: white;
    border: 2px solid #007bff;
}

.face-tag-input.unselected {
    background-color: #f5f5f5;
    border: 1px solid #ced4da;
}

.face-coordinates {
    font-size: 10px;
    margin-bottom: 8px;
}

/* Upload Area */
.upload-area {
    width: 100%;
    height: 50px;
    line-height: 50px;
    border-width: 1px;
    border-style: dashed;
    border-radius: 3px;
    text-align: center;
    margin: 0px;
    cursor: pointer;
    background-color: #f8f9fa;
    color: #6c757d;
    font-size: 13px;
}

/* Hamburger Menu */
.hamburger-card {
    max-width: 300px;
}

.hamburger-btn {
    font-size: 18px;
    padding: 8px 12px;
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 12px;
}

.pagination-btn {
    margin-right: 4px;
}

.pagination-nav-btn {
    min-width: 100px;
}

.pagination-nav-btn.prev {
    margin-right: 12px;
}

.pagination-nav-btn.next {
    margin-left: 12px;
}

/* Search and Filter */
.search-group-row {
    margin-bottom: 8px;
}

.search-label {
    font-size: 14px;
}

.search-input {
    font-size: 14px;
}

.search-input-large {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    margin-top: 12px;

}

.search-input-large:focus {
    box-shadow: 0 4px 16px rgba(0,123,255,0.2);
    border-color: #007bff !important;
    outline: none;
}

.group-sort-select {
    font-size: 14px;
}

/* Tags Display */
.tag-badge {
    display: inline-block;
    padding: 2px 6px;
    margin: 1px;
    background-color: white;
    color: black;
    border: 1px solid black;
    border-radius: 3px;
    font-size: 12px;
    font-weight: normal;
}

.tags-container {
    line-height: 1.8;
}

/* Main Column Styles */
.main-col {
    min-height: 95vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 0 15px;
    position: relative;
}

.main-col.with-panel {
    margin-right: 320px;
}

/* Person Stats */
.person-stats-container {
    font-size: 12px;
    color: var(--text-secondary);
    color: #6c757d;
    margin-bottom: 4px;
}

/* Group Headers */
.gallery-group-header {
    margin-top: 12px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid #dee2e6;
    font-size: 16px;
    font-weight: bold;
    color: #007bff;
}

/* Utility Classes */
.text-small {
    font-size: 12px;
}

.text-xs {
    font-size: 10px;
}

.mr-half {
    margin-right: 2px;
}

.flex-wrap {
    display: flex;
    flex-wrap: wrap;
}

/* Responsive Design */
@media (max-width: 768px) {
    .side-panel {
        width: 250px;
    }
    
    .main-col.with-panel {
        margin-right: 270px;
    }
    
    .gallery-thumbnail {
        width: 120px;
        height: 90px;
    }
    
    .modal-nav-btn {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .modal-close-btn {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }
}

@media (max-width: 576px) {
    .side-panel {
        width: 200px;
    }
    
    .main-col.with-panel {
        margin-right: 220px;
    }
    
    .gallery-thumbnail {
        width: 100px;
        height: 75px;
        margin: 4px;
    }
    
    .pagination-nav-btn {
        min-width: 80px;
        font-size: 11px;
    }
}

/* Face Overlay Bounding Box Styles - Higher Z-Index */
.face-overlay-box {
    border: none;
    box-sizing: border-box;
    position: relative;
    z-index: 100; /* Increased from 10 to ensure always above images */
}

.face-overlay-box.selected {
    border: none;
    z-index: 101; /* Increased from 11 to ensure selected faces are above unselected */
}

.face-overlay-corner {
    position: absolute;
    width: 15px;
    height: 15px;
    border: 2px solid #00ffff;
    background: transparent;
    z-index: inherit;
}

.face-overlay-box.selected .face-overlay-corner {
    border-color: #00ff00;
    border-width: 3px;
}

.face-overlay-corner-tl {
    top: -2px;
    left: -2px;
    border-right: none;
    border-bottom: none;
}

.face-overlay-corner-tr {
    top: -2px;
    right: -2px;
    border-left: none;
    border-bottom: none;
}

.face-overlay-corner-bl {
    bottom: -2px;
    left: -2px;
    border-right: none;
    border-top: none;
}

.face-overlay-corner-br {
    bottom: -2px;
    right: -2px;
    border-left: none;
    border-top: none;
}

.face-overlay-tag {
    font-family: Arial, sans-serif;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
    min-width: 40px;
    text-align: center;
    z-index: 102; /* Ensure tags are above everything */
    position: relative;
}

.face-overlay-name-tag {
    font-family: Arial, sans-serif;
    font-weight: bold;
    background-color: #00ffff;
    color: #000000;
    text-shadow: none;
    z-index: 102; /* Increased from 12 to ensure name tags are above images */
    position: relative;
}

.face-overlay-box.selected .face-overlay-name-tag {
    z-index: 105; /* Increased from 15 to ensure selected name tags are highest */
}

.face-overlay-box.selected .face-overlay-name-tag {
    background-color: #00ff00 !important;
    color: #000000 !important;
}

/* Dark/Light theme support for overlays */
[data-theme="light"] .face-overlay-box {
    border: none;
}

[data-theme="light"] .face-overlay-box.selected {
    border: none;
}

[data-theme="light"] .face-overlay-corner {
    border-color: #0066cc;
}

[data-theme="light"] .face-overlay-box.selected .face-overlay-corner {
    border-color: #009900;
}

[data-theme="light"] .face-overlay-name-tag {
    background-color: #0066cc !important;
    color: #ffffff !important;
}

[data-theme="light"] .face-overlay-box.selected .face-overlay-name-tag {
    background-color: #009900 !important;
    color: #ffffff !important;
}

.clickable-thumbnail {
    transition: transform 0.2s ease, opacity 0.2s ease;
    z-index: 2; /* Above main images but below face overlays */
    position: relative;
}

.clickable-thumbnail:hover {
    transform: scale(1.05);
    opacity: 0.8;
    box-shadow: 0 4px 8px rgba(0, 255, 0, 0.3);
}

/* Person Management Styles */
.persons-table-container {
    margin-top: 1rem;
}

.persons-table-container .dash-table-container {
    border-radius: 0.375rem;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.persons-table-container .dash-spreadsheet-container {
    max-height: 600px;
    overflow-y: auto;
}

.persons-table-container .dash-spreadsheet-container .dash-spreadsheet-inner table {
    border-collapse: separate;
    border-spacing: 0;
}

.persons-table-container .dash-spreadsheet-container .dash-spreadsheet-inner th {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #e6e6e6 !important;
    border-bottom: 2px solid #dee2e6;
}

.persons-table-container .dash-spreadsheet-container .dash-spreadsheet-inner td {
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

.persons-table-container .dash-spreadsheet-container .dash-spreadsheet-inner tr:hover td {
    background-color: #f8f9fa !important;
}

/* Modal Styles */
.modal-content {
    border-radius: 0.5rem;
}

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

.modal-footer {
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
}

/* Form Styles */
.form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

.form-control:focus {
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Toast Styles */
.toast {
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.toast-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

/* Modal layout styles */
.modal-layout-side {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.modal-layout-side #main-content-area {
    width: 100%;
    /* No need to reserve space - side panel is positioned outside modal */
}

.modal-layout-side #panels-container {
    /* Keep panels in DOM but position them outside via .side-panel fixed positioning */
    position: relative;
}

.modal-layout-side #panels-container .side-panel {
    /* Ensure fixed positioning works for side panels */
    position: fixed !important;
    right: 0 !important;
    top: 0 !important;
    height: 100vh !important;
    width: 300px !important;
    z-index: 1050 !important;
}

.modal-layout-below {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.modal-layout-below #main-content-area {
    width: 100%;
}

.modal-layout-below #panels-container {
    display: flex;
    flex-direction: row;
    gap: 15px;
    width: 100%;
}

.modal-layout-below #panels-container .side-panel {
    position: relative !important; /* Override fixed positioning for below layout */
    right: auto !important;
    top: auto !important;
    height: auto !important;
    flex: 1;
    width: auto !important; /* Override fixed width for below layout */
    max-width: none !important;
    z-index: auto !important;
}

/* Limit thumbnail width in below layout */
.modal-layout-below .person-thumbnail {
    max-width: 120px !important;
    width: auto !important;
}

.modal-layout-below .person-image-item {
    max-width: 120px !important;
    width: auto !important;
    margin: 4px !important;
}

/* Make thumbnails display horizontally in below layout */
.modal-layout-below .person-thumbnails-container {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: flex-start !important;
}

.modal-layout-below .person-thumbnails-container .person-image-item {
    flex: 0 0 auto !important;
    display: inline-block !important;
}

.edit-panel-hidden,
.person-panel-hidden {
    display: none !important;
}

/* In below layout, show visible panels */
.modal-layout-below #panels-container .side-panel:not(.edit-panel-hidden):not(.person-panel-hidden),
.modal-layout-below #panels-container .side-panel.edit-panel:not(.edit-panel-hidden),
.modal-layout-below #panels-container .side-panel.person-panel:not(.person-panel-hidden) {
    display: block;
}

@media (max-width: 768px) {
    .modal-layout-side #panels-container .side-panel {
        /* Mobile: panels remain fixed positioned outside modal */
        width: 250px !important;
    }
    
    .modal-layout-below .person-thumbnail {
        max-width: 100px !important;
    }
    
    .modal-layout-below .person-image-item {
        max-width: 100px !important;
    }
}

/* Edit panel below layout styles - 2 faces per row */
.modal-layout-below .face-info-row-below {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px 15px;
    margin-bottom: 10px;
    min-height: 88px;
}

.modal-layout-below .face-info-row-below:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.modal-layout-below .face-info-row-below .face-tag-input {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 12px;
}

.modal-layout-below .face-info-row-below .face-tag-input:focus {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.modal-layout-below .face-info-row-below .face-tag-input.selected {
    background-color: rgba(0, 255, 0, 0.2);
    border-color: #00ff00;
}

/* Ensure proper spacing between face pairs */
.modal-layout-below .face-info-row-below .row > .col:nth-child(3) {
    padding-left: 20px;
}

/* Mobile responsiveness for 2-faces-per-row layout */
@media (max-width: 768px) {
    .modal-layout-below .face-info-row-below .row > .col:nth-child(3),
    .modal-layout-below .face-info-row-below .row > .col:nth-child(4) {
        margin-top: 15px;
        padding-left: 15px;
    }
}

/* Edit panel side layout styles - 1 face per row */
.modal-layout-side .face-info-row-side {
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 8px;
    min-height: 88px;
}

.modal-layout-side .face-info-row-side:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.modal-layout-side .face-info-row-side .face-tag-input {
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 12px;
}

.modal-layout-side .face-info-row-side .face-tag-input:focus {
    background-color: rgba(255, 255, 255, 0.2);
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.modal-layout-side .face-info-row-side .face-tag-input.selected {
    background-color: rgba(0, 255, 0, 0.2);
    border-color: #00ff00;
}

/* Version Navigation Styles */
.version-link {
    display: inline-block;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.version-link:hover {
    opacity: 0.8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.version-link.active {
    cursor: default;
    animation: pulse-active 0.3s ease-in-out;
}

/* Click feedback animation */
@keyframes pulse-active {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Loading state for version switching */
.version-link.loading {
    opacity: 0.6;
    pointer-events: none;
}

.version-link.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border: 1px solid rgba(255,255,255,0.3);
    border-top: 1px solid rgba(255,255,255,0.8);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Image fade transition */
#main-modal-image {
    transition: opacity 0.3s ease-in-out;
    z-index: 1; /* Ensure main modal image is below face overlays */
    position: relative;
}

#image-container {
    position: relative;
    z-index: 1; /* Ensure image container is below face overlays */
}

/* Fade in/out classes for JavaScript control */
.fade-out {
    opacity: 0 !important;
}

.fade-in {
    opacity: 1 !important;
}

/* Version navigation container - now below image */
#version-navigation {
    margin: 8px 8px 8px 8px;
    padding: 3px 8px;
    max-width: 80%;
    text-align: center;
}

#version-navigation:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Enhanced version link hover effects */
.version-link:hover {
    background-color: rgba(0, 123, 255, 0.2) !important;
    border-color: #007bff !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.version-link.active:hover {
    background-color: rgba(0, 123, 255, 0.3) !important;
}

/* Version thumbnail hover effects */
img[id*="version-thumbnail"]:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* Delete button hover effects */
button[id*="delete-version-btn"]:hover {
    background-color: rgba(220, 53, 69, 1) !important;
    transform: scale(1.1);
    box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

/* Version navigation container enhancement */
#version-navigation {
    backdrop-filter: blur(5px);
}

/* Versions panel styling */
.versions-panel {
    backdrop-filter: blur(5px);
    z-index: 2; /* Above images but below face overlays */
    position: relative;
}

/* Versions panel layout - below mode horizontal stacking */
.modal-layout-below .versions-panel .versions-thumbnails {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    justify-content: flex-start !important;
}

.modal-layout-below .versions-panel .version-thumbnail-item {
    margin-bottom: 0 !important;
    flex: 0 0 auto !important;
}

.modal-layout-below .versions-panel .version-thumbnail-item img {
    width: 120px !important;
    height: 90px !important;
    object-position: top !important;
}

.modal-layout-below .versions-panel .version-thumbnail-item .version-title {
    max-width: 120px !important;
    font-size: 11px !important;
}

/* Versions panel layout - side mode vertical stacking (default) */
.modal-layout-side .versions-panel .versions-thumbnails {
    display: flex !important;
    flex-direction: column !important;
    gap: 5px !important;
}

.modal-layout-side .versions-panel .version-thumbnail-item {
    margin-bottom: 10px !important;
}

.modal-layout-side .versions-panel .version-thumbnail-item img {
    width: 120px !important;
    height: 90px !important;
    object-position: top !important;
}

.modal-layout-side .versions-panel .version-thumbnail-item .version-title {
    max-width: 120px !important;
    font-size: 10px !important;
}

/* Version thumbnails - Ensure below face overlays */
.version-thumbnail-item img {
    z-index: 2; /* Above main images but below face overlays */
    position: relative;
}

/* Version count badge for gallery thumbnails */
.version-count-badge {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background-color: rgba(108, 117, 125, 0.9) !important;
    color: white !important;
    font-size: 10px !important;
    font-weight: bold !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
    z-index: 10 !important;
    pointer-events: none !important;
    transition: all 0.2s ease;
}

/* Hover effect for gallery thumbnails with badges */
.gallery-thumbnail:hover + .version-count-badge,
.gallery-thumbnail:hover ~ .version-count-badge {
    background-color: rgba(108, 117, 125, 1) !important;
    transform: scale(1.05);
}