/* 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-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.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;
}

.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;
}

.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()避免被footer遮挡，不需要额外padding */

/* 移动端优化 (768px以下) */
@media (max-width: 768px) {

    /* 移动端布局高度调整 - 顶部导航56px + 底部约30px */
    .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 + 底部约25px */
    .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;
    }
}