/* CSS Variables */
:root {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --border: #2a2a2a;
    --error: #ef4444;
    --success: #22c55e;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    width: 100%;
    padding: 0 16px;
    margin: 0 auto;
}

/* Header */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

.gallery-header h1 {
    font-size: 24px;
    font-weight: 600;
}

@media (min-width: 768px) {
    .gallery-header h1 {
        font-size: 28px;
    }
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: #2a2a2a;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Photo Grid - Using CSS Grid for row-wise layout */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
}

@media (min-width: 640px) {
    .photo-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

@media (min-width: 1280px) {
    .photo-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (min-width: 1536px) {
    .photo-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

/* Photo Wrapper */
.photo-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Photo Card */
.photo-card {
    width: 100%;
}

.photo-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 8px;
    background: #1a1a1a;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

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

/* Download Link */
.download-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    background-color: var(--bg-tertiary);
    border-radius: 6px;
    text-decoration: none;
    transition: all 0.2s ease;
    align-self: flex-start;
}

.download-link:hover {
    color: var(--text-primary);
    background-color: #2a2a2a;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 80px 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-state p {
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: var(--bg-secondary);
    padding: 32px;
    border-radius: 12px;
    max-width: 400px;
    width: calc(100% - 32px);
    border: 1px solid var(--border);
}

.modal-content h2 {
    font-size: 24px;
    margin-bottom: 24px;
}

.password-input {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    margin-bottom: 16px;
    transition: border-color 0.2s ease;
}

.password-input:focus {
    outline: none;
    border-color: var(--accent);
}

.password-input.error {
    border-color: var(--error);
}

.error-message {
    color: var(--error);
    font-size: 14px;
    margin-bottom: 16px;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    cursor: pointer;
}

.lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    cursor: default;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    display: block;
    border-radius: 8px;
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background-color: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background-color 0.2s ease;
}

.lightbox-close:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

.lightbox-download {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
}

/* Lightbox Navigation */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: background-color 0.2s ease;
}

.lightbox-nav:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

.lightbox-prev {
    left: 16px;
}

.lightbox-next {
    right: 16px;
}

/* Upload Page Styles */
.upload-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

.upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 32px;
}

.upload-header h1 {
    font-size: 28px;
    font-weight: 600;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background-color: var(--bg-secondary);
}

.drop-zone.drag-over {
    border-color: var(--accent);
    background-color: rgba(59, 130, 246, 0.05);
}

.drop-zone-content h3 {
    font-size: 20px;
    margin-bottom: 8px;
}

.drop-zone-content p {
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-icon {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

/* File List */
.file-list-container {
    margin-top: 32px;
}

.file-list-container h3 {
    font-size: 18px;
    margin-bottom: 16px;
}

.file-list {
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 24px;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.file-item:last-child {
    border-bottom: none;
}

.file-item.uploading {
    background-color: rgba(59, 130, 246, 0.1);
}

.file-item.success {
    background-color: rgba(34, 197, 94, 0.1);
}

.file-item.error {
    background-color: rgba(239, 68, 68, 0.1);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.file-size {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.file-status {
    font-size: 13px;
    font-weight: 500;
    margin-right: 8px;
}

.status-pending { color: #6b7280; }
.status-uploading { color: #3b82f6; }
.status-success { color: #22c55e; }
.status-error { color: #ef4444; font-size: 12px; }

.remove-file-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s ease;
}

.remove-file-btn:hover {
    color: var(--error);
}

.upload-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Progress Bar */
.progress-bar-container {
    height: 4px;
    background-color: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-bar {
    height: 100%;
    background-color: var(--accent);
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.upload-progress {
    margin-top: 32px;
}

.upload-result {
    text-align: center;
}

.success-message {
    color: var(--success);
    font-size: 18px;
    margin-bottom: 16px;
}

.error-list {
    background-color: var(--bg-secondary);
    border: 1px solid var(--error);
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    text-align: left;
}

.error-list h4 {
    color: var(--error);
    margin-bottom: 8px;
    font-size: 16px;
}

.error-list ul {
    list-style: none;
    padding: 0;
}

.error-list li {
    color: var(--text-secondary);
    font-size: 14px;
    padding: 4px 0;
}

.overall-progress {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}

.upload-summary {
    margin-top: 16px;
}

/* Animations */
[x-transition] {
    transition: opacity 0.3s ease;
}

[x-transition].opacity-0 {
    opacity: 0;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .gallery-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .modal-content {
        padding: 24px;
    }
    
    .lightbox-nav {
        width: 40px;
        height: 40px;
    }
}