/**
 * 阿里巴巴风格在线客服 - 完全仿制版
 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-weight: 300;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    background: url('https://img.alicdn.com/tfs/TB1C.3nefb2gK0jSZK9XXaEgFXa-2880-2000.jpg');
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* ========== 聊天容器 ========== */
.chat-container {
    padding: 0;
    width: 100%;
    height: 100%;
    position: absolute;
}

/* PC端居中样式 */
@media (min-width: 769px) {
    .chat-container {
        position: relative;
        top: 80px;
        width: 50%;
        height: 70%;
        min-height: 500px;
        min-width: 820px;
        margin: 0 auto;
        box-shadow: 0 0 24px 0 rgba(15, 66, 76, 0.25);
        border-radius: 8px;
        overflow: hidden;
    }
}

/* 手机端全屏 */
@media (max-width: 768px) {
    body {
        background-attachment: scroll;
    }
    .chat-container {
        top: 0;
        border-radius: 0;
    }
}

/* ========== 头部 ========== */
.chat-header {
    height: 50px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
}

.chat-header-title {
    text-align: center;
    line-height: 50px;
}

.chat-header-title .agent-avatar {
    width: 40px;
    height: 40px;
    vertical-align: middle;
}

.chat-header-tool {
    position: absolute;
    right: 15px;
    cursor: pointer;
}

.sound-icon {
    font-size: 20px;
}

/* ========== 聊天区域 ========== */
.chat-body {
    position: absolute;
    top: 50px;
    bottom: 120px;
    left: 0;
    right: 0;
    width: 100%;
    background-color: #F5F5F5;
}

.chat-box {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 3px;
    left: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    word-wrap: break-word;
    padding: 10px;
}

.chat-box::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.chat-box::-webkit-scrollbar-thumb {
    background-color: #d2e0e1;
    border-radius: 8px;
}

/* ========== 消息样式 ========== */
.message {
    margin: 10px 10px;
    overflow: hidden;
}

.message.center {
    text-align: center;
}

.message.center .message-bubble {
    display: inline-block;
    padding: 8px 15px;
    background: linear-gradient(135deg, #ff5000 0%, #ff7000 100%);
    border-radius: 3px;
    color: #fff;
    font-size: 13px;
}

.message.left {
    text-align: left;
}

.message.right {
    text-align: right;
}

.message-content {
    display: inline-block;
    max-width: 70%;
    text-align: left;
}

.message-bubble {
    padding: 8px 12px;
    word-wrap: break-word;
    display: inline-block;
    position: relative;
    font-size: 14px;
    line-height: 1.5;
}

/* 左侧消息（客服） */
.message.left .message-bubble {
    background: #fff;
    border-radius: 10px;
    min-height: 14px;
}

/* 右侧消息（访客） */
.message.right .message-bubble {
    background: linear-gradient(135deg, #ff5000 0%, #ff9000 100%);
    color: #fff;
    border-radius: 10px;
    min-height: 14px;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.message.right .message-time {
    text-align: right;
}

.message-bubble a {
    color: #1890ff;
    text-decoration: underline;
}

.message.right .message-bubble a {
    color: #fff;
}

.message-bubble img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 6px;
    cursor: pointer;
}

.message-revoked {
    font-style: italic;
    color: #999;
    font-size: 12px;
}

/* ========== 快捷问题区域 ========== */
.footermsg {
    position: absolute;
    bottom: 70px;
    left: 0;
    right: 0;
    width: 100%;
    background: #F5F5F5;
    border-top: 1px solid #eee;
    overflow: hidden;
    height: 50px;
}

.scroll-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    z-index: 10;
    padding: 5px;
    color: #999;
    font-size: 12px;
}

.scroll-arrow:hover {
    color: #ff5000;
}

.left-arrow {
    left: 5px;
}

.right-arrow {
    right: 5px;
}

.service-info-container {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 10px 30px;
    width: 100%;
    box-sizing: border-box;
}

.service-info-container::-webkit-scrollbar {
    display: none;
}

.service-info {
    padding: 6px 14px;
    font-size: 13px;
    display: inline-block;
    background: #fff;
    border-radius: 30px;
    overflow: hidden;
    box-sizing: border-box;
    margin-right: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.service-info:hover {
    background: #ff5000;
    color: #fff;
}

.service-info span {
    white-space: nowrap;
}

/* ========== 输入区域 ========== */
.chat-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 70px;
    background-color: #F5F5F5;
}

.send-bar {
    display: flex;
    align-items: center;
    height: 100%;
    padding: 0 10px;
}

.tool-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tool-icon {
    font-size: 20px;
    color: #666;
    cursor: pointer;
    padding: 5px;
    transition: color 0.2s;
}

.tool-icon:hover {
    color: #ff5000;
}

#messageInput {
    flex: 1;
    height: 36px;
    background: #fff;
    border: none;
    border-radius: 18px;
    padding: 0 18px;
    font-size: 14px;
    outline: none;
    margin-left: 10px;
}

#messageInput::placeholder {
    color: #999;
}

.send-btn-div {
    padding-left: 10px;
}

.send-btn {
    padding: 10px 24px;
    background: linear-gradient(90deg, #ff5000 0%, #ff9000 98%);
    color: #fff;
    border: none;
    border-radius: 30px;
    font-size: 14px;
    cursor: pointer;
    transition: transform 0.2s;
}

.send-btn:hover {
    transform: scale(1.02);
}

.send-btn:active {
    transform: scale(0.98);
}

/* ========== 表情面板 ========== */
.emoji-panel {
    display: none;
    position: absolute;
    bottom: 130px;
    left: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 0 20px rgba(0,0,0,0.2);
    padding: 10px;
    z-index: 100;
    max-width: 372px;
    max-height: 200px;
    overflow-y: auto;
}

.emoji-panel.show {
    display: block;
}

.emoji-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
}

.emoji-item {
    width: 32px;
    height: 32px;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.emoji-item:hover {
    background: #f0f0f0;
}

/* ========== 评价弹窗 ========== */
.rating-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.rating-modal.show {
    display: flex;
}

.rating-content {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    width: 300px;
}

.rating-title {
    font-size: 16px;
    margin-bottom: 20px;
    color: #333;
}

.rating-stars {
    margin-bottom: 24px;
}

.rating-stars .star {
    font-size: 36px;
    cursor: pointer;
    color: #ddd;
    transition: all 0.2s;
    margin: 0 2px;
}

.rating-stars .star:hover,
.rating-stars .star.active {
    color: #ffc107;
    transform: scale(1.1);
}

.rating-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.rating-btns button {
    padding: 10px 30px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
}

.rating-skip {
    background: #f5f5f5;
    color: #666;
}

.rating-submit {
    background: linear-gradient(90deg, #ff5000 0%, #ff9000 98%);
    color: #fff;
}

/* ========== 拉黑遮罩 ========== */
.blocked-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.blocked-overlay.show {
    display: flex;
}

.blocked-content {
    text-align: center;
    color: #fff;
}

.blocked-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.blocked-text {
    font-size: 18px;
}

/* ========== 手机端适配 ========== */
@media (max-width: 768px) {
    .chat-container {
        height: 100%;
    }
    
    .tool-box {
        gap: 2px;
    }
    
    .tool-icon {
        font-size: 18px;
        padding: 3px;
    }
    
    #messageInput {
        margin-left: 5px;
        height: 34px;
        font-size: 13px;
    }
    
    .send-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .message-content {
        max-width: 80%;
    }
    
    .service-info {
        font-size: 12px;
        padding: 5px 12px;
    }
}

/* ========== 无效访问页面 ========== */
.invalid-access {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    z-index: 9999;
}
