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

html, body {
    height: 100%;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f5f5f5;

    /* Sticky-Footer: Footer klebt unten, wenn Content kürzer als Viewport ist */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Header */
header {
    background-color: #4CAF50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    flex-shrink: 0; /* nicht zusammenstauchen bei langen Seiten (Sticky-Footer Layout) */
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.8rem;
}

nav ul {
    display: flex;
    list-style: none;
    padding-top: 2px;
}

nav ul li {
    margin-left: 1.5rem;
}

nav ul li a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

nav ul li a:hover, 
nav ul li a.active {
    color: #e8f5e9;
    border-bottom: 2px solid #e8f5e9;
}

/* Main Content */
main {
    padding: 1rem 0;
    flex: 1 0 auto; /* nimmt Resthöhe ein, damit Footer nach unten gedrückt wird */
}

/* Map Container */
.map-container {
    margin-bottom: 2rem;
    position: relative;
}

.map-tagbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    margin-bottom: 10px;
}

.map-tagbar__inner {
    display: flex;
    gap: 8px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding-bottom: 2px; /* Platz fuer unteren Pixel-Schatten der Tags */
}

.map-tag {
    font-size: 0.65rem;
    padding: 6px 10px;
    white-space: nowrap;
    width: auto;
    flex: 0 0 auto;
}

@media (max-width: 768px) {
    /* Mobile: Tag-Leiste als Overlay, sonst wird sie durch fixen Karten-Viewport/overflow-hidden "weggedrückt" */
    .map-tagbar {
        position: absolute;
        top: 10px;
        left: 10px;
        right: 10px;
        margin: 0;
        z-index: 1100;
        padding: 8px;
    }

    .map-tagbar__inner {
        overflow: hidden;
    }

    .map-tag {
        font-size: 0.55rem;
        padding: 5px 8px;
        width: auto;
        max-width: none;
        overflow: visible;
        text-overflow: clip;
        flex: 0 0 auto;
    }
}

.map-tag.is-off {
    opacity: 0.45;
    filter: grayscale(1);
}

.map-tag--more {
    flex: 0 0 auto;
}

.map-tags-menu {
    position: absolute;
    top: 12px;
    left: auto;
    right: 12px;
    transform: none;
    z-index: 1300;
    width: max-content;
    min-width: 200px;
    max-width: calc(100% - 24px);
    max-height: calc(100% - 24px);
    margin: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.map-tags-menu__list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 55vh;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 3px 4px 2px 3px;
}

.map-tags-menu__list::-webkit-scrollbar {
    width: 6px;
}

.map-tags-menu__list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.map-tags-menu__list::-webkit-scrollbar-thumb {
    background: var(--secondary-color, #343a40);
    border-radius: 3px;
}

.map-tags-menu__actions {
    padding: 10px 0 4px;
    border-top: 2px solid rgba(0, 0, 0, 0.1);
    margin-top: 4px;
}

.map-tags-menu__actions .pixel-btn {
    font-size: 0.55rem;
    padding: 6px 10px;
    width: 100%;
    white-space: nowrap;
}

.map-tags-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--secondary-color, #343a40);
}

.map-tags-menu__item input {
    width: auto;
    transform: scale(1.1);
}

#map {
    height: 500px;
    width: 100%;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.map-options-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1200;
}

.map-options {
    position: absolute;
    top: 12px;
    right: 12px;
    width: min(320px, calc(100% - 24px));
    z-index: 1300;
}

.map-options__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}

.map-options__title {
    font-family: 'Press Start 2P', monospace;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--secondary-color, #343a40);
}

.map-options__close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 2px 6px;
}

@media (max-width: 480px) {
    /* Auf Mobile den X-Button optisch weiter rechts anliegend */
    .map-options.pixel-container {
        padding-right: 10px;
    }

    .map-options__close {
        padding-right: 2px;
        margin-right: -2px;
    }

    .map-tagbar {
        padding: 8px;
    }

}

.map-options__section {
    margin-top: 10px;
}

.map-options__action {
    width: 100%;
}

.map-options__toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--secondary-color, #343a40);
}

.map-options__toggle input {
    width: auto;
    transform: scale(1.1);
}

.map-options__label {
    display: block;
    margin-bottom: 8px;
    font-family: 'Press Start 2P', monospace;
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--secondary-color, #343a40);
}

.map-options__select {
    width: 100%;
}

body.cinema-mode header,
body.cinema-mode footer.site-footer {
    display: none !important;
}

body.cinema-mode main {
    padding: 0 !important;
    margin-top: 0 !important;
}

body.cinema-mode .container {
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
}

body.cinema-mode .map-container {
    margin: 0 !important;
}

body.cinema-mode #map {
    height: 100vh !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.map-container:fullscreen {
    margin: 0;
    padding: 0;
}

.map-container:fullscreen #map {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
}

.map-instructions {
    margin-top: 1rem;
    padding: 0.8rem;
    background-color: #e8f5e9;
    border-radius: 4px;
    color: #2e7d32;
}

/* Form Styles */
#automaten-form {
    background-color: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 700px;
    margin: 0 auto 2rem;
}

#automaten-form h2 {
    color: #2e7d32;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid #e8f5e9;
    padding-bottom: 0.5rem;
}

.form-group {
    margin-bottom: 1.2rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input, select, textarea {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 3px rgba(76, 175, 80, 0.3);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

button {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #4CAF50;
    color: white;
}

.btn-primary:hover {
    background-color: #388E3C;
}

.btn-secondary {
    background-color: #f5f5f5;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background-color: #eee;
}

/* Utility Classes */
.hidden {
    display: none;
}

/* Footer */
footer {
    background-color: #333;
    color: white;
}

footer.site-footer {
    padding: 1.5rem 0;
    text-align: center;
    margin-top: auto; /* Sticky am unteren Rand bei kurzen Seiten */
    flex-shrink: 0; /* Footer nicht zusammenstauchen */
}

.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.footer-copy {
    margin: 0;
    font-size: 0.9rem;
}

.footer-nav a {
    color: #fff;
    text-decoration: underline;
}

.footer-nav a:hover,
.footer-nav a:focus {
    color: #e8f5e9;
}

/* Responsive Styles */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        text-align: center;
    }
    
    nav ul {
        margin-top: 1rem;
    }
    
    nav ul li {
        margin: 0 0.7rem;
    }
    
    #map {
        height: 400px;
    }

    .footer-inner {
        flex-direction: column;
        justify-content: center;
        gap: 6px;
    }
}

/* Karten-Seite: Footer auf Mobile ausblenden (maximale Kartenfläche) */
@media (max-width: 768px) {
    body.page-map footer.site-footer {
        display: none;
    }
}

/* Map-Controls: Touch-Geräte brauchen unten etwas Luft, Desktop (auch klein gezogen) nicht. */
@media (max-width: 768px) and (hover: none) and (pointer: coarse) {
    body.page-map .leaflet-bottom.leaflet-right,
    body.page-map .leaflet-bottom.leaflet-left {
        /* wieder am unteren Rand, nur Safe-Area berücksichtigen */
        bottom: env(safe-area-inset-bottom);
    }

    /* Attribution hat praktisch keinen Margin und wird sonst gerne von der Browser-UI unten "abgeschnitten" */
    body.page-map .leaflet-control-attribution {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    nav ul {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    nav ul li {
        margin: 0.5rem;
    }
    
    #map {
        height: 300px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    button {
        width: 100%;
        margin-bottom: 0.5rem;
    }
}

/* ===================== MAP LOADING INDICATOR ===================== */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 12px;
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
    font-size: 14px;
    color: #333;
    pointer-events: none;
    transition: opacity 0.2s;
}
.map-loading.hidden {
    opacity: 0;
    pointer-events: none;
}
.map-loading__spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: map-spin 0.7s linear infinite;
}
@keyframes map-spin {
    to { transform: rotate(360deg); }
}

/* ===================== MAP EMPTY STATE ===================== */
.map-empty-state {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 243, 205, 0.95);
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 12px 20px;
    font-size: 13px;
    color: #856404;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.map-empty-state.hidden {
    display: none;
}
.map-empty-state a {
    color: #0056b3;
    text-decoration: underline;
}

/* ===================== MAP DB WARNING ===================== */
.map-db-warning {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(248, 215, 218, 0.95);
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 10px 18px;
    font-size: 12px;
    color: #721c24;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.map-db-warning.hidden {
    display: none;
}