/* 鐚庨拱鎷︽埅 路 瀹㈡湇宸ヤ綔鍙版牱寮� */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body, #app {
    height: 100%;
    font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    background: #f0f2f5;
}

/* ==================== 鐧诲綍椤� ==================== */
.login-wrap {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #3b5bdb 0%, #6d28d9 100%);
}

.login-card {
    width: 380px;
    border-radius: 12px;
}

.login-title {
    display: flex;
    align-items: center;
    margin-bottom: 24px;
}

.login-logo {
    font-size: 40px;
    margin-right: 12px;
}

.login-name {
    font-size: 18px;
    font-weight: 600;
    color: #303133;
}

.login-sub {
    font-size: 12px;
    color: #909399;
    margin-top: 4px;
}

/* ==================== 宸ヤ綔鍙板竷灞€ ==================== */
.workbench {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 52px;
    flex: none;
    background: #fff;
    border-bottom: 1px solid #e4e7ed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    color: #303133;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-agent {
    font-size: 14px;
    color: #606266;
}

.main {
    flex: 1;
    display: flex;
    min-height: 0;
    padding: 12px;
    gap: 12px;
}

/* ==================== 浼氳瘽鍒楄〃 ==================== */
.session-panel {
    width: 320px;
    flex: none;
    background: #fff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.session-header {
    flex: none;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid #ebeef5;
    font-size: 14px;
    color: #606266;
}

.session-list {
    flex: 1;
    overflow-y: auto;
}

.session-empty {
    padding: 48px 0;
    text-align: center;
    color: #c0c4cc;
    font-size: 13px;
}

.session-empty i {
    font-size: 42px;
    display: block;
    margin-bottom: 10px;
}

.session-item {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: pan-y;
    display: flex;
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f7fa;
    transition: background 0.15s;
}

.session-item:hover {
    background: #f5f7fa;
}

.session-item.active {
    background: #ecf5ff;
}

.session-avatar {
    position: relative;
    width: 42px;
    height: 42px;
    flex: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b5bdb, #6d28d9);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-right: 10px;
}

.online-dot {
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c0c4cc;
    border: 2px solid #fff;
}

.online-dot.on {
    background: #67c23a;
}

/* 系统通知会话的专用头像图标样式 */
.system-avatar-icon {
    font-size: 26px !important;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.session-body {
    flex: 1;
    min-width: 0;
}

.session-line1 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.session-name {
    font-size: 14px;
    color: #303133;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-name.session-name-vip {
    color: #f56c6c;
}

.session-line2 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 5px;
    gap: 8px;
}

.session-last {
    font-size: 12px;
    color: #909399;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 未读角标：挂在头像右上角，单字符时正圆、多字符时胶囊 */
.unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    box-sizing: border-box;
    border-radius: 10px;
    /* 与 iOS Color.red (#FF3B30) 一致的饱和红，el-badge 的 #f56c6c 观感偏淡 */
    background: #ff3b30;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    border: 1px solid #fff;
    white-space: nowrap;
}

/* 会话列表最后消息时间，与 iOS 版规则一致 */
.session-time {
    flex: none;
    font-size: 11px;
    color: #c0c4cc;
}

/* ==================== 鑱婂ぉ鍖� ==================== */
.chat-panel {
    flex: 1;
    background: #fff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #c0c4cc;
    font-size: 14px;
}

.chat-empty i {
    font-size: 56px;
    margin-bottom: 12px;
}

.chat-header {
    flex: none;
    height: 52px;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 16px;
    border-bottom: 1px solid #ebeef5;
}

/* 鑱婂ぉ澶撮儴杩斿洖鎸夐挳锛氫粎绉诲姩绔�樉绀� */
.chat-back {
    display: none;
}

.chat-title {
    font-size: 15px;
    font-weight: 600;
    color: #303133;
}

.chat-title-pop .chat-title.chat-title-vip {
    color: #f56c6c;
}

.chat-meta {
    flex: 1;
    font-size: 12px;
    color: #909399;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f6f8;
}

/* 娑堟伅琛� */
.msg-row {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.msg-row.mine {
    align-items: flex-end;
}

.msg-row.system {
    align-items: center;
}

.msg-system {
    font-size: 12px;
    color: #909399;
    background: #e9ebef;
    border-radius: 10px;
    padding: 3px 12px;
}

.msg-meta {
    font-size: 12px;
    color: #909399;
    margin-bottom: 4px;
}

/* 鑱婂ぉ澶撮儴鐨勫�娉�細姗欒壊绐佸嚭锛屼究浜庢帴寰呮椂蹇�€熺湅鍒� */
.chat-remark {
    color: #e6a23c;
}

/* 鐐瑰嚮鏍囬�寮瑰嚭鐨勭敤鎴疯�鎯呴潰鏉� */
.chat-title-clickable {
    cursor: pointer;
}

.chat-meta-pop {
    font-size: 13px;
    color: #606266;
    line-height: 2;
    min-width: 200px;
    max-width: 300px;
    word-break: break-all;
}

.chat-meta-pop .chat-remark {
    white-space: normal;
}

/* 鑱婂ぉ澶撮儴鎿嶄綔鎸夐挳锛氭�闈�/绉诲姩涓ゅ�鏂囨�锛岀敱濯掍綋鏌ヨ�鍒囨崲 */
.btn-txt-m {
    display: none;
}

/* 澶撮儴绂佽█鏍囩�锛氫笌鏂囧瓧淇濇寔闂磋窛 */
.chat-muted-tag {
    margin-left: 8px;
}

/* 鐢ㄦ埛閰嶇疆寮圭獥锛氬垎鍖哄睍绀哄紑鍏充笌瑙勫垯 */
.user-config {
    max-height: 60vh;
    overflow-y: auto;
}

.user-config-empty {
    text-align: center;
    color: #909399;
    padding: 24px 0;
}

.user-config-section {
    margin-bottom: 16px;
}

.user-config-title {
    font-weight: 600;
    color: #303133;
    margin-bottom: 8px;
    padding-left: 8px;
    border-left: 3px solid #409eff;
}

.user-config-switch {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    border-radius: 4px;
}

.user-config-switch:nth-child(odd) {
    background: #f7f8fa;
}

.user-config-group {
    margin-top: 10px;
}

.user-config-group-name {
    font-size: 13px;
    color: #606266;
    margin-bottom: 6px;
}

.user-config-group-empty {
    font-size: 12px;
    color: #c0c4cc;
}

.user-config-items .el-tag {
    margin: 0 6px 6px 0;
}

/* 鏉ョ數鎷︽埅璁板綍鍒楄〃锛氫笁鍒楀�榻� */
.user-config-logs {
    font-size: 13px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ebeef5;
    border-radius: 4px;
}

.user-config-log-row {
    display: flex;
    padding: 6px 12px;
    border-bottom: 1px solid #f2f3f5;
}

.user-config-log-row:last-child {
    border-bottom: none;
}

.user-config-log-head {
    color: #909399;
    background: #f7f8fa;
    font-weight: 600;
}

.user-config-logs .log-number {
    flex: 0 0 170px;
    color: #f56c6c;
}

.user-config-logs .log-reason {
    flex: 1;
    color: #606266;
    padding-right: 8px;
}

.user-config-logs .log-time {
    flex: 0 0 150px;
    color: #909399;
    text-align: right;
}

.user-config-logs .log-sim {
    font-style: normal;
    font-size: 11px;
    color: #909399;
    margin-left: 4px;
}

.msg-read {
    font-size: 11px;
    color: #c0c4cc;
    margin-top: 3px;
    text-align: right;
}

.msg-read.read {
    color: #67c23a;
}

.msg-bubble {
    max-width: 62%;
    padding: 9px 12px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #ebeef5;
    font-size: 14px;
    color: #303133;
    word-break: break-all;
    white-space: pre-wrap;
}

.msg-row.mine .msg-bubble {
    background: #3b5bdb;
    border-color: #3b5bdb;
    color: #fff;
}

/* Touch devices only: iOS Safari auto-zooms the page when focusing an input whose
   font-size is below 16px. Force 16px on touchscreens; desktop look is unchanged. */
@media (pointer: coarse) {
    .el-input__inner,
    .el-textarea__inner {
        font-size: 16px;
    }

    /* Own recallable bubbles: suppress the iOS long-press callout / text selection so a
       long-press cleanly opens the recall menu (see app.js onMsgTouchStart). */
    .msg-bubble-lp {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

.msg-image {
    max-width: 240px;
    max-height: 240px;
    border-radius: 6px;
    display: block;
    cursor: zoom-in;
}

/* el-image 澶栧眰 overflow:hidden 浼氳�鎺夎秴鍑洪儴鍒嗭紝灏哄�涓婇檺鐩存帴浣滅敤鍒板唴灞� img锛屼繚璇佸畬鏁存樉绀� */
.msg-image .el-image__inner {
    max-width: 240px;
    max-height: 240px;
}

.msg-video {
    width: 280px;
    max-width: 100%;
    border-radius: 6px;
    display: block;
    background: #000;
}

/* 杈撳叆鍖� */
.chat-input {
    flex: none;
    border-top: 1px solid #ebeef5;
    padding: 10px 14px 12px;
}

/* textarea 绛夎〃鍗曞厓绱犱笉缁ф壙 body 瀛椾綋锛岄渶鏄惧紡娌跨敤鍏ㄥ眬瀛椾綋 */
.chat-input .el-textarea__inner {
    font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

/* ==================== 甯哥敤鐭�彞闈㈡澘 ==================== */
.phrase-panel-title {
    font-size: 13px;
    color: #909399;
    text-align: center;
    padding-bottom: 8px;
    border-bottom: 1px solid #ebeef5;
}

.phrase-empty {
    font-size: 13px;
    color: #c0c4cc;
    text-align: center;
    padding: 20px 0;
}

.phrase-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 260px;
    overflow-y: auto;
}

.phrase-list li {
    display: flex;
    align-items: center;
    padding: 0 4px;
    border-bottom: 1px solid #f5f7fa;
}

.phrase-list li:last-child {
    border-bottom: none;
}

.phrase-text {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: #303133;
    padding: 9px 8px;
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-radius: 4px;
}

.phrase-text:hover {
    background: #f0f2f5;
    color: #409eff;
}

.phrase-actions {
    flex: none;
    display: none;
    padding-right: 4px;
}

.phrase-list li:hover .phrase-actions {
    display: inline-flex;
    gap: 10px;
}

.phrase-actions i {
    font-size: 15px;
    color: #909399;
    cursor: pointer;
}

.phrase-actions i:hover {
    color: #409eff;
}

.phrase-actions .el-icon-delete:hover {
    color: #f56c6c;
}

.phrase-add {
    text-align: center;
    font-size: 14px;
    color: #409eff;
    padding: 10px 0 2px;
    margin-top: 6px;
    border-top: 1px solid #ebeef5;
    cursor: pointer;
}

.phrase-add:hover {
    opacity: 0.8;
}

.input-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* Mobile-only send button parked at the toolbar's right end (hidden on desktop). */
.toolbar-send {
    display: none;
}

.uploading-tip {
    font-size: 12px;
    color: #409eff;
}

.input-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 8px;
}

.closed-tip {
    font-size: 12px;
    color: #e6a23c;
}

/* 婊氬姩鏉� */
.session-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.session-list::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: #dcdfe6;
    border-radius: 3px;
}

/* ==================== 绉诲姩绔�€傞厤 ==================== */
@media (max-width: 768px) {
    .login-card {
        width: 90%;
        max-width: 380px;
    }

    .topbar {
        height: 48px;
        padding: 0 10px;
    }

    .topbar-title {
        font-size: 14px;
    }

    .topbar-right {
        gap: 6px;
    }

    .topbar-agent {
        display: none;
    }

    /* 鍒楄〃/鑱婂ぉ鍗曞睆鍒囨崲锛氶粯璁ゅ叏灞忓垪琛�紝閫変腑浼氳瘽鍚庡叏灞忚亰澶� */
    .main {
        padding: 0;
        gap: 0;
    }

    .main:not(.mobile-chat-open) .chat-panel {
        display: none;
    }

    .main.mobile-chat-open .session-panel {
        display: none;
    }

    .session-panel {
        width: 100%;
        border-radius: 0;
    }

    .chat-panel {
        border-radius: 0;
    }

    .chat-header {
        height: 48px;
        flex-wrap: nowrap;
        gap: 8px;
        padding: 0 10px;
    }

    .chat-back {
        display: inline-flex;
        flex: none;
    }

    /* 鏍囬� Popover 澶栧眰鍗犳嵁鍓╀綑瀹藉害锛屾爣棰樹繚鎸佸崟琛岀渷鐣� */
    .chat-title-pop {
        flex: 0 1 88px;
        max-width: 28vw;
        min-width: 0;
        display: block;
    }

    .chat-title-pop .chat-title {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .chat-title {
        flex: 1;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* 鐢ㄦ埛璇︽儏璧般€岀敤鎴烽厤缃�/澶囨敞銆嶅脊绐楋紝澶撮儴鍙�暀鎿嶄綔鎸夐挳 */
    .chat-meta {
        display: none;
    }

    /* 按钮与标题保持同一行，宽度不足时只滚动按钮区域。 */
    .chat-actions {
        display: flex;
        flex: 1 1 0;
        min-width: 0;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
        touch-action: pan-x;
        scrollbar-width: thin;
    }

    .chat-actions .el-button {
        flex: 0 0 auto;
        padding: 5px 8px;
        margin-left: 0;
        white-space: nowrap;
    }

    .chat-actions::-webkit-scrollbar {
        height: 3px;
    }

    .chat-actions::-webkit-scrollbar-thumb {
        background: #dcdfe6;
        border-radius: 3px;
    }

    /* 绉诲姩绔�惎鐢ㄧ煭鏂囨� */
    .btn-txt-d {
        display: none;
    }

    .btn-txt-m {
        display: inline;
    }

    .chat-messages {
        padding: 10px;
    }

    .msg-bubble {
        max-width: 82%;
    }

    .msg-image {
        max-width: 160px;
        max-height: 200px;
    }

    .msg-image .el-image__inner {
        max-width: 160px;
        max-height: 200px;
    }

    .msg-video {
        width: 220px;
    }

    .chat-input {
        padding: 8px 10px 10px;
    }

    .input-footer {
        flex-wrap: wrap;
    }

    /* Mobile: show the toolbar send button at the right end, hide the footer one. */
    .toolbar-send {
        display: inline-block;
        margin-left: auto;
    }

    .input-footer .el-button {
        display: none;
    }

    /* 寮圭獥涓€寰嬮檺瀹� 90%锛岄伩鍏嶈秴鍑哄睆骞� */
    .el-dialog {
        width: 90% !important;
        margin: 6vh auto !important;
    }

    /* 鐭�彞闈㈡澘涓嶈秴鍑哄睆瀹� */
    .el-popover {
        max-width: calc(100vw - 32px) !important;
        box-sizing: border-box;
    }

    /* 鎷︽埅璁板綍鍒楃缉绐勯€傞厤绐勫睆 */
    .user-config-logs {
        font-size: 12px;
    }

    .user-config-logs .log-number {
        flex: 0 0 108px;
    }

    .user-config-logs .log-time {
        flex: 0 0 100px;
    }

    /* 鐭�彞鎿嶄綔鍥炬爣绉诲姩绔�棤鎮�仠锛屽父椹绘樉绀� */
    .phrase-actions {
        display: inline-flex;
        gap: 10px;
    }
}

/* 来电诊断弹窗：列表与单通时间线均分页，窄屏不产生横向滚动。 */
.decision-dialog {
    max-width: calc(100vw - 24px);
}

.decision-content {
    min-height: 100px;
    max-height: 65vh;
    overflow-y: auto;
    overflow-wrap: anywhere;
}

.decision-meta {
    padding: 12px;
    background: #f5f7fa;
    border-radius: 6px;
    line-height: 1.8;
}

.decision-caution {
    color: #946300;
    font-size: 12px;
}

.decision-filters {
    display: flex;
    gap: 10px;
    margin: 14px 0;
}

.decision-filters > * {
    flex: 1;
    min-width: 0;
}

.decision-empty {
    padding: 24px 8px;
    text-align: center;
    color: #909399;
}

.decision-call {
    border: 1px solid #e4e7ed;
    border-radius: 6px;
    margin-bottom: 10px;
}

.decision-call-head {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    border: 0;
    border-radius: 6px;
    padding: 12px;
    text-align: left;
    background: #fafbfc;
    color: #606266;
    font: inherit;
    cursor: pointer;
    overflow-wrap: anywhere;
}

.decision-result {
    color: #946300;
}

.decision-result-hangup_failed {
    color: #c03639;
}

.decision-timeline {
    padding: 12px 16px;
}

.decision-event {
    border-left: 2px solid #dcdfe6;
    padding: 0 0 16px 12px;
    line-height: 1.7;
}

.decision-event-time,
.decision-event small {
    font-size: 12px;
    color: #909399;
}

@media (max-width: 768px) {
    .decision-dialog .el-dialog__body {
        padding: 12px;
    }

    .decision-filters {
        flex-direction: column;
    }

    .decision-filters input {
        font-size: 16px;
    }

}

/* 消息气泡右键菜单（撤回） */
.ctx-mask {
    position: fixed;
    inset: 0;
    z-index: 3000;
}

.ctx-menu {
    position: fixed;
    z-index: 3001;
    min-width: 80px;
    background: #fff;
    border: 1px solid #ebeef5;
    border-radius: 6px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    padding: 4px 0;
}

.ctx-menu-item {
    padding: 6px 16px;
    font-size: 13px;
    color: #606266;
    cursor: pointer;
    text-align: center;
}

.ctx-menu-item:hover {
    background: #f5f7fa;
    color: #3b5bdb;
}

.session-ctx-menu {
    min-width: 120px;
}

.session-delete-item {
    display: block;
    width: 100%;
    min-height: 40px;
    border: 0;
    background: transparent;
    color: #f56c6c;
    font-family: inherit;
}

.session-delete-item:hover,
.session-delete-item:focus {
    color: #f56c6c;
    background: #fef0f0;
}

.el-message-box {
    max-width: calc(100vw - 32px);
}

/* 已撤回消息占位文案 */
.msg-recalled {
    color: #909399;
    font-size: 13px;
    font-style: italic;
}

/* 移动端响应式设计 */
@media (max-width: 768px) {
    .topbar-btn-audio {
        display: none !important;
    }
}

/* 移动端响应式设计 */
@media (max-width: 768px) {
    .topbar-btn-audio {
        display: none !important;
    }
}
