/* ============================================================ */
/* 全局重置 */
/* ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}
body {
    padding-top: 44px !important;
    padding-bottom: 44px !important;
    background: #fafcff !important;
    font-family: -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif;
}

@media (max-width: 768px) {
    body {
        padding-top: 40px !important;
        padding-bottom: 44px !important;
    }
}

@media (max-width: 480px) {
    body {
        padding-top: 36px !important;
        padding-bottom: 40px !important;
    }
}

/* ============================================================ */
/* 内容区 */
/* ============================================================ */
#content {
    padding: 0 !important;
    margin: 0 !important;
    height: 100% !important;
    background: #fafcff !important;
    display: flex !important;
    flex-direction: column !important;
    position: relative;
}

@media (max-width: 768px) {
    #content {
        height: calc(100vh - 84px) !important;
    }
}

@media (max-width: 480px) {
    #content {
        height: calc(100vh - 76px) !important;
    }
}

.dialog-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fafcff;
    height: 100%;
    overflow: hidden;
}

/* ===== 对话头部 ===== */
.dialog-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #e8ecf1;
    flex-shrink: 0;
    background: #ffffff;
    min-height: 52px;
}
.dialog-header .back-btn {
    font-size: 24px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    color: #1a2332;
}
.dialog-header .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 4px;
    flex: 1;
}
.dialog-header .user-info .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #008000, #FB9749);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}
.dialog-header .user-info .name {
    font-weight: 600;
    font-size: 16px;
    color: #1a2332;
}
.dialog-header .user-info .status {
    font-size: 11px;
    color: #8895aa;
}
.dialog-header .actions {
    display: flex;
    gap: 6px;
}
.dialog-header .actions button {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #8895aa;
    padding: 4px 8px;
    border-radius: 8px;
    transition: 0.2s;
}
.dialog-header .actions button:hover {
    background: #f1f4f9;
    color: #1a2332;
}

/* ===== 消息区域 ===== */
.dialog-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #fafcff;
}
.dialog-messages::-webkit-scrollbar {
    width: 4px;
}
.dialog-messages::-webkit-scrollbar-thumb {
    background: #d0d5dd;
    border-radius: 10px;
}

.message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: msgIn 0.25s ease;
    position: relative;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.message.sent { 
    align-items: flex-end;
    margin-left: auto; 
}
.message.received { 
    align-items: flex-start; 
}
.message .sender-name {
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 2px;
    padding: 0 4px;
}
.message.sent .sender-name {
    color: #008000;
}
.message.received .sender-name {
    color: #667eea;
}
.message .bubble {
    padding: 10px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    position: relative;
    max-width: 100%;
}
.message.sent .bubble {
    background: linear-gradient(135deg, #008000, #22c55e);
    color: white;
    border-bottom-right-radius: 4px;
}
.message.received .bubble {
    background: #fff;
    border: 1px solid #e8ecf1;
    color: #1a2332;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.message .time {
    font-size: 10px;
    color: rgba(255,255,255,0.6);
    margin-top: 4px;
    display: block;
}
.message.received .time {
    color: #b0b8c4;
}
.message.sent .time {
    text-align: right;
}

/* ===== 附件消息样式 ===== */
.message .bubble .file-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    margin-bottom: 4px;
}
.message.received .bubble .file-attachment {
    background: rgba(0,0,0,0.04);
}
.message .bubble .file-attachment .file-icon {
    font-size: 28px;
}
.message .bubble .file-attachment .file-info {
    flex: 1;
    min-width: 0;
}
.message .bubble .file-attachment .file-name {
    font-size: 13px;
    font-weight: 500;
    word-break: break-all;
}
.message .bubble .file-attachment .file-size {
    font-size: 11px;
    opacity: 0.7;
}

/* ============================================================ */
/* 消息操作按钮 */
/* ============================================================ */
.message .msg-actions {
    display: none;
    margin-top: 4px;
    gap: 2px;
    background: #ffffff;
    border-radius: 16px;
    padding: 2px 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid #e8ecf1;
}
.message:hover .msg-actions,
.message .msg-actions.show {
    display: flex;
}
.message.sent .msg-actions {
    align-self: flex-end;
}
.message.received .msg-actions {
    align-self: flex-start;
}
.message .msg-actions button {
    background: none;
    border: none;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 15px;
    color: #8895aa;
    border-radius: 10px;
    transition: all 0.2s;
}
.message .msg-actions button:hover {
    background: #f1f4f9;
    color: #1a2332;
}
.message .msg-actions button:active {
    transform: scale(0.9);
}
.message .msg-actions button.delete-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}
.message .msg-actions button.speak-btn.playing {
    color: #ef4444 !important;
    background: #fef2f2 !important;
}

/* 手机端适配：点击消息显示操作按钮 */
@media (max-width: 768px) {
    .message .msg-actions {
        padding: 2px 2px;
    }
    .message .msg-actions button {
        padding: 3px 6px;
        font-size: 13px;
    }
    .message .msg-actions.show {
        display: flex;
    }
}
@media (max-width: 480px) {
    .message .msg-actions button {
        padding: 2px 4px;
        font-size: 11px;
    }
}

/* ============================================================ */
/* 输入区域 */
/* ============================================================ */
.dialog-input-area {
    display: flex;
    align-items: flex-end;
    padding: 8px 12px;
    border-top: 1px solid #e8ecf1;
    gap: 6px;
    flex-shrink: 0;
    background: #ffffff;
    position: relative;
    z-index: 10;
}

@media (max-width: 768px) {
    .dialog-input-area {
        padding: 6px 10px 8px 10px;
    }
}

@media (max-width: 480px) {
    .dialog-input-area {
        padding: 4px 8px 6px 8px;
    }
}

.dialog-input-area .input-action-btn {
    background: none;
    border: none;
    color: #8895aa;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
}
.dialog-input-area .input-action-btn:hover {
    background: #f1f4f9;
    color: #1a2332;
}
.dialog-input-area .input-action-btn:active {
    transform: scale(0.92);
}
.dialog-input-area textarea {
    flex: 1;
    padding: 8px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    resize: none;
    outline: none;
    max-height: 80px;
    font-family: inherit;
    background: #f8fafc;
    transition: 0.2s;
    line-height: 1.5;
}
.dialog-input-area textarea:focus { 
    border-color: #008000; 
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0,128,0,0.06);
}
.dialog-input-area .send-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #008000, #FB9749);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dialog-input-area .send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0,128,0,0.3);
}
.dialog-input-area .send-btn:active {
    transform: scale(0.93);
}

/* 录音状态 */
.dialog-input-area .recording {
    background: #ef4444 !important;
    color: white !important;
    animation: pulse 0.8s infinite;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* ===== 附件菜单 ===== */
.attachment-menu {
    display: none;
    position: absolute;
    bottom: 70px;
    left: 12px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    padding: 16px 20px;
    z-index: 100;
    min-width: 200px;
}
.attachment-menu.show {
    display: block;
}
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.attachment-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 12px;
    transition: 0.2s;
    border: none;
    background: none;
}
.attachment-item:hover {
    background: #f1f4f9;
}
.attachment-item .attachment-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.attachment-item span {
    font-size: 11px;
    color: #555;
}

/* ===== Toast ===== */
#toastMsg {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a2332;
    color: white;
    padding: 10px 24px;
    border-radius: 30px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    font-family: -apple-system, "Microsoft YaHei", sans-serif;
    max-width: 90%;
    text-align: center;
}

/* ============================================================ */
/* 手机端适配 */
/* ============================================================ */
@media (max-width: 768px) {
    .dialog-header {
        padding: 10px 12px;
        min-height: 44px;
    }
    .dialog-header .user-info .name {
        font-size: 14px;
    }
    .dialog-header .user-info .status {
        font-size: 10px;
    }
    .dialog-messages {
        padding: 12px 14px;
    }
    .message {
        max-width: 85%;
    }
    .message .bubble {
        padding: 8px 12px;
        font-size: 13px;
    }
    .attachment-menu {
        bottom: 60px;
        left: 8px;
        padding: 12px 14px;
        min-width: 160px;
    }
    .attachment-item .attachment-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    .attachment-grid {
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .dialog-header .user-info .name {
        font-size: 13px;
    }
    .dialog-header .user-info .status {
        font-size: 9px;
    }
    .dialog-header .user-info .avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
    .attachment-menu {
        bottom: 50px;
        left: 4px;
        padding: 10px 12px;
        min-width: 140px;
    }
    .attachment-item .attachment-icon {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }
    .attachment-item span {
        font-size: 10px;
    }
    .attachment-grid {
        gap: 6px;
    }
    .message .msg-actions button {
        padding: 2px 4px;
        font-size: 11px;
    }
}