/* Stammbaum - Global Styles */

:root {
    --primary: #2c5f2d;
    --primary-light: #97bc62;
    --bg-light: #f8f9fa;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Navbar */
.navbar {
    position: relative;
    z-index: 1030; /* above tree toolbar (z-index: 10) and Bootstrap offcanvas */
}

.navbar-brand i {
    color: var(--primary-light);
}

/* Cards */
.card {
    border: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Person Avatar Placeholder */
.avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #dee2e6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.avatar-placeholder.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
}

.avatar-placeholder.avatar-lg {
    width: 80px;
    height: 80px;
    font-size: 2rem;
}

.avatar-placeholder svg {
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.avatar-img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.avatar-img.avatar-sm {
    width: 32px;
    height: 32px;
}

.avatar-img.avatar-lg {
    width: 80px;
    height: 80px;
}

/* Offcanvas Panel */
.offcanvas {
    width: 450px !important;
}

@media (max-width: 576px) {
    .offcanvas {
        width: 100% !important;
    }
}

.offcanvas-body .nav-tabs .nav-link {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
}

/* Person Detail Panel */
.person-detail-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #dee2e6;
}

.person-detail-header .info h5 {
    margin-bottom: 0.25rem;
}

.person-detail-header .info .text-muted {
    font-size: 0.85rem;
}

/* Relation links */
.relation-link {
    cursor: pointer;
    color: var(--primary);
    text-decoration: none;
}

.relation-link:hover {
    text-decoration: underline;
}

/* Media gallery */
.media-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
}

.media-gallery .media-item {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 0.375rem;
    cursor: pointer;
}

.media-gallery .media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-gallery .media-item .media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 0.7rem;
    padding: 2px 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.media-gallery .media-item:hover .media-overlay {
    opacity: 1;
}

.media-gallery .media-item .media-profile-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    color: #ffc107;
    font-size: 0.85rem;
    text-shadow: 0 0 3px rgba(0,0,0,0.6);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

button.media-profile-badge:hover {
    color: #dc3545;
}

.media-gallery .media-item .media-actions {
    position: absolute;
    top: 4px;
    right: 4px;
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.media-gallery .media-item:hover .media-actions {
    opacity: 1;
}

.media-gallery .media-item .media-action-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border-radius: 50%;
    background: rgba(255,255,255,0.9);
}

/* Upload dropzone */
.upload-dropzone {
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(44, 95, 45, 0.05);
}

/* Audit log */
.audit-entry {
    padding: 0.5rem 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
}

.audit-entry:last-child {
    border-bottom: none;
}

/* Search results */
.search-results {
    max-height: 300px;
    overflow-y: auto;
}

.search-result-item {
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 0.25rem;
}

.search-result-item:hover {
    background: var(--bg-light);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: block;
}

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

/* Toolbar */
.tree-toolbar {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 10;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tree-toolbar .btn {
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

@media (max-width: 576px) {
    .tree-toolbar {
        gap: 0.25rem;
    }

    .tree-toolbar .btn {
        padding: 0.2rem 0.4rem;
        font-size: 0.75rem;
    }

    /* Hide text labels on mobile, show only icons */
    .tree-toolbar .btn-text {
        display: none;
    }
}

/* ===== Dark Mode ===== */
[data-bs-theme="dark"] {
    --primary: #97bc62;
    --primary-light: #b8d88a;
    --bg-light: #1a1d21;
}

[data-bs-theme="dark"] .card {
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-bs-theme="dark"] .avatar-placeholder {
    background: #3a3f44;
    color: #868e96;
}

[data-bs-theme="dark"] .person-detail-header {
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] .relation-link {
    color: var(--primary);
}

[data-bs-theme="dark"] .upload-dropzone {
    border-color: #495057;
    color: #adb5bd;
}

[data-bs-theme="dark"] .upload-dropzone:hover,
[data-bs-theme="dark"] .upload-dropzone.dragover {
    border-color: var(--primary);
    background: rgba(151, 188, 98, 0.1);
}

[data-bs-theme="dark"] .audit-entry {
    border-bottom-color: #3a3f44;
}

[data-bs-theme="dark"] .search-result-item:hover {
    background: #2b3035;
}

[data-bs-theme="dark"] .empty-state {
    color: #868e96;
}

[data-bs-theme="dark"] .spinner-overlay {
    background: rgba(26, 29, 33, 0.85);
}

[data-bs-theme="dark"] .tree-toolbar .btn {
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
}

[data-bs-theme="dark"] .navbar-brand i {
    color: var(--primary);
}
