/**
 * 智能客服系统样式
 * 优化版本 - 清晰结构 + 现代化UI设计
 */

/* ========================================
   CSS 变量定义
======================================== */
:root {
    --cs-primary-blue: #3b82f6;
    --cs-primary-purple: #6366f1;
    --cs-primary-violet: #8b5cf6;
    --cs-secondary-blue: #60a5fa;
    --cs-light-blue: #7db9f7;
    --cs-pale-blue: #a5b4fc;
    --cs-green: #10b981;
    --cs-dark-green: #059669;
    --cs-gray-50: #f8fafc;
    --cs-gray-100: #f1f5f9;
    --cs-gray-200: #e2e8f0;
    --cs-gray-300: #cbd5e1;
    --cs-gray-400: #94a3b8;
    --cs-gray-500: #64748b;
    --cs-gray-600: #475569;
    --cs-gray-700: #334155;
    --cs-gray-800: #1e293b;
    --cs-gray-900: #0f172a;
    --cs-white: #ffffff;
    --cs-z-button: 9999;
    --cs-z-dialog: 10001;
    --cs-z-modal: 10002;
}

/* ========================================
   核心动画定义
======================================== */
@keyframes cs-pulse {
    0% {
        transform: scale(0.8);
        opacity: 0.8;
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
    }
    50% {
        opacity: 0.4;
        box-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
    }
    100% {
        transform: scale(1.6);
        opacity: 0;
        box-shadow: 0 0 40px rgba(59, 130, 246, 0.1);
    }
}

@keyframes cs-bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0) scale(1);
    }
    40% {
        transform: translateY(-8px) scale(1.02);
    }
    60% {
        transform: translateY(-4px) scale(1.01);
    }
}

@keyframes cs-wiggle {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-8deg) scale(1.05); }
    50% { transform: rotate(0deg) scale(1.1); }
    75% { transform: rotate(8deg) scale(1.05); }
}

@keyframes cs-glow {
    0%, 100% {
        box-shadow: 0 12px 35px rgba(96, 165, 250, 0.4), 0 0 40px rgba(147, 197, 253, 0.3);
    }
    50% {
        box-shadow: 0 12px 35px rgba(96, 165, 250, 0.5), 0 0 50px rgba(147, 197, 253, 0.4);
    }
}

@keyframes cs-shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes cs-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

@keyframes cs-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cs-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   客服按钮样式
======================================== */
#customerServiceButton {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: var(--cs-z-button);
    cursor: pointer;
}

.cs-button-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 脉冲动画环 */
.cs-pulse-ring,
.cs-pulse-ring-2 {
    position: absolute;
    width: 80px;
    height: 80px;
    border: 2px solid var(--cs-primary-blue);
    border-radius: 50%;
    animation: cs-pulse 2s infinite;
    opacity: 0;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.cs-pulse-ring-2 {
    animation-delay: 1s;
    border-color: var(--cs-primary-purple);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

/* 主按钮 */
.cs-button {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--cs-primary-blue) 0%, var(--cs-primary-purple) 50%, var(--cs-primary-violet) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.4), 0 0 30px rgba(139, 92, 246, 0.2);
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    z-index: 2;
    animation: cs-bounce 3s ease-in-out infinite;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.cs-button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 12px 35px rgba(96, 165, 250, 0.4), 0 0 40px rgba(147, 197, 253, 0.3);
    background: linear-gradient(135deg, var(--cs-secondary-blue) 0%, var(--cs-light-blue) 50%, var(--cs-pale-blue) 100%);
    animation: cs-glow 1.5s ease-in-out infinite;
}

.cs-button .material-icons {
    color: var(--cs-white);
    font-size: 28px;
    animation: cs-wiggle 4s ease-in-out infinite;
    transition: transform 0.3s ease;
}

/* 按钮激活状态 */
.cs-button-active .cs-button {
    background: linear-gradient(135deg, var(--cs-secondary-blue) 0%, var(--cs-light-blue) 50%, var(--cs-pale-blue) 100%);
    transform: scale(0.95);
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.5), 0 0 25px rgba(147, 197, 253, 0.4);
}

.cs-button-active .cs-pulse-ring,
.cs-button-active .cs-pulse-ring-2 {
    animation-play-state: paused;
}

/* 工具提示 */
.cs-tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(17, 24, 39, 0.95);
    color: var(--cs-white);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.cs-tooltip-arrow {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid rgba(17, 24, 39, 0.95);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.cs-button-container:hover .cs-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(-5px);
}

/* ========================================
   对话框样式
======================================== */

/* 对话框 */
#customerServiceDialog {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 480px;
    height: 580px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 20px;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.08);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    backdrop-filter: blur(20px);
}

.cs-dialog-open {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
}

.cs-dialog-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 对话框头部 */
.cs-dialog-header {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 50%, #8b5cf6 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: move;
    user-select: none;
    gap: 12px;
}

.cs-dialog-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    animation: cs-shine 3s infinite;
}

.cs-header-info {
    display: flex;
    align-items: center;
    z-index: 1;
}

.cs-avatar {
    width: 45px;
    height: 45px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    backdrop-filter: blur(10px);
}

.cs-avatar .material-icons {
    font-size: 24px;
    color: white;
}

/* 头部logo样式 */
.cs-avatar-logo {
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 2px !important;
    box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.cs-header-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.cs-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.cs-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    margin-top: 2px;
}

.cs-status-dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    margin-right: 6px;
    animation: cs-blink 2s infinite;
}

@keyframes cs-blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.cs-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1;
}

.cs-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* 模式切换按钮组 */
.cs-mode-switch {
    display: flex;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    padding: 2px;
    gap: 2px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-right: 12px;
    max-width: 180px;
}

.cs-mode-btn {
    display: flex;
    align-items: center;
    gap: 3px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    padding: 5px 10px;
    border-radius: 14px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    user-select: none;
}

.cs-mode-btn .material-icons {
    font-size: 14px;
}

.cs-mode-btn:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.cs-mode-btn.cs-mode-active {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cs-mode-btn.cs-mode-active:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 对话框主体 */
.cs-dialog-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cs-messages {
    flex: 1;
    padding: 20px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

/* ========================================
   消息样式
======================================== */
.cs-message {
    display: flex;
    margin-bottom: 20px;
    animation: cs-fade-in 0.3s ease-out;
}

.cs-message-content {
    max-width: 70%;
}

.cs-message-user .cs-message-content {
    margin-left: auto;
}

.cs-message-admin .cs-message-content {
    margin-right: auto;
}

.cs-message-header {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    gap: 8px;
}

.cs-message-user .cs-message-header {
    justify-content: flex-end;
}

.cs-message-admin .cs-message-header {
    justify-content: flex-start;
}

.cs-message-nickname {
    font-size: 12px;
    font-weight: 600;
    color: #4b5563;
}

.cs-message-user .cs-message-nickname {
    color: #3b82f6;
}

.cs-message-admin .cs-message-nickname {
    color: #059669;
}

.cs-message-time {
    font-size: 11px;
    color: #9ca3af;
}

.cs-message-body {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.cs-message-user .cs-message-body {
    flex-direction: row-reverse;
}

.cs-message-admin .cs-message-body {
    flex-direction: row;
}

.cs-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--cs-white);
    flex-shrink: 0;
}

.cs-message-user .cs-message-avatar {
    background: linear-gradient(135deg, var(--cs-primary-blue), var(--cs-primary-purple));
    margin-left: 12px;
}

.cs-message-admin .cs-message-avatar,
.cs-message-bot .cs-message-avatar {
    background: linear-gradient(135deg, var(--cs-dark-green), var(--cs-green));
    margin-right: 12px;
}

/* Logo头像样式 */
.cs-message-avatar-logo {
    background: #ffffff !important;
    border: 2px solid #e5e7eb !important;
    padding: 2px !important;
}

.cs-avatar-logo-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.cs-message-bubble {
    position: relative;
    padding: 14px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
    max-width: 320px;
    font-size: 14px;
}

.cs-message-user .cs-message-bubble {
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.2);
}

.cs-message-admin .cs-message-bubble {
    background: var(--cs-gray-50);
    color: var(--cs-gray-800);
    border-bottom-left-radius: 6px;
}

/* 兼容旧版消息文本样式 */
.cs-message-text {
    background: var(--cs-gray-50);
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.cs-message-bot .cs-message-text {
    background: linear-gradient(135deg, var(--cs-gray-100), var(--cs-gray-200));
    border-bottom-left-radius: 6px;
    border: 1px solid var(--cs-gray-200);
}

.cs-message-user .cs-message-text {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    border-bottom-right-radius: 6px;
    border: 1px solid #bfdbfe;
    margin-left: auto;
}

.cs-message-time {
    font-size: 11px;
    color: var(--cs-gray-500);
    margin-top: 4px;
    text-align: right;
}

.cs-message-bot .cs-message-time {
    text-align: left;
}


/* 深色模式下的样式 */
@media (prefers-color-scheme: dark) {
    .cs-message-nickname {
        color: #9ca3af;
    }
    
    .cs-message-user .cs-message-nickname {
        color: #60a5fa;
    }
    
    .cs-message-admin .cs-message-nickname {
        color: #10b981;
    }
    
    .cs-message-admin .cs-message-bubble {
        background: #374151;
        color: #f9fafb;
    }
}

/* 正在输入指示器样式 */
.cs-typing-indicator {
    animation: cs-fade-in 0.3s ease-in;
}

.cs-typing-bubble {
    background: #f3f4f6 !important;
    display: flex;
    align-items: center;
    padding: 8px 12px !important;
}

.cs-typing-dots {
    display: inline-flex;
    align-items: center;
    margin-right: 8px;
}

.cs-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #059669;
    margin-right: 3px;
    animation: cs-typing-bounce 1.4s infinite ease-in-out;
}

.cs-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.cs-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.cs-typing-dots span:nth-child(3) {
    margin-right: 0;
    animation-delay: 0s;
}

@keyframes cs-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes cs-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cs-typing-text {
    color: #6b7280;
    font-size: 12px;
    font-style: italic;
}

.cs-messages::-webkit-scrollbar {
    width: 6px;
}

.cs-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

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

.cs-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}


/* 对话框底部 */
.cs-dialog-footer {
    padding: 18px 20px;
}

.cs-input-container {
    display: flex;
    margin-bottom: 12px;
    background: var(--cs-white);
    border-radius: 25px;
    padding: 3px;
    border: 1px solid var(--cs-gray-200);
}

#csInput {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 16px;
    font-size: 14px;
    background: transparent;
    border-radius: 20px;
}

#csInput::placeholder {
    color: #94a3b8;
}

.cs-send-btn {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #56a3f0, #7db9f7);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(86, 163, 240, 0.25);
}

.cs-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(96, 165, 250, 0.4), 0 0 20px rgba(125, 185, 247, 0.25);
    background: linear-gradient(135deg, #60a5fa, #7db9f7);
}

.cs-send-btn .material-icons {
    font-size: 20px;
    color: var(--cs-white);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 快捷操作按钮 */
.cs-quick-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    justify-content: space-between;
}

.cs-quick-btn {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    color: #64748b;
    flex: 1;
    text-align: center;
    white-space: nowrap;
    min-width: 0;
    font-weight: 500;
}

.cs-quick-btn:hover {
    background: #56a3f0;
    color: white;
    border-color: #56a3f0;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(86, 163, 240, 0.25);
}

/* PC端专用样式 */
@media (min-width: 769px) {
    /* 拖拽功能 */
    .cs-dialog-header {
        cursor: move !important;
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 16px 20px !important;
        gap: 12px !important;
    }
    
    /* PC端头部信息区域 */
    .cs-header-info {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        z-index: 1 !important;
        flex: 1 !important;
    }
    
    .cs-avatar {
        width: 45px !important;
        height: 45px !important;
        margin-right: 12px !important;
    }
    
    .cs-info h3 {
        font-size: 16px !important;
        margin: 0 !important;
    }
    
    .cs-status {
        font-size: 12px !important;
        margin-top: 2px !important;
    }
    
    /* PC端切换按钮适中大小 */
    .cs-mode-switch {
        background: rgba(255, 255, 255, 0.15) !important;
        border-radius: 20px !important;
        padding: 3px !important;
        gap: 3px !important;
        backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        margin-right: 12px !important;
        max-width: 200px !important;
        flex-shrink: 0 !important;
    }
    
    .cs-mode-btn {
        padding: 6px 12px !important;
        border-radius: 16px !important;
        font-size: 12px !important;
        font-weight: 500 !important;
        gap: 4px !important;
        min-width: 75px !important;
        justify-content: center !important;
        white-space: nowrap !important;
    }
    
    .cs-mode-btn .material-icons {
        font-size: 14px !important;
    }
    
    .cs-mode-btn.cs-mode-active {
        background: rgba(255, 255, 255, 0.25) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* PC端关闭按钮 */
    .cs-close-btn {
        width: 36px !important;
        height: 36px !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
        z-index: 1 !important;
    }
    
    /* PC端调整大小手柄 - 完全隐藏 */
    .cs-resize-handle {
        position: absolute !important;
        opacity: 0 !important;
        background: transparent !important;
        transition: none !important;
        z-index: 100 !important;
        pointer-events: auto !important;
    }
    
    .cs-resize-se {
        bottom: 0 !important;
        right: 0 !important;
        width: 20px !important;
        height: 20px !important;
        cursor: se-resize !important;
    }
    
    .cs-resize-s {
        bottom: 0 !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 30px !important;
        height: 6px !important;
        cursor: s-resize !important;
    }
    
    .cs-resize-e {
        right: 0 !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        width: 6px !important;
        height: 30px !important;
        cursor: e-resize !important;
    }
}

/* 移动端背景遮罩和模糊效果 */
.cs-mobile-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    z-index: 9999 !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
    pointer-events: none !important;
}

.cs-mobile-backdrop.cs-backdrop-active {
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* 禁用背景滚动 */
body.cs-scroll-disabled {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    top: 0 !important;
    left: 0 !important;
}

/* 移动端输入法弹出时的优化 */
@media (max-width: 768px) {
    /* 当检测到键盘弹出时的调整 - 弹窗模式 */
    #customerServiceDialog.cs-keyboard-open {
        bottom: 10px !important;
        top: 20px !important;
        height: auto !important;
        max-height: calc(100vh - 40px) !important;
        min-height: 320px !important;
        transition: all 0.3s ease !important;
    }
    
    /* 输入法弹出时消息区域优化 */
    #customerServiceDialog.cs-keyboard-open .cs-messages-container {
        flex: 1 !important;
        min-height: 180px !important;
        max-height: 250px !important;
        overflow-y: auto !important;
    }
    
    /* 输入法弹出时头部压缩 */
    #customerServiceDialog.cs-keyboard-open .cs-dialog-header {
        padding: 12px 60px 12px 20px !important;
        min-height: 56px !important;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    /* 禁用移动端选中和高亮效果 */
    * {
        -webkit-tap-highlight-color: transparent !important;
        -webkit-touch-callout: none !important;
        -webkit-user-select: none !important;
        -moz-user-select: none !important;
        -ms-user-select: none !important;
        user-select: none !important;
        outline: none !important;
    }
    
    /* 允许输入框内容选择 */
    input, textarea {
        -webkit-user-select: text !important;
        -moz-user-select: text !important;
        -ms-user-select: text !important;
        user-select: text !important;
    }
    
    /* 移除所有聚焦边框和阴影 */
    *:focus, *:active {
        outline: none !important;
        border-color: inherit !important;
        box-shadow: none !important;
    }
    
    #customerServiceButton {
        bottom: 20px;
        right: 20px;
    }
    
    #customerServiceDialog {
        bottom: auto;
        right: 10px;
        left: 10px;
        top: 10vh;
        width: auto;
        height: 80vh;
        max-height: 80vh;
        min-height: 500px;
        -webkit-tap-highlight-color: transparent !important;
        outline: none !important;
        border: none !important;
        z-index: 10001 !important;
        border-radius: 16px !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    }
    
    /* 移动端对话框主体调整 */
    .cs-dialog-body {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        min-height: 400px !important;
    }
    
    /* 移动端消息容器优化 */
    .cs-messages-container {
        flex: 1 !important;
        min-height: 300px !important;
        max-height: calc(100vh - 240px) !important;
        overflow-y: auto !important;
        padding: 16px !important;
    }
    
    #customerServiceDialog * {
        -webkit-tap-highlight-color: transparent !important;
        outline: none !important;
    }
    
    .cs-dialog-header {
        padding: 16px 56px 16px 20px !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        text-align: left !important;
        position: relative;
        width: 100%;
        box-sizing: border-box;
        cursor: default !important;
        gap: 10px !important;
        min-height: 64px !important;
        border-radius: 16px 16px 0 0 !important;
    }
    
    /* 移动端隐藏调整大小手柄 */
    .cs-resize-handle {
        display: none !important;
        pointer-events: none !important;
    }
    
    
    .cs-header-info {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 12px !important;
        flex: 1 !important;
        text-align: left !important;
        z-index: 1 !important;
    }
    
    .cs-dialog-header h3 {
        font-size: 15px !important;
        margin: 0 !important;
        font-weight: 600 !important;
        text-align: left !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }
    
    .cs-status {
        font-size: 10px !important;
        opacity: 0.8 !important;
        text-align: left !important;
        margin-top: 1px !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }
    
    .cs-info {
        text-align: left !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        margin-left: -6px !important;
    }
    
    /* 移动端关闭按钮 */
    .cs-close-btn {
        position: absolute !important;
        top: 12px !important;
        right: 12px !important;
        width: 34px !important;
        height: 34px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.25) !important;
        backdrop-filter: blur(12px) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        z-index: 1000 !important;
        transition: all 0.2s ease !important;
        color: white !important;
        font-size: 16px !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    }
    
    .cs-close-btn:hover {
        background: rgba(255, 255, 255, 0.35) !important;
        transform: scale(1.05) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
    }
    
    /* 移动端头像优化 */
    .cs-avatar {
        width: 36px !important;
        height: 36px !important;
        border: 2px solid rgba(255, 255, 255, 0.3) !important;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12) !important;
        margin-right: 6px !important;
        flex-shrink: 0 !important;
    }
    
    .cs-header-logo-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    /* 移动端模式切换按钮 */
    .cs-mode-switch {
        margin: 0 !important;
        max-width: 156px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        background: rgba(255, 255, 255, 0.15) !important;
        border-radius: 18px !important;
        padding: 2px !important;
        gap: 2px !important;
        z-index: 1 !important;
        height: 34px !important;
        box-sizing: border-box !important;
    }
    
    .cs-mode-btn {
        padding: 5px 12px !important;
        border-radius: 16px !important;
        font-size: 11px !important;
        gap: 3px !important;
        height: 28px !important;
        box-sizing: border-box !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-weight: 500 !important;
        white-space: nowrap !important;
        transition: all 0.2s ease !important;
        min-width: 56px !important;
        background: transparent !important;
        border: none !important;
        color: rgba(255, 255, 255, 0.8) !important;
        cursor: pointer !important;
    }
    
    .cs-mode-btn .material-icons {
        font-size: 13px !important;
    }
    
    .cs-mode-btn:hover {
        color: white !important;
        background: rgba(255, 255, 255, 0.1) !important;
    }
    
    .cs-mode-btn.cs-mode-active {
        background: rgba(255, 255, 255, 0.25) !important;
        color: white !important;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1) !important;
    }
    
    .cs-mode-btn.cs-mode-active:hover {
        background: rgba(255, 255, 255, 0.3) !important;
    }
    
    .cs-tooltip {
        display: none;
    }
    
    .cs-button {
        width: 55px;
        height: 55px;
    }
    
    .cs-button .material-icons {
        font-size: 24px;
    }
    
    .cs-pulse-ring,
    .cs-pulse-ring-2 {
        width: 70px;
        height: 70px;
    }
    
    /* 平板端消息和输入区域优化 */
    .cs-messages-container {
        padding: 15px;
        min-height: 250px;
        flex: 1;
        overflow-y: auto;
    }
    
    /* 移动端输入区域 - 简洁版 */
    .cs-dialog-footer {
        padding: 16px 18px !important;
        background: var(--cs-white) !important;
        border-top: 1px solid var(--cs-gray-200) !important;
    }
    
    .cs-input-container {
        padding: 0 !important;
        margin-bottom: 12px !important;
        background: transparent !important;
        border-radius: 0 !important;
        border: none !important;
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }
    
    .cs-input,
    #csInput {
        height: 44px !important;
        border: 1px solid var(--cs-gray-200) !important;
        border-radius: 22px !important;
        flex: 1 !important;
        background: var(--cs-white) !important;
        padding: 12px 16px !important;
        font-size: 15px !important;
        color: var(--cs-gray-700) !important;
        box-sizing: border-box !important;
        outline: none !important;
        transition: none !important;
        -webkit-tap-highlight-color: transparent !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
    }
    
    #csInput:focus {
        border-color: var(--cs-gray-200) !important;
        outline: none !important;
        box-shadow: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    #csInput::placeholder {
        color: var(--cs-gray-400) !important;
    }
    
    .cs-send-btn {
        width: 44px !important;
        height: 44px !important;
        border-radius: 22px !important;
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: var(--cs-primary-blue) !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15) !important;
        -webkit-tap-highlight-color: transparent !important;
        outline: none !important;
        -webkit-touch-callout: none !important;
    }
    
    .cs-send-btn:hover {
        background: var(--cs-primary-purple) !important;
        transform: scale(1.02) !important;
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25) !important;
    }
    
    .cs-send-btn .material-icons {
        font-size: 20px !important;
        color: var(--cs-white) !important;
        margin-left: 1px !important;
    }
    
    /* 移动端快捷按钮 - 简洁版 */
    .cs-quick-actions {
        display: flex !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        padding: 0 !important;
        background: transparent !important;
        border-top: none !important;
    }
    
    .cs-quick-btn {
        flex: 1 !important;
        padding: 10px 8px !important;
        min-height: 36px !important;
        font-size: 13px !important;
        font-weight: 500 !important;
        border-radius: 18px !important;
        border: 1px solid var(--cs-gray-200) !important;
        background: var(--cs-gray-50) !important;
        color: var(--cs-gray-600) !important;
        transition: all 0.2s ease !important;
        text-align: center !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        line-height: 1.2 !important;
        -webkit-tap-highlight-color: transparent !important;
        outline: none !important;
        -webkit-touch-callout: none !important;
    }
    
    .cs-quick-btn:hover {
        background: var(--cs-primary-blue) !important;
        border-color: var(--cs-primary-blue) !important;
        color: var(--cs-white) !important;
        transform: translateY(-1px) !important;
    }
}

@media (max-width: 480px) {
    #customerServiceDialog {
        bottom: auto;
        right: 8px;
        left: 8px;
        top: 10vh;
        width: auto;
        height: 80vh;
        max-height: 80vh;
        min-height: 450px;
        border-radius: 14px !important;
        box-shadow: 0 16px 48px rgba(0, 0, 0, 0.25) !important;
    }
    
    /* 小屏幕输入法弹出时的调整 - 弹窗模式 */
    #customerServiceDialog.cs-keyboard-open {
        bottom: 8px !important;
        top: 15px !important;
        height: auto !important;
        max-height: calc(100vh - 30px) !important;
        min-height: 280px !important;
    }
    
    /* 小屏幕输入法弹出时消息区域优化 */
    #customerServiceDialog.cs-keyboard-open .cs-messages-container {
        flex: 1 !important;
        min-height: 150px !important;
        max-height: 200px !important;
        overflow-y: auto !important;
        padding: 12px !important;
    }
    
    /* 小屏幕输入法弹出时头部进一步压缩 */
    #customerServiceDialog.cs-keyboard-open .cs-dialog-header {
        padding: 10px 60px 10px 20px !important;
        min-height: 52px !important;
    }
    
    .cs-dialog-header {
        padding: 14px 56px 14px 18px !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        text-align: left !important;
        position: relative;
        width: 100%;
        box-sizing: border-box;
        cursor: default !important;
        gap: 8px !important;
        min-height: 60px !important;
        border-radius: 14px 14px 0 0 !important;
    }
    
    
    .cs-header-info {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 10px !important;
        flex: 1 !important;
        text-align: left !important;
        z-index: 1 !important;
    }
    
    .cs-dialog-header h3 {
        font-size: 14px !important;
        margin: 0 !important;
        font-weight: 600 !important;
        text-align: left !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }
    
    .cs-status {
        font-size: 10px !important;
        opacity: 0.8 !important;
        text-align: left !important;
        margin-top: 1px !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }
    
    .cs-info {
        text-align: left !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        margin-left: -8px !important;
    }
    
    /* 移动端头像优化 */
    .cs-avatar {
        width: 34px !important;
        height: 34px !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
        margin-right: 6px !important;
        border: 2px solid rgba(255, 255, 255, 0.3) !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    }
    
    .cs-messages-container {
        padding: 15px;
        min-height: 280px;
        flex: 1;
        overflow-y: auto;
    }
    
    .cs-message {
        margin-bottom: 12px;
    }
    
    .cs-message-text {
        padding: 10px 12px;
        font-size: 14px;
        line-height: 1.4;
        max-width: 85%;
    }
    
    .cs-dialog-footer {
        padding: 14px 16px !important;
        background: var(--cs-white) !important;
        border-top: 1px solid var(--cs-gray-200) !important;
    }
    
    .cs-input-container {
        padding: 0 !important;
        margin-bottom: 10px !important;
        background: transparent !important;
        border-radius: 0 !important;
        border: none !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
    }
    
    .cs-input,
    #csInput {
        height: 40px !important;
        border: 1px solid var(--cs-gray-200) !important;
        border-radius: 20px !important;
        flex: 1 !important;
        background: var(--cs-white) !important;
        padding: 10px 14px !important;
        font-size: 14px !important;
        color: var(--cs-gray-700) !important;
        box-sizing: border-box !important;
        outline: none !important;
        transition: none !important;
        -webkit-tap-highlight-color: transparent !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
    }
    
    #csInput:focus {
        border-color: var(--cs-gray-200) !important;
        outline: none !important;
        box-shadow: none !important;
        -webkit-tap-highlight-color: transparent !important;
    }
    
    #csInput::placeholder {
        color: var(--cs-gray-400) !important;
    }
    
    .cs-send-btn {
        width: 40px !important;
        height: 40px !important;
        border-radius: 20px !important;
        flex-shrink: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: var(--cs-primary-blue) !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        box-shadow: 0 1px 6px rgba(59, 130, 246, 0.15) !important;
        -webkit-tap-highlight-color: transparent !important;
        outline: none !important;
        -webkit-touch-callout: none !important;
    }
    
    .cs-send-btn:hover {
        background: var(--cs-primary-purple) !important;
        transform: scale(1.02) !important;
        box-shadow: 0 3px 10px rgba(59, 130, 246, 0.25) !important;
    }
    
    .cs-send-btn .material-icons {
        font-size: 18px !important;
        color: var(--cs-white) !important;
        margin-left: 1px !important;
    }
    
    /* 强制修复移动端输入框布局 - 最高优先级 */
    #customerServiceDialog .cs-input-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        justify-content: space-between !important;
    }
    
    #customerServiceDialog .cs-input,
    #customerServiceDialog #csInput {
        flex: 1 !important;
        min-width: 0 !important;
        width: auto !important;
    }
    
    #customerServiceDialog .cs-send-btn {
        display: flex !important;
        flex-shrink: 0 !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* 480px断点模式切换按钮优化 */
    .cs-mode-switch {
        margin: 0 !important;
        max-width: 148px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        flex-shrink: 0 !important;
        background: rgba(255, 255, 255, 0.15) !important;
        border-radius: 17px !important;
        padding: 2px !important;
        gap: 2px !important;
        z-index: 1 !important;
        height: 32px !important;
        box-sizing: border-box !important;
    }
    
    .cs-mode-btn {
        padding: 4px 10px !important;
        border-radius: 14px !important;
        font-size: 10px !important;
        gap: 2px !important;
        height: 26px !important;
        box-sizing: border-box !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-weight: 500 !important;
        white-space: nowrap !important;
        transition: all 0.2s ease !important;
        min-width: 52px !important;
        background: transparent !important;
        border: none !important;
        color: rgba(255, 255, 255, 0.8) !important;
        cursor: pointer !important;
    }
    
    .cs-mode-btn .material-icons {
        font-size: 12px !important;
    }
    
    .cs-mode-btn:hover {
        color: white !important;
        background: rgba(255, 255, 255, 0.1) !important;
    }
    
    .cs-mode-btn.cs-mode-active {
        background: rgba(255, 255, 255, 0.25) !important;
        color: white !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1) !important;
    }
    
    .cs-mode-btn.cs-mode-active:hover {
        background: rgba(255, 255, 255, 0.3) !important;
    }
    
    /* 移动端快捷回复按钮优化 */
    .cs-quick-actions {
        padding: 8px 10px;
        gap: 4px;
        border-top: 1px solid var(--cs-gray-200);
        background: var(--cs-gray-50);
        display: flex;
        flex-wrap: nowrap;
    }
    
    .cs-quick-actions {
        display: flex !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
        padding: 0 !important;
        background: transparent !important;
        border-top: none !important;
    }
    
    .cs-quick-btn {
        flex: 1 !important;
        padding: 8px 6px !important;
        min-height: 32px !important;
        font-size: 12px !important;
        font-weight: 500 !important;
        border-radius: 16px !important;
        border: 1px solid var(--cs-gray-200) !important;
        background: var(--cs-gray-50) !important;
        color: var(--cs-gray-600) !important;
        transition: all 0.2s ease !important;
        text-align: center !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        line-height: 1.2 !important;
        -webkit-tap-highlight-color: transparent !important;
        outline: none !important;
        -webkit-touch-callout: none !important;
    }
    
    .cs-quick-btn:hover {
        background: var(--cs-primary-blue) !important;
        border-color: var(--cs-primary-blue) !important;
        color: var(--cs-white) !important;
        transform: translateY(-1px) !important;
    }
    
    /* 移动端关闭按钮优化 */
    .cs-close-btn {
        position: absolute !important;
        top: 15px !important;
        right: 15px !important;
        width: 32px !important;
        height: 32px !important;
        padding: 0 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        background: rgba(255, 255, 255, 0.2) !important;
        backdrop-filter: blur(10px) !important;
        border: 1px solid rgba(255, 255, 255, 0.3) !important;
        z-index: 20 !important;
        margin: 0 !important;
        transform: none !important;
    }
    
    .cs-close-btn .material-icons {
        font-size: 18px;
        color: white;
    }
    
    .cs-close-btn:hover {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(1.05);
    }
    
    /* 移动端头像优化 */
    .cs-avatar {
        width: 45px;
        height: 45px;
        border: 2px solid rgba(255, 255, 255, 0.3);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    .cs-avatar-logo {
        padding: 2px !important;
    }
    
    .cs-header-logo-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    #customerServiceDialog {
        background: rgba(31, 41, 55, 0.95);
        backdrop-filter: blur(20px);
    }
    
    .cs-message-text {
        background: #374151;
        color: #f9fafb;
        border-color: #4b5563;
    }
    
    .cs-message-bot .cs-message-text {
        background: linear-gradient(135deg, #374151, #4b5563);
        border-color: #4b5563;
    }
    
    .cs-input-container {
        background: #374151;
    }
    
    #csInput {
        color: #f9fafb;
    }
    
    #csInput::placeholder {
        color: #9ca3af;
    }
    
    .cs-quick-btn {
        background: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }
}

/* 打字指示器样式 */
.cs-typing-indicator {
    opacity: 0.8;
}

.cs-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
}

.cs-typing-dots span {
    width: 8px;
    height: 8px;
    background: #8b5cf6;
    border-radius: 50%;
    animation: cs-typing-bounce 1.4s infinite ease-in-out;
}

.cs-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.cs-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.cs-typing-dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes cs-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.cs-typing-text {
    font-size: 12px;
    color: #6b7280;
    font-style: italic;
}

/* 暗色模式下的打字指示器 */
@media (prefers-color-scheme: dark) {
    .cs-typing-dots span {
        background: #60a5fa;
    }
    
    .cs-typing-text {
        color: #9ca3af;
    }
}

/* 用户信息模态框样式 */
.cs-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    backdrop-filter: blur(8px);
    animation: cs-fadeIn 0.3s ease-out;
}

@keyframes cs-fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.cs-modal-container {
    background: white;
    border-radius: 20px;
    width: 90%;
    max-width: 450px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.25);
    transform: scale(0.95);
    animation: cs-modalIn 0.3s ease-out forwards;
}

@keyframes cs-modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.cs-modal-header {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 50%, #8b5cf6 100%);
    color: white;
    padding: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    backdrop-filter: blur(10px);
}

.cs-modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255,255,255,0.1) 50%, transparent 70%);
    animation: cs-shine 3s infinite;
}

.cs-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    z-index: 1;
}

.cs-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1;
}

.cs-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.cs-modal-body {
    padding: 32px 24px;
}

.cs-modal-intro {
    text-align: center;
    margin-bottom: 32px;
}

.cs-modal-icon {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.3);
}

.cs-modal-icon .material-icons {
    color: white;
    font-size: 28px;
}

.cs-modal-intro p {
    color: #64748b;
    line-height: 1.6;
    margin: 0;
    font-size: 15px;
}

/* 表单样式 */
.cs-user-form {
    max-width: 100%;
}

.cs-form-group {
    margin-bottom: 24px;
}

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

.cs-form-group .required {
    color: #ef4444;
}

.cs-form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 15px;
    transition: all 0.3s ease;
    background: #fafafa;
    box-sizing: border-box;
}

.cs-form-group input:focus {
    outline: none;
    border-color: #8b5cf6;
    background: white;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.cs-form-group input::placeholder {
    color: #9ca3af;
}

.cs-form-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: 6px;
    line-height: 1.4;
}

.cs-form-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
    border: 1px solid #fecaca;
    animation: cs-shake 0.5s ease-in-out;
}

@keyframes cs-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.cs-form-actions {
    display: flex;
    gap: 12px;
    margin-top: 32px;
}

.cs-btn-cancel,
.cs-btn-confirm {
    flex: 1;
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.cs-btn-cancel {
    background: #f8fafc;
    color: #64748b;
    border: 2px solid #e2e8f0;
}

.cs-btn-cancel:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.cs-btn-confirm {
    background: linear-gradient(135deg, #60a5fa, #7db9f7);
    color: white;
    box-shadow: 0 4px 15px rgba(96, 165, 250, 0.25);
}

.cs-btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(96, 165, 250, 0.35), 0 0 20px rgba(125, 185, 247, 0.2);
    background: linear-gradient(135deg, #4a90e2, #6ba3f5);
}

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

/* 在线聊天特殊样式 */
.cs-online-chat-btn {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    color: white !important;
    border-color: transparent !important;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.cs-online-chat-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.cs-online-chat-btn:hover::before {
    left: 100%;
}

.cs-online-chat-btn:hover {
    background: linear-gradient(135deg, #059669, #047857) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.3) !important;
}

/* 状态指示器 */
.cs-status-online {
    background: #10b981 !important;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

/* 系统消息样式 */
.cs-message-system {
    justify-content: center;
    margin-bottom: 16px;
}

.cs-message-system .cs-message-content {
    max-width: 280px;
    text-align: center;
}

.cs-message-system .cs-message-text {
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    border: 1px solid #a7f3d0;
    color: #065f46;
    font-size: 13px;
    border-radius: 16px;
    padding: 10px 14px;
    position: relative;
}

.cs-message-system .cs-message-text::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(16, 185, 129, 0.1) 50%, transparent 70%);
    animation: cs-shimmer 2s infinite;
    border-radius: inherit;
}

@keyframes cs-shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* 现代化交互效果 */
.cs-modal-overlay {
    animation: cs-overlayFadeIn 0.3s ease-out;
}

@keyframes cs-overlayFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
    }
}

/* 按钮悬停微动画 */
.cs-btn-confirm:hover,
.cs-btn-cancel:hover {
    transform: translateY(-1px) scale(1.02);
}

.cs-btn-confirm:active,
.cs-btn-cancel:active {
    transform: translateY(0) scale(0.98);
}

/* 表单输入动画 */
.cs-form-group input:focus {
    animation: cs-inputFocus 0.3s ease-out;
}

/* 最终兜底规则 - 确保发送按钮在所有移动端设备显示 */
@media (max-width: 768px) {
    #customerServiceDialog .cs-input-container {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }
    
    #customerServiceDialog #csInput {
        flex: 1 1 auto !important;
        min-width: 0 !important;
        width: auto !important;
        max-width: calc(100% - 50px) !important;
    }
    
    #customerServiceDialog .cs-send-btn {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex: 0 0 auto !important;
        width: 32px !important;
        height: 32px !important;
        position: static !important;
        background: #56a3f0 !important;
        border: none !important;
        border-radius: 16px !important;
        color: white !important;
    }
}

@keyframes cs-inputFocus {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.3);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
    }
}

/* 在线聊天按钮特效 */
.cs-online-chat-btn:hover {
    animation: cs-onlineGlow 1.5s ease-in-out infinite;
}

@keyframes cs-onlineGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(16, 185, 129, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(16, 185, 129, 0.8);
    }
}

/* 系统消息动画增强 */
.cs-message-system .cs-message-text {
    animation: cs-systemMessageIn 0.5s ease-out;
}

@keyframes cs-systemMessageIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 响应式优化 */
@media (max-width: 480px) {
    .cs-modal-container {
        width: 95%;
        margin: 20px;
    }
    
    .cs-modal-body {
        padding: 24px 20px;
    }
    
    .cs-modal-intro {
        margin-bottom: 24px;
    }
    
    .cs-form-actions {
        flex-direction: column;
        gap: 8px;
    }
    
    .cs-btn-cancel,
    .cs-btn-confirm {
        padding: 12px 20px;
    }
}


/* 拖拽时的样式 */
.cs-dragging {
    user-select: none;
    will-change: transform;
    transition: none !important;
}

.cs-dragging .cs-dialog-header {
    cursor: grabbing !important;
}

/* 调整大小时的样式 - 性能优化 */
.cs-resizing {
    will-change: width, height !important;
    transition: none !important;
    user-select: none !important;
    pointer-events: auto !important;
}

.cs-resizing * {
    transition: none !important;
    user-select: none !important;
}

/* 对话框性能优化 */
#customerServiceDialog {
    will-change: auto;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

#customerServiceDialog.cs-dragging {
    will-change: transform;
}


/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .cs-modal-container {
        background: #1f2937;
    }
    
    .cs-modal-intro p {
        color: #9ca3af;
    }
    
    .cs-form-group label {
        color: #f3f4f6;
    }
    
    .cs-form-group input {
        background: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .cs-form-group input:focus {
        border-color: #8b5cf6;
        background: #4b5563;
    }
    
    .cs-form-hint {
        color: #9ca3af;
    }
    
    .cs-btn-cancel {
        background: #374151;
        color: #d1d5db;
        border-color: #4b5563;
    }
    
    .cs-btn-cancel:hover {
        background: #4b5563;
        border-color: #6b7280;
    }
    
    .cs-message-system .cs-message-text {
        background: linear-gradient(135deg, #064e3b, #065f46);
        border-color: #047857;
        color: #a7f3d0;
    }
    
    /* 深色模式下的头部logo */
    .cs-avatar-logo {
        background: rgba(31, 41, 55, 0.95) !important;
        box-shadow: inset 0 0 0 2px rgba(96, 165, 250, 0.3);
    }
}