/* history.css - Premium Modern Design */

:root {
    --primary: #c29b62; /* Antique gold for history vibe */
    --primary-hover: #e0b475;
    --bg-dark: #121212;
    --text-light: #f5f5f5;
    --text-muted: #a0a0a0;
    --glass-bg: rgba(20, 20, 20, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --panel-width: 400px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-light);
    overflow: hidden; /* Prevent scrolling, app is full screen */
}

#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

#content {
    flex: 1;
    display: flex;
    width: 100%;
    height: 100%;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
}

/* Map Container */
#map-container {
    flex: 1;
    position: relative;
    height: 100%;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
    background: #1a1a1a;
}

/* Leaflet Dark Theme Overrides */
.leaflet-container {
    background: #1a1a1a;
    font-family: 'Inter', sans-serif;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    color: var(--text-light);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}
.leaflet-popup-content {
    margin: 14px 18px;
    font-size: 14px;
}
.leaflet-popup-close-button {
    color: var(--text-muted) !important;
}

/* App Header */
.app-header {
    position: absolute;
    top: 24px;
    left: 24px;
    z-index: 1000;
    pointer-events: none;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.back-to-home {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.3s ease;
    text-shadow: none;
    background: rgba(18, 18, 18, 0.6);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(8px);
    width: fit-content;
}

.back-to-home:hover {
    color: var(--primary);
    background: rgba(18, 18, 18, 0.8);
    border-color: var(--primary);
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: #fff;
    letter-spacing: -0.5px;
}

.app-header .subtitle {
    font-size: 1.1rem;
    color: var(--primary);
    font-weight: 300;
}

/* Search Container */
.search-container {
    margin-top: 20px;
    position: relative;
    width: 300px;
    pointer-events: auto; /* Re-enable pointer events for the search inside the header */
}

.search-input {
    width: 100%;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: var(--transition);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.search-input:focus {
    box-shadow: 0 0 0 2px var(--primary);
}

.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.search-results.hidden {
    display: none;
}

.search-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--glass-border);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

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

.search-item:hover {
    background: rgba(194, 155, 98, 0.2);
}

.search-item-title {
    font-weight: 600;
    color: #fff;
    font-size: 0.95rem;
}

.search-item-job {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Timeline / Slider */
.timeline-container {
    position: absolute;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    padding: 20px 32px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.timeline-header {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    text-shadow: 0 0 10px rgba(194, 155, 98, 0.3);
}

.slider-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 16px;
}

.year-min, .year-max {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 24px;
    width: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    margin-top: -10px;
    box-shadow: 0 0 10px rgba(194, 155, 98, 0.5);
    transition: transform 0.1s;
}

input[type=range]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 4px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
}

/* Detail Panel */
.detail-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: var(--panel-width);
    height: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    z-index: 1001;
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
}

.detail-panel.hidden {
    transform: translateX(100%);
}

.panel-header {
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.panel-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    color: #fff;
    transform: scale(1.1);
}

.panel-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.gallery-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 16px;
    margin-bottom: 16px;
}

.gallery-img {
    height: 140px;
    border-radius: 8px;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: var(--transition);
}

.gallery-img:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.5);
}

.gallery-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 150px;
    max-width: 200px;
}

.gallery-meta {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-muted);
}

.gallery-year {
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 2px;
}

.gallery-desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notizen-section {
    margin-bottom: 24px;
    line-height: 1.6;
    font-size: 0.95rem;
    color: #ddd;
}

.bewohner-section h3 {
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: #fff;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 8px;
}

.timeline-list {
    list-style: none;
    position: relative;
    padding-left: 20px;
}

.timeline-list::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--glass-border);
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -25px;
    top: 6px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 8px var(--primary);
}

.timeline-year {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 4px;
}

.timeline-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: #fff;
}

.timeline-job {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-graph {
    margin-top: 8px;
    background: rgba(194, 155, 98, 0.1);
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
}

.btn-graph:hover {
    background: var(--primary);
    color: var(--bg-dark);
}

/* Modal Graph */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    width: 90%;
    height: 90%;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.modal-body {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#d3-graph-container {
    width: 100%;
    height: 100%;
}

.image-modal-content {
    width: 90%;
    max-width: 1200px;
    height: 90%;
}

.image-modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    gap: 20px;
}

#image-modal-img {
    max-width: 100%;
    max-height: calc(100% - 100px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.image-modal-meta {
    text-align: center;
    max-width: 800px;
}

.image-modal-meta .gallery-year {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.image-modal-meta .gallery-desc {
    font-size: 1.05rem;
    -webkit-line-clamp: unset;
    display: block;
    color: #eee;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        top: 16px;
        left: 16px;
        right: 16px; /* Ensure header doesn't cause horizontal scroll */
        width: calc(100% - 32px);
    }

    .app-header h1 {
        font-size: 1.8rem;
    }

    .app-header .subtitle {
        font-size: 0.95rem;
    }

    .search-container {
        width: 100%;
        max-width: none;
        margin-top: 12px;
    }

    .detail-panel {
        width: 100%;
    }

    /* Move Leaflet controls down on mobile to avoid overlap with the header */
    .leaflet-top.leaflet-right {
        top: 160px;
    }

    /* Adjust timeline container for mobile */
    .timeline-container {
        bottom: 20px;
        padding: 12px 16px;
        width: 95%;
    }

    .timeline-header {
        font-size: 1.5rem;
    }

    .slider-wrapper {
        gap: 8px;
    }
}

/* Frontend Photo Tags */
.frontend-foto-tag {
    position: absolute;
    width: 16px;
    height: 16px;
    margin-left: -8px;
    margin-top: -8px;
    background-color: rgba(194, 155, 98, 0.8); /* Using var(--primary) with opacity */
    border: 2px solid white;
    border-radius: 50%;
    pointer-events: auto;
    box-shadow: 0 0 5px rgba(0,0,0,0.5);
    transition: transform 0.2s, background-color 0.2s;
}

.frontend-foto-tag.has-person-link {
    cursor: pointer;
    background-color: rgba(231, 76, 60, 0.8); /* Distinct color for linked tags */
}

.frontend-foto-tag.has-person-link:hover {
    transform: scale(1.2);
    background-color: rgba(231, 76, 60, 1);
}

.frontend-foto-tag-label {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
}

.frontend-foto-tag:hover .frontend-foto-tag-label,
#image-modal-tags.show-names .frontend-foto-tag-label {
    opacity: 1;
}

.gallery-tags-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    z-index: 10;
}

.gallery-tags-indicator svg {
    width: 14px;
    height: 14px;
}
