/* Dynamic Album Gallery CSS */

/* Loading Animation */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
    font-size: 1.1rem;
    grid-column: 1 / -1;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    border-top-color: #ea580c;
    animation: spin 1s ease-in-out infinite;
    margin-left: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Album Grid */
.albums-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 32px;
    margin-bottom: 60px;
}

.album-card {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
}

.album-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}

.album-cover {
    position: relative;
    height: 250px;
    overflow: hidden;
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.album-card:hover .album-cover img {
    transform: scale(1.05);
}

.album-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(45deg, rgba(234, 88, 12, 0.8), rgba(194, 65, 12, 0.8));
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.album-card:hover .album-overlay {
    opacity: 1;
}

.photo-count {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    backdrop-filter: blur(5px);
}

.album-info {
    padding: 24px;
}

.album-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 8px;
}

.album-description {
    color: #64748b;
    font-size: 14px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.album-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #94a3b8;
    font-size: 12px;
}

.album-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

.album-meta i {
    color: #ea580c;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    inset: 0;
    background: rgba(0,0,0,0.95);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.modal.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    position: relative;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    background: rgba(30, 41, 59, 0.9);
    color: white;
    padding: 20px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
    z-index: 10001;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.3s;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.2);
    transform: rotate(90deg);
}

.modal-gallery {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    background: #f8fafc;
    /* Bu önemli: Modal açıldığında her zaman en üstten başlasın */
    scroll-behavior: smooth;
}

/* Modal açıldığında galeriyi sıfırla */
.modal.active .modal-gallery {
    animation: resetScroll 0.1s ease;
}

@keyframes resetScroll {
    from {
        scroll-behavior: auto;
    }
    to {
        scroll-behavior: smooth;
    }
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    /* Grid'in üst kısmından başlamasını sağla */
    margin-top: 0;
    padding-top: 0;
}

/* Gallery Item - Mevcut site stiline uyumlu */
.gallery-item {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    /* Z-index sorununu önlemek için */
    z-index: 1;
}

.gallery-item:hover {
    transform: translateY(-8px);
    box-shadow: 0 25px 50px rgba(0,0,0,0.2);
    z-index: 2;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.1);
}

.gallery-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.gallery-item:hover .gallery-overlay {
    background: rgba(0,0,0,0.7);
}

.gallery-info {
    text-align: center;
    color: white;
    padding: 20px;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s;
}

.gallery-item:hover .gallery-info {
    opacity: 1;
    transform: translateY(0);
}

.gallery-info h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.gallery-info p {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 4px;
}

.photo-number {
    font-size: 0.8rem;
    opacity: 0.8;
    display: block;
}

.gallery-category {
    display: inline-block;
    background: #ea580c;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin: 16px;
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 3;
}

/* Album Lightbox - Gruplandırılmış galeri */
.album-lightbox {
    display: none;
    position: fixed;
    z-index: 20000;
    inset: 0;
    background: rgba(0,0,0,0.98);
    animation: fadeIn 0.3s ease;
}

.album-lightbox.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.album-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.album-lightbox img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    object-fit: contain;
}

.album-lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: rgba(239, 68, 68, 0.2);
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.3s;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.album-lightbox-close:hover {
    background: rgba(239, 68, 68, 0.4);
    transform: rotate(90deg);
}

.album-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(234, 88, 12, 0.8);
    border: none;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.album-lightbox-nav:hover {
    background: #ea580c;
    transform: translateY(-50%) scale(1.1);
}

.album-lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.album-lightbox-prev {
    left: -80px;
}

.album-lightbox-next {
    right: -80px;
}

.album-lightbox-info {
    margin-top: 30px;
    text-align: center;
    max-width: 90vw;
}

.album-lightbox-caption {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.album-lightbox-counter {
    color: rgba(255,255,255,0.8);
    font-size: 1rem;
    margin-bottom: 20px;
}

.album-lightbox-thumbnails {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    max-width: 800px;
    margin: 0 auto;
}

.thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.thumbnail:hover {
    opacity: 1;
    transform: scale(1.1);
}

.thumbnail.active {
    border-color: #ea580c;
    opacity: 1;
    transform: scale(1.1);
}

.thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Error State */
.error-state {
    text-align: center;
    grid-column: 1 / -1;
    padding: 60px 20px;
}

.error-state i {
    font-size: 4rem;
    color: #ef4444;
    margin-bottom: 20px;
    display: block;
}

.error-state h3 {
    color: #ef4444;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.error-state p {
    color: #64748b;
    margin-bottom: 20px;
}

.error-state button {
    background: #ea580c;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
}

.error-state button:hover {
    background: #c2410c;
    transform: translateY(-2px);
}

/* Empty State */
.empty-state {
    text-align: center;
    grid-column: 1 / -1;
    padding: 60px 20px;
}

.empty-state i {
    font-size: 4rem;
    color: #cbd5e1;
    margin-bottom: 20px;
    display: block;
}

.empty-state h3 {
    color: #64748b;
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.empty-state p {
    color: #94a3b8;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .albums-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 24px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .albums-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-title {
        font-size: 1.2rem;
    }

    .modal-gallery {
        padding: 20px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 12px;
    }

    .album-lightbox-nav {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .album-lightbox-prev {
        left: 10px;
    }

    .album-lightbox-next {
        right: 10px;
    }

    .album-lightbox-close {
        top: -40px;
        font-size: 1.5rem;
        width: 40px;
        height: 40px;
    }

    .album-lightbox-caption {
        font-size: 1rem;
        margin-bottom: 8px;
    }

    .album-lightbox-thumbnails {
        gap: 6px;
        max-width: 100%;
    }

    .thumbnail {
        width: 50px;
        height: 50px;
    }
}

@media (max-width: 480px) {
    .album-cover {
        height: 200px;
    }

    .album-info {
        padding: 20px;
    }

    .album-title {
        font-size: 1.2rem;
    }

    .album-description {
        font-size: 13px;
    }

    .modal-gallery {
        padding: 16px;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;
    }

    .album-lightbox-nav {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .album-lightbox-prev {
        left: 5px;
    }

    .album-lightbox-next {
        right: 5px;
    }

    .photo-count {
        font-size: 12px;
        padding: 4px 8px;
    }

    .album-lightbox-close {
        top: -35px;
        right: -5px;
        width: 35px;
        height: 35px;
        font-size: 1.3rem;
    }

    .album-lightbox-thumbnails {
        gap: 4px;
        padding: 0 10px;
    }

    .thumbnail {
        width: 40px;
        height: 40px;
    }

    .album-lightbox-info {
        margin-top: 20px;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    .modal-gallery {
        background: #0f172a;
    }

    .gallery-item {
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    }

    .gallery-item:hover {
        box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    }
}

/* Smooth Scrollbar */
.modal-gallery::-webkit-scrollbar {
    width: 8px;
}

.modal-gallery::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}

.modal-gallery::-webkit-scrollbar-thumb {
    background: rgba(234, 88, 12, 0.3);
    border-radius: 4px;
}

.modal-gallery::-webkit-scrollbar-thumb:hover {
    background: rgba(234, 88, 12, 0.5);
}

/* Fix: Modal açıldığında scroll pozisyonunu sıfırla */
.modal:not(.active) .modal-gallery {
    scroll-behavior: auto;
}

.modal.active .modal-gallery {
    scroll-behavior: smooth;
    /* Modal açıldığında scroll pozisyonunu en üste getir */
    animation: scrollToTop 0.1s ease-out forwards;
}

@keyframes scrollToTop {
    to {
        scroll-top: 0;
    }
}