@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --bg: #020617;
    --card-bg: rgba(30, 41, 59, 0.5);
    --glass-bg: rgba(15, 23, 42, 0.8);
    --primary: #38bdf8;
    --primary-hover: #0ea5e9;
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --accent: #818cf8;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg);
    background-image: 
        radial-gradient(at 0% 0%, rgba(56, 189, 248, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(129, 140, 248, 0.05) 0px, transparent 50%);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    overflow-x: hidden;
}

/* Header & Glassmorphism */
header {
    text-align: center;
    padding: 4rem 2rem 2rem;
    width: 100%;
    max-width: 900px;
}

h1 {
    font-size: 3.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    letter-spacing: -0.025em;
    background: linear-gradient(to right, #38bdf8, #818cf8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

header p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

/* Search Area */
.search-wrapper {
    position: sticky;
    top: 1rem;
    z-index: 100;
    width: 100%;
    max-width: 700px;
    padding: 0 1.5rem;
    margin-bottom: 3rem;
}

.search-container {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 9999px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.1), var(--shadow);
    transform: translateY(-2px);
}

.search-container input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    padding: 0.75rem 1.5rem;
    font-size: 1.1rem;
    outline: none;
    min-width: 0;
}

.clear-search {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0 1rem;
    display: none;
}

.clear-search:hover {
    color: var(--text);
}

.search-container button {
    background: var(--primary);
    color: #020617;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s;
    flex-shrink: 0;
}

.search-container button:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

.search-container button:active {
    transform: scale(0.98);
}

/* Tag Suggestions */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding: 0 1rem;
}

.tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 0.4rem 1rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tag:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-color: var(--text-muted);
}

/* Gallery Grid */
#gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    width: 100%;
    max-width: 1400px;
    padding: 0 2rem 4rem;
}

.img-card {
    background: var(--card-bg);
    border-radius: 16px;
    overflow: hidden;
    aspect-ratio: 4 / 5;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: fadeInUp 0.5s ease-out backwards;
}

.img-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
}

.img-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.img-card:hover img {
    transform: scale(1.1);
}

.overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(2, 6, 23, 0.9) 0%, rgba(2, 6, 23, 0.4) 40%, transparent 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.img-card:hover .overlay {
    opacity: 1;
}

.img-title {
    font-weight: 500;
    font-size: 0.95rem;
    margin-top: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.provider-badge {
    align-self: flex-start;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.provider-badge.Reddit { background: #ff4500; color: white; }
.provider-badge.Unsplash { background: #fff; color: #000; }
.provider-badge.Pixabay { background: #00ab6b; color: white; }
.provider-badge.Pexels { background: #05a081; color: white; }

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.95);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.lightbox.active {
    display: flex;
    opacity: 1;
}

.lightbox-content {
    max-width: 90%;
    max-height: 85vh;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.lightbox img {
    max-width: 100%;
    max-height: 75vh;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.8);
    object-fit: contain;
}

.lightbox-info {
    text-align: center;
    width: 100%;
}

.lightbox-title {
    color: white;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.lightbox-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-source {
    padding: 0.6rem 1.5rem;
    border-radius: 9999px;
    background: var(--primary);
    color: #020617;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.close-lightbox {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    color: white;
    font-size: 2.5rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 1100;
}

.close-lightbox:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading & Status States */
#status {
    text-align: center;
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 2rem;
    width: 100%;
}

.stats-bar {
    width: 100%;
    max-width: 1400px;
    margin-bottom: 1.5rem;
    padding: 0 2rem;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text-muted);
    display: none;
}

.spinner {
    font-size: 1.5rem;
    margin-right: 10px;
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    h1 { font-size: 2.5rem; }
    #gallery { grid-template-columns: 1fr; padding: 0 1.5rem 2rem; }
    .lightbox { padding: 1rem; }
    .search-wrapper { top: 0.5rem; }
}