/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #ffffff;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    overflow-y: scroll;
}

/* Page Title */
.page-title {
    text-align: center;
    padding: 1.5rem 1rem 0.5rem 1rem;
    background: #ffffff;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.page-title h1 {
    font-size: 1.8rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

/* Control Bar - Sticky, Full Width */
.control-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0.5rem 1rem;
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Zoom Control */
.zoom-control {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
}

/* Photo Count */
.photo-count {
    font-size: 14px;
    color: #000;
    font-weight: 500;
}

.zoom-btn {
    width: 24px;
    height: 24px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 3px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.zoom-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.zoom-slider {
    width: 80px;
    height: 3px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 2px;
    outline: none;
    cursor: grab;
}

.zoom-slider:active {
    cursor: grabbing;
}

.zoom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: #667eea;
    border-radius: 50%;
    cursor: grab;
    transition: transform 0.1s, background 0.2s;
}

.zoom-slider::-webkit-slider-thumb:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.zoom-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.15);
}

.zoom-slider::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: #667eea;
    border-radius: 50%;
    cursor: grab;
    border: none;
    transition: transform 0.1s, background 0.2s;
}

.zoom-slider::-moz-range-thumb:hover {
    background: #764ba2;
    transform: scale(1.1);
}

.zoom-slider::-moz-range-thumb:active {
    cursor: grabbing;
    transform: scale(1.15);
}

/* Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--image-size, 150px), 1fr));
    gap: 2px;
    padding: 4px 2px 2px 2px;
    max-width: 100%;
    transition: all 0.15s ease-out;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
    aspect-ratio: 1;
    background: #f5f5f5;
}

.gallery-item:hover {
    z-index: 10;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-item .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    color: white;
    padding: 8px;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}

.gallery-item:hover .overlay {
    opacity: 1;
}

.gallery-item .date {
    font-size: 11px;
    font-weight: 500;
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0);
    opacity: 0;
    transition: background-color 0.2s ease-out, opacity 0.2s ease-out;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal.show {
    background-color: rgba(0,0,0,0.9);
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-content img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 8px;
    background: #1a1a1a;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

.modal-info {
    color: white;
    text-align: center;
    margin-top: 1.5rem;
    padding: 0 1rem;
}

.modal-info h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-info p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover,
.close:focus {
    color: #667eea;
}

/* Navigation Arrows */
.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    z-index: 1001;
    padding: 0;
    line-height: 1;
}

.nav-arrow:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-50%) scale(1.1);
}

.nav-arrow.prev {
    left: 20px;
}

.nav-arrow.next {
    right: 20px;
}

.nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.nav-arrow:disabled:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1);
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: #999;
    background: #ffffff;
    margin-top: 2rem;
    font-size: 14px;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #667eea;
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.2s;
    z-index: 99;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.back-to-top:hover {
    background: #764ba2;
    box-shadow: 0 4px 12px rgba(118, 75, 162, 0.5);
}

/* Responsive Design */
@media (max-width: 768px) {
    .page-title h1 {
        font-size: 1.4rem;
    }

    .control-bar {
        padding: 0.5rem;
    }

    .zoom-btn {
        width: 20px;
        height: 20px;
        font-size: 14px;
    }

    .zoom-slider {
        width: 60px;
    }

    .photo-count {
        font-size: 12px;
    }

    .gallery {
        padding-top: 8px;
        gap: 1px;
    }

    .modal-content img {
        max-height: 70vh;
    }

    .close {
        top: 10px;
        right: 20px;
        font-size: 35px;
    }
}

@media (max-width: 480px) {
    .gallery {
        gap: 1px;
    }
}
