/* ================================================
   商务简约聊天界面模板 - 专业稳重设计
   商务风格：深蓝色系、纯色设计、简约大气
   ================================================ */

/* 
   注意：模板变量通过后端注入为 --template-{变量名} 格式
   这些变量在 index.html 的 <style id="template-variables"> 中定义
   确保该样式标签在模板样式文件之后加载，以保证变量优先级
*/

:root {
    /* 主题变量 - 引用后端注入的模板变量，带默认值 */
    --tpl-primary: var(--template-primaryColor, #1e3a8a);
    --tpl-primary-end: var(--template-primaryGradientEnd, #2563eb);
    --tpl-bg: var(--template-bgColor, #f5f7fa);
    --tpl-card-bg: var(--template-cardBgColor, #ffffff);
    --tpl-text: var(--template-textColor, #1f2937);
    --tpl-admin-bubble: var(--template-adminBubbleColor, #ffffff);
    --tpl-radius: var(--template-borderRadius, 12px);
    
    /* 计算色 - 商务风格配色 */
    --tpl-primary-light: color-mix(in srgb, var(--tpl-primary) 8%, white);
    --tpl-primary-lighter: color-mix(in srgb, var(--tpl-primary) 4%, white);
    --tpl-primary-dark: color-mix(in srgb, var(--tpl-primary) 85%, black);
    --tpl-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --tpl-shadow-md: 0 2px 4px -1px rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
    --tpl-shadow-lg: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --tpl-shadow-xl: 0 8px 12px -2px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --tpl-shadow-primary: 0 2px 8px 0 rgba(0, 0, 0, 0.12);
    --tpl-border-color: rgba(0, 0, 0, 0.1);
    --tpl-border-light: rgba(0, 0, 0, 0.08);
}

/* ================================================
   背景系统 - 纯色商务风格
   ================================================ */
.modern-background {
    background: var(--tpl-bg) !important;
}

.gradient-layer {
    display: none !important;
}

/* ================================================
   聊天容器 - 商务卡片设计
   ================================================ */
.chat-container-premium {
    background: var(--tpl-card-bg) !important;
    border: 1px solid var(--tpl-border-color) !important;
    border-radius: var(--tpl-radius) !important;
    box-shadow: var(--tpl-shadow-lg) !important;
    overflow: hidden;
}

/* ================================================
   头部设计 - 纯色商务风格
   ================================================ */
.chat-header-simple {
    background: var(--tpl-primary) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
    padding: 1.25rem 1.5rem !important;
    position: relative;
}

.chat-header-simple h1 {
    color: #ffffff !important;
    font-weight: 600 !important;
    font-size: 1.125rem !important;
    letter-spacing: 0.01em;
    text-shadow: none;
    position: relative;
    z-index: 1;
}

/* 队列状态文字 */
#queue-status,
.chat-header-simple .text-gray-500,
.chat-header-simple .text-xs {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 400 !important;
}

/* ================================================
   头像设计 - 简洁商务风格
   ================================================ */
.header-avatar {
    background: rgba(255, 255, 255, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
    position: relative;
    z-index: 1;
    transition: all 0.2s ease;
}

.header-avatar:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
}

.header-avatar img {
    filter: brightness(0) invert(1) !important;
}

/* ================================================
   头部图标按钮 - 简洁商务风格
   ================================================ */
.header-icon-btn {
    color: rgba(255, 255, 255, 0.95) !important;
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    position: relative;
    z-index: 1;
    padding: 0.5rem !important;
}

.header-icon-btn:hover {
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.2) !important;
    border-color: rgba(255, 255, 255, 0.3) !important;
}

.header-icon-btn:active {
    background: rgba(255, 255, 255, 0.15) !important;
}

.header-icon-btn img {
    filter: brightness(0) invert(1) !important;
}

/* ================================================
   状态指示器 - 简洁脉冲
   ================================================ */
.status-dot-simple {
    background: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2) !important;
    border: 2px solid #ffffff !important;
    border-radius: 50% !important;
    width: 10px !important;
    height: 10px !important;
    animation: statusPulseBusiness 2.5s ease-in-out infinite !important;
}

.status-dot-simple.offline {
    background: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2) !important;
}

.status-dot-simple.connecting {
    background: #f59e0b !important;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2) !important;
}

@keyframes statusPulseBusiness {
    0%, 100% { 
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
        opacity: 1;
    }
    50% { 
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
        opacity: 0.9;
    }
}

/* ================================================
   消息区域 - 精致背景
   ================================================ */
.messages-container {
    background: var(--tpl-bg) !important;
    padding: 1.5rem !important;
}

/* ================================================
   消息气泡 - 现代精致设计
   ================================================ */

/* 客服/AI消息气泡 - 简洁白色卡片 */
.message-bubble.admin-message,
.message-bubble.ai-message,
.msg-bubble-left {
    background: var(--tpl-admin-bubble) !important;
    border: 1px solid var(--tpl-border-color) !important;
    color: var(--tpl-text) !important;
    border-radius: 4px 10px 10px 10px !important;
    box-shadow: var(--tpl-shadow-sm) !important;
    position: relative;
    padding: 0.75rem 1rem !important;
    transition: all 0.2s ease;
    max-width: 75%;
}

.message-bubble.admin-message::after,
.message-bubble.ai-message::after {
    display: none !important;
}

.message-bubble.admin-message *,
.message-bubble.ai-message * {
    color: var(--tpl-text) !important;
}

/* 用户消息气泡 - 纯色商务风格 */
.message-bubble.user-message,
.msg-bubble-right {
    background: var(--tpl-primary) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 10px 10px 4px 10px !important;
    box-shadow: var(--tpl-shadow-sm) !important;
    padding: 0.75rem 1rem !important;
    max-width: 75%;
    transition: all 0.2s ease;
    position: relative;
}

.message-bubble.user-message * {
    color: #ffffff !important;
}

/* 消息悬停效果 - 简洁反馈 */
.message-bubble:hover {
    transform: translateY(-1px) !important;
}

.message-bubble.user-message:hover {
    box-shadow: var(--tpl-shadow-md) !important;
}

.message-bubble.admin-message:hover,
.message-bubble.ai-message:hover {
    box-shadow: var(--tpl-shadow-md) !important;
    border-color: var(--tpl-border-color) !important;
}

/* ================================================
   输入区域 - 商务风格
   ================================================ */
.footer-premium {
    background: var(--tpl-card-bg) !important;
    border-top: 1px solid var(--tpl-border-color) !important;
    padding: 1.25rem 1.5rem !important;
}

.input-premium {
    background: var(--tpl-bg) !important;
    border: 1.5px solid var(--tpl-border-color) !important;
    border-radius: 8px !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04) !important;
    transition: all 0.2s ease !important;
    position: relative;
}

.input-premium::before {
    display: none !important;
}

.input-premium:focus-within {
    background: #ffffff !important;
    border-color: var(--tpl-primary) !important;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.1), var(--tpl-shadow-sm) !important;
}

.input-glow-border {
    display: none !important;
}

.input-textarea {
    color: var(--tpl-text) !important;
    font-size: 0.9375rem !important;
    line-height: 1.5 !important;
}

.input-textarea::placeholder {
    color: #94a3b8 !important;
    opacity: 0.8;
}

/* ================================================
   发送按钮 - 纯色商务风格
   ================================================ */
.send-btn-simple {
    background: var(--tpl-primary) !important;
    border-radius: 8px !important;
    box-shadow: var(--tpl-shadow-sm) !important;
    transition: all 0.2s ease !important;
    position: relative;
}

.send-btn-simple::before {
    display: none !important;
}

.send-btn-simple:hover:not(:disabled) {
    background: color-mix(in srgb, var(--tpl-primary) 90%, black) !important;
    box-shadow: var(--tpl-shadow-md) !important;
}

.send-btn-simple:active:not(:disabled) {
    background: color-mix(in srgb, var(--tpl-primary) 85%, black) !important;
}

.send-btn-simple:disabled {
    background: #e2e8f0 !important;
    box-shadow: none !important;
    cursor: not-allowed;
}

/* ================================================
   功能按钮区域 - 精致设计
   ================================================ */
.function-buttons-premium {
    background: var(--tpl-card-bg) !important;
    border-top: 1px solid var(--tpl-border-light) !important;
    padding: 0.75rem 1.25rem !important;
}

.function-chip {
    background: var(--tpl-bg) !important;
    border: 1.5px solid var(--tpl-border-color) !important;
    color: #64748b !important;
    border-radius: 8px !important;
    padding: 0.5rem 0.875rem !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
    position: relative;
}

.function-chip::before {
    display: none !important;
}

.function-chip:hover {
    background: var(--tpl-primary) !important;
    border-color: var(--tpl-primary) !important;
    color: #ffffff !important;
    box-shadow: var(--tpl-shadow-sm) !important;
}

.function-chip:hover .chip-icon {
    filter: brightness(0) invert(1);
}

/* ================================================
   操作按钮 - 精致次要样式
   ================================================ */
.action-btn-secondary {
    background: var(--tpl-bg) !important;
    border: 1.5px solid var(--tpl-border-light) !important;
    border-radius: 12px !important;
    color: #64748b !important;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.action-btn-secondary:hover {
    background: #ffffff !important;
    border-color: var(--tpl-primary) !important;
    color: var(--tpl-primary) !important;
    transform: translateY(-1px);
    box-shadow: var(--tpl-shadow-sm) !important;
}

/* ================================================
   打字指示器 - 简洁动画
   ================================================ */
.typing-avatar {
    background: var(--tpl-primary) !important;
    box-shadow: var(--tpl-shadow-sm) !important;
}

.typing-bubble {
    background: var(--tpl-admin-bubble) !important;
    border: 1px solid var(--tpl-border-color) !important;
    box-shadow: var(--tpl-shadow-sm) !important;
    border-radius: 4px 10px 10px 10px !important;
}

.typing-dot {
    background: var(--tpl-primary) !important;
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    animation: typingBounceMinimal 1.4s ease-in-out infinite !important;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s !important; }
.typing-dot:nth-child(3) { animation-delay: 0.4s !important; }

@keyframes typingBounceMinimal {
    0%, 60%, 100% { 
        transform: translateY(0); 
        opacity: 0.5;
    }
    30% { 
        transform: translateY(-8px); 
        opacity: 1;
    }
}

/* ================================================
   消息入场动画 - 简洁流畅
   ================================================ */
.chat-message {
    animation: messageSlideIn 0.3s ease-out both !important;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ================================================
   滚动条 - 精致优雅
   ================================================ */
.messages-container::-webkit-scrollbar {
    width: 6px !important;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent !important;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12) !important;
    border-radius: 10px !important;
    transition: background 0.2s ease;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2) !important;
}

/* ================================================
   引用消息样式 - 简洁设计
   ================================================ */
#reply-preview {
    background: var(--tpl-primary-light) !important;
    border: 1.5px solid color-mix(in srgb, var(--tpl-primary) 20%, transparent) !important;
    border-radius: 8px !important;
    box-shadow: var(--tpl-shadow-sm) !important;
}

#reply-preview .text-blue-600 {
    color: var(--tpl-primary) !important;
    font-weight: 600 !important;
}

/* ================================================
   时间戳和元信息 - 精致细节
   ================================================ */
.message-meta-time,
.message-meta-time .time {
    color: #94a3b8 !important;
    font-size: 0.6875rem !important;
    font-weight: 400 !important;
}

/* ================================================
   系统消息 - 精致胶囊
   ================================================ */
.system-notification-content,
.system-message-pill {
    background: var(--tpl-primary-light) !important;
    color: var(--tpl-primary-dark) !important;
    border-radius: 100px !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    padding: 0.5rem 1.25rem !important;
    box-shadow: var(--tpl-shadow-sm) !important;
}

/* ================================================
   功能面板 - 精致设计
   ================================================ */
#function-panel {
    border-radius: 8px !important;
    box-shadow: var(--tpl-shadow-md) !important;
}

.function-panel-item {
    border-radius: 6px !important;
    transition: all 0.2s ease !important;
    border: 1.5px solid transparent !important;
}

.function-panel-item:hover {
    background: var(--tpl-bg) !important;
    border-color: var(--tpl-border-light) !important;
    box-shadow: var(--tpl-shadow-sm) !important;
}

/* ================================================
   弹窗样式优化 - 精致现代
   ================================================ */
#rating-modal .bg-white,
#language-modal .bg-white,
#message-modal .bg-white,
#announcement-modal .announcement-card {
    border-radius: 8px !important;
    box-shadow: var(--tpl-shadow-lg) !important;
    border: 1px solid var(--tpl-border-color) !important;
}

/* 评分弹窗星星 */
#star-rating .star-btn.text-yellow-400 {
    color: #fbbf24 !important;
}

#star-rating .star-btn:hover {
    transform: scale(1.1);
    transition: transform 0.2s ease;
}

/* 确认按钮样式 */
#rating-modal #submit-rating,
#language-modal #confirm-language,
#announcement-modal .confirm-btn {
    background: var(--tpl-primary) !important;
    border: none !important;
    border-radius: 8px !important;
    box-shadow: var(--tpl-shadow-sm) !important;
    transition: all 0.2s ease !important;
}

#rating-modal #submit-rating:hover:not(:disabled),
#language-modal #confirm-language:hover,
#announcement-modal .confirm-btn:hover {
    background: color-mix(in srgb, var(--tpl-primary) 90%, black) !important;
    box-shadow: var(--tpl-shadow-md) !important;
}

/* ================================================
   移动端优化 - 商务适配
   ================================================ */
@media (max-width: 768px) {
    /* 移动端保持商务简约浅色背景 */
    #chat-widget-container {
        background: var(--tpl-bg) !important;
    }
    
    .chat-container-premium {
        border-radius: 0 !important;
        box-shadow: none !important;
        border-left: none !important;
        border-right: none !important;
        background: var(--tpl-bg) !important;
    }
    
    .chat-header-simple,
    header.chat-header-simple,
    #chat-widget-container > header {
        background: var(--tpl-primary) !important;
        padding: 1rem 1.25rem !important;
        border-radius: 0 !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    .message-bubble {
        max-width: 85% !important;
        padding: 0.75rem 1rem !important;
    }
    
    /* 移动端气泡选择器修复 */
    .message-bubble.user-message,
    .user-message .message-bubble {
        background: var(--tpl-primary) !important;
    }
    
    .message-bubble.admin-message,
    .admin-message .message-bubble {
        background: var(--tpl-admin-bubble) !important;
    }
    
    .footer-premium {
        padding: 1rem 1.25rem !important;
        padding-bottom: calc(1rem + env(safe-area-inset-bottom)) !important;
        background: var(--tpl-card-bg) !important;
    }
    
    .messages-container {
        padding: 1.25rem !important;
        background: var(--tpl-bg) !important;
    }
    
    /* 移动端头部和底部样式 */
    header {
        background: var(--tpl-primary) !important;
        backdrop-filter: none !important;
    }
    
    footer {
        background: var(--tpl-card-bg) !important;
        backdrop-filter: none !important;
    }
}

/* ================================================
   底部按钮对齐修复
   ================================================ */
#emoji-btn,
#function-panel-btn,
.toolbar-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #64748b !important;
    background: transparent !important;
    border: none !important;
    border-radius: 8px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    padding: 0 !important;
    transition: all 0.2s ease !important;
}

#emoji-btn:hover,
#function-panel-btn:hover,
.toolbar-btn:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    color: var(--tpl-primary) !important;
}

#send-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* ================================================
   深色模式支持（可选）
   ================================================ */
@media (prefers-color-scheme: dark) {
    /* 暂不启用深色模式，保持简约风格一致性 */
}
