/* style.css - 响应式优化版本 */

/* 基础重置和字体 */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5; 
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

/* -----------------------------------
 * 1. 桌面端 (Desktop) 样式: 居中、宽敞
 * ----------------------------------- */
#chat-container {
    background-color: #ffffff;
    width: 90%; /* 默认宽度占屏幕90% */
    max-width: 900px; /* 最大宽度限制在 900px，确保在大屏幕上不会过宽 */
    height: 90vh; /* 默认高度占视口高度90% */
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15); /* 更大气、更深的阴影 */
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: all 0.3s ease-in-out; /* 平滑过渡效果 */
}

/* 头部昵称设置区域 */
#header {
    padding: 15px 20px;
    background-color: #1e88e5; /* 蓝色主题 */
    color: white;
    font-size: 1.2em;
    font-weight: 600;
    display: flex; /* 使用 Flexbox 布局 */
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#header h2 {
    margin: 0;
    font-size: 1.3em;
}

#senderName {
    padding: 8px 10px;
    margin-left: 20px;
    border: none;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    width: 150px;
    font-size: 0.9em;
    box-sizing: border-box;
}
#senderName::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

/* 消息显示区域 */
#messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: #fafafa;
}
/* 滚动条美化 */
#messages::-webkit-scrollbar { width: 8px; }
#messages::-webkit-scrollbar-thumb {
    background-color: #c4c4c4;
    border-radius: 10px;
}

/* 消息气泡样式 (维持不变，但结构更灵活) */
.message {
    display: flex;
    margin-bottom: 15px;
    align-items: flex-start; /* 消息顶部对齐 */
}

.bubble {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 65%; /* 消息气泡略窄，更美观 */
    line-height: 1.4;
    word-break: break-word; 
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05); /* 轻微阴影，增加立体感 */
}

.sender-name {
    display: block;
    font-size: 0.8em;
    color: #666;
    margin-bottom: 3px;
    font-weight: 600;
}

/* 他人的消息 */
.other {
    justify-content: flex-start;
}
.other .bubble {
    background-color: #ffffff; /* 保持白色，更精致 */
    color: #333;
    border: 1px solid #e0e0e0;
    border-top-left-radius: 4px;
}
.other .sender-name {
    color: #1e88e5; /* 别人的昵称使用主题色 */
}


/* 自己的消息 */
.self {
    justify-content: flex-end;
}
.self .bubble {
    background-color: #1e88e5;
    color: white;
    border-top-right-radius: 4px;
}
.self .sender-name {
    color: #ffffff; /* 自己的昵称也用白色 */
    text-align: right;
}

/* 系统消息 */
.system {
    justify-content: center;
    font-size: 0.85em;
    color: #999;
    margin: 15px 0;
    text-align: center;
}

/* 消息输入区域 */
#input-area {
    display: flex;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    gap: 10px; /* 增加输入框和按钮的间距 */
}

#messageInput {
    flex-grow: 1;
    padding: 12px 18px;
    border: 1px solid #dcdcdc;
    border-radius: 25px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s;
}

#messageInput:focus {
    border-color: #1e88e5;
    box-shadow: 0 0 0 2px rgba(30, 136, 229, 0.2);
}

#sendButton {
    background-color: #1e88e5;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background-color 0.3s, transform 0.1s;
    flex-shrink: 0; /* 防止按钮被压缩 */
}

#sendButton:hover {
    background-color: #1565c0;
}
#sendButton:active {
    transform: scale(0.98);
}


/* -----------------------------------
 * 2. 移动端 (Mobile) 样式:  full-screen 模式
 * ----------------------------------- */
@media (max-width: 600px) {
    body {
        /* 在手机上，背景色改为白色 */
        background-color: #ffffff; 
    }
    
    #chat-container {
        /* 在小屏幕上占满整个视口 */
        width: 100vw;
        height: 100vh;
        max-width: none;
        box-shadow: none; /* 去除阴影，更像原生 App */
        border-radius: 0;
    }

    #header {
        /* 手机端头部居中 */
        justify-content: center; 
        padding: 12px 15px;
    }

    #header h2 {
        /* 移动端标题小一点 */
        font-size: 1.1em;
    }

    #senderName {
        /* 移动端将昵称输入框隐藏在菜单中或移到底部，这里为了简易，保持在顶部但缩小宽度 */
        width: 120px;
        margin-left: 10px;
        padding: 6px 8px;
        font-size: 0.85em;
    }

    #messages {
        padding: 10px;
    }
    
    /* 移动端消息气泡占更大部分 */
    .bubble {
        max-width: 85%; 
    }

    #input-area {
        padding: 10px 10px;
    }

    #messageInput {
        padding: 10px 15px;
    }

    #sendButton {
        padding: 10px 20px;
    }
}

/* 隐藏在前端的昵称标签，使用气泡里的昵称 */
#header > span {
    display: none;
}