/* ==================== 图片查看器 & 媒体菜单 ==================== */
.image-viewer-modal {
    display: none;
    position: fixed;
    z-index: 20000;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s;
}

.image-viewer-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    animation: zoom 0.3s;
}

@keyframes zoom {
    from { transform: scale(0.7); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.image-viewer-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 20001;
}

.image-viewer-close:hover {
    color: #bbb;
    text-decoration: none;
}

.media-menu .menu-item:hover {
    background: #f1f5f9;
    color: #3b82f6;
}

.media-btn:hover {
    background: #f1f5f9;
    color: #3b82f6;
    transform: rotate(90deg);
}
/* Global Variables & Reset */
:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --bg-color: #f8fafc;
    --sidebar-bg: #ffffff;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --danger-color: #ef4444;
    --success-color: #22c55e;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.admin-layout {
    display: flex;
    height: calc(100vh - 50px);
    /* Subtract footer height */
}

/* Sidebar Styles */
.sessions-sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--sidebar-bg);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .brand-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    background: #eff6ff;
    border-radius: 8px;
    font-size: 18px;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

/* Generic Header Actions */
.header-actions {
    display: flex;
    gap: 8px;
}

.btn-refresh,
.btn-system-settings,
.btn-code,
.btn-clear-all {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-refresh:hover,
.btn-system-settings:hover,
.btn-code:hover,
.btn-clear-all:hover {
    background: #f1f5f9;
    color: var(--primary-color);
}

/* Stats Bar */
.stats-bar {
    display: flex;
    padding: 12px 20px;
    background: var(--bg-color);
    border-bottom: 1px solid var(--border-color);
}

.stats-bar .stat-item {
    flex: 1;
    text-align: center;
}

.stats-bar .label {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    color: #64748b;
    margin-bottom: 4px;
}

.stats-bar .value {
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: #1e293b;
}

/* 杩囨护鏍囩 */
.filter-tabs {
    display: flex;
    padding: 12px 20px;
    gap: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.tab-btn {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.tab-btn:hover {
    background: #f8fafc;
    color: var(--primary-color);
    border-color: #cbd5e1;
}

.tab-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* 浼氳瘽鍒楄〃 */
.sessions-list {
    flex: 1;
    overflow-y: auto;
}

.session-item {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.2s;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.session-item.active {
    background: #eff6ff;
    border-left: 3px solid var(--primary-color);
}

.session-item .session-content {
    flex: 1;
    cursor: pointer;
    min-width: 0;
    -webkit-tap-highlight-color: transparent;
    /* 绉婚櫎绉诲姩绔粯璁ょ偣鍑婚珮浜?*/
    user-select: none;
    /* 闃叉闀挎寜閫変腑鏂囨湰 */
    -webkit-user-select: none;
}

.session-item .delete-session-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: #fee2e2;
    color: #ef4444;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    opacity: 0;
}

.session-item:hover .delete-session-btn {
    opacity: 1;
}

.session-item .delete-session-btn:hover {
    background: #ef4444;
    color: white;
    transform: scale(1.05);
}

.session-item .session-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.session-item .visitor-info-left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.session-item .visitor-name {
    font-weight: 500;
    color: #1e293b;
    font-size: 14px;
}

.session-item .visitor-phone {
    font-size: 12px;
    color: #64748b;
}

.session-item .time {
    font-size: 11px;
    color: #94a3b8;
    flex-shrink: 0;
}

.session-item .last-message {
    font-size: 13px;
    color: #64748b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-item .unread-badge {
    position: absolute;
    top: 16px;
    right: 20px;
    background: #ef4444;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.session-item .status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 8px;
}

.session-item .status-badge.active {
    background: #dcfce7;
    color: #16a34a;
}

.session-item .status-badge.closed {
    background: #f1f5f9;
    color: #64748b;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
}

/* 鍙充晶鑱婂ぉ鍖哄煙 */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}

.empty-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-chat p {
    font-size: 16px;
}

/* 鑱婂ぉ鍖哄煙 */
.chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    background: white;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.visitor-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.visitor-info .avatar {
    width: 40px;
    height: 40px;
    background: #eff6ff;
    color: var(--primary-color);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border: 1px solid #bfdbfe;
}

.visitor-info h3 {
    font-size: 16px;
    color: #1e293b;
    margin-bottom: 4px;
}

.visitor-title-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-bottom: 4px;
}

.visitor-admin-tags-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    max-width: 100%;
}

.admin-tag-chip,
.session-admin-tag-chip {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 6px;
    background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
    color: #4338ca;
    line-height: 1.35;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.session-admin-tags-row {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 2px;
    max-width: 100%;
}

.session-admin-tag-chip {
    font-size: 10px;
    padding: 1px 6px;
    max-width: 100px;
}

.btn-edit-visitor-tags {
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 6px;
    border: 1px solid #c7d2fe;
    background: #eef2ff;
    color: #4f46e5;
    cursor: pointer;
    font-weight: 500;
    line-height: 1.4;
}

.btn-edit-visitor-tags:hover {
    background: #e0e7ff;
}

.visitor-admin-tags-editor {
    margin-bottom: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    max-width: 100%;
}

.visitor-admin-tags-editor input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 8px;
}

.visitor-admin-tags-editor-actions {
    display: flex;
    gap: 8px;
}

.btn-tag-save {
    padding: 6px 14px;
    border: none;
    border-radius: 8px;
    background: var(--primary-color, #3b82f6);
    color: white;
    font-size: 13px;
    cursor: pointer;
    font-weight: 500;
}

.btn-tag-cancel {
    padding: 6px 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: white;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
}

.visitor-info .time {
    font-size: 12px;
    color: #94a3b8;
}

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

.btn-close-session {
    padding: 8px 16px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-close-session:hover {
    background: #fecaca;
}

.btn-back {
    padding: 8px 16px;
    background: #f1f5f9;
    color: #64748b;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    text-decoration: none;
    transition: background 0.2s;
    display: inline-block;
}

.btn-back:hover {
    background: #e2e8f0;
}

/* 绉诲姩绔鑸爮 - 榛樿闅愯棌 */
.mobile-navbar {
    display: none;
}

.mobile-overlay {
    display: none;
}

/* 绠＄悊鍛樹俊鎭?*/
.admin-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    padding-left: 20px;
    border-left: 1px solid #e2e8f0;
}

.admin-name {
    font-size: 13px;
    color: #475569;
    font-weight: 500;
}

.btn-logout {
    padding: 8px 16px;
    background: white;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-logout:hover {
    background: #f1f5f9;
    color: var(--danger-color);
    border-color: #fee2e2;
}

/* 娑堟伅鍖哄煙 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: #f8fafc;
}

.message {
    margin-bottom: 16px;
    animation: messageIn 0.3s ease-out;
    position: relative;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    display: inline-block;
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message-content img {
    max-width: 250px;
    max-height: 250px;
    border-radius: 8px;
    display: block;
    cursor: pointer;
    transition: transform 0.2s;
}

.message-content img:hover {
    transform: scale(1.02);
}

.message-content.image-message {
    padding: 4px;
    background: transparent !important;
    box-shadow: none !important;
}

/* 鍥剧墖鏌ョ湅鍣ㄦā鎬佹 */
.image-viewer-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    padding: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.image-viewer-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    animation: zoomIn 0.3s ease-in-out;
}

@keyframes zoomIn {
    from {
        transform: scale(0.7);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.image-viewer-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 50px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 10001;
    line-height: 1;
}

.image-viewer-close:hover,
.image-viewer-close:focus {
    color: #bbb;
    text-decoration: none;
}

.message.visitor .message-content {
    background: white;
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.message.admin .message-content {
    background: var(--primary-color);
    color: white;
    border-bottom-right-radius: 4px;
    float: right;
    box-shadow: var(--shadow-sm);
}

/* 欢迎语富文本：品牌名加粗强调（后台气泡为深色底，用浅橙保证对比度） */
.message.admin .message-content.rich-html-message strong.markup-emphasis,
.message.admin .message-content.rich-html-message .markup-emphasis {
    color: #ffd4a8;
    font-weight: 700;
}

.message.system .message-content {
    background: #f1f5f9;
    color: #64748b;
    font-size: 13px;
    text-align: center;
    max-width: 90%;
    margin: 0 auto;
    display: block;
    float: none;
}

.message-info {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
    padding: 0 4px;
    clear: both;
}

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

.message.admin .message-info {
    text-align: right;
    float: right;
    clear: both;
}

.message.admin .msg-read-status {
    font-size: 11px;
    font-weight: 500;
}

.message.admin .msg-read-status.is-read {
    color: #16a34a;
}

.message.admin .msg-read-status.is-unread {
    color: #94a3b8;
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* 杈撳叆鍖哄煙 */
.chat-input-area {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: center;
}

.image-btn {
    background: white;
    color: #8b5cf6;
    border: 2px solid #e2e8f0;
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.image-btn:hover {
    border-color: #8b5cf6;
    background: #f8fafc;
    transform: translateY(-2px);
}

.image-btn:active {
    transform: translateY(0);
}

.image-preview {
    margin-top: 12px;
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-width: 200px;
    max-height: 150px;
    border-radius: 12px;
    border: 2px solid #e2e8f0;
}

.cancel-image-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    border: 2px solid white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.cancel-image-btn:hover {
    background: #dc2626;
    transform: scale(1.1);
}

#replyInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#replyInput:focus {
    border-color: #667eea;
}

.send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.send-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-btn:active {
    transform: translateY(0);
}

/* 婊氬姩鏉℃牱寮?*/
.sessions-list::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

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

.sessions-list::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 澶撮儴鎿嶄綔鎸夐挳 */
.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-mail-settings {
    background: rgba(59, 130, 246, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: all 0.3s;
}

.btn-mail-settings:hover {
    background: rgba(59, 130, 246, 0.3);
    transform: rotate(90deg);
}

.btn-clear-all {
    background: rgba(239, 68, 68, 0.2);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    transition: all 0.3s;
}

.btn-clear-all:hover {
    background: rgba(239, 68, 68, 0.4);
    transform: scale(1.1);
}

/* 閭欢璁剧疆妯℃€佹 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: white;
    color: var(--text-main);
    border-radius: 12px 12px 0 0;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.close-btn:hover {
    background: #f1f5f9;
    color: var(--text-main);
    transform: rotate(90deg);
}

.modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 琛ㄥ崟鏍峰紡 */
.form-section {
    margin-bottom: 25px;
}

.form-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 8px;
}

.required {
    color: #ef4444;
    margin-left: 2px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-hint {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 5px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 14px;
    font-weight: 500;
    color: #334155;
}

/* 杈撳叆缁?*/
.input-group {
    display: flex;
    gap: 10px;
}

.input-group input {
    flex: 1;
}

.input-group .btn-test {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.input-group .btn-test:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.input-group .btn-test:active {
    transform: translateY(0);
}

.input-group .btn-test:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* 娴嬭瘯鍖哄煙 */
.test-section {
    background: #f8fafc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

/* 鎸夐挳鏍峰紡 */
.btn-primary,
.btn-secondary {
    padding: 10px 24px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

/* 鍝嶅簲寮?- 绉诲姩绔紭鍖?*/
@media (max-width: 768px) {
    body {
        overflow: auto;
    }

    /* 甯冨眬鍒囨崲 - 涓哄鑸爮鍜屽簳閮ㄧ暀鍑虹┖闂?*/
    .admin-layout {
        position: relative;
        padding-top: 56px;
        /* 瀵艰埅鏍忛珮搴?*/
        padding-bottom: 50px;
        /* 搴曢儴淇℃伅楂樺害 */
        min-height: 100vh;
    }

    /* 渚ц竟鏍?- 榛樿闅愯棌锛屼粠瀵艰埅鏍忎笅鏂规粦鍑?*/
    .sessions-sidebar {
        width: 100%;
        position: fixed;
        left: 0;
        top: 56px;
        /* 浠庡鑸爮涓嬫柟寮€濮?*/
        z-index: 100;
        height: calc(100vh - 56px);
        /* 鍑忓幓瀵艰埅鏍忛珮搴?*/
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .sessions-sidebar.show {
        transform: translateX(0);
    }

    /* 涓昏亰澶╁尯鍩?- 鍑忓幓瀵艰埅鏍忛珮搴?*/
    .chat-main {
        width: 100%;
        position: relative;
        min-height: calc(100vh - 56px - 50px);
        /* 鍑忓幓瀵艰埅鏍忓拰搴曢儴淇℃伅楂樺害 */
    }

    /* 绉诲姩绔《閮ㄥ鑸爮 */
    .mobile-navbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 56px;
        background: white;
        border-bottom: 1px solid #e2e8f0;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        z-index: 99;
        padding: 0 15px;
    }

    /* 绉诲姩绔彍鍗曟寜閽?*/
    .mobile-menu-btn {
        background: white;
        color: #667eea;
        border: 1px solid #e2e8f0;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        font-size: 20px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .mobile-menu-btn:hover {
        background: #f8fafc;
        border-color: #cbd5e1;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
        transform: translateY(-1px);
    }

    .mobile-menu-btn:active {
        transform: translateY(0) scale(0.98);
    }

    /* 鑿滃崟鎸夐挳灞曞紑鐘舵€?*/
    .mobile-menu-btn.active {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        border-color: transparent;
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }

    .mobile-menu-btn.active:hover {
        box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
    }

    /* 瀵艰埅鏍忎腑闂?- 鍝佺墝鏍囪瘑 */
    .mobile-navbar-center {
        display: flex;
        align-items: center;
        gap: 8px;
        flex: 1;
        justify-content: center;
    }

    .mobile-brand-icon {
        font-size: 22px;
        line-height: 1;
    }

    .mobile-brand-text {
        font-size: 16px;
        font-weight: 600;
        color: #1e293b;
    }

    /* 瀵艰埅鏍忓彸渚ф寜閽?*/
    .mobile-navbar-right {
        display: flex;
        align-items: center;
        gap: 8px;
        flex-shrink: 0;
    }

    .mobile-nav-btn {
        background: white;
        color: #667eea;
        border: 1px solid #e2e8f0;
        width: 40px;
        height: 40px;
        border-radius: 8px;
        font-size: 18px;
        cursor: pointer;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-nav-btn:hover {
        background: #f8fafc;
        border-color: #cbd5e1;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
        transform: translateY(-1px);
    }

    .mobile-nav-btn:active {
        transform: translateY(0) scale(0.98);
    }

    /* 閬僵灞?- 浠庡鑸爮涓嬫柟寮€濮?*/
    .mobile-overlay {
        position: fixed;
        top: 56px;
        /* 浠庡鑸爮涓嬫柟寮€濮?*/
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 99;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .mobile-overlay.show {
        opacity: 1;
        visibility: visible;
    }

    /* 渚ц竟鏍忓ご閮?*/
    .sidebar-header {
        padding: 15px;
    }

    .sidebar-header h2 {
        font-size: 16px;
    }

    .header-actions {
        gap: 8px;
    }

    .btn-mail-settings,
    .btn-clear-all,
    .btn-refresh {
        width: 32px;
        height: 32px;
        font-size: 16px;
        padding: 0;
    }

    /* 缁熻鏍?*/
    .stats-bar {
        padding: 12px 15px;
    }

    .stat-item {
        font-size: 12px;
    }

    /* 杩囨护鏍囩 */
    .filter-tabs {
        padding: 8px 15px;
    }

    .tab-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* 浼氳瘽鍒楄〃 */
    .sessions-list {
        padding: 8px;
    }

    .session-item {
        padding: 12px;
        margin-bottom: 8px;
        border-radius: 12px;
        background: white;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    /* 鎵嬫満绔偣鍑诲弽棣?- 浣跨敤 active 鑰屼笉鏄?hover */
    .session-item:active {
        background: #f8fafc;
        transform: scale(0.98);
        transition: all 0.1s ease;
    }

    .session-item.active {
        background: #ede9fe !important;
        box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    }

    .session-item .name {
        font-size: 14px;
    }

    .session-item .phone {
        font-size: 12px;
    }

    .session-item .last-message {
        font-size: 12px;
    }

    .session-item .time {
        font-size: 11px;
    }

    /* 鎵嬫満绔垹闄ゆ寜閽竴鐩存樉绀?*/
    .session-item .delete-session-btn {
        width: 32px;
        height: 32px;
        font-size: 16px;
        opacity: 1 !important;
        /* 鎵嬫満绔竴鐩存樉绀?*/
        background: #fee2e2;
        color: #ef4444;
        border-radius: 8px;
        box-shadow: 0 2px 4px rgba(239, 68, 68, 0.1);
    }

    /* 鍒犻櫎鎸夐挳鐐瑰嚮鍙嶉 */
    .session-item .delete-session-btn:active {
        background: #ef4444;
        color: white;
        transform: scale(0.9);
        box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
    }

    /* 浼氳瘽鍐呭瑙︽懜浼樺寲 */
    .session-item .session-content {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        /* 绂佺敤鍙屽嚮缂╂斁 */
    }

    /* 浼氳瘽鍐呭鐐瑰嚮鍙嶉 - 鏇存槑鏄剧殑瑙嗚鏁堟灉 */
    .session-item .session-content:active {
        opacity: 0.7;
    }

    /* 鑱婂ぉ澶撮儴 */
    .chat-header {
        padding: 12px 15px;
        flex-direction: row;
        gap: 8px;
        align-items: center;
    }

    .visitor-info {
        flex: 1;
        min-width: 0;
    }

    .visitor-info .avatar {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .visitor-info .info h3 {
        font-size: 14px;
    }

    .visitor-info .info p {
        font-size: 11px;
    }

    .chat-header .actions {
        flex-shrink: 0;
        gap: 8px;
    }

    .btn-close-session,
    .btn-back {
        padding: 8px 12px;
        font-size: 13px;
    }

    /* 鑱婂ぉ娑堟伅鍖哄煙 */
    .chat-messages {
        padding: 15px 10px;
    }

    .message {
        max-width: 100%;
        padding: 10px 14px;
    }

    .message .text {
        font-size: 14px;
        line-height: 1.5;
    }

    .message .time {
        font-size: 11px;
        margin-top: 6px;
    }

    /* 绉诲姩绔‘淇濈鐞嗗憳娑堟伅闈犲彸 */
    .message.admin {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    .message.admin .message-content {
        float: right;
    }

    .message.admin .message-info {
        text-align: right;
        width: 100%;
    }

    /* 璁垮娑堟伅闈犲乏 */
    .message.visitor {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .message.visitor .message-content {
        float: left;
    }

    .message.visitor .message-info {
        text-align: left;
        width: 100%;
    }

    /* 杈撳叆鍖哄煙 */
    .chat-input-area {
        padding: 12px 10px;
    }

    .input-wrapper {
        gap: 8px;
    }

    .input-wrapper input {
        padding: 12px 15px;
        font-size: 14px;
    }

    .send-btn {
        padding: 12px 16px;
        font-size: 14px;
        min-width: 70px;
    }

    /* 绌虹姸鎬?*/
    .empty-chat {
        padding: 20px;
    }

    .empty-icon {
        font-size: 60px;
    }

    .empty-chat p {
        font-size: 14px;
    }

    /* 妯℃€佹 */
    .modal {
        padding: 10px;
        align-items: flex-start;
        overflow-y: auto;
    }

    .modal-content {
        width: 100%;
        max-width: 100%;
        max-height: none;
        margin: 20px 0;
        border-radius: 12px;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .close-btn {
        font-size: 28px;
        width: 32px;
        height: 32px;
    }

    .modal-body {
        padding: 15px;
        max-height: none;
    }

    .form-section {
        margin-bottom: 20px;
    }

    .form-section h3 {
        font-size: 15px;
        margin-bottom: 12px;
    }

    .form-group {
        margin-bottom: 15px;
    }

    .form-group label {
        font-size: 13px;
        margin-bottom: 6px;
    }

    .form-group input,
    .form-group select {
        padding: 10px 12px;
        font-size: 14px;
    }

    .form-hint {
        font-size: 11px;
        margin-top: 4px;
    }

    .input-group {
        flex-direction: column;
        gap: 8px;
    }

    .input-group input {
        flex: none;
        width: 100%;
    }

    .btn-test {
        width: 100%;
        padding: 10px;
    }

    .modal-footer {
        padding: 12px 15px;
        gap: 10px;
    }

    .modal-footer button {
        flex: 1;
        padding: 12px;
        font-size: 14px;
    }

    /* 閫氱煡鏍峰紡 */
    .notification {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        max-width: none !important;
        font-size: 13px !important;
        padding: 12px 15px !important;
    }

    /* 绉诲姩绔簳閮ㄤ俊鎭?*/
    .admin-footer {
        padding: 8px 12px;
        min-height: 45px;
    }

    .admin-footer .footer-content {
        flex-direction: column;
        gap: 6px;
        text-align: center;
        align-items: center;
    }

    .footer-left {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 5px;
        align-items: center;
        white-space: nowrap;
    }

    .footer-right {
        flex-direction: column;
        gap: 5px;
        align-items: center;
    }

    .footer-logo {
        font-size: 16px;
        width: 28px;
        height: 28px;
    }

    .footer-brand,
    .footer-copyright {
        font-size: 11px;
        line-height: 1.4;
    }

    .footer-version {
        font-size: 10px;
        padding: 2px 6px;
    }
}

/* 骞虫澘璁惧浼樺寲 */
@media (min-width: 769px) and (max-width: 1024px) {
    .sessions-sidebar {
        width: 280px;
    }

    .session-item {
        padding: 12px;
    }

    .modal-content {
        width: 90%;
        max-width: 600px;
    }
}

/* 瓒呭皬灞忓箷 */
@media (max-width: 375px) {
    .chat-header {
        padding: 10px;
        gap: 6px;
    }

    .visitor-info .avatar {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .visitor-info .info h3 {
        font-size: 13px;
    }

    .visitor-info .info p {
        font-size: 10px;
    }

    .chat-header .actions {
        gap: 6px;
    }

    .btn-close-session,
    .btn-back {
        padding: 6px 10px;
        font-size: 12px;
    }

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

    .message {
        max-width: 90%;
        padding: 8px 12px;
    }

    .message .text {
        font-size: 13px;
    }

    /* 瓒呭皬灞忕‘淇濈鐞嗗憳娑堟伅闈犲彸 */
    .message.admin {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
    }

    .message.admin .message-content {
        float: right;
    }

    .message.admin .message-info {
        text-align: right;
        width: 100%;
    }

    /* 璁垮娑堟伅闈犲乏 */
    .message.visitor {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .message.visitor .message-content {
        float: left;
    }

    .message.visitor .message-info {
        text-align: left;
        width: 100%;
    }

    .input-wrapper input {
        padding: 10px 12px;
        font-size: 13px;
    }

    .send-btn {
        padding: 10px 12px;
        min-width: 60px;
    }

    .modal-header h2 {
        font-size: 16px;
    }

    .form-group input {
        padding: 9px 10px;
        font-size: 13px;
    }
}

/* 绠＄悊鍚庡彴搴曢儴淇℃伅 */
.admin-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 8px 20px;
    z-index: 50;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    pointer-events: none;
}

.admin-footer * {
    pointer-events: auto;
}

.admin-footer .footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-logo {
    font-size: 18px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
}

/* 蹇嵎閾炬帴寮瑰嚭灞?*/
.input-wrapper {
    position: relative;
}

.shortcut-links-popover {
    position: absolute;
    bottom: 100%;
    left: 40px;
    width: 220px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 -10px 25px rgba(0,0,0,0.1);
    z-index: 1000;
    margin-bottom: 12px;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.popover-header {
    padding: 12px 15px;
    font-size: 13px;
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    color: #64748b;
}

.popover-links-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 6px;
}

.popover-link-item {
    padding: 10px 12px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.popover-link-item:hover {
    background: #eff6ff;
    color: #3b82f6;
}

.popover-link-item svg {
    opacity: 0.5;
}

/* 閾炬帴娑堟伅姘旀场 (瀹㈡湇绔瑙? */
.message.admin .message-content.link-message {
    padding: 12px 20px;
    background: white !important;
    border: 2px solid #3b82f6 !important;
    border-radius: 18px !important;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    text-decoration: none;
    color: #3b82f6 !important;
    font-weight: 600;
    margin-bottom: 5px;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.1);
    float: right;
    clear: both;
}

.message.admin .message-content.link-message:hover {
    background: #3b82f6 !important;
    color: white !important;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.2);
}

.message.admin .message-content.link-message svg {
    flex-shrink: 0;
}

.footer-brand {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

.footer-version {
    background: white;
    border: 1px solid #e2e8f0;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

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

.footer-copyright {
    font-size: 13px;
    color: #64748b;
}

/* admin-layout浣跨敤calc()閬垮厤琚玣ooter閬尅锛屼笉闇€瑕侀澶杙adding */

/* 绉诲姩绔紭鍖?(768px浠ヤ笅) */
@media (max-width: 768px) {

    /* 绉诲姩绔竷灞€楂樺害璋冩暣 - 椤堕儴瀵艰埅56px + 搴曢儴绾?0px */
    .admin-layout {
        padding-bottom: 40px;
        /* 璋冩暣搴曢儴闂磋窛 */
    }

    .admin-footer {
        padding: 5px 8px;
        min-height: auto;
    }

    .admin-footer .footer-content {
        flex-direction: row;
        justify-content: center;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .footer-left {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 4px;
        white-space: nowrap;
    }

    .footer-right {
        gap: 4px;
    }

    .footer-logo {
        font-size: 12px;
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }

    .footer-brand {
        font-size: 10px;
        white-space: nowrap;
    }

    .footer-copyright {
        font-size: 9px;
        line-height: 1.3;
        white-space: nowrap;
    }

    .footer-version {
        font-size: 8px;
        padding: 1px 4px;
        white-space: nowrap;
    }
}

/* 瓒呭皬灞忓箷浼樺寲 (480px浠ヤ笅) */
@media (max-width: 480px) {

    /* 瓒呭皬灞忓竷灞€楂樺害璋冩暣 - 椤堕儴瀵艰埅56px + 搴曢儴绾?5px */
    .admin-layout {
        padding-bottom: 25px;
        /* 璋冩暣搴曢儴闂磋窛 */
    }

    .admin-footer {
        padding: 3px 6px;
        min-height: auto;
    }

    .admin-footer .footer-content {
        gap: 5px;
        font-size: 9px;
    }

    .footer-left {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 3px;
        white-space: nowrap;
    }

    .footer-logo {
        font-size: 10px;
        width: 18px;
        height: 18px;
    }

    .footer-brand {
        font-size: 9px;
    }

    .footer-copyright {
        font-size: 8px;
        display: none;
    }

    .footer-right {
        display: none;
    }

    .footer-version {
        font-size: 7px;
        padding: 1px 3px;
    }
}

/* 璀﹀憡妗嗘牱寮?*/
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    border: 1px solid transparent;
}

.alert strong {
    font-weight: 600;
    margin-right: 4px;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffecb5;
    color: #856404;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
}

.alert-success {
    background-color: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}



/* 绯荤粺璁剧疆妯℃€佹鏍峰紡 */
.settings-modal-content {
    max-width: 600px;
    width: 90%;
}

/* 閫夐」鍗″鑸?*/
.settings-tabs {
    display: flex;
    border-bottom: 2px solid #e2e8f0;
    background: #f8fafc;
    padding: 0 20px;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    font-size: 15px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.tab-btn.active {
    color: var(--primary-color);
    background: white;
    border-bottom-color: var(--primary-color);
}

/* 閫夐」鍗″唴瀹?*/
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 閫夐」鍗″唴鐨勬ā鎬佹涓讳綋 */
.tab-content .modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* ==================== 瀹㈡湇璁剧疆鏍峰紡 ==================== */

/* 鑷姩鍥炲瑙勫垯瀹瑰櫒 */
.auto-reply-rules {
    margin-bottom: 15px;
}

.empty-rules {
    padding: 30px;
    text-align: center;
    color: #94a3b8;
    background: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
}

/* 鍗曚釜瑙勫垯鏍峰紡 */
.auto-reply-rule {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.3s;
}

.auto-reply-rule:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.rule-number {
    font-weight: 600;
    color: #475569;
    font-size: 14px;
}

.btn-delete-rule {
    padding: 5px 12px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-delete-rule:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.rule-body .form-group {
    margin-bottom: 12px;
}

.rule-body .form-group:last-child {
    margin-bottom: 0;
}

.rule-keywords,
.rule-reply {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 14px;
    transition: all 0.3s;
}

.rule-keywords:focus,
.rule-reply:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.rule-reply {
    resize: vertical;
    min-height: 60px;
    font-family: inherit;
}

/* 娣诲姞瑙勫垯鎸夐挳 */
.btn-add-rule {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}

.btn-add-rule:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-add-rule:active {
    transform: translateY(0);
}

/* 琛ㄥ崟鍒嗙粍鏍峰紡澧炲己 */
.form-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
    color: #1e293b;
    font-size: 16px;
}

/* 澶嶉€夋鏍囩鏍峰紡 */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-weight: 500;
    color: #475569;
}

/* 鏂囨湰鍩熸牱寮?*/
#welcomeMessage {
    width: 100%;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.3s;
}

#welcomeMessage:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 鍝嶅簲寮忚皟鏁?*/
@media (max-width: 768px) {
    .auto-reply-rule {
        padding: 12px;
    }

    .rule-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .btn-delete-rule {
        align-self: flex-end;
    }
}

/* --- Multi-Agent Support Styles --- */

/* Role Badges */
.role-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 5px;
    font-weight: 600;
    vertical-align: middle;
    display: inline-block;
}
.role-badge.admin {
    background: #eff6ff;
    color: #3b82f6;
    border: 1px solid #bfdbfe;
}
.role-badge.agent {
    background: #f0fdf4;
    color: #22c55e;
    border: 1px solid #bbf7d0;
}

/* Settings Table for Agents */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin-top: 10px;
}
.settings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.settings-table th {
    background: #f8fafc;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #64748b;
    border-bottom: 1px solid #e2e8f0;
}
.settings-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}
.settings-table tr:last-child td {
    border-bottom: none;
}
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}
.status-badge.online {
    background: #dcfce7;
    color: #16a34a;
}
.status-badge.offline {
    background: #f1f5f9;
    color: #64748b;
}

.btn-edit:hover, .btn-delete:hover {
    text-decoration: underline;
    opacity: 0.8;
}

/* Adjustments for agent modal */
#agentEditModal .form-group {
    margin-bottom: 15px;
}
#agentEditModal label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
}
#agentEditModal input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
}
/* 发送链接按钮样式 (匹配图片按钮) */
.link-btn {
    background: white;
    color: #3b82f6;
    border: 1px solid #e2e8f0;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.link-btn:hover {
    border-color: #3b82f6;
    background: #f8fafc;
    transform: translateY(-2px);
}

/* 快捷链接弹出层样式 */
.shortcut-links-popover {
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 280px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    z-index: 1000;
    overflow: hidden;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.popover-header {
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popover-add-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #3b82f6;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: all 0.2s;
}

.popover-add-btn:hover {
    background: #2563eb;
    transform: rotate(90deg);
}

.popover-add-form {
    padding: 12px;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
}

.popover-add-form input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 8px;
    outline: none;
}

.popover-add-form input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.popover-form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.btn-save-mini, .btn-cancel-mini {
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    border: 1px solid transparent;
}

.btn-save-mini {
    background: #3b82f6;
    color: white;
}

.btn-save-mini:hover { background: #2563eb; }

.btn-cancel-mini {
    background: white;
    border-color: #e2e8f0;
    color: #64748b;
}

.btn-cancel-mini:hover { background: #f1f5f9; }

.popover-links-list {
    max-height: 300px;
    overflow-y: auto;
    padding: 8px 0;
}

.popover-link-item {
    padding: 10px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.popover-link-item:hover {
    background: #f1f5f9;
}

.popover-link-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.popover-link-text {
    font-size: 14px;
    font-weight: 500;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popover-link-url {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popover-link-delete {
    padding: 6px;
    color: #94a3b8;
    border: none;
    background: transparent;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.popover-link-item:hover .popover-link-delete {
    opacity: 1;
    color: #ef4444;
}

.popover-link-delete:hover {
    background: #fee2e2;
    border-radius: 4px;
}

/* 链接消息气泡 (客服端预览) */
.message.admin .message-content.link-message,
.message.visitor .message-content.link-message {
    padding: 10px 16px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #1e293b;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.message-content.link-message:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.message-content.link-message svg {
    flex-shrink: 0;
    color: #64748b;
}

/* --- Avatar System Styles --- */
.admin-profile-brief {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
}

.admin-avatar-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.admin-name-mini {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Message Avatars (Admin Panel) */
.message {
    display: flex !important;
    gap: 12px !important;
    margin-bottom: 20px !important;
    align-items: flex-end !important;
}

.message.admin {
    flex-direction: row-reverse !important;
}

.message-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
    background: #f1f5f9 !important;
}

.message-body {
    display: flex !important;
    flex-direction: column !important;
    max-width: 80% !important;
}

.message.admin .message-body {
    align-items: flex-end !important;
}

.message.visitor .message-body {
    align-items: flex-start !important;
}

.message-content {
    padding: 10px 14px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    word-break: break-all !important;
}

.message.visitor .message-content {
    background: #f1f5f9 !important;
    color: #1e293b !important;
    border-bottom-left-radius: 4px !important;
    float: none !important;
}

.message.admin .message-content {
    background: #4f46e5 !important;
    color: white !important;
    border-bottom-right-radius: 4px !important;
    float: none !important;
}

.message-info {
    font-size: 11px !important;
    color: #94a3b8 !important;
    margin-top: 4px !important;
}

/* --- Avatar System Styles --- */
.admin-profile-brief {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 12px;
    border: 1px solid #e2e8f0;
}

.admin-avatar-mini {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.admin-name-mini {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chat Message Avatars (Admin Panel) */
.message {
    display: flex !important;
    gap: 12px !important;
    margin-bottom: 20px !important;
    align-items: flex-end !important;
}

.message.admin {
    flex-direction: row-reverse !important;
}

.message-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
    background: #f1f5f9 !important;
}

.message-body {
    display: flex !important;
    flex-direction: column !important;
    max-width: 80% !important;
}

.message.admin .message-body {
    align-items: flex-end !important;
}

.message.visitor .message-body {
    align-items: flex-start !important;
}

.message-content {
    padding: 10px 14px !important;
    border-radius: 14px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    word-break: break-all !important;
}

.message.visitor .message-content {
    background: #f1f5f9 !important;
    color: #1e293b !important;
    border-bottom-left-radius: 4px !important;
    float: none !important;
}

.message.admin .message-content {
    background: #4f46e5 !important;
    color: white !important;
    border-bottom-right-radius: 4px !important;
    float: none !important;
}

.message-info {
    font-size: 11px !important;
    color: #94a3b8 !important;
    margin-top: 4px !important;
}

/* --- Avatar System Styles Patch --- */
.message {
    align-items: flex-start !important;
}

.message.admin {
    flex-direction: row !important;
    justify-content: flex-end !important;
}

.message.visitor {
    flex-direction: row !important;
    justify-content: flex-start !important;
}


/* --- Avatar System Styles Patch --- */
.message {
    align-items: flex-start !important;
}

.message.admin {
    flex-direction: row !important;
    justify-content: flex-end !important;
}

.message.visitor {
    flex-direction: row !important;
    justify-content: flex-start !important;
}

/* --- Avatar System Styles Patch (Wrap Fix) --- */
.message-content {
    word-break: normal !important;
    overflow-wrap: break-word !important; 
    word-wrap: break-word !important;
    white-space: pre-wrap !important;
    max-width: 100% !important;
    width: fit-content !important;
}

.message-body {
    width: auto !important;
    min-width: 0 !important;
}

/* 渚ц竟鏍忔悳绱㈡鏍峰紡 */
.sidebar-search {
    padding: 10px 15px;
    background: var(--sidebar-bg);
}

.search-inner {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 10px;
    color: var(--text-secondary);
    pointer-events: none;
}

#agentSearchInput {
    width: 100%;
    padding: 8px 30px 8px 35px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    background: #f8fafc;
    transition: all 0.2s;
    outline: none;
}

#agentSearchInput:focus {
    border-color: var(--primary-color);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.clear-search {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: none;
    padding: 0 4px;
    line-height: 1;
}

.clear-search:hover {
    color: var(--danger-color);
}


/* ==================== 撤回消息样式 (仅管理端) ==================== */
.recalled-msg {
    opacity: 0.6;
    filter: grayscale(0.5);
    position: relative;
}

.recalled-msg .message-content {
    text-decoration: line-through;
    background-color: #f1f5f9 !important;
    border-color: #e2e8f0 !important;
    color: #94a3b8 !important;
}

.recalled-msg .message-info {
    font-style: italic;
}
