/* Modern Dark Theme - Fotonest Consumer (Refined) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-gradient: radial-gradient(circle at 50% 0%, #2c3e50, #000000 80%);
    --surface-color: rgba(255, 255, 255, 0.05);
    --primary-color: #3B82F6;
    --text-primary: #FFFFFF;
    --text-secondary: #9CA3AF;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --glass-bg: rgba(0, 0, 0, 0.7);
    --border-radius: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    /* Keep gradient static */
    color: var(--text-primary);
    min-height: 100vh;
    padding-bottom: 100px;
}

/* Empty State */
.empty-gallery {
    grid-column: 1 / -1;
    /* Span full width */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    opacity: 0.8;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Glassmorphic Sticky Header */
header {
    position: sticky;
    top: 0;
    z-index: 50;
    width: 100%;
    background: rgba(0, 0, 0, 0.1);
    /* Very transparent to show gradient */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 16px 0;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    /* Restore padding to match body */
}

header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #60A5FA, #C084FC);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Buttons */
.primary-button {
    background: linear-gradient(135deg, var(--primary-color), #2563EB);
    color: white;
    padding: 12px 28px;
    border-radius: 99px;
    font-weight: 600;
    border: none;
    box-shadow: 0 4px 12px var(--accent-glow);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.primary-button:active {
    transform: scale(0.96);
    box-shadow: 0 2px 6px var(--accent-glow);
}

/* Camera Section (Centered & Clean) */
.camera-section {
    position: relative;
    margin-top: 24px;
    display: flex;
    flex-direction: column;
    /* Stack button and video vertically */
    justify-content: center;
    align-items: center;
    min-height: 120px;
    border-radius: var(--border-radius);
    overflow: hidden;
    gap: 24px;
    /* Space between button and video */
}

/* When video is active */
video {
    width: 100%;
    max-width: 600px;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    /* display: none handled by JS */
}

/* Capture & Upload Sections (Standard Flow) */
#captureControls,
#uploadSection {
    width: 100%;
    display: flex;
    /* overridden by inline display: none */
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

#capturedImage {
    max-width: 100%;
    max-height: 50vh;
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#uploadButton,
#captureButton {
    /* Inherit base .primary-button styles via HTML class */
    /* Just ensure no extra overrides unless needed */
    margin-top: 8px;
    min-width: 160px;
    /* Ensure consistent minimum width */
    text-align: center;
    justify-content: center;
}

#uploadButton:active,
#captureButton:active {
    transform: scale(0.96);
}

#uploadButton:active,
#captureButton:active {
    transform: scale(0.98);
}

/* Grid Gallery */
.gallery {
    margin-top: 32px;
    display: grid;
    /* Default: fill with 150px cards */
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

/* Mobile Strict 2-Column Mode */
@media (max-width: 640px) {
    .gallery {
        grid-template-columns: 1fr 1fr;
        /* Force 2 columns */
        gap: 8px;
    }
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    /* Square */
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-color);
    opacity: 0;
    /* Hidden for animation */
    animation: fadeInPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Image */
.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05);
}

/* Floating Badge */
.download-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.download-badge svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1F2937;
    border: 1px solid #374151;
    color: white;
    padding: 12px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error span:first-child {
    color: #F87171;
}

.toast.info span:first-child {
    color: #34D399;
}

/* Animation Keyframes */
@keyframes fadeInPop {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}