/* 基础样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    color: #fff;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    max-width: 1000px;
    width: 100%;
    padding: 20px;
}

/* 头部样式 */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.description-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    max-width: 800px;
    margin: 0 auto;
}

.description {
    font-size: 1.1rem;
    line-height: 1.6;
    text-align: center;
}

/* 角色指示器 */
.role-indicator {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
}

.role-a {
    background: #4caf50;
}

.role-b {
    background: #ff9800;
}

/* 使用说明样式 */
.instructions {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    margin: 20px 0;
}

.instructions ol {
    margin-left: 20px;
    line-height: 1.8;
}

/* 状态面板样式 */
.status-panel {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.status {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
    font-weight: bold;
    text-align: center;
    transition: all 0.3s ease;
}

.status.connected {
    background: rgba(76, 175, 80, 0.3);
    color: #a5d6a7;
}

.status.disconnected {
    background: rgba(244, 67, 54, 0.3);
    color: #ef9a9a;
}

.status.connecting {
    background: rgba(255, 193, 7, 0.3);
    color: #fff59d;
}

/* 按钮样式 */
.action-buttons {
    display: flex;
    gap: 15px;
    margin: 20px 0;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    background: #4a90e2;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.action-buttons button {
    flex: 1;
}

button:hover {
    background: #357abd;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 连接信息样式 */
.connection-info {
    margin-top: 20px;
}

.connection-info-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.info-section {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 15px;
}

.info-section h3 {
    margin-bottom: 10px;
    color: #90caf9;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* 复制按钮样式 */
.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
}

.copy-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* 修改1: 链接信息框不允许调整大小且高度减少1/3 */
#localInfo, #remoteInfo {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    resize: none; /* 禁止调整大小 */
    min-height: 80px; /* 原120px减少1/3到80px */
    font-family: monospace;
}

/* 修改1: 移除链接信息框的焦点边框样式 */
#localInfo:focus, #remoteInfo:focus {
    outline: none;
    box-shadow: none;
    border: none;
}

/* 修改2: 设置链接信息框滚动条样式 */
#localInfo::-webkit-scrollbar, #remoteInfo::-webkit-scrollbar {
    width: 6px;
}

#localInfo::-webkit-scrollbar-track, #remoteInfo::-webkit-scrollbar-track {
    background: transparent;
}

#localInfo::-webkit-scrollbar-thumb, #remoteInfo::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

#localInfo::-webkit-scrollbar-thumb:hover, #remoteInfo::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 修改1: 普通textarea保持原有样式 */
textarea {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
    resize: vertical;
    min-height: 120px;
    font-family: monospace;
}

textarea::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* 聊天面板样式 */
.chat-panel {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    display: none; /* 默认隐藏，连接建立后显示 */
}

.chat-messages {
    height: 400px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

/* 修改2: 设置聊天消息区域滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* 消息样式 - 添加换行支持 */
.message {
    max-width: 70%;
    padding: 12px 16px;
    margin-bottom: 12px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    line-height: 1.4;
    white-space: pre-wrap; /* 新增：保留换行符和空格 */
    word-break: break-word; /* 新增：允许单词内换行 */
}

.message.system {
    align-self: center;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-style: italic;
    max-width: 90%;
    text-align: center;
    border-radius: 10px;
}

.message.received {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border-bottom-left-radius: 4px;
}

.message.sent {
    align-self: flex-end;
    background: #4a90e2;
    color: white;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-top: 5px;
    text-align: right;
}

.message img {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 5px;
}

/* 新增：透明工具栏容器 */
.chat-toolbar-container {
    background: transparent;
    margin-bottom: 10px;
    position: relative; /* 为表情选择器定位提供参考 */
}

.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 15px;
}

/* 工具栏布局 */
.chat-toolbar {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.toolbar-left {
    display: flex;
    gap: 8px;
}

.toolbar-right {
    display: flex;
    gap: 8px;
}

/* 工具栏按钮样式 */
.emoji-btn, .file-btn, .clear-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
}

.emoji-btn:hover, .file-btn:hover, .clear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

/* 消息输入框样式 */
/* 修改2: 消息输入框允许调整大小但限制最小高度 */
#messageInput {
    padding: 12px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1rem;
    flex: 1;
    min-height: 140px; /* 保持当前高度作为最小高度 */
    resize: vertical; /* 允许垂直调整大小 */
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
    line-height: 1.4;
    font-family: inherit;
}

/* 修改1: 移除焦点时的边框样式 */
#messageInput:focus {
    outline: none;
    box-shadow: none;
    border: none;
}

/* 修改2: 设置消息输入框滚动条样式 */
#messageInput::-webkit-scrollbar {
    width: 6px;
}

#messageInput::-webkit-scrollbar-track {
    background: transparent;
}

#messageInput::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

#messageInput::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

input[type="file"] {
    display: none;
}

/* 发送按钮样式 */
.send-btn {
    padding: 12px 20px;
    width: 120px;
    flex: none;
    height: 50px;
}

/* 表情选择器样式 - 修复位置 */
.emoji-picker {
    display: none;
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 8px;
    padding: 15px;
    flex-wrap: wrap;
    gap: 5px;
    z-index: 100;
    overflow-y: auto;
    justify-content: center;
    max-height: 200px;
    width: 66.67%;
    bottom: calc(100% + 8px); /* 选择器底边在表情按钮顶边上方8像素 */
    left: 0;
}

/* 修改2: 设置表情选择器滚动条样式 */
.emoji-picker::-webkit-scrollbar {
    width: 6px;
}

.emoji-picker::-webkit-scrollbar-track {
    background: transparent;
}

.emoji-picker::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.emoji-picker::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.emoji-picker.show {
    display: flex;
}

.emoji {
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 状态日志样式 */
.status-log {
    height: 150px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 10px;
    margin-top: 15px;
    font-family: monospace;
    font-size: 0.9rem;
}

/* 修改2: 设置状态日志滚动条样式 */
.status-log::-webkit-scrollbar {
    width: 6px;
}

.status-log::-webkit-scrollbar-track {
    background: transparent;
}

.status-log::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.status-log::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

.status-message {
    margin-bottom: 8px;
    padding: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
}