/**
 * Jizone 在线客服样式
 */

/* 悬浮按钮样式 */
.jizone-cs-button {
    position: fixed;
    z-index: 9999;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    backdrop-filter: blur(10px);
    transform: scale(1);
}

.jizone-cs-button:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 6px 25px rgba(79, 70, 229, 0.4);
}

.jizone-cs-button:active {
    transform: translateY(0);
}

.jizone-cs-button.jizone-cs-button-bottom-right {
    bottom: 30px;
    right: 30px;
}

.jizone-cs-button.jizone-cs-button-bottom-left {
    bottom: 30px;
    left: 30px;
}

.jizone-cs-button.jizone-cs-button-top-right {
    top: 30px;
    right: 30px;
}

.jizone-cs-button.jizone-cs-button-top-left {
    top: 30px;
    left: 30px;
}

.jizone-cs-button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.jizone-cs-button-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #EF4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* 遮罩层 */
.jizone-cs-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.jizone-cs-overlay.jizone-cs-overlay-active {
    opacity: 1;
    visibility: visible;
}

/* 聊天窗口样式 */
.jizone-cs-chat {
    position: fixed;
    z-index: 10001;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    width: 380px;
    height: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.jizone-cs-chat.jizone-cs-chat-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.jizone-cs-chat.jizone-cs-chat-bottom-right {
    bottom: 100px;
    right: 30px;
}

.jizone-cs-chat.jizone-cs-chat-bottom-left {
    bottom: 100px;
    left: 30px;
}

.jizone-cs-chat.jizone-cs-chat-top-right {
    top: 100px;
    right: 30px;
}

.jizone-cs-chat.jizone-cs-chat-top-left {
    top: 100px;
    left: 30px;
}

/* 聊天头部 */
.jizone-cs-chat-header {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 12px 12px 0 0;
}

.jizone-cs-chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.jizone-cs-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.jizone-cs-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

.jizone-cs-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.9;
}

.jizone-cs-status-dot {
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.jizone-cs-chat-controls {
    display: flex;
    gap: 8px;
}

.jizone-cs-minimize-btn,
.jizone-cs-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.jizone-cs-minimize-btn:hover,
.jizone-cs-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* 聊天主体 */
.jizone-cs-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #F9FAFB;
}

.jizone-cs-welcome-message {
    margin-bottom: 20px;
}

.jizone-cs-messages-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.jizone-cs-message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.jizone-cs-message-admin {
    align-self: flex-start;
}

.jizone-cs-message-user {
    align-self: flex-end;
}

.jizone-cs-message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.jizone-cs-message-user .jizone-cs-message-content {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
}

.jizone-cs-message-time {
    font-size: 11px;
    color: #6B7280;
    margin-top: 4px;
    text-align: right;
}

.jizone-cs-message-user .jizone-cs-message-time {
    color: #9CA3AF;
    text-align: left;
}

/* 聊天底部 */
.jizone-cs-chat-footer {
    background: white;
    border-top: 1px solid #E5E7EB;
    padding: 16px;
    border-radius: 0 0 12px 12px;
}

/* 用户输入区域 - 姓名和邮箱比例 1:3 */
.jizone-cs-user-info {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    width: 100%;
    box-sizing: border-box;
}

.jizone-cs-user-info .jizone-cs-input[name="user_name"] {
    flex: 0 0 25% !important; /* 占25% - 1/4 */
    width: 25%;
    min-width: 80px;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jizone-cs-user-info .jizone-cs-input[name="user_email"] {
    flex: 0 0 75% !important; /* 占75% - 3/4 */
    width: 75%;
    min-width: 200px;
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.jizone-cs-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.jizone-cs-input:focus {
    outline: none;
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.jizone-cs-message-input-container {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.jizone-cs-message-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 14px;
    resize: none;
    min-height: 40px;
    max-height: 120px;
    transition: border-color 0.2s ease;
}

.jizone-cs-message-input:focus {
    outline: none;
    border-color: #4F46E5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.jizone-cs-send-btn {
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    border: none;
    border-radius: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.jizone-cs-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.jizone-cs-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.jizone-cs-offline-message {
    text-align: center;
    padding: 16px;
    background: #FEF3C7;
    border-radius: 8px;
    font-size: 14px;
    color: #92400E;
}

.jizone-cs-offline-message p {
    margin: 0;
}

/* 最小化状态 */
.jizone-cs-minimized {
    position: fixed;
    z-index: 9999;
    background: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    color: white;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.3);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.jizone-cs-minimized:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(79, 70, 229, 0.4);
}

.jizone-cs-minimized-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jizone-cs-restore-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.jizone-cs-restore-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 响应式设计 */
@media (max-width: 480px) {
    .jizone-cs-overlay {
        background: rgba(0, 0, 0, 0.3);
    }
    
    .jizone-cs-chat {
        width: 90%;
        height: 70vh;
        max-height: 70vh;
        border-radius: 16px;
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        bottom: auto !important;
        margin: 0;
        transform: translate(-50%, -50%) translateY(20px);
    }
    
    .jizone-cs-chat.jizone-cs-chat-active {
        transform: translate(-50%, -50%) translateY(0);
    }
    
    .jizone-cs-chat-header {
        border-radius: 16px 16px 0 0;
    }
    
    .jizone-cs-chat-footer {
        border-radius: 0 0 16px 16px;
    }
    
    .jizone-cs-button {
        bottom: 20px;
        right: 20px;
    }
    
    .jizone-cs-button.jizone-cs-button-bottom-left {
        left: 20px;
    }
    
    /* 移动端优化输入框布局 */
    .jizone-cs-user-info {
        flex-direction: row;
        gap: 8px;
    }
    
    .jizone-cs-user-info .jizone-cs-input[name="user_name"] {
        flex: 0 0 30% !important; /* 小屏幕姓名占30% */
        width: 30%;
        min-width: 70px;
        font-size: 16px; /* 防止iOS缩放 */
        box-sizing: border-box;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .jizone-cs-user-info .jizone-cs-input[name="user_email"] {
        flex: 0 0 70% !important; /* 小屏幕邮箱占70% */
        width: 70%;
        min-width: 150px;
        font-size: 16px; /* 防止iOS缩放 */
        box-sizing: border-box;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* 超小屏幕额外优化 */
@media (max-width: 360px) {
    .jizone-cs-chat {
        width: 95%;
        height: 75vh;
    }
    
    .jizone-cs-user-info .jizone-cs-input[name="user_name"] {
        flex: 0 0 35% !important;
        width: 35%;
        min-width: 60px;
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .jizone-cs-user-info .jizone-cs-input[name="user_email"] {
        flex: 0 0 65% !important;
        width: 65%;
        min-width: 120px;
        font-size: 14px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

/* 加载动画 */
.jizone-cs-loading {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.jizone-cs-loading-dots {
    display: flex;
    gap: 4px;
}

.jizone-cs-loading-dot {
    width: 8px;
    height: 8px;
    background: #4F46E5;
    border-radius: 50%;
    animation: loading 1.4s infinite ease-in-out both;
}

.jizone-cs-loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.jizone-cs-loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loading {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 错误提示 */
.jizone-cs-error {
    background: #FEE2E2;
    color: #DC2626;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin: 8px 0;
}

.jizone-cs-success {
    background: #D1FAE5;
    color: #065F46;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    margin: 8px 0;
}

/* 滚动条样式 */
.jizone-cs-chat-body::-webkit-scrollbar {
    width: 6px;
}

.jizone-cs-chat-body::-webkit-scrollbar-track {
    background: #F3F4F6;
}

.jizone-cs-chat-body::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 3px;
}

.jizone-cs-chat-body::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}