/**
 * Automatic Folder Gallery Stylesheet
 * Custom CSS with glassmorphism, responsive grid layouts, and custom lightbox styling.
 */

:root {
    --afg-primary: #1a202c;
    --afg-accent: #3182ce;
    --afg-text: #2d3748;
    --afg-text-muted: #718096;
    --afg-bg: #ffffff;
    
    /* Card Glassmorphism details */
    --afg-glass-bg: rgba(255, 255, 255, 0.6);
    --afg-glass-border: rgba(255, 255, 255, 0.4);
    --afg-glass-shadow: rgba(0, 0, 0, 0.05);
    --afg-glass-blur: 16px;
    
    /* Dark mode variants */
    --afg-dark-overlay: rgba(0, 0, 0, 0.85);
    
    /* Spacing & Transitions */
    --afg-radius-lg: 16px;
    --afg-radius-md: 10px;
    --afg-radius-sm: 6px;
    --afg-transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    --afg-transition-bounce: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Gallery wrapper container */
.afg-gallery-wrapper {
    width: 100%;
    margin: 2rem 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--afg-text);
}

/* Grids */
.afg-albums-grid,
.afg-images-grid {
    display: grid;
    gap: 24px;
    width: 100%;
}

.afg-grid-cols-2 {
    grid-template-columns: repeat(1, 1fr);
}
.afg-grid-cols-3 {
    grid-template-columns: repeat(1, 1fr);
}
.afg-grid-cols-4 {
    grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 576px) {
    .afg-grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
    .afg-grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
    .afg-grid-cols-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
    .afg-grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
    .afg-grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
    .afg-grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Glassmorphic Album Card styling */
.afg-album-card {
    background: var(--afg-glass-bg);
    border: 1px solid var(--afg-glass-border);
    border-radius: var(--afg-radius-lg);
    box-shadow: 0 8px 32px 0 var(--afg-glass-shadow);
    backdrop-filter: blur(var(--afg-glass-blur));
    -webkit-backdrop-filter: blur(var(--afg-glass-blur));
    overflow: hidden;
    cursor: pointer;
    transition: var(--afg-transition-bounce);
    position: relative;
    display: flex;
    flex-direction: column;
}

.afg-album-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 40px 0 rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.6);
}

.afg-album-card-cover-wrapper {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 Aspect Ratio */
    overflow: hidden;
}

.afg-album-card-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: var(--afg-transition);
}

.afg-album-card:hover .afg-album-card-cover {
    transform: scale(1.1);
}

/* Cover Hover Overlay button */
.afg-album-card-hover-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--afg-transition);
}

.afg-album-card:hover .afg-album-card-hover-overlay {
    opacity: 1;
}

.afg-btn-view {
    color: #fff;
    background: var(--afg-accent);
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(49, 130, 206, 0.4);
    transform: translateY(10px);
    transition: var(--afg-transition-bounce);
}

.afg-album-card:hover .afg-btn-view {
    transform: translateY(0);
}

.afg-album-card-content {
    padding: 20px;
    background: rgba(255, 255, 255, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.afg-album-card-title {
    margin: 0 0 5px 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--afg-primary);
}

.afg-album-card-count {
    font-size: 0.85rem;
    color: var(--afg-text-muted);
}

/* Album View (Hidden initially unless active) */
.afg-album-view {
    display: none;
    opacity: 0;
    transform: scale(0.98);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.afg-album-view.afg-active {
    display: block;
    opacity: 1;
    transform: scale(1);
}

.afg-albums-list-view {
    display: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.afg-albums-list-view.afg-active {
    display: block;
    opacity: 1;
}

/* Header within album view */
.afg-album-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 24px;
    align-items: flex-start;
}

.afg-back-button {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: var(--afg-text);
    padding: 8px 16px;
    border-radius: var(--afg-radius-md);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    margin-bottom: 16px;
    transition: var(--afg-transition);
}

.afg-back-button:hover {
    background: #f7fafc;
    border-color: #cbd5e0;
    transform: translateX(-4px);
}

.afg-album-title-area {
    width: 100%;
}

.afg-album-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--afg-primary);
}

.afg-album-meta {
    font-size: 0.95rem;
    color: var(--afg-text-muted);
}

/* Album Image Grid Items */
.afg-image-item {
    position: relative;
    border-radius: var(--afg-radius-md);
    overflow: hidden;
    cursor: zoom-in;
    background: #edf2f7;
    transition: var(--afg-transition);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
}

.afg-image-item:hover {
    transform: scale(1.03);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
}

.afg-image-inner {
    position: relative;
    width: 100%;
    padding-top: 75%; /* 4:3 aspect ratio */
}

.afg-image-inner img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.5s ease;
}

/* Lazy loading placeholder effect */
.afg-lazy-img {
    opacity: 0;
}

.afg-lazy-img.afg-loaded {
    opacity: 1;
}

/* Image overlay details */
.afg-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--afg-transition);
}

.afg-image-item:hover .afg-image-overlay {
    opacity: 1;
}

.afg-zoom-icon {
    color: #fff;
    transform: scale(0.7);
    transition: var(--afg-transition-bounce);
}

.afg-image-item:hover .afg-zoom-icon {
    transform: scale(1);
}

/* Empty State / Errors */
.afg-no-albums {
    background: #f7fafc;
    border: 2px dashed #e2e8f0;
    border-radius: var(--afg-radius-lg);
    padding: 40px;
    text-align: center;
    color: var(--afg-text-muted);
}

/* Built-in Premium Lightbox Styles */
.afg-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.afg-lightbox[aria-hidden="false"] {
    display: flex;
    opacity: 1;
}

.afg-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--afg-dark-overlay);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.afg-lightbox-close,
.afg-lightbox-prev,
.afg-lightbox-next {
    position: absolute;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--afg-transition);
    z-index: 10;
}

.afg-lightbox-close:hover,
.afg-lightbox-prev:hover,
.afg-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Positioning controls */
.afg-lightbox-close {
    top: 24px;
    right: 24px;
    width: 48px;
    height: 48px;
}

.afg-lightbox-prev {
    left: 24px;
    width: 56px;
    height: 56px;
}

.afg-lightbox-next {
    right: 24px;
    width: 56px;
    height: 56px;
}

.afg-lightbox-content {
    position: relative;
    max-width: 85%;
    max-height: 80%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 5;
}

.afg-lightbox-img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: var(--afg-radius-md);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    opacity: 0;
    transform: scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.afg-lightbox-img.afg-img-active {
    opacity: 1;
    transform: scale(1);
}

/* Caption and Counters */
.afg-lightbox-caption {
    width: 100%;
    color: #fff;
    text-align: center;
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.afg-lightbox-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.afg-lightbox-counter {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Spinner Loader */
.afg-lightbox-spinner {
    position: absolute;
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #fff;
    animation: afg-spin 1s ease-in-out infinite;
    display: none;
}

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

/* Responsiveness for Lightbox Navigation */
@media (max-width: 768px) {
    .afg-lightbox-prev {
        left: 10px;
        width: 44px;
        height: 44px;
    }
    .afg-lightbox-next {
        right: 10px;
        width: 44px;
        height: 44px;
    }
    .afg-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    .afg-lightbox-content {
        max-width: 95%;
    }
}
