/**
 * Comment Link Preview Styles
 * Styles for link previews within comments
 */

/* Container for all link previews in a comment */
.comment-link-previews {
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Individual link preview card */
.comment-link-preview-card {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.comment-link-preview-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
    text-decoration: none;
}

/* Container layout */
.comment-link-preview-container {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 0;
    max-height: 80px;
    min-height: 80px;
}

/* Thumbnail section */
.comment-link-preview-thumbnail {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.comment-link-preview-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.comment-link-preview-card:hover .comment-link-preview-thumbnail img {
    transform: scale(1.05);
}

/* Content section */
.comment-link-preview-content {
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #ffffff;
    overflow: hidden;
}

/* Header with favicon and domain */
.comment-link-preview-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.3rem;
}

.comment-link-preview-favicon {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    object-fit: contain;
}

.comment-link-preview-domain {
    font-size: 0.75rem;
    color: #667eea;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Title */
.comment-link-preview-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1a1a1a;
    margin: 0 0 0.25rem 0;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Description */
.comment-link-preview-description {
    font-size: 0.75rem;
    color: #666;
    line-height: 1.3;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Footer */
.comment-link-preview-footer {
    display: none; /* Hide footer to save space */
}

/* Inline link icon (replaces the URL text) */
.comment-inline-link-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    margin: 0 4px;
    transition: all 0.2s ease;
    vertical-align: middle;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.comment-inline-link-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.5);
    text-decoration: none;
    color: white;
}

.comment-inline-link-icon i {
    font-size: 0.75rem;
}

/* Dark theme support */
[data-theme="dark"] .comment-link-preview-card {
    background: #2d3748;
    border-color: #4a5568;
}

[data-theme="dark"] .comment-link-preview-content {
    background: #2d3748;
}

[data-theme="dark"] .comment-link-preview-title {
    color: #f7fafc;
}

[data-theme="dark"] .comment-link-preview-description {
    color: #cbd5e0;
}

[data-theme="dark"] .comment-link-preview-thumbnail {
    background: #1a202c;
}

[data-theme="dark"] .comment-link-preview-card:hover {
    border-color: #667eea;
    background: #374151;
}

/* Responsive design */
@media (max-width: 768px) {
    .comment-link-preview-container {
        grid-template-columns: 70px 1fr;
        max-height: 70px;
        min-height: 70px;
    }
    
    .comment-link-preview-thumbnail {
        min-height: 70px;
        max-height: 70px;
    }
    
    .comment-link-preview-content {
        padding: 0.4rem 0.6rem;
    }
    
    .comment-link-preview-title {
        font-size: 0.8rem;
    }
    
    .comment-link-preview-description {
        font-size: 0.7rem;
    }
}

/* When there's no thumbnail, make content full width */
.comment-link-preview-container:not(:has(.comment-link-preview-thumbnail)) {
    grid-template-columns: 1fr;
}

/* Animation for newly added previews */
@keyframes slideInPreview {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comment-link-preview-card {
    animation: slideInPreview 0.3s ease-out;
}

/* Loading state */
.comment-link-preview-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #999;
}

.comment-link-preview-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error state */
.comment-link-preview-error {
    padding: 0.75rem;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 6px;
    color: #c33;
    font-size: 0.85rem;
    text-align: center;
}

/* Compact mode for nested comments */
.comment-item[style*="margin-left"] .comment-link-preview-container {
    grid-template-columns: 70px 1fr;
    max-height: 70px;
    min-height: 70px;
}

.comment-item[style*="margin-left"] .comment-link-preview-thumbnail {
    min-height: 70px;
    max-height: 70px;
}

/* Ensure link icons don't break text flow */
.comment-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Style for links that are being processed */
.comment-text[data-links-processing="true"] {
    opacity: 0.7;
}

