/* ============================================================
   Linzer Weihnachtsmärkte – Gemeinsames Stylesheet
   Verwendet von: index.php (Galerie) und admin.php (Verwaltung)
   Optik angelehnt an christkindlmarkt-linz.at
   ============================================================ */

/* ---- Schrift (lokal, SIL Open Font License) ---- */
@font-face {
    font-family: 'Raleway';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url('fonts/raleway-latin.woff2') format('woff2');
}

/* Lock Serif (Hausschrift Linzer Weihnachtsmärkte) – nur Großbuchstaben, Ziffern, Satzzeichen */
@font-face {
    font-family: 'Lock Serif';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('fonts/lockserif-medium.woff2') format('woff2');
}

/* ---- Reset & Basis ---- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Raleway', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
}

/* ============================================================
   GALERIE (index.php)
   ============================================================ */

body.page-gallery {
    --xmas-bordeaux: #40061c;
    --xmas-bordeaux-dark: #2a0412;
    --xmas-gold: #c1ab8a;
    --xmas-text: #47425d;
    --xmas-head: #333;
    background: #fff;
    color: var(--xmas-text);
    display: flex;
    flex-direction: column;
}

/* ---- Kopfbereich: Logo und Titel nebeneinander ---- */
.hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 34px;
    padding: 30px 24px;
    background: var(--xmas-bordeaux);
    color: #fff;
}

.hero-logo {
    display: block;
    width: 270px;
    max-width: 45%;
    height: auto;
}

.hero-text {
    padding-left: 34px;
    border-left: 1px solid rgba(193, 171, 138, 0.5);
}

.hero h1 {
    font-family: 'Lock Serif', Georgia, serif;
    font-size: clamp(1.5rem, 3vw, 2.3rem);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 2px;
    line-height: 1.1;
}

.hero-sub {
    margin-top: 8px;
    font-size: clamp(0.85rem, 1.6vw, 1.05rem);
    line-height: 1.45;
    color: var(--xmas-gold);
}

.gallery-container {
    flex: 1;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 50px 40px 60px;
}

/* ---- Portfolio Grid ---- */
.portfolio {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.projekt {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #f1eff4;
    box-shadow: 0 4px 14px rgba(37, 37, 37, 0.12);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.projekt:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(37, 37, 37, 0.2);
}

.projekt img.projekt-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    transition: transform 0.4s ease;
}

.projekt:hover img.projekt-img {
    transform: scale(1.045);
}

/* ---- Caption Overlay ---- */
.projekt .caption-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 64px 14px 16px;
    background: linear-gradient(transparent, rgba(42, 4, 18, 0.85));
    color: #fff;
    font-size: 0.95rem;
    font-weight: 600;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.projekt:hover .caption-overlay {
    opacity: 1;
}

/* ---- Download Button ---- */
.projekt .download-overlay {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 3;
    display: flex;
    gap: 6px;
}

.download-overlay a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: rgba(64, 6, 28, 0.85);
    border: 1px solid var(--xmas-gold);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    transition: background 0.2s, transform 0.2s;
}

.download-overlay a:hover {
    background: var(--xmas-bordeaux);
    transform: scale(1.08);
}

.download-overlay a img {
    width: 22px;
    height: 22px;
    filter: brightness(0) invert(1);
}

/* ---- Format-Info (Hoch-/Querformat) neben dem Download ---- */
.format-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: rgba(64, 6, 28, 0.85);
    border: 1px solid var(--xmas-gold);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.format-badge::before {
    content: '';
    border: 1px solid var(--xmas-gold);
    border-radius: 2px;
}

.format-badge.is-landscape::before { width: 20px; height: 14px; }
.format-badge.is-portrait::before { width: 14px; height: 20px; }

/* ---- Lightbox ---- */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(42, 4, 18, 0.6);
    backdrop-filter: blur(20px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    position: relative;
    max-width: 95vw;
    max-height: 95vh;
    background: rgba(37, 37, 37, 0.55);
    backdrop-filter: blur(20px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    overflow: hidden;
}

.lightbox-image-container {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
    overflow: hidden;
}

.lightbox-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(15px);
    transform: scale(1.1);
    z-index: 1;
}

.lightbox-image {
    max-width: 96%;
    max-height: 96%;
    object-fit: contain;
    border-radius: 8px;
    position: relative;
    z-index: 2;
    box-shadow: 0 5px 16px rgba(0, 0, 0, 0.3);
}

.lightbox-sidebar {
    width: 300px;
    padding: 30px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.lightbox-close:hover {
    background: var(--xmas-bordeaux);
    transform: scale(1.1);
}

.lightbox-close::before,
.lightbox-close::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 2px;
    background: white;
    transform: rotate(45deg);
}

.lightbox-close::after {
    transform: rotate(-45deg);
}

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 46px;
    background: rgba(64, 6, 28, 0.85);
    border: 1px solid var(--xmas-gold);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s ease;
    text-decoration: none;
    margin-top: auto;
}

.download-btn:hover {
    background: var(--xmas-bordeaux);
}

.download-btn img {
    width: 24px;
    height: 24px;
    filter: brightness(0) invert(1);
}

.sidebar-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
    margin-top: 40px;
    margin-bottom: 20px;
}

.info-filename {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    font-weight: 600;
    word-break: break-all;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-data {
    color: white;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
}

.info-label {
    color: rgba(255, 255, 255, 0.55);
    font-weight: 500;
}

.info-value {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.info-compact {
    color: rgba(255, 255, 255, 0.55);
    font-size: 13px;
    margin-top: 4px;
}

.lightbox-caption {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    line-height: 1.5;
    padding: 12px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.caption-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.caption-label {
    color: rgba(255, 255, 255, 0.55);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.caption-text {
    color: rgba(255, 255, 255, 0.9);
}

.copy-badge {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 500px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    font-family: inherit;
    font-weight: 600;
    padding: 2px 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-badge:hover {
    background: var(--xmas-bordeaux);
    color: #fff;
}

/* ---- Meldungen ---- */
.error-message {
    color: #721c24;
    text-align: center;
    padding: 40px;
    background: rgba(248, 215, 218, 0.9);
    border-radius: 8px;
    border: 1px solid rgba(220, 53, 69, 0.3);
    margin: 20px 0;
}

.info-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    background: #f1eff4;
    border-radius: 8px;
    margin: 20px 0;
}

.info-message h3 {
    color: var(--xmas-bordeaux);
    font-weight: 600;
    margin-bottom: 8px;
}

/* ---- Footer ---- */
.site-footer {
    background: var(--xmas-bordeaux);
    color: var(--xmas-gold);
    text-align: center;
    padding: 28px 20px;
    font-size: 0.9rem;
}

/* ---- Galerie Responsive ---- */
@media (max-width: 768px) {
    .hero {
        gap: 16px;
        padding: 16px;
    }

    .hero-text {
        padding-left: 16px;
    }

    .gallery-container {
        padding: 30px 20px 40px;
    }

    .portfolio {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }

    .lightbox-content {
        flex-direction: column;
        max-width: 90vw;
        max-height: 90vh;
    }

    .lightbox-sidebar {
        width: 100%;
        max-height: 200px;
        overflow-y: auto;
    }
}

/* ============================================================
   ADMIN (admin.php)
   ============================================================ */

:root {
    --bg: #f1eff4;
    --card: #ffffff;
    --border: #e0e0e0;
    --text: #47425d;
    --text-light: #777;
    --primary: #40061c;
    --primary-hover: #2a0412;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body.page-admin {
    background: linear-gradient(160deg, #5a0a28 0%, #40061c 45%, #2a0412 100%);
    color: var(--text);
}

/* ---- Login ---- */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 24px;
}

.login-card input[type="password"] {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.login-card input:focus {
    border-color: var(--primary);
}

.login-card button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.login-card button:hover {
    background: var(--primary-hover);
}

.login-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
}

/* ---- Admin Header ---- */
.admin-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 0 0 var(--radius) var(--radius);
}

.admin-header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

.admin-header nav {
    display: flex;
    gap: 12px;
    align-items: center;
}

.admin-header nav a {
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 6px 14px;
    border-radius: 6px;
    transition: all 0.2s;
}

.admin-header nav a:hover {
    background: var(--bg);
    color: var(--text);
}

.btn-logout {
    color: var(--danger) !important;
}

.admin-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px;
}

/* ---- Upload Area ---- */
.upload-zone {
    background: var(--card);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    margin-bottom: 32px;
}

.upload-zone.dragover {
    border-color: var(--primary);
    background: #f6eef0;
}

.upload-zone h2 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.upload-zone p {
    color: var(--text-light);
    font-size: 0.9rem;
}

.upload-zone input[type="file"] {
    display: none;
}

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    opacity: 0.6;
}

/* ---- Upload Progress ---- */
.upload-progress {
    display: none;
    margin-bottom: 24px;
}

.upload-progress.active {
    display: block;
}

.progress-bar-outer {
    background: var(--border);
    border-radius: 20px;
    height: 8px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-inner {
    background: var(--primary);
    height: 100%;
    width: 0%;
    border-radius: 20px;
    transition: width 0.3s;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-light);
}

/* ---- Photo Grid ---- */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.photo-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: all 0.2s;
    cursor: grab;
    position: relative;
}

.photo-card:active { cursor: grabbing; }
.photo-card.dragging { opacity: 0.5; transform: scale(0.95); }
.photo-card.drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }

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

.photo-card-body {
    padding: 12px;
}

/* ---- Left: Name, Meta, Caption ---- */
.photo-card-left {
    width: 100%;
}

.photo-card-filename {
    font-size: 0.8rem;
    color: var(--text);
    font-weight: 500;
    word-break: break-all;
    line-height: 1.3;
}

.photo-card-meta {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 2px;
    margin-bottom: 8px;
}

/* ---- Actions (overlaid on image, bottom-left) ---- */
.photo-card-image-wrap {
    position: relative;
}

.photo-card-actions-col {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: flex;
    flex-direction: row;
    gap: 6px;
    z-index: 2;
}

.btn-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    transition: all 0.2s;
    padding: 0;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.btn-icon:hover {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btn-icon img {
    width: 24px;
    height: 24px;
    opacity: 0.7;
}

.btn-icon:hover img {
    opacity: 1;
}

.caption-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    resize: vertical;
    min-height: 48px;
    outline: none;
    transition: border-color 0.2s;
}

.caption-input:focus {
    border-color: var(--primary);
}



/* ---- Buttons ---- */
.btn {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-save { background: var(--primary); color: white; }
.btn-save:hover { background: var(--primary-hover); }
.btn-save:disabled { opacity: 0.5; cursor: default; }

.btn-delete { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-delete:hover { background: var(--danger); color: white; }

.btn-cancel { background: var(--bg); color: var(--text); }

.btn-confirm-delete { background: var(--danger); color: white; }
.btn-confirm-delete:hover { background: var(--danger-hover); }

/* ---- Icons ---- */
.icon-header {
    width: 32px;
    height: 32px;
    vertical-align: middle;
    margin-right: 4px;
}

.icon-nav {
    width: 24px;
    height: 24px;
    vertical-align: middle;
}

.icon-btn {
    width: 22px;
    height: 22px;
    vertical-align: middle;
}

.icon-white { filter: brightness(0) invert(1); }
.icon-danger { filter: brightness(0) saturate(100%) invert(27%) sepia(91%) saturate(5765%) hue-rotate(354deg) brightness(93%) contrast(96%); }



/* ---- Sort Badge (inline with filename) ---- */
.sort-badge {
    background: rgba(64, 6, 28, 0.8);
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    padding: 2px 10px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-left: auto;
}

.photo-card-filename-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Rename Button (Bleistift) ---- */
.btn-rename {
    background: transparent;
    border: none;
    color: var(--text-light);
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: all 0.2s;
}

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

.rename-input {
    flex: 1;
    padding: 4px 8px;
    border: 1px solid var(--primary);
    border-radius: 4px;
    font-size: 0.8rem;
    font-family: inherit;
    outline: none;
    min-width: 0;
}

/* ---- Sortier-Modus Toggle Button ---- */
.btn-sortmode {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-sortmode:hover {
    background: var(--bg);
}

.btn-sortmode.active {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-sortmode.active img {
    filter: brightness(0) invert(1);
}

/* ---- Sortier-Modus: kompakte Flex-Ansicht ---- */
.photo-grid.sort-mode {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    align-items: flex-start;
}

.photo-grid.sort-mode .photo-card {
    /* ~67% von 280px = ca. 188px Breite */
    width: 188px;
    flex: 0 0 188px;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

.photo-grid.sort-mode .photo-card.dragging {
    opacity: 0.4;
    transform: scale(0.92);
}

.photo-grid.sort-mode .photo-card.drag-over {
    box-shadow: inset 0 0 0 2px var(--primary);
}

.photo-grid.sort-mode .photo-card-image {
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
}

/* Action-Spalte und Body im Sortier-Modus ausblenden */
.photo-grid.sort-mode .photo-card-actions-col,
.photo-grid.sort-mode .photo-card-body {
    display: none;
}

/* Kleines Sortier-Badge oben links auf dem Bild im Sortier-Modus */
.photo-grid.sort-mode .photo-card-image-wrap::before {
    content: attr(data-sort);
    position: absolute;
    top: 4px;
    left: 4px;
    background: rgba(64, 6, 28, 0.85);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 3px;
    z-index: 2;
    pointer-events: none;
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    pointer-events: none;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ---- Confirm Dialog ---- */
.dialog-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 9000;
    display: none;
    align-items: center;
    justify-content: center;
}

.dialog-overlay.active { display: flex; }

.dialog-box {
    background: var(--card);
    border-radius: var(--radius);
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.dialog-box h3 { margin-bottom: 12px; font-size: 1.1rem; }
.dialog-box p { color: var(--text-light); font-size: 0.9rem; margin-bottom: 24px; }

.dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ---- Admin Responsive ---- */
@media (max-width: 768px) {
    .admin-content { padding: 16px; }
    .admin-header { padding: 12px 16px; }
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
    .upload-zone { padding: 32px 16px; }
}