﻿/* ========== GALLERY.CSS - STYLE DLA GALERII ZDJĘĆ ========== */

/* --- SIATKA GALERII --- */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    padding: 10px;
}

/* --- POJEDYNCZE ZDJĘCIE --- */
.photo-item {
    overflow: visible;
    border: 4px solid #d4af37;
    border-radius: 10px;
    background: white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: transform 0.2s ease;
}

    .photo-item:hover {
        transform: scale(1.03);
    }

    .photo-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
        transition: transform .2s ease, filter .2s ease;
    }

    .photo-item:hover img {
        filter: brightness(1.1);
    }

/* --- LIGHTBOX --- */
.lightbox {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0,0,0,0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

    .lightbox.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .lightbox img {
        max-width: 90%;
        max-height: 90%;
        border-radius: 8px;
        object-fit: contain;
    }

/* --- PRZYCISK ZAMYKANIA --- */
.close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 40px;
    color: white;
    cursor: pointer;
    transition: transform 0.2s ease;
}

    .close:hover {
        transform: scale(1.1);
    }

/* --- STRZAŁKI NAWIGACJI --- */
.nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    padding: 20px;
    transition: transform 0.2s ease;
}

    .nav:hover {
        transform: translateY(-50%) scale(1.2);
    }

.prev {
    left: 20px;
}

.next {
    right: 20px;
}

/* --- PRZYCISKI UPLOADU --- */
.upload-btn,
#showUpload,
#uploadForm button,
#uploadForm input[type="file"] {
    display: block;
    margin: 12px auto;
    padding: 10px 22px;
    background: white;
    border: 2px solid #d4af37;
    border-radius: 6px;
    font-family: 'Cormorant Garamond', serif;
    font-size: 18px;
    color: #333;
    cursor: pointer;
    transition: 0.2s;
}

    .upload-btn:hover,
    #showUpload:hover,
    #uploadForm button:hover,
    #uploadForm input[type="file"]:hover {
        background: #faf6e9;
    }

/* --- PRZYCISKI ADMINA --- */
.admin-btn {
    width: 100%;
    padding: 10px;
    margin-top: 6px;
    border-radius: 6px;
    font-size: 15px;
    font-family: Arial, sans-serif;
    cursor: pointer;
    border: none;
    color: white;
    transition: 0.2s;
}

.delete-btn {
    background: #c0392b;
}

    .delete-btn:hover {
        background: #e74c3c;
    }

.toggle-btn {
    background: #555;
}

    .toggle-btn:hover {
        background: #666;
    }

.restore-btn {
    background: #28a745;
}

    .restore-btn:hover {
        background: #218838;
    }

.admin-controls {
    margin-top: 10px;
}

/* --- TRIGGER LIGHTBOXA --- */
.lightbox-trigger {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

    .lightbox-trigger img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        display: block;
    }

/* --- LAZY LOADING PLACEHOLDER ---*/
.photo-item img.lazy {
    filter: blur(10px);
    transition: filter 0.5s ease;
}

.photo-item img.loaded {
    filter: blur(0);
}

.thumb-wrapper {
    aspect-ratio: 1 / 1;
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
}

/* --- UKRYTE ZDJĘCIA - zachowuje lazy loading --- */
.photo-hidden .thumb-wrapper img.lazy {
    filter: blur(10px) brightness(0.5) grayscale(0.2);
}

.photo-hidden .thumb-wrapper img.loaded {
    filter: brightness(0.5) grayscale(0.2);
}

/* -------- KOMUNIKATY I FORMULARZE ------ */

/* Komunikat błędu */
.alert-danger {
    padding: 15px;
    margin: 20px auto;
    max-width: 600px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    text-align: center;
    font-family: 'Lato', sans-serif;
    font-size: 16px;
}

/* -------- KOMUNIKAT SUKCESU ------ */
.alert-success {
    padding: 15px;
    margin: 20px auto;
    max-width: 600px;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    text-align: center;
    font-family: 'Lato', sans-serif;
    font-size: 16px;
}

/* -------- KOMUNIKAT INFORMACYJNY (UPLOAD NIEDOSTĘPNY) ------ */
.alert-info {
    padding: 20px;
    margin: 20px auto;
    max-width: 600px;
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    text-align: center;
}

    .alert-info strong {
        display: block;
        margin-bottom: 10px;
        font-size: 18px;
    }

/* -------- FORMULARZ KODU DOSTĘPU ------ */
.access-code-form {
    max-width: 400px;
    margin: 30px auto;
    padding: 30px;
    border: 2px solid #d4af37;
    border-radius: 10px;
    background: #faf6e9;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

    .access-code-form h2 {
        text-align: center;
        color: #333;
        font-family: 'Playfair Display', serif;
        margin-bottom: 10px;
    }

    .access-code-form p {
        text-align: center;
        color: #666;
        margin-bottom: 20px;
    }

    .access-code-form input[type="text"] {
        width: 100%;
        padding: 12px;
        margin: 10px 0;
        border: 2px solid #d4af37;
        border-radius: 5px;
        font-size: 18px;
        text-align: center;
        font-family: 'Lato', sans-serif;
        transition: border-color 0.3s ease;
    }

        .access-code-form input[type="text"]:focus {
            outline: none;
            border-color: #b8942e;
        }

    .access-code-form button {
        width: 100%;
        padding: 12px;
        background: #d4af37;
        color: white;
        border: none;
        border-radius: 5px;
        font-size: 16px;
        font-weight: bold;
        cursor: pointer;
        transition: background 0.3s ease;
    }

        .access-code-form button:hover {
            background: #b8942e;
        }

/* --- KOMUNIKATY O PUSTEJ GALERII --- */
.gallery-empty-message {
    margin: 40px auto;
    max-width: 650px;
    padding: 30px;
    text-align: center;
    border-radius: 10px;
    border: 3px solid #d4af37;
    background: linear-gradient(135deg, #fdfcf7 0%, #fff9e6 100%);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.15);
}

    .gallery-empty-message h3 {
        font-family: 'Playfair Display', serif;
        font-size: 32px;
        color: #d4af37;
        margin-bottom: 15px;
        font-weight: 600;
    }

    .gallery-empty-message p {
        font-family: 'Lato', sans-serif;
        font-size: 18px;
        line-height: 1.6;
        color: #555;
        margin-bottom: 10px;
    }

    .gallery-empty-message strong {
        color: #d4af37;
        font-weight: 600;
    }

    /* -------- ANIMACJA DLA "BĄDŹ PIERWSZY" ------ */
    .gallery-empty-message.first-upload {
        animation: pulse-border 2s ease-in-out infinite;
    }

@keyframes pulse-border {
    0%, 100% {
        border-color: #d4af37;
        box-shadow: 0 4px 12px rgba(212, 175, 55, 0.15);
    }

    50% {
        border-color: #c49a2d;
        box-shadow: 0 6px 20px rgba(212, 175, 55, 0.25);
    }
}

/* ----- MEDIA QUERIES - RESPONSYWNOŚĆ ------ */

/* ----- Tablety (landscape) i mniejsze ekrany ---- */
@media (max-width: 1024px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 12px;
    }
}

/* ---- Tablety (portrait) ---- */
@media (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 12px;  /* Mniejszy gap dla mobile (oszczędność miejsca) */
        padding: 8px;
    }
    
    .photo-item {
        border: 3px solid #d4af37;  /* Cieńsza ramka na mobile */
    }

    .access-code-form {
        padding: 20px;
        margin: 20px 10px;
    }

    .alert-danger,
    .alert-success,
    .alert-info {
        margin: 15px 10px;
        padding: 12px;
        font-size: 14px;
    }
}

/* ---- Smartfony (większe - iPhone 12, Samsung Galaxy) ---- */
@media (max-width: 480px) {
    .gallery {
        grid-template-columns: repeat(3, 1fr); /* 3 STAŁE KOLUMNY */
        gap: 8px;
        padding: 5px;
    }

    /* ---- Lightbox - mniejsze przyciski ---- */
    .close {
        font-size: 30px;
        top: 10px;
        right: 15px;
    }

    .nav {
        font-size: 30px;
        padding: 10px;
    }

    .prev {
        left: 5px;
    }

    .next {
        right: 5px;
    }

    /* ---- Formularz kodu - kompaktowy ---- */
    .access-code-form {
        padding: 15px;
        margin: 15px 5px;
    }

        .access-code-form h2 {
            font-size: 20px;
        }

        .access-code-form p {
            font-size: 14px;
        }

        .access-code-form input[type="text"] {
            font-size: 16px;
            padding: 10px;
        }

    /* ---- Komunikaty - mniejsze ---- */
    .alert-danger,
    .alert-success,
    .alert-info {
        margin: 10px 5px;
        padding: 10px;
        font-size: 13px;
    }

    /* ---- Przyciski uploadu ---- */
    #showUpload,
    #uploadForm button {
        padding: 8px 16px;
        font-size: 16px;
    }
}

/* ---- Smartfony (małe - iPhone SE, stare Androidy) ---- */
@media (max-width: 375px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr); /* 2 STAŁE KOLUMNY */
        gap: 6px;
        padding: 5px;
    }

    .access-code-form {
        padding: 12px;
        margin: 10px 5px;
    }

        .access-code-form h2 {
            font-size: 18px;
        }

    .lightbox img {
        max-width: 95%;
        max-height: 95%;
    }
}

/* ---- Bardzo małe ekrany (320px - iPhone 5) ---- */
@media (max-width: 320px) {
    .gallery {
        grid-template-columns: repeat(2, 1fr); /* 2 STAŁE KOLUMNY */
        gap: 5px;
        padding: 5px;
    }

    .photo-item {
        border-width: 2px; /* Cieńsza ramka */
    }

    .close {
        font-size: 24px;
        top: 5px;
        right: 10px;
    }

    .nav {
        font-size: 24px;
        padding: 8px;
    }
}

/* --- KOMUNIKATY O PUSTEJ GALERII --- */
.gallery-empty-message {
    margin: 40px auto;
    max-width: 650px;
    padding: 30px;
    text-align: center;
    border-radius: 10px;
    border: 3px solid #d4af37;
    background: linear-gradient(135deg, #fdfcf7 0%, #fff9e6 100%);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.15);
}

    .gallery-empty-message h3 {
        font-family: 'Playfair Display', serif;
        font-size: 32px;
        color: #d4af37;
        margin-bottom: 15px;
        font-weight: 600;
    }

    .gallery-empty-message p {
        font-family: 'Lato', sans-serif;
        font-size: 18px;
        line-height: 1.6;
        color: #555;
        margin-bottom: 10px;
    }

    .gallery-empty-message strong {
        color: #d4af37;
        font-weight: 600;
    }

    /* ---- Wariant dla "bądź pierwszy"  ---- */
    .gallery-empty-message.first-upload {
        border-color: #d4af37;
        background: linear-gradient(135deg, #fffef8 0%, #fff5d6 100%);
        animation: pulse-border 2s ease-in-out infinite;
    }

@keyframes pulse-border {
    0%, 100% {
        border-color: #d4af37;
        box-shadow: 0 4px 12px rgba(212, 175, 55, 0.15);
    }

    50% {
        border-color: #c49a2d;
        box-shadow: 0 6px 20px rgba(212, 175, 55, 0.25);
    }
}

/* --- PRZYCISK POWROTU DO GALERII --- */
.back-to-gallery {
    display: inline-block;
    margin-bottom: 15px;
    padding: 10px 20px;
    background: white;
    border: 2px solid #d4af37;
    border-radius: 6px;
    color: #333;
    text-decoration: none;
    font-family: 'Lato', sans-serif;
    font-size: 16px;
    transition: 0.2s;
}

    .back-to-gallery:hover {
        background: #faf6e9;
        color: #d4af37;
    }


/* --- PASEK AKCJI ADMINA (galeria + kosz) --- */
.admin-actions-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 20px auto;
    padding: 15px 20px;
    background: linear-gradient(135deg, #fff9e6 0%, #fdfcf7 100%);
    border: 2px solid #d4af37;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.15);
}

.trash-count {
    margin: 0;
    font-family: 'Lato', sans-serif;
    font-size: 16px;
    color: #333;
}

    .trash-count strong {
        color: #d4af37;
        font-weight: 600;
    }

    .trash-count i {
        color: #d4af37;
        margin-right: 8px;
    }

/* ---- Przyciski akcji admina ---- */
.btn-admin-action {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-family: 'Lato', sans-serif;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    color: white;
}

    .btn-admin-action i {
        margin-right: 8px;
    }

.btn-download {
    background: #28a745;
}

    .btn-download:hover {
        background: #218838;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    }

.btn-delete-all {
    background: #c0392b;
}

    .btn-delete-all:hover {
        background: #e74c3c;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(192, 57, 43, 0.3);
    }

/* ---- Pusty kosz ---- */
.empty-trash {
    text-align: center;
    margin: 40px auto;
    padding: 30px;
    max-width: 500px;
    color: #28a745;
    font-family: 'Lato', sans-serif;
    font-size: 18px;
    background: #d4edda;
    border: 2px solid #c3e6cb;
    border-radius: 10px;
}

    .empty-trash i {
        font-size: 24px;
        margin-right: 10px;
    }

/* ---- Responsywność ---- */
@media (max-width: 768px) {
    .admin-actions-bar {
        flex-direction: column;
        gap: 15px;
    }

    .btn-admin-action {
        width: 100%;
    }
}