/* Grundlegende Stile */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #10b981;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --bg-light: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    color: var(--text-dark);
}

body {
    overflow: hidden; /* Nur für Karten-Seite */
}

body.timeline-page {
    overflow-y: auto; /* Scrolling für Timeline-Seite */
    height: auto;
}

#map {
    width: 100%;
    height: 100%;
}

/* Custom Pin Markers */
.custom-pin-marker {
    background: transparent !important;
    border: none !important;
}

.custom-pin-marker:hover {
    z-index: 1000 !important;
}

.custom-pin-marker > div:first-child {
    transition: all 0.2s ease;
}

.custom-pin-marker:hover > div:first-child {
    transform: scale(1.15) !important;
}

/* Kategorie-Auswahl beim Klick auf die Karte */
#category-selector {
    position: absolute;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    padding: 16px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 1000;
    transform: translate(-50%, -100%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border-color);
    min-width: 200px;
}

#category-selector h4 {
    margin: 0 0 12px 0;
    text-align: center;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-dark);
}

#category-selector button {
    border: 1px solid var(--border-color);
    background-color: white;
    padding: 10px 16px;
    cursor: pointer;
    border-radius: var(--radius-md);
    width: 100%;
    font-weight: 500;
    transition: all 0.2s ease;
    font-size: 14px;
}

#category-selector button:hover {
    background-color: var(--bg-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Seitenleiste (Info-Panel) */
#info-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 400px;
    height: 100%;
    background-color: white;
    box-shadow: var(--shadow-xl);
    z-index: 1001;
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

#info-panel.hidden {
    transform: translateX(-100%);
}

/* Mobile: Vollbild-Seitenleiste */
@media (max-width: 768px) {
    #info-panel {
        width: 100%;
        right: 0;
    }
}

.panel-header {
    display: flex;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    border-bottom: 1px solid var(--border-color);
    color: white;
    gap: 12px;
}

.panel-header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-action-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    cursor: pointer;
    color: white;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.panel-header img {
    width: 28px;
    height: 28px;
    margin-right: 12px;
    filter: brightness(0) invert(1);
}

.panel-header h2 {
    margin: 0;
    font-size: 1.3em;
    font-weight: 600;
    flex-grow: 1;
}

#panel-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: white;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    line-height: 1;
}

#panel-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.panel-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    gap: 16px;
}

.panel-content h3 {
    margin: 0 0 8px 0;
    font-size: 1.1em;
    font-weight: 600;
    color: var(--text-dark);
}

.panel-content textarea {
    width: 100%;
    min-height: 120px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
    transition: border-color 0.2s ease;
    font-size: 14px;
}

.panel-content textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Date Range Section */
.date-range-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background-color: var(--bg-light);
    border-radius: var(--radius-md);
}

/* Address Section */
.address-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background-color: var(--bg-light);
    border-radius: var(--radius-md);
}

.address-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fetch-address-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    transition: transform 0.2s ease;
}

.fetch-address-btn:hover {
    transform: rotate(180deg);
}

.fetch-address-btn.loading {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.address-section small {
    color: var(--text-light);
    font-size: 12px;
}

.address-section input {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.address-section input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.date-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.date-input-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
}

.date-input-group input[type="date"] {
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.date-input-group input[type="date"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Image Gallery */
#panel-image-container {
    width: 100%;
    margin-bottom: 15px;
}

.image-gallery {
    position: relative;
    width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.gallery-main-image {
    width: 100%;
    height: 350px;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.3s ease;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.gallery-main-image:hover {
    transform: scale(1.02);
}

.gallery-thumbnails {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    overflow-x: auto;
    padding: 4px 0;
}

.gallery-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.gallery-thumbnail:hover {
    border-color: var(--primary-color);
}

.gallery-thumbnail.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

#panel-image {
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

#panel-image.hidden {
    display: none;
}

.image-upload-section {
    margin-top: 8px;
    margin-bottom: 15px;
}

.website-link-section {
    margin-top: 8px;
    margin-bottom: 15px;
}

.website-link-section input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    box-sizing: border-box;
    transition: border-color 0.2s ease;
}

.website-link-section input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.image-upload-section input[type="text"] {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    box-sizing: border-box;
    margin-bottom: 10px;
    transition: border-color 0.2s ease;
}

.image-upload-section input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

#drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 30px 20px;
    text-align: center;
    color: var(--text-light);
    transition: all 0.2s ease;
    background-color: var(--bg-light);
}

#drop-zone:hover {
    border-color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.05);
}

#drop-zone.dragover {
    border-color: var(--secondary-color);
    background-color: rgba(16, 185, 129, 0.05);
    color: var(--secondary-color);
}

.panel-actions {
    display: flex;
    gap: 12px;
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.btn-primary {
    padding: 12px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    padding: 12px 20px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
}

.btn-secondary:hover {
    background-color: #059669;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-danger {
    padding: 12px 20px;
    background-color: var(--danger-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#start-route-btn {
    padding: 12px 20px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

#start-route-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#panel-save-btn {
    margin-top: 0;
    padding: 12px 20px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    align-self: flex-start;
}

#panel-save-btn:hover {
    background-color: #059669;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Behälter für Filter & Buttons */
.leaflet-bar#filter-container {
    display: flex;
    gap: 8px;
    background-color: white;
    padding: 8px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

#filter-container button {
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    background-color: white;
    cursor: pointer;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s ease;
}

#filter-container button:hover {
    background-color: var(--bg-light);
    transform: translateY(-1px);
}

#filter-container .filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

#filter-container #clear-routes-btn {
    border-color: var(--danger-color);
    background-color: var(--danger-color);
    color: white;
}

#filter-container #clear-routes-btn:hover {
    background-color: var(--danger-hover);
    border-color: var(--danger-hover);
}

#filter-container #save-route-btn {
    border-color: var(--secondary-color);
    background-color: var(--secondary-color);
    color: white;
}

#filter-container #save-route-btn:hover {
    background-color: #059669;
    border-color: #059669;
}

/* Stil für den Routen-Tooltip */
.route-summary-tooltip {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #777;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 12px;
    text-align: center;
    white-space: nowrap;
}

/* Versteckt den leeren Standard-Routen-Container */
.leaflet-routing-container {
    display: none !important;
}

/* Stil für den Löschen-Button im Popup der Route */
.delete-route-btn {
    margin-top: 8px;
    padding: 6px 10px;
    background-color: #dc3545;
    color: white;
    border: 1px solid #dc3545;
    border-radius: 4px;
    cursor: pointer;
}
.delete-route-btn:hover {
    background-color: #c82333;
}

/* Stile für Layout, Nav, Forms */
body {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

body.timeline-page {
    height: auto;
    min-height: 100vh;
}

main.content {
    flex-grow: 1;
    overflow: hidden;
}

body.timeline-page main.content {
    overflow: visible;
}

.main-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #1e40af 0%, var(--primary-color) 100%);
    color: white;
    padding: 0 24px;
    height: 60px;
    flex-shrink: 0;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 20px;
}

.nav-brand {
    color: white;
    text-decoration: none;
    font-size: 1.6em;
    font-weight: 700;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
}

.nav-links {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-links a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    transition: background-color 0.2s ease;
}

.nav-links a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Offline-Indikator */
.offline-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    font-size: 14px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.offline-indicator.online {
    background-color: rgba(16, 185, 129, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ef4444;
    animation: pulse 2s infinite;
}

.offline-indicator.online .status-dot {
    background-color: #10b981;
    animation: none;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.status-text {
    font-weight: 500;
}

.last-update {
    font-size: 12px;
    opacity: 0.8;
}

.form-container {
    width: 100%;
    max-width: 420px;
    margin: 60px auto;
    padding: 32px;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.form-container h2 {
    margin-top: 0;
    margin-bottom: 24px;
    color: var(--text-dark);
    font-size: 1.8em;
    font-weight: 700;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 14px;
}

.form-control {
    width: 100%;
    padding: 12px;
    box-sizing: border-box;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

.btn {
    padding: 14px 20px;
    border: none;
    border-radius: var(--radius-md);
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    width: 100%;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.form-link {
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
}

.form-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.form-link a:hover {
    text-decoration: underline;
}

.alert {
    padding: 12px 16px;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Image Modal/Lightbox */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.image-modal.active {
    display: flex;
}

.image-modal-content {
    position: relative;
    width: 85vw;
    height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.image-modal-img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
}

.image-modal-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.image-modal-close:hover {
    background-color: var(--danger-color);
    color: white;
    transform: scale(1.1);
}

.image-modal-delete {
    position: absolute;
    top: -50px;
    left: 0;
    background: var(--danger-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.image-modal-delete:hover {
    background-color: var(--danger-hover);
    transform: scale(1.1);
}

.image-modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.image-modal-nav:hover {
    background: white;
    transform: translateY(-50%) scale(1.1);
}

.image-modal-prev {
    left: 20px;
}

.image-modal-next {
    right: 20px;
}

/* Timeline View */
.timeline-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px 80px;
    background-color: var(--bg-light);
    min-height: calc(100vh - 60px); /* 60px = Navigation Höhe */
}

.timeline-header {
    text-align: center;
    margin-bottom: 50px;
}

.timeline-header h1 {
    font-size: 2.5em;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.timeline-header p {
    color: var(--text-light);
    font-size: 1.1em;
}

.timeline {
    position: relative;
    padding: 20px 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-color), var(--secondary-color));
    border-radius: 2px;
}

.timeline-item {
    margin-bottom: 60px;
    position: relative;
}

.timeline-item:nth-child(odd) .timeline-content {
    margin-left: auto;
    margin-right: 50%;
    padding-right: 50px;
}

.timeline-item:nth-child(even) .timeline-content {
    margin-right: auto;
    margin-left: 50%;
    padding-left: 50px;
}

.timeline-marker {
    position: absolute;
    left: 50%;
    top: 20px;
    transform: translateX(-50%);
    width: 20px;
    height: 20px;
    background-color: var(--primary-color);
    border: 4px solid white;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
    z-index: 1;
}

.timeline-content {
    background: white;
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.timeline-content:hover {
    box-shadow: var(--shadow-xl);
    transform: translateY(-4px);
}

.timeline-date {
    display: inline-block;
    padding: 6px 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
    color: white;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.timeline-title {
    font-size: 1.4em;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 12px 0;
}

.timeline-description {
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 16px;
}

.timeline-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.timeline-image {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
}

.timeline-image:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}