/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header styles */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 20px 0;
}

.title {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
    font-size: 2.5rem;
    font-weight: 700;
}

.search-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    max-width: 400px;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

.search-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-btn, .clear-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.search-btn {
    background: #667eea;
    color: white;
}

.search-btn:hover {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.clear-btn {
    background: #f8f9fa;
    color: #333;
    border: 2px solid #e1e5e9;
}

.clear-btn:hover {
    background: #e9ecef;
}

.filters {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.filter-select {
    padding: 10px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 20px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
}

.filter-select:focus {
    border-color: #667eea;
}

/* Main content */
.main {
    padding: 40px 0;
}

/* Grid layout */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.grid-item {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.grid-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

.grid-item-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.grid-item:hover .grid-item-image {
    transform: scale(1.05);
}

.grid-item-content {
    padding: 20px;
}

.grid-item-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
    line-height: 1.4;
}

.grid-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.tag {
    background: #f8f9fa;
    color: #495057;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.grid-item-meta {
    font-size: 14px;
    color: #6c757d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-type {
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

/* Loading states */
.loading-indicator {
    text-align: center;
    padding: 60px 20px;
    color: white;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.load-more-container {
    text-align: center;
    margin: 40px 0;
}

.load-more-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.load-more-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Error states */
.error-message {
    text-align: center;
    padding: 40px 20px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 15px;
    margin: 20px 0;
}

.retry-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #c82333;
}

/* Responsive design */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }
    
    .search-container {
        flex-direction: column;
        align-items: center;
    }
    
    .search-input {
        width: 100%;
        max-width: none;
    }
    
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 20px;
    }
    
    .filters {
        flex-direction: column;
        align-items: center;
    }
    
    .filter-select {
        width: 200px;
    }
}

@media (max-width: 480px) {
    .grid-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .container {
        padding: 0 15px;
    }
}

/* Image container and overlay */
.grid-item-image-container {
    position: relative;
    overflow: hidden;
}

.grid-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom, rgba(0,0,0,0.7) 0%, transparent 30%, transparent 70%, rgba(0,0,0,0.7) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 15px;
}

.grid-item-overlay .content-type {
    align-self: flex-start;
}

.view-link {
    color: #667eea;
    font-weight: 600;
    cursor: pointer;
}

/* Lazy loading and error states */
.grid-item-image.lazy {
    background: #f8f9fa;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.grid-item-image.lazy::before {
    content: "Loading...";
    color: #6c757d;
    font-size: 14px;
}

.image-placeholder {
    height: 200px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: #6c757d;
}

.placeholder-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.placeholder-text {
    font-size: 14px;
}

.grid-item.image-error {
    opacity: 0.7;
}

/* Loading placeholders */
.grid-item.loading {
    background: #f8f9fa;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.grid-item.loading .grid-item-image {
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

.grid-item.loading .grid-item-content {
    background: #f8f9fa;
}

.loading-placeholder {
    color: #6c757d;
    font-size: 14px;
}

.loading-title {
    height: 20px;
    background: #e9ecef;
    border-radius: 4px;
    margin-bottom: 10px;
    width: 80%;
}

.loading-tags {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.loading-tag {
    height: 16px;
    background: #e9ecef;
    border-radius: 8px;
    width: 60px;
}

.loading-meta {
    height: 16px;
    background: #e9ecef;
    border-radius: 4px;
    width: 60%;
}