/* 组件样式 */

/* 图片组件 */
.message-image {
    max-width: 90%;
    border-radius: 8px;
    margin: var(--space-sm) 0;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.message-image.loading {
    background-color: var(--border-color);
    min-height: 200px;
}

.message-image.error {
    opacity: 0.5;
}

/* 链接卡片 */
.link-card {
    display: flex;
    align-items: center;
    padding: var(--space-md);
    margin: var(--space-sm) 0;
    background-color: var(--bg-color);
    border-radius: 8px;
    min-height: 48px;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.link-card:active {
    transform: scale(0.98);
}

.link-icon {
    width: 24px;
    height: 24px;
    margin-right: var(--space-md);
    flex-shrink: 0;
}

.link-content {
    flex: 1;
    min-width: 0;
}

.link-title {
    font-size: var(--font-size-base);
    color: var(--accent-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.link-url {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

/* YouTube 视频链接 */
.link-card.youtube .link-icon::before {
    content: "▶";
    color: #FF0000;
    font-size: 20px;
}

/* 播客链接 */
.link-card.podcast .link-icon::before {
    content: "🎙";
    font-size: 20px;
}

/* 公众号文章链接 */
.link-card.article .link-icon::before {
    content: "📄";
    font-size: 20px;
}

/* 微信文章链接（特殊样式） */
.link-card.wechat-article {
    background-color: #f7f7f7;
    border: 1px solid #e0e0e0;
}

.link-card.wechat-article .link-icon::before,
.link-card.wechat-article .wechat-icon::before {
    content: "📰";
    font-size: 20px;
}

.link-card.wechat-article .link-title {
    color: #333;
    font-weight: 500;
}

.link-card.wechat-article .link-url {
    color: #07c160;  /* 微信绿色 */
    font-size: var(--font-size-xs);
}

/* 普通链接 */
.link-card.default .link-icon::before {
    content: "🔗";
    font-size: 20px;
}

/* 内联链接 */
.inline-link {
    color: var(--accent-color);
    text-decoration: underline;
}

/* 图片灯箱 */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-normal), visibility var(--transition-normal);
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.lightbox-close {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    width: 48px;
    height: 48px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    line-height: 1;
}

/* 图片占位符 */
.image-placeholder {
    width: 100%;
    max-width: 300px;
    height: 200px;
    background-color: var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: var(--font-size-sm);
}

.image-placeholder::before {
    content: "图片加载失败";
}

/* 骨架屏 */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* 内容块引用样式 */
.message-content blockquote {
    border-left: 3px solid var(--accent-color);
    padding-left: var(--space-md);
    margin: var(--space-sm) 0;
    color: var(--text-secondary);
}

.message-content code {
    background-color: var(--bg-color);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre {
    background-color: var(--bg-color);
    padding: var(--space-md);
    border-radius: 8px;
    overflow-x: auto;
    margin: var(--space-sm) 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

/* 富媒体链接卡片 */
.rich-link-card {
    display: block;
    background-color: var(--bg-color);
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    max-width: 480px;
    text-decoration: none;
    margin: 8px 0;
}

.rich-link-card:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.rich-link-card:active {
    transform: scale(0.98);
}

.rich-link-wrapper {
    display: flex;
    flex-direction: row;
    min-height: 100px;
}

.rich-link-image-wrapper {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    overflow: hidden;
    background-color: #f5f5f5;
}

.rich-link-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 微信文章占位符样式 */
.rich-link-image-wrapper.wechat-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f0f7f0 0%, #e8f5e8 100%);
    position: relative;
}

.wechat-article-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.wechat-article-icon svg {
    opacity: 0.6;
}

.wechat-text {
    font-size: 11px;
    color: #07c160;
    font-weight: 500;
    opacity: 0.8;
}

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

.rich-link-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.rich-link-description {
    font-size: 13px;
    color: #666;
    margin: 4px 0 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.rich-link-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #999;
}

.rich-link-favicon {
    width: 16px;
    height: 16px;
    border-radius: 2px;
}

.rich-link-domain {
    color: #999;
}

.rich-link-author {
    color: #999;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 加载状态 */
.rich-link-card.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #f5f5f5 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading-rich 1.5s infinite;
}

@keyframes loading-rich {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.rich-link-loading {
    padding: 12px;
    min-height: 80px;
}

.rich-link-loading .rich-link-content {
    opacity: 0.7;
}

.rich-link-loading .rich-link-url {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* 响应式布局 */
@media (max-width: 480px) {
    .rich-link-wrapper {
        flex-direction: column;
    }

    .rich-link-image-wrapper {
        width: 100%;
        height: 180px;
    }

    /* 微信占位符在移动端的样式 */
    .rich-link-image-wrapper.wechat-placeholder {
        height: 120px;
    }

    .wechat-article-icon svg {
        width: 36px;
        height: 36px;
    }

    .wechat-text {
        font-size: 10px;
    }
}

/* YouTube视频卡片样式 */
.youtube-card {
    display: block;
    background-color: var(--bg-color);
    border-radius: 12px;
    overflow: hidden;
    margin: var(--space-sm) 0;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 400px;
}

.youtube-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.youtube-card:active {
    transform: scale(0.98);
}

/* YouTube缩略图容器 */
.youtube-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 宽高比 */
    background-color: #000;
    overflow: hidden;
}

.youtube-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* YouTube播放按钮 */
.youtube-play-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68px;
    height: 48px;
    background-color: rgba(255, 0, 0, 0.85);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    transition: background-color var(--transition-fast);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.youtube-card:hover .youtube-play-button {
    background-color: rgba(255, 0, 0, 1);
}

/* YouTube视频信息 */
.youtube-info {
    padding: var(--space-md);
    background-color: var(--bg-color);
}

.youtube-title {
    font-size: var(--font-size-base);
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
    min-height: 1.4em;
}

.youtube-author {
    display: block;
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.8;
}

.youtube-badge {
    display: inline-block;
    font-size: var(--font-size-sm);
    color: #FF0000;
    background-color: rgba(255, 0, 0, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

/* 媒体查询 - 桌面端 */
@media (min-width: 1024px) {
    .message-image {
        max-width: 600px;
    }

    .link-card {
        min-height: 52px;
    }

    .youtube-card {
        max-width: 480px;
    }
}

/* 自动注入的二维码样式 */
.qr-code-auto {
    max-width: 200px !important;
    margin-top: 12px;
    border: 1px solid #e0e0e0;
    padding: 8px;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 消息文本容器样式 */
.message-text {
    line-height: 1.6;
}

/* 消息段落样式 */
.message-paragraph {
    margin: 0 0 12px 0;
    line-height: 1.6;
}

.message-paragraph:last-child {
    margin-bottom: 0;
}