/* ── Meyrick Archives — Custom Styles ──────────────── */

:root {
    --mem-dark: #2c3e50;
    --mem-magenta: #591a20;
    --mem-accent: #3498db;
    --mem-fonds: #e74c3c;
    --mem-subfonds: #9b59b6;
    --mem-series: #e67e22;
    --mem-box: #f1c40f;
    --mem-file: #1abc9c;
    --mem-item: #3498db;
    --mem-bundle: #2ecc71;
    --mem-folder: #e67e22;
    --mem-volume: #95a5a6;
}

/* ── Navbar Brand ────────────────────────────────────── */

.navbar-magenta { background-color: var(--mem-magenta) !important; }

.brand-text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1;
    padding: 2px 0;
}

.brand-title {
    font-family: Georgia, 'Times New Roman', serif;
    font-size: 2rem;
    color: #fff;
}

.brand-subtitle {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
}

.brand-separator {
    margin: 0 3px;
}

.brand-mobile {
    font-size: 0.9rem;
}

#userMenuBtn {
    padding: 0.2rem 0.4rem;
    border-radius: var(--bs-border-radius-sm);
}

/* ── Layout ──────────────────────────────────────────── */

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.container-fluid > .row {
    flex: 1;
    overflow: hidden;
}

#main-content {
    height: calc(100vh - 56px);
    overflow-y: auto;
    padding-bottom: 20px;
}

/* ── Sidebar / Tree ──────────────────────────────────── */

#sidebarOffcanvas .offcanvas-body {
    height: calc(100vh - 56px);
}

@media (min-width: 992px) {
    #sidebarOffcanvas {
        height: calc(100vh - 56px);
    }
}

.sidebar {
    font-size: 0.8rem;
}

.tree-node {
    padding: 0;
}

.tree-node-label {
    cursor: pointer;
    padding: 1px 4px;
    border-radius: 3px;
    display: inline-flex;
    align-items: flex-start;
    gap: 3px;
    word-break: break-word;
    line-height: 1.2;
}

.tree-node-label:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.tree-node-label.active {
    background-color: var(--mem-accent);
    color: white;
}

.tree-node-label .badge {
    margin-top: 1px;
    flex-shrink: 0;
}

.tree-toggle {
    cursor: pointer;
    width: 14px;
    display: inline-block;
    text-align: center;
    user-select: none;
    flex-shrink: 0;
    font-size: 0.7rem;
    margin-top: 2px;
}

.tree-children {
    padding-left: 12px;
}

.tree-children.collapsed {
    display: none;
}

/* ── Level Badges ────────────────────────────────────── */

.badge-fonds      { background-color: var(--mem-fonds) !important; }
.badge-fonds-mem  { background-color: var(--mem-magenta) !important; }
.badge-subfonds   { background-color: var(--mem-subfonds) !important; }
.badge-series     { background-color: var(--mem-series) !important; }
.badge-subseries  { background-color: var(--mem-series) !important; opacity: 0.8; }
.badge-box        { background-color: var(--mem-box) !important; color: #333 !important; }
.badge-file       { background-color: var(--mem-file) !important; }
.badge-item       { background-color: var(--mem-item) !important; }
.badge-bundle     { background-color: var(--mem-bundle) !important; }
.badge-folder     { background-color: var(--mem-folder) !important; }
.badge-volume     { background-color: var(--mem-volume) !important; }

/* ── Search Results ──────────────────────────────────── */

.search-result-item {
    cursor: pointer;
    transition: background-color 0.15s;
}

.search-result-item:hover {
    background-color: rgba(52, 152, 219, 0.05);
}

.search-result-item .highlight {
    background-color: #fff3cd;
    font-weight: bold;
    padding: 0 2px;
    border-radius: 2px;
}

.search-result-item .ref-id {
    font-family: monospace;
    font-size: 0.85em;
    color: #666;
}

/* ── Record Detail ───────────────────────────────────── */

.record-detail .breadcrumb {
    font-size: 0.85rem;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›" !important;
}

.record-meta dt {
    font-weight: 600;
    color: #555;
    margin-bottom: 0;
}

.record-meta dd {
    margin-bottom: 0.5rem;
}

.record-detail .card {
    margin-bottom: 0.5rem;
}

.thumbnail-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.thumbnail-gallery img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}

.thumbnail-gallery img:hover {
    border-color: var(--mem-accent);
}

.thumbnail-gallery img.thumbnail-selected {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px #dc3545;
}

.thumbnail-gallery.reorder-mode img {
    cursor: grab;
    opacity: 0.9;
}

.thumbnail-gallery.reorder-mode img.dragging {
    opacity: 0.3;
}

.thumbnail-gallery.reorder-mode img:hover {
    border-color: var(--mem-accent);
    transform: scale(1.05);
}

/* ── Notes ───────────────────────────────────────────── */

.note-item {
    border-left: 3px solid var(--mem-accent);
    padding-left: 12px;
    margin-bottom: 12px;
}

.note-item .note-meta {
    font-size: 0.8rem;
    color: #888;
}

.note-item .note-actions {
    opacity: 0;
    transition: opacity 0.15s;
}

.note-item:hover .note-actions {
    opacity: 1;
}

/* ── Lightbox ────────────────────────────────────────── */

.lightbox-content {
    background-color: rgba(0, 0, 0, 0.85) !important;
    border: none;
}

.lightbox-toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 10;
    display: flex;
    gap: 4px;
    align-items: center;
    background: rgba(0, 0, 0, 0.45);
    padding: 4px 8px;
    border-radius: 6px;
}

.lightbox-toolbar #lb-counter {
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.lightbox-body {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    cursor: grab;
}

.lightbox-body:active {
    cursor: grabbing;
}

.lightbox-img {
    max-width: none;
    max-height: none;
    transition: transform 0.15s ease;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    pointer-events: none;  /* let body handle all mouse events */
}

/* ── Offline indicator ───────────────────────────────── */

.offline-badge {
    background-color: #e74c3c;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
}

.offline-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

.thumbnail-offline {
    filter: grayscale(100%);
    opacity: 0.5;
    cursor: default !important;
}

/* ── Editable fields ─────────────────────────────────── */

.editable-field {
    position: relative;
}

.editable-field .edit-btn {
    opacity: 0;
    transition: opacity 0.15s;
    position: absolute;
    top: 0;
    right: 0;
}

.editable-field:hover .edit-btn {
    opacity: 1;
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 991.98px) {
    #sidebar {
        min-height: auto !important;
    }
}

/* ── Animations ──────────────────────────────────────── */

.flash-icon {
    animation: flash 1s ease-in-out infinite;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

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

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

/* ── Tour ────────────────────────────────────────────── */

.tour-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10000;
}

.tour-highlighted {
    position: relative;
    z-index: 10001 !important;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.6), 0 0 15px rgba(13, 110, 253, 0.3);
    border-radius: 4px;
    background: white;
}

.tour-tooltip {
    position: fixed;
    z-index: 10002;
    background: #2c3e50;
    color: #fff;
    border-radius: 8px;
    padding: 12px 16px;
    max-width: 320px;
    min-width: 240px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    font-size: 0.85rem;
    display: none;
}

.tour-tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.tour-tooltip-body {
    margin-bottom: 10px;
    line-height: 1.4;
    opacity: 0.9;
}

.tour-tooltip-footer {
    display: flex;
    justify-content: space-between;
    gap: 6px;
}

/* ── Print ───────────────────────────────────────────── */

@media print {
    .navbar, #sidebar, #search-area, .note-actions, .edit-btn {
        display: none !important;
    }
    #main-content {
        margin: 0 !important;
        padding: 0 !important;
    }
}

/* Year range inputs — hide spinners for cleaner look */
#year-from::-webkit-outer-spin-button,
#year-from::-webkit-inner-spin-button,
#year-to::-webkit-outer-spin-button,
#year-to::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
#year-from, #year-to {
    -moz-appearance: textfield;
    text-align: center;
}
#date-mode-toggle {
    padding: 0.25rem 0.4rem;
    font-size: 0.8rem;
    line-height: 1.5;
    height: calc(1.5em + 0.5rem + calc(var(--bs-border-width) * 2));
}

/* Backup action items in user dropdown */
.backup-action {
    background-color: #fff3cd !important;
    border-left: 3px solid #dc3545;
}
.backup-action:hover {
    background-color: #ffe69c !important;
}
.backup-action.disabled {
    background-color: #f8f8f8 !important;
    border-left-color: #ccc;
}

/* Notes inset card in listings */
.notes-inset {
    background: #f8f9fa;
    border-left: 3px solid var(--mem-accent);
    padding: 8px 12px;
    margin: 6px 0 2px 0;
    border-radius: 0 4px 4px 0;
    font-size: 0.85rem;
}
.notes-inset .note-entry {
    padding: 4px 0;
    border-bottom: 1px solid #e9ecef;
}
.notes-inset .note-entry:last-child {
    border-bottom: none;
}
.notes-inset .note-meta {
    font-size: 0.75rem;
    color: #888;
}
.notes-inset .note-delete-btn {
    opacity: 0;
    transition: opacity 0.15s;
}
.notes-inset .note-entry:hover .note-delete-btn {
    opacity: 1;
}
.note-toggle-btn {
    color: var(--mem-accent);
    cursor: pointer;
}
.note-toggle-btn:hover {
    color: var(--mem-dark);
}

/* ── Year Input Clear Buttons ───────────────────────── */

.year-input-wrap {
    position: relative;
    display: inline-block;
}

.year-clear-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #999;
    font-size: 0.85rem;
    line-height: 1;
    padding: 0 3px;
    cursor: pointer;
    z-index: 2;
}
.year-clear-btn:hover {
    color: #333;
}

