/* ===== 基础样式重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    color: #333;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    font-size: 12px;
    background: #f0f2f5;
}

/* 背景图片容器 */
.background-image {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-image: url('备份/bj.png');
    transition: all 0.5s ease;
}

/* 背景设置面板 */
.bg-settings-panel {
    position: fixed;
    bottom: 50px;
    right: 12px;
    width: 250px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 10px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(221, 221, 221, 0.5);
    z-index: 101;
    display: none;
    overflow: hidden;
    backdrop-filter: blur(8px);
}
.bg-settings-panel.show { display: block; animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
.bg-settings-header { padding: 10px 12px; border-bottom: 1px solid rgba(221, 221, 221, 0.5); display: flex; justify-content: space-between; align-items: center; background: rgba(248, 249, 250, 0.9); }
.bg-settings-title { font-size: 13px; font-weight: 600; color: #333; }
.bg-settings-close { background: none; border: none; color: #666; cursor: pointer; font-size: 14px; padding: 3px; border-radius: 50%; transition: background 0.2s; }
.bg-settings-close:hover { background: rgba(0, 0, 0, 0.05); }
.bg-settings-content { padding: 10px; }
.bg-upload-area { border: 1.5px dashed #ddd; border-radius: 6px; padding: 12px; text-align: center; margin-bottom: 10px; cursor: pointer; transition: all 0.3s; background: rgba(248, 249, 250, 0.5); }
.bg-upload-area:hover { border-color: #6c757d; background: rgba(248, 249, 250, 0.8); }
.upload-icon { font-size: 22px; color: #6c757d; margin-bottom: 6px; }
.upload-text { font-size: 12px; color: #555; margin-bottom: 3px; }
.upload-hint { font-size: 10px; color: #888; }
.bg-file-input { display: none; }
.bg-controls { margin-top: 12px; }
.control-group { margin-bottom: 10px; }
.control-label { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.control-label span { font-size: 12px; color: #555; font-weight: 500; }
.control-value { font-size: 11px; color: #6c757d; font-weight: 600; min-width: 32px; text-align: right; }
.bg-slider { width: 100%; height: 4px; -webkit-appearance: none; appearance: none; background: linear-gradient(to right, #000, #fff); border-radius: 2px; outline: none; }
.bg-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%; background: #6c757d; cursor: pointer; border: 1.5px solid white; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.bg-slider::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: #6c757d; cursor: pointer; border: 1.5px solid white; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.bg-slider#brightnessSlider { background: linear-gradient(to right, #000, #fff); }
.bg-slider#contrastSlider { background: linear-gradient(to right, #000 0%, #888 50%, #fff 100%); }
.bg-btns { display: flex; gap: 7px; margin-top: 12px; }
.bg-btn { flex: 1; padding: 7px; border: none; border-radius: 5px; background: #6c757d; color: white; cursor: pointer; font-size: 11px; font-weight: 500; transition: background 0.2s; }
.bg-btn:hover { background: #868e96; }
.bg-btn.secondary { background: #adb5bd; }
.bg-btn.secondary:hover { background: #ced4da; }
.bg-btn.danger { background: #dc3545; }
.bg-btn.danger:hover { background: #e35d6a; }

/* 加载动画 */
.loader-container {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255, 255, 255, 0.95); display: flex; flex-direction: column; justify-content: center; align-items: center; z-index: 9999; transition: opacity 0.5s, visibility 0.5s;
}
.loader-container.hidden { opacity: 0; visibility: hidden; }
.loader { width: 45px; height: 45px; position: relative; margin-bottom: 12px; }
.loader-circle { position: absolute; width: 100%; height: 100%; border: 2.5px solid transparent; border-top-color: #6c757d; border-radius: 50%; animation: spin 1s linear infinite; }
.loader-circle:nth-child(2) { border-top-color: #868e96; animation: spin 1.5s linear infinite reverse; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.loader-text { font-size: 14px; color: #6c757d; font-weight: 500; letter-spacing: 0.5px; }

/* 头部样式 */
.header {
    background: rgba(255, 255, 255, 0.95); padding: 7px 10px; border-bottom: 1px solid rgba(221, 221, 221, 0.5); display: flex; align-items: center; justify-content: space-between; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06); position: relative; z-index: 10; min-height: 44px; width: 100%; position: sticky; top: 0; left: 0; right: 0;
}
.logo-container { display: flex; align-items: center; gap: 8px; }
.logo { width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; overflow: hidden; border: 1.5px solid rgba(255, 255, 255, 0.8); box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.08); background: white; }
.logo img { width: 100%; height: 100%; object-fit: cover; }
.title { font-size: 14px; font-weight: 600; letter-spacing: 0.2px; color: #333; }
.subtitle { font-size: 10px; color: #666; margin-top: 1px; }
.header-actions { display: flex; gap: 7px; align-items: center; }
.icon-btn { background: none; border: none; color: #666; font-size: 15px; cursor: pointer; transition: all 0.2s; padding: 5px; border-radius: 50%; position: relative; }
.icon-btn:hover { color: #333; background: rgba(0, 0, 0, 0.05); }
.bg-settings-btn { background: none; border: none; color: #666; font-size: 16px; cursor: pointer; padding: 5px; border-radius: 50%; transition: all 0.2s; }
.bg-settings-btn:hover { color: #333; background: rgba(0, 0, 0, 0.05); }

/* 聊天区域 */
.chat-container {
    flex: 1; overflow-y: auto; padding: 8px 8px 60px; display: flex; flex-direction: column; position: relative; -webkit-overflow-scrolling: touch; width: 100%; margin: 0;
}

/* 消息样式 */
.message { display: flex; align-items: flex-start; margin-bottom: 8px; max-width: 90%; animation: fadeIn 0.3s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.message.user { align-self: flex-end; flex-direction: row; }
.avatar { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; overflow: hidden; border: 1.5px solid rgba(255, 255, 255, 0.9); box-shadow: 0 1.5px 3px rgba(0, 0, 0, 0.08); background: white; }
.user .avatar { margin-left: 6px; order: 2; }
.support .avatar { margin-right: 6px; order: 0; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.message-content { margin: 0; padding: 7px 10px; border-radius: 14px; font-size: 12px; line-height: 1.3; position: relative; max-width: calc(100% - 36px); word-wrap: break-word; min-height: 30px; display: flex; flex-direction: column; justify-content: center; }
.support .message-content { background: rgba(255, 255, 255, 0.96); border: 1px solid rgba(224, 224, 224, 0.6); color: #333; box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.06); border-top-left-radius: 4px; order: 1; }
.user .message-content { background: linear-gradient(135deg, rgba(108, 117, 125, 0.96), rgba(134, 142, 150, 0.96)); color: white; border-top-right-radius: 4px; box-shadow: 0 1.5px 4px rgba(0, 0, 0, 0.09); order: 1; }

/* 图片消息专用样式 */
.message-content img.message-image {
    max-width: 180px; max-height: 200px; border-radius: 8px; margin-top: 4px; cursor: pointer; border: 1px solid rgba(255,255,255,0.2); display: block; object-fit: cover;
}
.support .message-content img.message-image { border: 1px solid #e0e0e0; }
.user .message-content img.message-image { border: 1px solid rgba(255,255,255,0.3); }

/* ===== 输入区域 - 终极强制单行修复 ===== */
.input-container {
    background: rgba(255, 255, 255, 0.98);
    padding: 8px 10px;
    border-top: 1px solid rgba(221, 221, 221, 0.5);
    display: flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.04);
    width: 100%;
    margin: 0;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.send-btn {
    background: linear-gradient(135deg, #6c757d, #868e96);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    order: 1;
    flex-shrink: 0;
    flex: 0 0 auto;
}

/* 超级强制单行输入框 - 使用最重要的属性 */
.message-input {
    flex: 1;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 18px;
    padding: 0 12px !important;  /* 上下内边距强制为0 */
    color: #212529;
    font-size: 12px;
    outline: none;
    height: 36px !important;  /* 固定高度 */
    min-height: 36px !important;
    max-height: 36px !important;
    line-height: 36px !important;  /* 行高等于高度 */
    width: 100%;
    order: 2;
    
    /* 强制单行显示 - 核武器级别的设置 */
    white-space: nowrap !important;  /* 强制不换行 */
    overflow-x: auto !important;      /* 水平滚动 */
    overflow-y: hidden !important;    /* 禁止垂直滚动 */
    word-break: keep-all !important;  /* 保持单词完整 */
    word-wrap: normal !important;     /* 正常换行规则 */
    text-overflow: clip !important;   /* 直接裁剪 */
    resize: none !important;          /* 禁止调整大小 */
    -webkit-appearance: none;
    appearance: none;
    box-sizing: border-box;
    display: block;
    
    /* 删除所有可能导致换行的属性 */
    -webkit-line-clamp: unset;
    line-clamp: unset;
}

/* 输入状态也保持单行 */
.message-input:focus {
    white-space: nowrap !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    border-color: #adb5bd;
    background: white;
}

/* 占位符也强制单行 */
.message-input::placeholder {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    line-height: 36px !important;
    color: #999;
}

/* 自定义滚动条让横向滚动更好看 */
.message-input::-webkit-scrollbar {
    height: 3px;
}
.message-input::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 3px;
}
.message-input::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 3px;
}

.image-selector-btn, .emoji-selector-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
    flex-shrink: 0;
    flex: 0 0 auto;
}

.image-selector-btn:hover, .emoji-selector-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* 隐藏的原生文件输入 */
#imageUploadInput { display: none; }

/* 表情面板 */
.emoji-panel { position: absolute; bottom: 50px; left: 10px; width: 240px; background: rgba(255, 255, 255, 0.98); border-radius: 10px; box-shadow: 0 3px 15px rgba(0, 0, 0, 0.08); border: 1px solid rgba(221, 221, 221, 0.3); z-index: 101; display: none; overflow: hidden; backdrop-filter: blur(8px); }
.emoji-panel.show { display: block; animation: slideUp 0.3s ease; }
.emoji-header { padding: 9px 10px; border-bottom: 1px solid rgba(221, 221, 221, 0.3); display: flex; justify-content: space-between; align-items: center; background: rgba(248, 249, 250, 0.8); }
.emoji-title { font-size: 12px; font-weight: 600; color: #333; }
.emoji-close { background: none; border: none; color: #666; cursor: pointer; font-size: 14px; padding: 2px; }
.emoji-categories { display: flex; padding: 0 8px; border-bottom: 1px solid rgba(221, 221, 221, 0.3); background: rgba(248, 249, 250, 0.5); }
.emoji-category { padding: 5px 8px; border: none; background: none; cursor: pointer; font-size: 16px; transition: all 0.2s; position: relative; }
.emoji-category.active { color: #6c757d; }
.emoji-category.active::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 1.5px; background: #6c757d; }
.emoji-grid { max-height: 160px; overflow-y: auto; padding: 7px; display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; }
.emoji-item { width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; border-radius: 5px; transition: background 0.2s; }
.emoji-item:hover { background: rgba(0, 0, 0, 0.05); }

/* 历史记录面板 - 聊天记录存档样式 */
.history-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 320px;
    height: 100%;
    background: white;
    z-index: 1000;
    transition: right 0.3s ease;
    box-shadow: -2px 0 15px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
}
.history-panel.open { right: 0; }

.history-header {
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-header h3 {
    font-size: 18px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}
.history-header h3 i {
    font-size: 20px;
}
.close-history {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.close-history:hover {
    background: rgba(255,255,255,0.3);
}

.history-stats {
    padding: 12px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #495057;
}
.stats-badge {
    background: #6c757d;
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
}
.clear-history-btn {
    background: none;
    border: 1px solid #dc3545;
    color: #dc3545;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}
.clear-history-btn:hover {
    background: #dc3545;
    color: white;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f5f5f5;
}

.history-item {
    background: white;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid #667eea;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.history-item:hover {
    transform: translateX(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.history-date {
    font-size: 11px;
    color: #868e96;
    display: flex;
    align-items: center;
    gap: 4px;
}
.history-date i {
    font-size: 10px;
}
.history-time {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 10px;
    color: #495057;
}
.history-preview {
    font-size: 14px;
    color: #212529;
    font-weight: 500;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #6c757d;
}
.history-count {
    display: flex;
    align-items: center;
    gap: 4px;
}
.history-count i {
    font-size: 10px;
}
.history-type {
    background: #e9ecef;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
}
.empty-history {
    text-align: center;
    color: #adb5bd;
    padding: 50px 20px;
    background: white;
    border-radius: 10px;
}
.empty-history i {
    font-size: 40px;
    margin-bottom: 15px;
    color: #dee2e6;
}
.empty-history p {
    font-size: 14px;
    margin-bottom: 5px;
}
.empty-history small {
    font-size: 11px;
    opacity: 0.8;
}

.badge {
    background: #dc3545;
    color: white;
    font-size: 9px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -2px;
    right: -2px;
}

.empty-chat { 
    text-align: center; 
    padding: 30px 20px; 
    color: #666; 
    font-size: 13px; 
    background: rgba(255, 255, 255, 0.9); 
    border-radius: 12px; 
    margin: 20px; 
    backdrop-filter: blur(4px);
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* 图片预览模态框 */
.image-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(5px);
}
.image-preview-modal.show { display: flex; animation: fadeIn 0.2s ease; }
.preview-image {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    border: 2px solid rgba(255,255,255,0.2);
    object-fit: contain;
    cursor: default;
}
.preview-close-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    background: rgba(0,0,0,0.3);
    padding: 6px 16px;
    border-radius: 30px;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

@media (max-width: 480px) {
    body { font-size: 11px; }
    .history-panel { width: 100%; }
    .header { padding: 6px 8px; }
    .title { font-size: 13px; }
    .logo { width: 30px; height: 30px; }
    .emoji-panel { width: calc(100% - 20px); left: 10px; bottom: 55px; }
    
    /* 移动端强制单行 */
    .message-input {
        height: 36px !important;
        min-height: 36px !important;
        max-height: 36px !important;
        line-height: 36px !important;
        white-space: nowrap !important;
        overflow-x: auto !important;
        padding: 0 12px !important;
    }
}

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: rgba(241, 241, 241, 0.5); }
::-webkit-scrollbar-thumb { background: rgba(193, 193, 193, 0.5); border-radius: 3px; }