/**
 * 在线客服前端样式
 * 
 * @package Online_Customer_Service
 */

/* ===== CSS变量 ===== */
:root {
    --ocs-primary-color: #4F46E5;
    --ocs-secondary-color: #10B981;
    --ocs-bg-light: #FFFFFF;
    --ocs-bg-dark: #1F2937;
    --ocs-text-light: #111827;
    --ocs-text-dark: #F9FAFB;
    --ocs-border-light: #E5E7EB;
    --ocs-border-dark: #374151;
    --ocs-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --ocs-shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* ===== 字体导入 ===== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* ===== 主容器 ===== */
.ocs-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: 'Inter', sans-serif;
}

/* ===== 浮动按钮 ===== */
.ocs-float-button {
    position: relative;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--ocs-primary-color) 0%, var(--ocs-secondary-color) 100%);
    border-radius: 50%;
    box-shadow: var(--ocs-shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: fadeInUp 0.5s ease-out;
}

.ocs-float-button:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 30px 60px -15px rgba(0, 0, 0, 0.3);
}

.ocs-float-button:active {
    transform: translateY(-2px) scale(1.02);
}

/* 按钮图标 */
.ocs-float-button svg {
    width: 32px;
    height: 32px;
    color: white;
    transition: all 0.3s ease;
}

.ocs-float-button .ocs-icon-close {
    display: none;
    position: absolute;
}

.ocs-float-button.active .ocs-icon-open {
    display: none;
}

.ocs-float-button.active .ocs-icon-close {
    display: block;
}

/* 脉冲动画环 */
.ocs-pulse-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid var(--ocs-primary-color);
    border-radius: 50%;
    animation: pulse 2s ease-out infinite;
    opacity: 0;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 聊天窗口 ===== */
.ocs-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--ocs-bg-light);
    border-radius: 16px;
    box-shadow: var(--ocs-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ocs-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
    .ocs-chat-window {
        background: var(--ocs-bg-dark);
        color: var(--ocs-text-dark);
    }
}

/* ===== 聊天窗口头部 ===== */
.ocs-chat-header {
    background: linear-gradient(135deg, var(--ocs-primary-color) 0%, var(--ocs-secondary-color) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.ocs-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.ocs-header-avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.ocs-header-avatar svg {
    width: 24px;
    height: 24px;
}

.ocs-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.ocs-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 4px 0 0;
    font-size: 13px;
    opacity: 0.95;
}

.ocs-status-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.ocs-minimize-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ocs-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.ocs-minimize-btn svg {
    width: 20px;
    height: 20px;
}

/* ===== 聊天内容区域 ===== */
.ocs-chat-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--ocs-bg-light);
}

@media (prefers-color-scheme: dark) {
    .ocs-chat-content {
        background: var(--ocs-bg-dark);
    }
}

/* 自定义滚动条 */
.ocs-chat-content::-webkit-scrollbar {
    width: 6px;
}

.ocs-chat-content::-webkit-scrollbar-track {
    background: transparent;
}

.ocs-chat-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.ocs-chat-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* ===== 欢迎区域 ===== */
.ocs-welcome-section {
    text-align: center;
    margin-bottom: 24px;
}

.ocs-welcome-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--ocs-primary-color) 0%, var(--ocs-secondary-color) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounceIn 0.6s ease-out;
}

.ocs-welcome-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.ocs-welcome-section h4 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 600;
    color: var(--ocs-text-light);
}

@media (prefers-color-scheme: dark) {
    .ocs-welcome-section h4 {
        color: var(--ocs-text-dark);
    }
}

.ocs-welcome-section p {
    margin: 0;
    font-size: 14px;
    color: #6B7280;
    line-height: 1.5;
}

/* ===== 客服渠道网格 ===== */
.ocs-channels-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.ocs-channel-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: white;
    border: 2px solid var(--ocs-border-light);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    color: inherit;
    animation: slideInUp 0.4s ease-out;
    animation-fill-mode: both;
}

@media (prefers-color-scheme: dark) {
    .ocs-channel-btn {
        background: #374151;
        border-color: var(--ocs-border-dark);
    }
}

.ocs-channel-btn:nth-child(1) { animation-delay: 0.1s; }
.ocs-channel-btn:nth-child(2) { animation-delay: 0.15s; }
.ocs-channel-btn:nth-child(3) { animation-delay: 0.2s; }
.ocs-channel-btn:nth-child(4) { animation-delay: 0.25s; }
.ocs-channel-btn:nth-child(5) { animation-delay: 0.3s; }
.ocs-channel-btn:nth-child(6) { animation-delay: 0.35s; }

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ocs-channel-btn:hover {
    transform: translateY(-2px);
    border-color: var(--ocs-primary-color);
    box-shadow: 0 10px 20px -5px rgba(79, 70, 229, 0.2);
}

.ocs-channel-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--ocs-primary-color) 0%, var(--ocs-secondary-color) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.ocs-channel-btn:hover .ocs-channel-icon {
    transform: scale(1.1) rotate(5deg);
}

.ocs-channel-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.ocs-channel-info {
    flex: 1;
    text-align: left;
}

.ocs-channel-info h5 {
    margin: 0 0 4px;
    font-size: 16px;
    font-weight: 600;
    color: var(--ocs-text-light);
}

@media (prefers-color-scheme: dark) {
    .ocs-channel-info h5 {
        color: var(--ocs-text-dark);
    }
}

.ocs-channel-info p {
    margin: 0;
    font-size: 13px;
    color: #6B7280;
}

/* ===== 返回按钮 ===== */
.ocs-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    margin-bottom: 16px;
    background: transparent;
    border: 1px solid var(--ocs-border-light);
    border-radius: 8px;
    color: var(--ocs-text-light);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

@media (prefers-color-scheme: dark) {
    .ocs-back-btn {
        border-color: var(--ocs-border-dark);
        color: var(--ocs-text-dark);
    }
}

.ocs-back-btn:hover {
    background: rgba(79, 70, 229, 0.1);
    border-color: var(--ocs-primary-color);
    color: var(--ocs-primary-color);
}

.ocs-back-btn svg {
    width: 16px;
    height: 16px;
}

/* ===== 聊天界面 ===== */
.ocs-chat-interface {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ocs-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ===== 输入区域 ===== */
.ocs-input-area {
    margin-top: auto;
}

.ocs-chat-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ocs-chat-form input,
.ocs-chat-form textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--ocs-border-light);
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
    background: white;
    color: var(--ocs-text-light);
}

@media (prefers-color-scheme: dark) {
    .ocs-chat-form input,
    .ocs-chat-form textarea {
        background: #374151;
        border-color: var(--ocs-border-dark);
        color: var(--ocs-text-dark);
    }
}

.ocs-chat-form input:focus,
.ocs-chat-form textarea:focus {
    outline: none;
    border-color: var(--ocs-primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.ocs-chat-form textarea {
    resize: none;
    min-height: 80px;
}

.ocs-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--ocs-primary-color) 0%, var(--ocs-secondary-color) 100%);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ocs-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -5px rgba(79, 70, 229, 0.4);
}

.ocs-send-btn:active {
    transform: translateY(0);
}

.ocs-send-btn svg {
    width: 20px;
    height: 20px;
}

.ocs-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ===== 微信二维码 ===== */
.ocs-wechat-qr {
    display: flex;
    flex-direction: column;
}

.ocs-qr-container {
    text-align: center;
    padding: 32px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    .ocs-qr-container {
        background: #374151;
    }
}

.ocs-qr-container img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-bottom: 16px;
}

.ocs-qr-container p {
    margin: 0;
    font-size: 15px;
    font-weight: 500;
    color: var(--ocs-text-light);
}

@media (prefers-color-scheme: dark) {
    .ocs-qr-container p {
        color: var(--ocs-text-dark);
    }
}

/* ===== 响应式设计 ===== */
@media (max-width: 480px) {
    .ocs-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 20px;
    }
    
    .ocs-float-button {
        width: 56px;
        height: 56px;
    }
    
    .ocs-float-button svg {
        width: 28px;
        height: 28px;
    }
}

/* ===== 消息气泡 ===== */
.ocs-message {
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ocs-message.bot {
    background: rgba(79, 70, 229, 0.1);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ocs-message.user {
    background: linear-gradient(135deg, var(--ocs-primary-color) 0%, var(--ocs-secondary-color) 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

/* ===== 加载动画 ===== */
.ocs-loading {
    display: inline-flex;
    gap: 4px;
}

.ocs-loading span {
    width: 8px;
    height: 8px;
    background: var(--ocs-primary-color);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.ocs-loading span:nth-child(1) { animation-delay: -0.32s; }
.ocs-loading span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== 辅助功能 ===== */
.ocs-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===== 打印样式 ===== */
@media print {
    .ocs-chat-widget {
        display: none !important;
    }
}
