:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --border-color: #e0e0e0;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --error-color: #dc2626;
    --success-color: #16a34a;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.album-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.album-selector label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.album-selector input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.875rem;
    min-width: 150px;
    transition: border-color 0.2s ease;
}

.album-selector input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-icon {
    padding: 0.5rem;
    background-color: transparent;
    border: 1px solid var(--border-color);
}

.btn-icon:hover {
    background-color: var(--bg-secondary);
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    min-height: calc(100vh - 200px);
}

.loading,
.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.hidden {
    display: none !important;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error-message {
    color: var(--error-color);
}

.error-message p {
    margin-bottom: 1rem;
    font-size: 1.125rem;
}

.gallery-info {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.gallery-info h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.gallery-info p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.gallery-stats {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.separator {
    opacity: 0.5;
}

#view-mode {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    padding: 0.5rem;
    background-color: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.view-btn:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.view-btn.active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.gallery {
    display: grid;
    gap: 1.5rem;
}

.gallery.grid-view {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.gallery.masonry-view {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    grid-auto-rows: 10px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background-color: var(--bg-card);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 2px solid var(--border-color);
}

.gallery.grid-view .gallery-item {
    aspect-ratio: 1;
    height: auto;
}

.gallery.masonry-view .gallery-item {
    height: auto;
    display: flex;
    align-items: flex-start;
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.gallery-item img {
    width: 100%;
    display: block !important;
    visibility: visible !important;
    transition: transform 0.3s ease;
}

.gallery.grid-view .gallery-item img {
    height: 100%;
    object-fit: cover;
}

.gallery.masonry-view .gallery-item img {
    height: auto;
    object-fit: cover;
    width: 100%;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 1rem;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-item-overlay {
    transform: translateY(0);
}

.gallery-item-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.gallery-item-description {
    font-size: 0.75rem;
    opacity: 0.9;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 0.75rem;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.lightbox-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 1rem;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    transition: background-color 0.2s ease;
}

.lightbox-nav:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: 2rem;
}

.lightbox-next {
    right: 2rem;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

#lightbox-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.lightbox-info {
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 8px;
    color: white;
    text-align: center;
    max-width: 600px;
}

.lightbox-info h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.lightbox-info p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-bottom: 1rem;
}

.lightbox-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.lightbox-actions .btn {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.lightbox-actions .btn:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.lightbox-counter {
    font-size: 0.875rem;
    opacity: 0.8;
}

.footer {
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-controls {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .album-selector {
        flex-direction: column;
        align-items: stretch;
    }

    .album-selector input {
        width: 100%;
    }

    .gallery.grid-view {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .gallery.masonry-view {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .lightbox {
        padding: 1rem;
    }

    .lightbox-nav {
        padding: 0.75rem;
    }

    .lightbox-prev {
        left: 1rem;
    }

    .lightbox-next {
        right: 1rem;
    }

    #lightbox-image {
        max-height: 60vh;
    }

    .lightbox-info {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .gallery.grid-view,
    .gallery.masonry-view {
        grid-template-columns: 1fr;
    }

    .main-content {
        padding: 1rem;
    }

    .header {
        padding: 1rem;
    }
}

.lightbox-camera-info {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    font-size: 0.9rem;
}

.lightbox-camera-info:empty {
    display: none;
}

.camera-info-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #fff;
}

.camera-info-grid {
    display: flex;
    flex-wrap: nowrap;
    gap: 1.5rem;
    justify-content: flex-start;
}

.camera-info-item {
    display: flex;
    flex-direction: column;
}

.camera-info-label {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.camera-info-value {
    font-size: 0.9rem;
    color: #fff;
    font-weight: 500;
}
