/* --- GRUNDEINSTELLUNGEN --- */
:root {
    --primary-color: #007aff;
    --bg-color: #f4f4f9;
    --text-color: #333;
    --success-bg: #e6f7ec;
    --success-text: #0a6839;
    --error-bg: #fdecea;
    --error-text: #a51e23;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    /* Verhindert horizontales Scrollen */
    overflow-x: hidden; 
}

/* --- UPLOAD CONTAINER (FORMULAR) --- */
.upload-container {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    text-align: center;
    width: 100%;
    max-width: 450px;
    margin: 0 auto; /* Zentriert den Container */
    box-sizing: border-box;
}

h2 {
    margin-top: 0;
    font-weight: 700;
    font-size: 1.5rem;
}

p {
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

/* Verstecktes Input-Feld */
#filesToUpload {
    display: none;
}

/* Das "Datei auswählen" Feld */
.file-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background-color: #f8f9fa;
    color: #555;
    border: 2px dashed #ccc;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
    min-height: 60px; /* Groß genug für Daumen */
    transition: all 0.2s;
}

.file-label:active {
    background-color: #e2e2e2;
    transform: scale(0.98);
}

/* Der "Hochladen" Button */
button[type="submit"] {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0,122,255, 0.2);
    transition: transform 0.1s;
    -webkit-appearance: none; /* Wichtig für iOS Button Styling */
}

button[type="submit"]:active {
    transform: scale(0.98);
    background-color: #005ecf;
}

/* Nachrichten Boxen */
.message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95em;
    text-align: left;
    line-height: 1.4;
}
.message.success { background-color: var(--success-bg); color: var(--success-text); border: 1px solid #b7ebc9; }
.message.error { background-color: var(--error-bg); color: var(--error-text); border: 1px solid #f9c6c5; }

/* Link zur Galerie */
.gallery-link-wrapper {
    margin-top: 25px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}
.gallery-link-wrapper a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1em;
    display: inline-block;
    padding: 10px;
}

/* --- GALERIE GRID --- */
.gallery-header {
    max-width: 1000px;
    margin: 0 auto 20px auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-back {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    background: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.gallery-container {
    display: grid;
    /* Responsive Grid: Passt Spaltenanzahl automatisch an */
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); 
    gap: 8px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
    padding-bottom: 60px;
}

.gallery-item {
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1 / 1; /* Immer quadratisch */
    background-color: #ddd; /* Platzhalterfarbe beim Laden */
    position: relative;
}

.gallery-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* --- LIGHTBOX (MODAL) FÜR MOBILE --- */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px); /* Schöner Unschärfe-Effekt im Hintergrund */
}

.modal-content {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    position: relative;
}

#modal-image {
    max-width: 100%;
    max-height: 80vh; /* Platz lassen für Buttons unten/oben */
    object-fit: contain;
    user-select: none;
}

/* Große Klickflächen für Navigation */
.close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: 300;
    line-height: 30px;
    padding: 10px;
    z-index: 2002;
    cursor: pointer;
    background: rgba(0,0,0,0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    text-align: center;
}

.prev, .next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 40px;
    font-weight: bold;
    padding: 20px;
    cursor: pointer;
    user-select: none;
    z-index: 2001;
    background: rgba(0,0,0,0.2); /* Hintergrund damit man sie auf hellen Bildern sieht */
    border-radius: 5px;
}

.next { right: 10px; }
.prev { left: 10px; }

.caption-container {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    color: #ccc;
    pointer-events: none;
}

/* --- MOBILE SPECIFIC TWEAKS (MEDIA QUERY) --- */
@media screen and (max-width: 600px) {
    body {
        padding: 10px; /* Weniger Rand außen */
        background-color: #fff; /* Auf Mobile oft sauberer ganz weiß */
    }

    .upload-container {
        padding: 20px 15px;
        box-shadow: none; /* Flaches Design auf Mobile */
        border: 1px solid #f0f0f0;
    }

    h2 { font-size: 1.3rem; }
    
    /* Input Font-Size 16px verhindert iOS Auto-Zoom beim Tippen */
    input, select, textarea, button {
        font-size: 16px; 
    }

    /* Galerie Anpassungen */
    .gallery-container {
        gap: 4px; /* Engerer Abstand für mehr Bildfläche */
        grid-template-columns: repeat(3, 1fr); /* 3 Bilder nebeneinander auf Handy */
    }

    /* Auf sehr kleinen Screens (iPhone SE etc) nur 2 Bilder */
    @media screen and (max-width: 350px) {
        .gallery-container {
            grid-template-columns: repeat(2, 1fr);
        }
    }

    /* Modal Navigation mobilfreundlicher */
    .prev, .next {
        font-size: 25px; /* Etwas kleiner damit sie das Bild nicht verdecken */
        padding: 15px;
        background: rgba(0,0,0,0.4);
        border-radius: 50%;
    }
}