/* ==========================================================================
   EDYG Fotogalerie
   Saubere CSS-Gesamtversion – Stand v1.5.1
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Variablen / Basis
   -------------------------------------------------------------------------- */

:root {
    --bg: #f5f7f9;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #68727d;
    --line: #dde3e8;
    --accent: #195b8c;
    --danger: #a32121;
    --ok: #267a3d;

    --radius: 14px;
    --radius-small: 10px;
    --shadow: 0 8px 30px rgba(18, 38, 52, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family:
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--accent);
    text-decoration: none;
}

img {
    max-width: 100%;
}

button,
input,
textarea,
select {
    font: inherit;
}


/* --------------------------------------------------------------------------
   2. Header / Navigation
   -------------------------------------------------------------------------- */

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;

    min-height: 72px;
    padding: 10px clamp(14px, 4vw, 34px);

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;

    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(8px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;

    color: var(--text);
    font-size: 1.1rem;
    font-weight: 750;
}

.site-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 170px;
    max-height: 54px;
    object-fit: contain;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.top-nav a {
    font-weight: 650;
}

.user-pill {
    padding: 7px 10px;
    border-radius: 999px;
    background: #edf2f6;
    font-size: 0.9rem;
}


/* --------------------------------------------------------------------------
   3. Seitenlayout
   -------------------------------------------------------------------------- */

.container {
    width: min(1180px, calc(100% - 28px));
    margin: 28px auto 60px;
}

.hero {
    margin-bottom: 24px;
    padding: clamp(22px, 5vw, 46px);

    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.hero h1 {
    margin: 0 0 8px;
    font-size: clamp(1.7rem, 4vw, 2.6rem);
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.9rem;
}

.empty {
    padding: 32px;
    text-align: center;
    color: var(--muted);
}

.panel {
    margin-bottom: 20px;
    padding: 20px;

    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px;
}

.card {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-body {
    padding: 16px;
}

.card h2,
.card h3 {
    margin: 0 0 8px;
}

.cover {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #e8edf1;
}


/* --------------------------------------------------------------------------
   4. Buttons / Aktionen
   -------------------------------------------------------------------------- */

.btn,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 10px 14px;

    border: 0;
    border-radius: var(--radius-small);

    background: var(--accent);
    color: #ffffff;

    font-weight: 700;
    cursor: pointer;
}

.btn.secondary,
button.secondary {
    background: #e8eef3;
    color: var(--text);
}

.btn.danger,
button.danger {
    background: var(--danger);
    color: #ffffff;
    border-color: var(--danger);
}

.btn.danger:hover,
button.danger:hover {
    filter: brightness(0.92);
}

button:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}


/* --------------------------------------------------------------------------
   5. Formulare / Login
   -------------------------------------------------------------------------- */

.form-grid {
    display: grid;
    gap: 14px;
}

.form-row {
    display: grid;
    gap: 6px;
}

label {
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    padding: 11px 12px;

    border: 1px solid #cfd7dd;
    border-radius: var(--radius-small);

    background: #ffffff;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.7rem 0;
}

.check-row input {
    width: auto;
}

.login-wrap {
    max-width: 440px;
    margin: 7vh auto;
}

.login-logo {
    display: block;
    width: auto;
    max-width: 180px;
    max-height: 76px;
    margin: 0 auto 22px;
}


/* --------------------------------------------------------------------------
   6. Meldungen / Status
   -------------------------------------------------------------------------- */

.flash {
    margin-bottom: 14px;
    padding: 12px 14px;

    border-radius: var(--radius-small);
    background: #eef3f7;
}

.flash.success {
    background: #e8f5eb;
    color: #195b2b;
}

.flash.error {
    background: #fae9e9;
    color: #7c1f1f;
}

.badge {
    display: inline-block;
    padding: 4px 8px;

    border-radius: 999px;
    background: #edf0f3;

    font-size: 0.83rem;
    font-weight: 700;
}

.badge.ok {
    background: #e8f4ea;
    color: #216733;
}


/* --------------------------------------------------------------------------
   7. Tabellen
   -------------------------------------------------------------------------- */

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 10px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}


/* --------------------------------------------------------------------------
   8. Upload
   -------------------------------------------------------------------------- */

.dropzone {
    padding: 30px;

    text-align: center;

    background: #fafcfd;
    border: 2px dashed #aebbc5;
    border-radius: var(--radius);

    transition: 0.2s;
}

.dropzone.drag {
    border-color: var(--accent);
    background: #edf6fc;
}

.progress {
    height: 10px;
    margin-top: 12px;

    overflow: hidden;
    border-radius: 999px;
    background: #e0e6ea;
}

.progress > span {
    display: block;
    width: 0;
    height: 100%;

    background: var(--accent);
    transition: width 0.15s;
}


/* --------------------------------------------------------------------------
   9. Fotogalerie / Admin-Fotos
   -------------------------------------------------------------------------- */

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.photo-tile {
    position: relative;
    overflow: hidden;

    background: #e7ebee;
    border-radius: var(--radius-small);
}

.photo-tile img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.photo-actions {
    position: absolute;
    right: 7px;
    bottom: 7px;
    left: 7px;

    display: flex;
    justify-content: flex-end;
    gap: 6px;
}

.photo-actions form {
    margin: 0;
}

.photo-actions button {
    padding: 7px 9px;
    background: rgba(20, 30, 38, 0.82);
    font-size: 0.78rem;
}

.photo-manage-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.admin-photo-tile {
    position: relative;
}

.photo-select {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;

    width: 34px;
    height: 34px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.58);
    border-radius: 8px;

    cursor: pointer;
}

.photo-select input {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
}

.danger-zone {
    border: 1px solid rgba(163, 33, 33, 0.35);
}


/* --------------------------------------------------------------------------
   10. Admin-Reihenfolge v1.5.1
   -------------------------------------------------------------------------- */

.order-buttons {
    display: flex;
    align-items: center;
    gap: 6px;
}

.order-buttons form {
    margin: 0;
}

.order-btn {
    min-width: 38px;
    height: 36px;
    padding: 0 10px;

    font-size: 18px;
    line-height: 1;
}


/* --------------------------------------------------------------------------
   11. Öffentliche Mehrsprachigkeit
   -------------------------------------------------------------------------- */

.public-language-bar {
    max-width: 1200px;
    margin: 8px auto 0;
    padding: 0 16px;

    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;

    font-size: 0.95rem;
}

.public-language-bar label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.public-language-bar select {
    width: auto;
    min-width: 130px;
    padding: 7px 34px 7px 10px;
    border-radius: 8px;
}


/* --------------------------------------------------------------------------
   12. Öffentliche Albumübersicht
   -------------------------------------------------------------------------- */

.public-albums {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
}

.public-album-card {
    overflow: hidden;

    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.11);
}

.public-album-card a {
    display: block;
    color: inherit;
    text-decoration: none;
}

.public-album-cover {
    overflow: hidden;
    aspect-ratio: 4 / 3;
    background: #eeeeee;
}

.public-album-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.public-album-body {
    padding: 15px 17px;
}

.public-album-body h2 {
    margin: 0 0 7px;
}

.public-gallery-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}


/* --------------------------------------------------------------------------
   13. Lightbox – aktuelle Navigation
   Pfeil links/rechts mittig, X oben rechts
   -------------------------------------------------------------------------- */

#lightbox {
    position: fixed;
    inset: 0;
    z-index: 999999;

    display: none;
    align-items: center;
    justify-content: center;

    padding: 24px;

    background: rgba(0, 0, 0, 0.94);

    touch-action: pan-y;
    user-select: none;
}

#lightbox.open {
    display: flex;
}

#lightbox .lightbox-stage {
    position: relative;

    width: min(96vw, 1600px);
    height: min(92vh, 1100px);

    display: flex;
    align-items: center;
    justify-content: center;
}

#lightbox .lightbox-image-wrap {
    position: relative;

    display: flex;
    align-items: center;
    justify-content: center;

    max-width: 100%;
    max-height: 100%;
}

#lightbox .lightbox-image-wrap img {
    display: block;

    width: auto;
    height: auto;

    max-width: 100%;
    max-height: 92vh;

    object-fit: contain;
}

#lightbox .lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 30;

    width: 46px;
    height: 46px;
    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;

    background: rgba(0, 0, 0, 0.62);
    color: #ffffff;

    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

#lightbox .lightbox-nav {
    position: absolute;
    top: 50%;
    z-index: 25;

    width: 54px;
    height: 70px;
    padding: 0;

    display: flex;
    align-items: center;
    justify-content: center;

    transform: translateY(-50%);

    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 14px;

    background: rgba(0, 0, 0, 0.52);
    color: #ffffff;

    font-size: 48px;
    line-height: 1;
    cursor: pointer;
}

#lightbox .lightbox-prev {
    left: 10px;
}

#lightbox .lightbox-next {
    right: 10px;
}

#lightbox .lightbox-counter {
    position: absolute;
    bottom: 12px;
    left: 50%;

    transform: translateX(-50%);

    padding: 5px 11px;

    border-radius: 999px;
    background: rgba(0, 0, 0, 0.58);
    color: #ffffff;

    font-size: 14px;
    white-space: nowrap;
}

#lightbox button:hover {
    background: rgba(0, 0, 0, 0.78);
}

#lightbox button:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 2px;
}


/* --------------------------------------------------------------------------
   14. Footer
   -------------------------------------------------------------------------- */

.site-footer {
    padding: 26px;
    text-align: center;
    color: var(--muted);
}


/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {

    .public-albums {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


@media (max-width: 700px) {

    .site-header {
        min-height: auto;
        align-items: flex-start;
    }

    .brand {
        gap: 9px;
        font-size: 1rem;
    }

    .site-logo {
        max-width: 125px;
        max-height: 46px;
    }

    .top-nav {
        justify-content: flex-end;
        gap: 9px;
        font-size: 0.92rem;
    }

    .user-pill {
        display: none;
    }

    .container {
        margin-top: 18px;
    }

    .gallery {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .photo-manage-head .actions {
        width: 100%;
    }

    .photo-manage-head .actions .btn {
        flex: 1;
    }

    .admin-photo-gallery .photo-select {
        width: 38px;
        height: 38px;
    }

    .order-buttons {
        flex-direction: column;
        align-items: stretch;
    }
}


@media (max-width: 600px) {

    /* Sprachwahl: Welt-Symbol + Text bleiben sichtbar */
    .public-language-bar {
        padding: 0 10px;
        gap: 7px;
        flex-wrap: nowrap;
    }

    .public-language-bar label {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        white-space: nowrap;
        font-size: 0.9rem;
    }

    .public-language-bar select {
        min-width: 108px;
        max-width: 145px;
        font-size: 0.9rem;
    }

    .public-albums {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .public-gallery-top .btn {
        width: 100%;
        text-align: center;
    }

    /* Lightbox */
    #lightbox {
        padding: 0;
    }

    #lightbox .lightbox-stage {
        width: 100vw;
        height: 100vh;
    }

    #lightbox .lightbox-image-wrap {
        max-width: 100vw;
        max-height: 100vh;
    }

    #lightbox .lightbox-image-wrap img {
        max-width: 100vw;
        max-height: 100vh;
    }

    #lightbox .lightbox-close {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));

        width: 44px;
        height: 44px;

        font-size: 22px;
    }

    #lightbox .lightbox-nav {
        width: 44px;
        height: 64px;

        border-radius: 12px;

        font-size: 42px;
    }

    #lightbox .lightbox-prev {
        left: max(6px, env(safe-area-inset-left));
    }

    #lightbox .lightbox-next {
        right: max(6px, env(safe-area-inset-right));
    }

    #lightbox .lightbox-counter {
        bottom: max(10px, env(safe-area-inset-bottom));
    }
}


@media (max-width: 430px) {

    .site-header {
        display: block;
    }

    .brand {
        justify-content: center;
        margin-bottom: 9px;
    }

    .site-logo {
        max-width: 118px;
    }

    .top-nav {
        justify-content: center;
    }

    .gallery {
        gap: 6px;
    }

    .photo-tile {
        border-radius: 7px;
    }

    .public-language-bar {
        justify-content: center;
    }
}
