/* Common Styles - Frontend Gallery */

/* ===========================
   Reset & Base
   =========================== */
html, body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background: #0b0b0b;
    color: #f2f2f2;
}

* {
    box-sizing: border-box;
}

:root {
    /* Brand colors - will be overridden by inline styles from brand_presets */
    --primary-color: var(--color-primary);
    --secondary-color: #666666;
    
    /* Masonry Layout Configuration */
    --masonry-columns-desktop: 5;
    --masonry-columns-tablet: 2;
    --masonry-columns-mobile: 2;
    --masonry-gap: 10px;
    
    /* Admin Panel Colors */
    --bg-dark: #121212;
    --bg-darker: #0a0a0a;
    --bg-card: #1a1a1a;
    --bg-card-hover: #1f1f1f;
    --bg-input: #0f0f0f;
    --border-color: #2a2a2a;
    --border-color-light: #333;
    --text-primary: #ffffff;
    --text-secondary: #888888;
    --color-primary: #ff6600;
    --color-primary-hover: #cc5200;
    --color-success: #22c55e;
    --color-warning: #fbbf24;
    --color-danger: #ef4444;
    --color-info: #3b82f6;
    --color-offline: #9e9e9e;
}

/* ===========================
   Header
   =========================== */
header {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-bottom: 12px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    border-bottom: 1px solid #333;
    background: var(--primary-color, var(--color-primary));
}

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

.logo {
    height: 32px;
    width: auto;
    filter: brightness(0) invert(1);
    margin-left: auto;
}

h1 {
    margin: 0;
    font-size: 18px;
    color: #fff;
}

/* ===========================
   Main Content
   =========================== */
.wrap {
    max-width: 1600px;
    margin: 0 auto;
}

main.wrap {
    padding: 20px;
}

/* ===========================
   Gallery Grid
   =========================== */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Unified Card Styles for Gallery Items and Session Cards */
.gallery-item,
.session-card {
    background: #1a1a1a;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #333;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: block;
    text-decoration: none;
    color: inherit;
}

.gallery-item:hover,
.session-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    border-color: var(--primary-color);
}

.gallery-item img,
.gallery-item video,
.session-card img {
    transition: transform 0.4s ease;
    display: block;
}

.gallery-item:hover img,
.gallery-item:hover video,
.session-card:hover img {
    transform: scale(1.05);
}

/* Grid Layout: Quadratische Karten */
.gallery:not(.masonry-gallery) .gallery-item,
.sessions-grid:not(.masonry-sessions) .session-card {
    aspect-ratio: 1;
}

/* Grid Layout: Medien füllen Container */
.gallery:not(.masonry-gallery) .gallery-item img,
.gallery:not(.masonry-gallery) .gallery-item video,
.sessions-grid:not(.masonry-sessions) .session-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Masonry Layout: Natürliche Höhe */
.gallery.masonry-gallery .gallery-item img,
.gallery.masonry-gallery .gallery-item video,
.sessions-grid.masonry-sessions .session-card img {
    width: 100%;
    height: auto;
}

.gallery-item-wrapper {
    position: relative;
}

.gallery-preview {
    display: block;
    width: 100%;
}

/* Download Button - Desktop */
.download-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: rgba(102, 102, 102, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    text-decoration: none;
}

.download-btn:hover {
    background: var(--primary-color, rgba(152, 27, 30, 0.95));
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.download-btn:active {
    transform: scale(0.95);
}

.download-btn svg {
    width: 20px;
    height: 20px;
}

/* Share Button - Mobile (iOS/Android) */
.share-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    background: var(--primary-color, rgba(152, 27, 30, 0.95));
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.share-btn:hover {
    background: var(--primary-color, rgba(152, 27, 30, 1));
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.share-btn:active {
    transform: scale(0.95);
}

.share-btn svg {
    width: 20px;
    height: 20px;
}

/* ===========================
   Lightbox
   =========================== */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox-content {
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.lightbox-content img,
.lightbox-content video {
    max-width: 100%;
    max-height: 95vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 32px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    padding: 0;
    transition: all 0.2s;
    z-index: 10000;
    font-family: Arial, sans-serif;
    font-weight: 300;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* ===========================
   Sessions Grid (Event Overview)
   =========================== */
.sessions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 28px;
    margin: 40px 0;
}

.session-card .empty-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 56px;
    opacity: 0.3;
    background: #0f0f0f;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state p {
    font-size: 18px;
}

/* ===========================
   Empty State
   =========================== */
.empty-state {
    text-align: center;
    padding: 100px 20px;
    color: #666;
}

.empty-state p {
    font-size: 20px;
    font-weight: 500;
    margin-bottom: 16px;
}

/* ===========================
   Footer
   =========================== */
footer {
    background: #0b0b0b;
    border-top: 1px solid #333;
    padding: 50px 20px 40px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

.footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    justify-content: center;
    margin: 0 0 12px;
}

footer p {
    margin: 8px 0;
}

footer a {
    color: #888;
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--primary-color);
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 1024px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 20px;
    }
    
    .sessions-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 12px;
    }
    
    main.wrap {
        padding: 12px;
    }
    
    .sessions-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .lightbox-close {
        top: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .gallery {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    h1 {
        font-size: 16px;
    }
}

/* ===========================
   Utilities
   =========================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
/* ===========================
   Upload Progress / Loading State
   =========================== */
.upload-progress-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 40px 20px;
}

.upload-progress-card {
    background: linear-gradient(145deg, #1a1a1a, #0f0f0f);
    border: 1px solid #333;
    border-radius: 20px;
    padding: 48px 40px;
    max-width: 500px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.upload-progress-title {
    font-size: 26px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 32px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.upload-progress-bar-container {
    width: 100%;
    height: 12px;
    background: #0b0b0b;
    border-radius: 8px;
    overflow: hidden;
    margin: 24px 0 16px;
    border: 1px solid #222;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 8px;
    transition: width 0.5s ease;
    box-shadow: 0 0 12px rgba(152, 27, 30, 0.5);
    position: relative;
}

.upload-progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes pulse {
    0%, 100% { width: 0%; opacity: 0.6; }
    50% { width: 100%; opacity: 1; }
}

.upload-progress-text {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin: 16px 0;
}

.upload-progress-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #222;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 32px auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.upload-progress-note {
    font-size: 14px;
    color: #888;
    margin-top: 24px;
    line-height: 1.5;
}

@media (max-width: 480px) {
    .upload-progress-card {
        padding: 32px 24px;
    }
    
    .upload-progress-title {
        font-size: 22px;
    }
    
    .upload-progress-text {
        font-size: 16px;
    }
}

/* ===========================
   Masonry Layout
   =========================== */

/* Masonry Container */
.gallery.masonry-gallery,
.sessions-grid.masonry-sessions {
    display: block !important;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.gallery.masonry-gallery.loaded,
.sessions-grid.masonry-sessions.loaded {
    opacity: 1;
}

/* Masonry Items */
.masonry-gallery .gallery-item,
.masonry-sessions .session-card {
    /* Width is set dynamically by JavaScript */
    float: left;
    box-sizing: border-box;
    margin-bottom: var(--masonry-gap);
}

/* Masonry Loading Spinner */
.masonry-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 11, 11, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

.masonry-loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #333;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: masonry-spin 1s linear infinite;
}

@keyframes masonry-spin {
    to { transform: rotate(360deg); }
}

/* Responsive Masonry - Tablets */
@media (max-width: 1024px) {
    .masonry-gallery .gallery-item {
        width: calc((100% - (var(--masonry-columns-tablet) - 1) * var(--masonry-gap)) / var(--masonry-columns-tablet));
    }
    
    .masonry-sessions .session-card {
        width: calc((100% - (var(--masonry-columns-tablet) - 1) * var(--masonry-gap)) / var(--masonry-columns-tablet));
    }
}

/* Responsive Masonry - Mobile */
@media (max-width: 640px) {
    .masonry-gallery .gallery-item {
        width: calc((100% - (var(--masonry-columns-mobile) - 1) * var(--masonry-gap)) / var(--masonry-columns-mobile));
    }
    
    .masonry-sessions .session-card {
        width: calc((100% - (var(--masonry-columns-mobile) - 1) * var(--masonry-gap)) / var(--masonry-columns-mobile));
    }
    
    .gallery {
        gap: 16px;
    }
}

/* ===========================
   ZIP Download Button
   =========================== */
.zip-download-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 48px;
    margin-bottom: 24px;
}

.zip-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 14px;
    padding: 16px 28px;
    background: var(--primary-color, #222);
    color: #fff;
    border-radius: 14px;
    text-decoration: none;
    font-family: inherit;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.18);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.zip-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.26);
    filter: brightness(1.08);
}

.zip-download-btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
}

.zip-download-icon {
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}

.zip-download-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.zip-download-label {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.zip-download-badge {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.72;
}

.zip-download-hint {
    margin-top: 12px;
    font-size: 0.82rem;
    opacity: 0.55;
    text-align: center;
    color: inherit;
}

.zip-dl-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    flex-shrink: 0;
}

.zip-dl-icon-idle {
    font-size: 1.8rem;
    line-height: 1;
    transition: opacity 0.15s;
}

.zip-dl-spinner {
    display: none;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: zip-spin 0.75s linear infinite;
}

@keyframes zip-spin {
    to { transform: rotate(360deg); }
}

.zip-download-btn.is-loading .zip-dl-icon-idle {
    display: none;
}

.zip-download-btn.is-loading .zip-dl-spinner {
    display: block;
}

.zip-download-btn.is-loading {
    opacity: 0.85;
    cursor: wait;
    pointer-events: none;
}

@media (max-width: 600px) {
    .zip-download-btn {
        padding: 14px 20px;
        gap: 11px;
    }
    .zip-download-icon {
        font-size: 1.5rem;
    }
    .zip-download-label {
        font-size: 0.92rem;
    }
}
