/* Gallery Styles - Custom Flickr Gallery */
/* Modern UI/UX Design */

/* ============================================
   CSS Variables for Consistent Theming
   ============================================ */
:root {
    --gallery-primary: #8B1B3D;
    --gallery-primary-dark: #6B1530;
    --gallery-primary-light: #A82050;
    --gallery-accent: #C9A227;
    --gallery-text: #2D3748;
    --gallery-text-light: #718096;
    --gallery-text-muted: #64748B;
    --gallery-bg: #F7FAFC;
    --gallery-card-bg: #FFFFFF;
    --gallery-border: #94A3B8;
    --gallery-shadow: rgba(45, 55, 72, 0.08);
    --gallery-shadow-hover: rgba(45, 55, 72, 0.15);
    --gallery-radius: 16px;
    --gallery-radius-sm: 10px;
    --gallery-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --gallery-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ============================================
   Filters Section - Modern Minimal Design
   ============================================ */
.gallery-filters {
    background: transparent;
    padding: 2rem 0 0 0; /* Added top padding as requested */
    margin-bottom: 2rem;
}

.gallery-search {
    margin-bottom: 1.5rem;
}

.gallery-search-wrapper {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
}

.gallery-search-icon {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--gallery-text-muted);
    pointer-events: none;
    z-index: 1;
    transition: color 0.2s ease;
}

.gallery-search-wrapper:focus-within .gallery-search-icon {
    color: var(--gallery-primary);
}

.gallery-search input {
    width: 100%;
    padding: 0.875rem 1.25rem 0.875rem 3.25rem;
    border: 1px solid var(--gallery-border);
    border-radius: 6px;
    font-size: 1.35rem;
    font-family: var(--gallery-font);
    transition: var(--gallery-transition);
    background: var(--gallery-card-bg);
    color: var(--gallery-text);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.gallery-search input:hover {
    border-color: #A0AEC0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.gallery-search input:focus {
    outline: none;
    border-color: var(--gallery-primary);
    box-shadow: 0 0 0 3px rgba(139, 27, 61, 0.15); /* Soft focus ring */
}

.gallery-search input::placeholder {
    color: var(--gallery-text-muted);
    font-weight: 400;
}

/* Date Filters */
.gallery-date-filters {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

.gallery-filter-select {
    padding: 0.875rem 2.75rem 0.875rem 1.25rem;
    border: 1px solid var(--gallery-border);
    border-radius: 6px;
    font-size: 1.25rem;
    font-weight: 500;
    font-family: var(--gallery-font);
    background: var(--gallery-card-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 1.25rem center;
    color: var(--gallery-text);
    cursor: pointer;
    transition: var(--gallery-transition);
    min-width: 180px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.gallery-filter-select:hover {
    border-color: #A0AEC0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.gallery-filter-select:focus {
    outline: none;
    border-color: var(--gallery-primary);
    box-shadow: 0 0 0 3px rgba(139, 27, 61, 0.15);
}

/* Clear Filters Button */
.gallery-clear-filters {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    border: 1px solid #FECACA;
    border-radius: 6px;
    font-size: 1.25rem;
    font-weight: 600;
    font-family: var(--gallery-font);
    background: #FEF2F2;
    color: #B91C1C;
    cursor: pointer;
    transition: var(--gallery-transition);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.gallery-clear-filters:hover {
    background: #FEE2E2;
    border-color: #FCA5A5;
    color: #991B1B;
    box-shadow: 0 4px 8px rgba(220, 38, 38, 0.15);
    transform: translateY(-1px);
}

.gallery-clear-filters:active {
    transform: translateY(0);
}

.gallery-clear-filters svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ============================================
   Album Grid
   ============================================ */
#albumGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.75rem;
    padding: 0;
}

.album-card {
    background: var(--gallery-card-bg);
    border-radius: var(--gallery-radius);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px var(--gallery-shadow), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: var(--gallery-transition);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--gallery-border);
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
}

.album-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px var(--gallery-shadow-hover), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    text-decoration: none;
    color: inherit;
    border-color: transparent;
}

.album-cover {
    position: relative;
    width: 100%;
    padding-top: 66.67%; /* 3:2 aspect ratio */
    background: linear-gradient(135deg, #EDF2F7 0%, #E2E8F0 100%);
    overflow: hidden;
}

.album-cover img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.album-card:hover .album-cover img {
    transform: scale(1.08);
}

/* Photo Count Badge */
.photo-count {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.95);
    color: var(--gallery-text);
    padding: 0.6rem 1.1rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(8px);
    letter-spacing: 0.01em;
    font-family: var(--gallery-font);
    transition: var(--gallery-transition);
}

.album-card:hover .photo-count {
    background: var(--gallery-primary);
    color: #fff;
    transform: scale(1.05);
}

/* Album Title Section */
.album-title-section {
    padding: 1.25rem 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    align-items: flex-start;
    flex: 1;
}

.album-date-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.6rem 1rem;
    background: linear-gradient(135deg, var(--gallery-primary) 0%, var(--gallery-primary-dark) 100%);
    color: #fff;
    border-radius: 6px;
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    font-family: var(--gallery-font);
    transition: var(--gallery-transition);
}

.album-card:hover .album-date-chip {
    background: linear-gradient(135deg, var(--gallery-accent) 0%, #B8911F 100%);
    transform: translateX(2px);
}

.album-title {
    padding: 0;
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--gallery-text);
    text-align: left;
    line-height: 1.45;
    font-family: var(--gallery-font);
    letter-spacing: -0.01em;
    transition: color 0.2s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.album-card:hover .album-title {
    color: var(--gallery-primary);
}

/* ============================================
   Photo Grid (Album Page)
   ============================================ */
#photoGrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.photo-item {
    position: relative;
    width: 100%;
    padding-top: 100%;
    background: linear-gradient(135deg, #EDF2F7 0%, #E2E8F0 100%);
    overflow: hidden;
    border-radius: var(--gallery-radius-sm);
    cursor: pointer;
    transition: var(--gallery-transition);
    box-shadow: 0 2px 4px var(--gallery-shadow);
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.photo-item:hover {
    transform: scale(1.03);
    box-shadow: 0 10px 20px var(--gallery-shadow-hover);
    z-index: 1;
}

.photo-item img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.photo-item:hover img {
    transform: scale(1.1);
}

/* ============================================
   Loading States (Skeleton)
   ============================================ */
.skeleton-album {
    background: var(--gallery-card-bg);
    border-radius: var(--gallery-radius);
    overflow: hidden;
    box-shadow: 0 4px 6px -1px var(--gallery-shadow);
    border: 1px solid var(--gallery-border);
}

.skeleton-album-cover {
    width: 100%;
    padding-top: 66.67%;
    background: linear-gradient(90deg, #EDF2F7 25%, #E2E8F0 50%, #EDF2F7 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

.skeleton-album-title {
    height: 70px;
    margin: 1.25rem;
    background: linear-gradient(90deg, #EDF2F7 25%, #E2E8F0 50%, #EDF2F7 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 8px;
}

.skeleton-photo {
    width: 100%;
    padding-top: 100%;
    background: linear-gradient(90deg, #EDF2F7 25%, #E2E8F0 50%, #EDF2F7 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--gallery-radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   Error States
   ============================================ */
.gallery-error {
    text-align: center;
    padding: 4rem 2rem;
    background: var(--gallery-card-bg);
    border-radius: var(--gallery-radius);
    box-shadow: 0 4px 6px -1px var(--gallery-shadow);
    border: 1px solid var(--gallery-border);
}

.gallery-error-icon {
    font-size: 3.5rem;
    margin-bottom: 1.25rem;
    opacity: 0.8;
}

.gallery-error-message {
    font-size: 1.0625rem;
    color: var(--gallery-text-light);
    margin-bottom: 1.75rem;
    font-family: var(--gallery-font);
    line-height: 1.6;
}

.gallery-error-retry {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: var(--gallery-primary);
    color: #fff;
    border: none;
    border-radius: var(--gallery-radius-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--gallery-transition);
    font-family: var(--gallery-font);
}

.gallery-error-retry:hover {
    background: var(--gallery-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 27, 61, 0.3);
}

.gallery-error-retry:disabled {
    background: #CBD5E0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ============================================
   Empty State
   ============================================ */
.gallery-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--gallery-text-light);
    font-family: var(--gallery-font);
}

.gallery-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.4;
}

.gallery-empty p {
    font-size: 1.0625rem;
    margin: 0;
}

/* ============================================
   Modal / Lightbox
   ============================================ */
.gallery-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 10000;
    cursor: pointer;
    backdrop-filter: blur(8px);
}

.gallery-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.gallery-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    cursor: default;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.gallery-modal-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.gallery-modal-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 64px;
    height: 64px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
    transition: var(--gallery-transition);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.gallery-modal-nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
    border-color: rgba(255, 255, 255, 0.4);
}

.gallery-modal-close {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 56px;
    height: 56px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #fff;
    transition: var(--gallery-transition);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.gallery-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.4);
}

.gallery-modal-prev {
    left: 1.5rem;
}

.gallery-modal-next {
    right: 1.5rem;
}

.gallery-modal-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 1.125rem;
    font-family: var(--gallery-font);
    font-weight: 500;
}

/* ============================================
   Load More Button
   ============================================ */
.load-more-container,
.load-more-albums-container {
    text-align: center;
    margin: 3rem 0;
    padding: 1rem;
}

.load-more-btn,
.load-more-albums-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 1rem 2.5rem;
    background: var(--gallery-card-bg);
    color: var(--gallery-primary);
    border: 2px solid var(--gallery-primary);
    border-radius: 50px;
    font-size: 1.0625rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--gallery-transition);
    font-family: var(--gallery-font);
    letter-spacing: 0.01em;
}

.load-more-btn:hover,
.load-more-albums-btn:hover {
    background: var(--gallery-primary);
    color: #fff;
    box-shadow: 0 8px 20px rgba(139, 27, 61, 0.3);
    transform: translateY(-3px);
}

.load-more-btn:active,
.load-more-albums-btn:active {
    transform: translateY(-1px);
}

.load-more-btn:disabled,
.load-more-albums-btn:disabled {
    background: #F7FAFC;
    color: #A0AEC0;
    border-color: #E2E8F0;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ============================================
   Album Page Header
   ============================================ */
.album-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid var(--gallery-border);
}

.album-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--gallery-primary);
    text-decoration: none;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    transition: var(--gallery-transition);
    font-family: var(--gallery-font);
    padding: 0.75rem 1.25rem;
    background-color: rgba(139, 27, 61, 0.05);
    border-radius: 50px;
}

.album-back-link:hover {
    color: var(--gallery-primary-dark);
    background-color: rgba(139, 27, 61, 0.1);
    transform: translateX(-4px);
    text-decoration: none;
}

.album-header h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gallery-text);
    font-family: var(--gallery-font);
    line-height: 1.3;
    letter-spacing: -0.02em;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 1024px) {
    #albumGrid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    #albumGrid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1.25rem;
    }

    #photoGrid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .album-title-section {
        padding: 1rem;
    }

    .album-title {
        font-size: 1rem;
    }

    .gallery-modal-nav {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .gallery-modal-prev {
        left: 0.75rem;
    }

    .gallery-modal-next {
        right: 0.75rem;
    }

    .gallery-modal-close {
        top: 0.75rem;
        right: 0.75rem;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .album-header h1 {
        font-size: 1.5rem;
    }

    .load-more-btn,
    .load-more-albums-btn {
        padding: 0.875rem 2rem;
        font-size: 1rem;
    }

    .gallery-date-filters {
        gap: 0.5rem;
    }

    .gallery-filter-select {
        min-width: 140px;
        padding: 0.75rem 2.5rem 0.75rem 1rem;
        font-size: 1rem;
    }

    .gallery-clear-filters {
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }

    .gallery-search input {
        padding: 1rem 1.25rem 1rem 3.25rem;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    #albumGrid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    #photoGrid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .album-cover {
        padding-top: 56.25%; /* 16:9 on mobile */
    }

    .photo-item {
        border-radius: 8px;
    }

    .gallery-date-filters {
        flex-direction: column;
        width: 100%;
    }

    .gallery-filter-select {
        width: 100%;
    }

    .gallery-clear-filters {
        width: 100%;
        justify-content: center;
    }

    .gallery-search input {
        border-radius: 12px;
    }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.album-card:focus-visible,
.photo-item:focus-visible,
.gallery-filter-select:focus-visible,
.gallery-search input:focus-visible,
.load-more-btn:focus-visible,
.load-more-albums-btn:focus-visible,
.gallery-clear-filters:focus-visible {
    outline: 3px solid var(--gallery-primary);
    outline-offset: 2px;
}
