/**
 * Media Module - Link Previews & Music Embeds
 * Handles rich media content display in chat
 */

/* ===== LINK PREVIEWS ===== */
.link_preview {
    display: flex;
    margin: 10px 0;
    border: 1px solid;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    max-width: 100%;
    background: inherit;
    color: inherit;
    border-color: inherit;
}

.link_preview:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.link_preview .preview_title {
    color: inherit;
}

.link_preview .preview_description {
    color: inherit;
    opacity: 0.8;
}

.link_preview .preview_url,
.link_preview .preview_site_name {
    color: inherit;
    opacity: 0.7;
}

.link_preview_loading {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 10px 0;
    padding: 20px;
    border: 1px solid;
    border-radius: 8px;
    background: inherit;
    color: inherit;
    border-color: inherit;
    transition: all 0.2s ease;
}

/* Theme support - inherit from parent containers */
.back_chat .link_preview,
.back_priv .link_preview,
.back_panel .link_preview,
.back_menu .link_preview,
.back_box .link_preview,
.back_modal .link_preview,
.back_input .link_preview,
#news_data .link_preview,
#friend_post .link_preview,
.post_element .link_preview {
    background: inherit;
    color: inherit;
    border-color: inherit;
}

/* Link preview content */
.preview_image {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    overflow: hidden;
}

.preview_image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview_content {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.preview_title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preview_description {
    font-size: 12px;
    line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preview_url {
    font-size: 11px;
    text-decoration: none;
    font-family: monospace;
}

.preview_site_info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: auto;
}

.preview_site_name {
    font-size: 12px;
    font-weight: 500;
}

/* News/blog specific adjustments */
.post_content .link_preview {
    margin: 8px 0;
    border-radius: 6px;
}

.post_content .link_preview .preview_image {
    width: 100px;
    height: 100px;
}

.post_content .link_preview .preview_content {
    padding: 10px;
}

.post_content .link_preview .preview_title {
    font-size: 13px;
}

.post_content .link_preview .preview_description {
    font-size: 11px;
}

/* Loading spinner */
.loading_spinner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading_spinner::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid;
    border-top: 2px solid;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.backglob .loading_spinner::before {
    border-color: rgba(255, 255, 255, 0.2);
    border-top-color: #03add8;
}

body:not(.backglob) .loading_spinner::before {
    border-color: #e9ecef;
    border-top-color: #007bff;
}

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

/* ===== MUSIC SERVICE EMBEDS ===== */
.chat_music_container {
    margin: 10px 0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    max-width: 100%;
    background: rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.music_embed_wrapper {
    position: relative;
    width: 100%;
}

.music_embed_wrapper iframe {
    width: 100%;
    border: none;
    border-radius: 8px 8px 0 0;
}

.music_service_badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 10;
    pointer-events: none;
}

/* Service-specific badge colors */
.spotify_container .music_service_badge {
    background: #1db954;
}

.soundcloud_container .music_service_badge {
    background: #ff5500;
}

.apple_music_container .music_service_badge {
    background: #fa243c;
}

.tidal_container .music_service_badge {
    background: #000;
}

.deezer_container .music_service_badge {
    background: #a238ff;
}

.youtube_music_container .music_service_badge {
    background: #ff0000;
}

.amazon_music_container .music_service_badge {
    background: #ff9900;
}

.bandcamp_container .music_service_badge {
    background: #629aa0;
}

.mixcloud_container .music_service_badge {
    background: #314359;
}

/* Simple music links (fallback) */
.chat_music_link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    transition: all 0.2s ease;
    text-decoration: none;
}

.chat_music_link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.chat_music_link i {
    font-size: 16px;
}

.chat_music_link a {
    color: inherit;
    text-decoration: none;
    font-weight: 500;
}

/* Service-specific link colors */
.facebook_music i,
.facebook_content i {
    color: #4267b2;
}

.pandora_music i {
    color: #005483;
}

.tidal_music i {
    color: #000;
}

.deezer_music i {
    color: #a238ff;
}

.youtube_music i {
    color: #ff0000;
}

.amazon_music i {
    color: #ff9900;
}

.bandcamp_music i {
    color: #629aa0;
}

.mixcloud_music i {
    color: #314359;
}

/* ===== IMAGE ORIENTATION FIX ===== */
.chat_image, 
.post_image img, 
.chat_video_container img {
    image-orientation: from-image;
    -webkit-image-orientation: from-image;
    -moz-image-orientation: from-image;
}

/* Fallback for rotated images */
.chat_image[style*="transform: rotate"], 
.post_image img[style*="transform: rotate"],
.chat_video_container img[style*="transform: rotate"] {
    transform: none;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    /* Link previews */
    .link_preview {
        flex-direction: column;
    }
    
    .preview_image {
        width: 100%;
        height: 200px;
    }
    
    .preview_content {
        padding: 16px;
    }
    
    /* Music embeds */
    .chat_music_container {
        margin: 8px 0;
    }
    
    .private_logs .chat_music_container {
        max-width: 100%;
        width: 100%;
    }
    
    .private_logs .chat_music_container iframe {
        width: 100%;
        height: 152px;
    }
    
    .music_service_badge {
        font-size: 11px;
        padding: 3px 6px;
        top: 6px;
        right: 6px;
    }
    
    .chat_music_link {
        padding: 6px 10px;
        font-size: 14px;
    }
}

