/* 组件样式 */

/* 消息组件 - 微信标准样式 */
.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    animation: messageSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    margin-bottom: 0.75rem;
    padding: 0 0.5rem;
}

.message.own {
    align-self: flex-end;
    align-items: flex-end;
}

.message.other {
    align-self: flex-start;
    align-items: flex-start;
}

/* 移除hover效果的装饰线，保持微信简洁风格 */
.message::before {
    display: none;
}

.message-content {
    background-color: #ffffff;
    padding: 0.625rem 0.875rem;
    border-radius: 0.5rem;
    margin-bottom: 0.375rem;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: none;
    position: relative;
    border: 1px solid #e5e5e5;
    /* 允许消息内容被选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

/* 普通文本消息保持紧凑 - 高优先级 */
.message-content .text-message:not(.markdown-rendered) {
    padding: 0 !important;
    margin: 0 !important;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Markdown消息可以有额外的内边距 - 高优先级 */
.message-content .text-message.markdown-rendered {
    padding: 0.375rem 28px 0.375rem 0 !important; /* 右边留出按钮空间 */
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* 自己发送的消息 - 微信绿色气泡 */
.message.own .message-content {
    background: #95ec69;
    color: #000000;
    border: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    color: #999999;
    margin-bottom: 0.25rem;
    font-weight: 400;
    justify-content: flex-end;
    /* 允许消息元信息被选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.message.other .message-meta {
    justify-content: flex-start;
}

.message-time {
    background: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.75rem;
    font-weight: 400;
    color: #999999;
    /* 允许时间文本被选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.message.own .message-time {
    background: transparent;
    color: #999999;
}

.message-status {
    font-size: 0.8rem;
    opacity: 0.8;
}

.status-sending {
    color: #fbbf24;
}

.status-sent {
    color: #10b981;
}

.status-failed {
    color: #ef4444;
}

/* 文本消息 */
.text-message {
    white-space: pre-wrap;
    position: relative;
    /* 允许文本选择和复制 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
    /* 确保文本可以被选中 */
    cursor: text;
}

/* Markdown渲染样式 */
.text-message.markdown-rendered {
    white-space: normal;
    /* 确保Markdown渲染的内容也可以被选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
    cursor: text;
}

.text-message.markdown-rendered h1,
.text-message.markdown-rendered h2,
.text-message.markdown-rendered h3,
.text-message.markdown-rendered h4,
.text-message.markdown-rendered h5,
.text-message.markdown-rendered h6 {
    margin: 0.3em 0 0.2em 0;
    font-weight: bold;
    line-height: 1.3;
}

.text-message.markdown-rendered h1 { font-size: 1.4em; }
.text-message.markdown-rendered h2 { font-size: 1.2em; }
.text-message.markdown-rendered h3 { font-size: 1.1em; }
.text-message.markdown-rendered h4,
.text-message.markdown-rendered h5,
.text-message.markdown-rendered h6 { font-size: 1em; }

.text-message.markdown-rendered p {
    margin: 0.2em 0;
    line-height: 1.5;
}

/* 第一个和最后一个元素的边距优化 */
.text-message.markdown-rendered > *:first-child {
    margin-top: 0;
}

.text-message.markdown-rendered > *:last-child {
    margin-bottom: 0;
}

.text-message.markdown-rendered ul,
.text-message.markdown-rendered ol {
    margin: 0.3em 0;
    padding-left: 1.2em;
}

.text-message.markdown-rendered li {
    margin: 0.1em 0;
}

.text-message.markdown-rendered blockquote {
    margin: 0.3em 0;
    padding: 0.4em 0.6em;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.message.other .text-message.markdown-rendered blockquote {
    border-left-color: rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.05);
}

.text-message.markdown-rendered code {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.9em;
}

.message.other .text-message.markdown-rendered code {
    background: rgba(0, 0, 0, 0.1);
}

.text-message.markdown-rendered pre {
    background: rgba(255, 255, 255, 0.15);
    padding: 0.6em;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.3em 0;
}

.message.other .text-message.markdown-rendered pre {
    background: rgba(0, 0, 0, 0.08);
}

.text-message.markdown-rendered pre code {
    background: none;
    padding: 0;
}

.text-message.markdown-rendered strong {
    font-weight: bold;
}

.text-message.markdown-rendered em {
    font-style: italic;
}

.text-message.markdown-rendered a {
    color: inherit;
    text-decoration: underline;
    opacity: 0.9;
}

.text-message.markdown-rendered hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    margin: 0.5em 0;
}

.message.other .text-message.markdown-rendered hr {
    border-top-color: rgba(0, 0, 0, 0.2);
}

/* Markdown切换按钮 */
.markdown-toggle {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.8);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    transition: all 0.2s ease;
    opacity: 0.6;
    z-index: 1;
    /* 确保按钮不影响文本布局和选择 */
    pointer-events: auto;
    /* 按钮本身不可选择 */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.markdown-toggle:hover {
    opacity: 1;
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.95);
}

.message.own .markdown-toggle {
    background: rgba(255, 255, 255, 0.3);
}

.message.own .markdown-toggle:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 文件消息 */
.file-message {
    min-width: 220px;
    /* 允许文件名等文本被选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.625rem;
}

.file-icon {
    font-size: 2.25rem;
    flex-shrink: 0;
    /* 移除渐变背景，让emoji图标显示原始颜色 */
    color: inherit;
    /* 保留阴影效果但调整颜色 */
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
    /* 确保emoji图标正常显示 */
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
    line-height: 1;
}

.file-details {
    flex: 1;
    min-width: 0;
    /* 允许文件详情文本被选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

.file-name {
    font-weight: 500;
    margin-bottom: 0.375rem;
    word-break: break-all;
    font-size: 0.95rem;
    line-height: 1.4;
    /* 允许文件名被选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    cursor: text;
}

.file-size {
    font-size: 0.85rem;
    opacity: 0.75;
    font-weight: 400;
    /* 允许文件大小被选择 */
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
    cursor: text;
}

.download-btn {
    background: #07c160;
    color: white;
    border: none;
    padding: 0.5rem 0.875rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 400;
    transition: background 0.2s ease;
    flex-shrink: 0;
    box-shadow: none;
    position: relative;
    overflow: hidden;
}

.download-btn:hover {
    background: #06ad56;
}

.message.own .download-btn {
    background: rgba(0, 0, 0, 0.1);
    color: #000000;
}

.message.own .download-btn:hover {
    background: rgba(0, 0, 0, 0.15);
}

/* 图片预览 */
.image-preview {
    margin-top: 0.5rem;
    border-radius: 12px;
    overflow: hidden;
    background: #f8f9fa;
    border: 1px solid rgba(0, 0, 0, 0.08);
    max-width: 300px;
    position: relative;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-preview img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 200px;
    object-fit: cover;
    transition: transform 0.2s ease;
    border-radius: 8px;
}

.image-preview img:hover {
    transform: scale(1.02);
    cursor: pointer;
}

/* 图片加载状态 */
.image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #666;
    font-size: 14px;
}

.image-loading .loading-spinner {
    font-size: 20px;
    margin-bottom: 8px;
    animation: spin 1s linear infinite;
}

/* 图片加载错误状态 */
.image-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    color: #999;
    font-size: 14px;
}

.image-error .retry-btn {
    margin-top: 8px;
    background: #07c160;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s ease;
}

.image-error .retry-btn:hover {
    background: #06a552;
}

/* 顶部加载指示器 - 无限滚动 */
.top-loading-indicator {
    display: none;
    justify-content: center;
    align-items: center;
    padding: 0.75rem 0;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, rgba(7, 193, 96, 0.05) 0%, rgba(26, 173, 25, 0.05) 100%);
    border-radius: 12px;
    border: 1px solid rgba(7, 193, 96, 0.1);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.top-loading-indicator.fade-in {
    opacity: 1;
}

.top-loading-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #07c160;
    font-size: 0.85rem;
    font-weight: 500;
}

.top-loading-spinner {
    animation: spin 1s linear infinite;
    font-size: 1rem;
}

.top-loading-text {
    letter-spacing: 0.01em;
}

/* 文件上传组件 - 简化版 */

.upload-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: #07c160;
    font-weight: 500;
    padding: 0.75rem;
    background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
    border-radius: 12px;
    margin-bottom: 0.75rem;
    border: 1px solid rgba(7, 193, 96, 0.2);
}

.upload-spinner {
    animation: spin 1s linear infinite;
    font-size: 1.5rem;
}

.upload-progress {
    width: 100%;
    height: 6px;
    background-color: rgba(7, 193, 96, 0.2);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #07c160, #00d4aa);
    border-radius: 3px;
    width: 0%;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 1.5s infinite;
}

/* 消息输入组件 - 微信移动端风格 */
.message-input {
    width: 100%;
    display: flex;
    align-items: center;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

.input-field-container {
    flex: 1;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    padding: 0;
    position: relative;
    min-height: 40px;
    box-shadow: none;
    transition: border-color 0.2s ease;
}

/* 文件上传按钮 - 微信移动端风格 */
.file-button {
    background: #ffffff;
    border: 1px solid #d9d9d9;
    color: #666666;
    padding: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    touch-action: manipulation;
    box-shadow: none;
}

.file-button:hover:not(:disabled) {
    background: #f5f5f5;
    border-color: #bfbfbf;
}

.file-button:active:not(:disabled) {
    background: #e6e6e6;
    border-color: #999999;
}

.input-field-container textarea {
    flex: 1;
    border: none;
    padding: 10px 12px;
    font-size: 16px;
    resize: none;
    min-height: 18px;
    max-height: 80px;
    background: transparent;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.4;
    outline: none;
    font-weight: 400;
}

.input-field-container textarea::placeholder {
    color: #999999;
    font-style: normal;
}

.input-field-container:focus-within {
    border-color: #07c160;
    box-shadow: none;
}

.send-button {
    background: #07c160;
    color: white;
    border: none;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 4px;
    touch-action: manipulation;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    opacity: 0;
    box-shadow: none;
}

/* 发送按钮显示状态 */
.send-button.show {
    transform: translateY(-50%) scale(1);
    opacity: 1;
}

.send-button:hover:not(:disabled) {
    background: #06ad56;
    box-shadow: none;
}

.send-button:active:not(:disabled) {
    background: #059748;
    transform: translateY(-50%) scale(0.95);
}

.send-button:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

/* 发送图标样式 */
.send-icon {
    width: 16px;
    height: 16px;
    color: white;
}

/* 发送按钮加载状态 */
.send-button.loading {
    background: #cccccc;
    cursor: not-allowed;
}

.send-button.loading .send-icon {
    animation: spin 1s linear infinite;
}

/* 功能按钮 - 微信风格 (更新版本) */
.function-button {
    background: #07c160;
    color: white;
    border: none;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 4px;
    touch-action: manipulation;
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%) scale(1);
    opacity: 1;
    box-shadow: 0 2px 8px rgba(7, 193, 96, 0.2);
    font-size: 16px;
    z-index: 10;
    pointer-events: auto;
}

/* 功能按钮显示状态 */
.function-button.show {
    transform: translateY(-50%) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* 功能按钮隐藏状态 */
.function-button.hide {
    transform: translateY(-50%) scale(0);
    opacity: 0;
    pointer-events: none;
}

.function-button:hover:not(:disabled) {
    background: #06ad56;
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 4px 12px rgba(7, 193, 96, 0.3);
}

.function-button:hover .function-icon {
    transform: rotate(90deg);
}

.function-button:active:not(:disabled) {
    background: #059748;
    transform: translateY(-50%) scale(0.95);
}

/* 功能按钮图标 */
.function-icon {
    width: 16px;
    height: 16px;
    color: white;
    transition: transform 0.2s ease;
}

/* 功能菜单弹窗 */
.function-menu {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px;
    z-index: 1000;
    transform: scale(0) translateY(20px);
    opacity: 0;
    transition: all 0.2s ease;
    transform-origin: bottom right;
    min-width: 200px;
}

/* 功能菜单显示状态 */
.function-menu.show {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* 功能菜单项 */
.function-menu-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    gap: 12px;
    font-size: 14px;
    color: #333;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.function-menu-item:hover {
    background-color: #f5f5f5;
}

.function-menu-item:active {
    background-color: #e6e6e6;
}

/* 功能菜单项图标 */
.function-menu-item-icon {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

/* 功能菜单项文本 */
.function-menu-item-text {
    flex: 1;
    font-weight: 400;
}

/* 功能菜单遮罩 */
.function-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    background: transparent;
    display: none;
}

.function-menu-overlay.show {
    display: block;
}

/* PWA相关样式 */

/* PWA安装按钮（已禁用） */

/* PWA安装横幅 */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    z-index: 1001;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.pwa-install-banner.show {
    transform: translateY(0);
}

.pwa-install-banner.hide {
    transform: translateY(100%);
}

.install-content {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 16px;
}

.install-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.install-text {
    flex: 1;
}

.install-text h3 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.install-text p {
    margin: 0;
    font-size: 14px;
    color: #666;
}

.install-actions {
    display: flex;
    gap: 12px;
}

.install-yes, .install-no {
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.install-yes {
    background: #07c160;
    color: white;
    border: none;
}

.install-yes:hover {
    background: #06a552;
}

.install-no {
    background: transparent;
    color: #666;
    border: 1px solid #d0d0d0;
}

.install-no:hover {
    background: #f5f5f5;
}

/* PWA更新横幅 */
.pwa-update-banner {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #07c160;
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(7, 193, 96, 0.3);
    z-index: 1002;
    animation: slideDown 0.3s ease;
}

.update-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.update-btn, .close-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.update-btn:hover, .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.close-btn {
    padding: 4px 8px;
    font-size: 14px;
    font-weight: bold;
}

/* 连接状态指示器 */
.connection-status {
    position: fixed;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    z-index: 999;
    transition: all 0.3s ease;
}

.connection-status.online {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.connection-status.connecting {
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.connection-status.offline {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* PWA动画效果 */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}
