/* Additional styles for better image handling */
.media-preview {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-preview img {
    width: 100%;
    height: auto;
    max-height: 250px;
    object-fit: contain;
}

.image-loading {
    color: #999;
    font-style: italic;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.image-error {
    color: #ff6b6b;
    text-align: center;
    padding: 20px;
}

.image-error i {
    font-size: 3rem;
    margin-bottom: 10px;
    display: block;
}

.proxy-warning {
    background-color: #fff3cd;
    color: #856404;
    padding: 10px 15px;
    border-radius: 5px;
    margin: 10px 0;
    font-size: 14px;
}

/* Loader styles */
.loader {
    display: none;
    flex-direction: column;
    align-items: center;
    margin: 1.5rem auto;
    color: #555;
    font-size: 1rem;
}

.loader .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #ddd;
    border-top: 4px solid #e1306c;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 10px;
}

@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

/* Results styles */
#results {
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.media-item {
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.media-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.video-container {
    position: relative;
    width: 100%;
    height: 250px;
    overflow: hidden;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e1306c;
    font-size: 20px;
    opacity: 0.9;
    transition: var(--transition);
}

.video-container:hover .play-button {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.media-actions {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.download-link {
    display: inline-block;
    padding: 10px 15px;
    background: #e1306c;
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s ease;
    text-align: center;
}

.download-link:hover {
    background: #c72b5c;
}

.copy-link {
    padding: 10px 15px;
    background: #f0f0f0;
    color: #333;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.copy-link:hover {
    background: #e0e0e0;
}

.error {
    padding: 15px;
    background: #ffebee;
    color: #c62828;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
}

.success {
    padding: 15px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .media-grid {
        grid-template-columns: 1fr;
    }
    
    .media-actions {
        flex-direction: row;
        justify-content: center;
    }
    
    .download-link, .copy-link {
        flex: 1;
        text-align: center;
    }
}