/**
 * 95ywj智能客服样式
 */

/* 基础变量 */
:root {
    --ai-primary-color: #2563eb;
    --ai-secondary-color: #1d4ed8;
    --ai-danger-color: #f56c6c;
    --ai-warning-color: #e6a23c;
    --ai-bg-color: #ffffff;
    --ai-bg-secondary: #f5f7fa;
    --ai-text-color: #303133;
    --ai-text-secondary: #606266;
    --ai-border-color: #dcdfe6;
    --ai-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --ai-border-radius: 12px;
    --ai-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 悬浮按钮 */
.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border-radius: 50%;
    box-shadow: var(--ai-shadow);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='.9em' font-size='80'%3E%F0%9F%98%8A%3C/text%3E%3C/svg%3E");
    background-size: 40px;
    background-position: center;
    background-repeat: no-repeat;
}

.ai-chat-widget:hover {
    transform: scale(1.1);
}

.ai-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: var(--ai-danger-color);
    border-radius: 50%;
    color: white;
    font-size: 12px;
    display: none;
}

.ai-chat-widget.has-message .ai-chat-badge {
    display: block;
}

/* 聊天窗口 */
.ai-chat-window {
    position: fixed;
    bottom: 90px;
    left: 20px;
    width: 380px;
    height: 560px;
    background: var(--ai-bg-color);
    border-radius: var(--ai-border-radius);
    box-shadow: var(--ai-shadow);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.ai-chat-window-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 聊天头部 */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border-radius: var(--ai-border-radius) var(--ai-border-radius) 0 0;
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ai-chat-logo {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid white;
    flex-shrink: 0;
}

.ai-chat-header-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.ai-chat-header-top {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.ai-chat-title {
    font-size: 13px;
    font-weight: 600;
}

.ai-chat-status {
    font-size: 10px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-chat-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.ai-chat-url {
    font-size: 8px;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    padding: 0px 3px;
}

.ai-chat-header-bottom {
    display: flex;
    align-items: center;
    gap: 6px;
    line-height: 1.2;
}

.ai-chat-brand {
    font-size: 9px;
    font-weight: 500;
    opacity: 0.9;
}

.ai-chat-divider {
    font-size: 10px;
    opacity: 0.5;
}

.ai-chat-warn {
    font-size: 8px;
    opacity: 0.65;
}

.ai-chat-header-right {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.ai-chat-btn {
    width: 26px;
    height: 26px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 聊天主体 */
.ai-chat-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--ai-bg-secondary);
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* 消息样式 */
.ai-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
}

.ai-message-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-message-assistant {
    align-self: flex-start;
}

/* AI消息内容容器（垂直布局：内容 + 操作按钮） */
.ai-message-body {
    display: flex;
    flex-direction: column;
    min-width: 0; /* 防止flex子元素溢出 */
    flex: 1;
}

.ai-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ai-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.ai-message-user .ai-message-content {
    background: var(--ai-primary-color);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-message-assistant .ai-message-content {
    background: white;
    color: var(--ai-text-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ai-message-content a {
    color: var(--ai-primary-color);
    text-decoration: underline;
}

.ai-message-content img {
    max-width: 100%;
    border-radius: 8px;
}

/* APP卡片 */
.ai-app-card {
    display: flex;
    gap: 12px;
    padding: 15px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 320px;
}

.ai-app-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    object-fit: cover;
}

.ai-app-info {
    flex: 1;
    min-width: 0;
}

.ai-app-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--ai-text-color);
    margin-bottom: 4px;
}

.ai-app-level {
    font-size: 12px;
    color: #f5a623;
    margin-bottom: 8px;
}

.ai-app-desc {
    font-size: 13px;
    color: var(--ai-text-secondary);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-app-guide {
    font-size: 12px;
    color: var(--ai-text-secondary);
    margin-bottom: 8px;
    padding: 8px;
    background: var(--ai-bg-secondary);
    border-radius: 6px;
}

.ai-app-download {
    display: inline-block;
    padding: 6px 16px;
    background: var(--ai-primary-color);
    color: white;
    border-radius: 20px;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s;
}

.ai-app-download:hover {
    background: #3a7bd5;
}

/* 转接提示 */
.ai-chat-transfer-tip {
    padding: 10px 15px;
    background: #fef0f0;
    border-top: 1px solid #fde2e2;
    text-align: center;
}

.ai-transfer-btn {
    padding: 8px 24px;
    background: var(--ai-danger-color);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
}

.ai-transfer-countdown {
    color: var(--ai-warning-color);
    font-size: 14px;
}

.ai-haio-contact {
    text-align: center;
    padding: 10px;
}

.ai-haio-contact p {
    margin: 5px 0;
    font-size: 14px;
}

.ai-haio-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 20px;
    background: var(--ai-primary-color);
    color: white;
    text-decoration: none;
    border-radius: 20px;
}

/* 输入区域 */
.ai-chat-input-area {
    padding: 8px 12px;
    background: white;
    border-top: 1px solid var(--ai-border-color);
    border-radius: 0 0 var(--ai-border-radius) var(--ai-border-radius);
    position: relative;
}

.ai-chat-tools {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
}

.ai-chat-tool-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--ai-bg-secondary);
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-tool-btn:hover {
    background: var(--ai-border-color);
}

.ai-chat-tool-btn.recording {
    background: var(--ai-danger-color);
    color: white;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.ai-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#ai-chat-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--ai-border-color);
    border-radius: 16px;
    resize: none;
    font-size: 14px;
    font-family: var(--ai-font-family);
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
}

#ai-chat-input:focus {
    border-color: var(--ai-primary-color);
}

.ai-chat-send-btn {
    padding: 8px 16px;
    background: var(--ai-primary-color);
    color: white;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.ai-chat-send-btn:hover {
    background: #3a7bd5;
}

.ai-chat-send-btn:disabled {
    background: var(--ai-border-color);
    cursor: not-allowed;
}

/* 气泡提示 */
.ai-chat-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 14px;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
}

.ai-chat-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* 响应式 */
@media (max-width: 480px) {
    .ai-chat-window {
        width: 100%;
        height: 100%;
        bottom: 0;
        left: 0;
        border-radius: 0;
    }

    .ai-chat-header {
        border-radius: 0;
    }

    .ai-chat-widget {
        bottom: 10px;
        left: 10px;
    }
}

/* 滚动条样式 */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--ai-border-color);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #c0c4cc;
}

/* 录音提示（兼容旧版） */
.ai-recording-tip {
    text-align: center;
    padding: 10px;
    color: #f56c6c;
    font-size: 14px;
}

.recording-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    background: #f56c6c;
    border-radius: 50%;
    margin-right: 8px;
    animation: recording-pulse 1s infinite;
}

@keyframes recording-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== 按住说话语音模式 ========== */
.ai-voice-hold-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    background: #fff;
    border: 1px solid var(--ai-border-color);
    border-radius: 16px;
    color: var(--ai-text-color);
    font-size: 14px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ai-voice-hold-area:active,
.ai-voice-hold-area.pressing {
    background: #f5f7fa;
    border-color: var(--ai-primary-color);
}

.ai-voice-hold-area.canceling {
    background: #fef0f0;
    border-color: var(--ai-danger-color);
}

.ai-voice-hold-area.canceling .ai-voice-hold-text {
    color: var(--ai-danger-color);
}

.ai-voice-hold-text {
    pointer-events: none;
}

/* 录音遮罩层 */
.ai-voice-recording-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 100%;
    background: rgba(255,255,255,0.98);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--ai-border-color);
    padding: 14px 0 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    z-index: 20;
    animation: voiceOverlayIn 0.2s ease;
}

@keyframes voiceOverlayIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-voice-cancel-hint {
    font-size: 13px;
    color: #666;
    transition: color 0.2s;
}

.ai-voice-cancel-hint.canceled {
    color: var(--ai-danger-color);
}

/* 声波波纹 */
.ai-voice-wave-box {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    gap: 3px;
}

.ai-voice-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 40px;
}

.ai-voice-wave span {
    display: block;
    width: 3px;
    background: linear-gradient(180deg, var(--ai-primary-color), var(--ai-secondary-color));
    border-radius: 2px;
    height: 4px;
    transition: height 0.08s ease;
}

/* 消息操作按钮区域（复制按钮） */
.ai-message-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    padding-left: 0; /* 已在body容器内，不需要左偏移对齐 */
    align-items: center;
    min-height: 24px;
}

.ai-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.4;
    color: #606266;
    background-color: transparent;
    border: 1px solid #dcdfe6;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.ai-copy-btn:hover {
    opacity: 1;
    border-color: #2563eb;
    color: #2563eb;
    background-color: rgba(74, 144, 226, 0.05);
}

.ai-copy-btn:active {
    transform: scale(0.95);
}

.ai-copy-btn.copied {
    background-color: #f0f9eb;
    border-color: #1d4ed8;
    color: #1d4ed8;
    opacity: 1;
}

/* 朗读按钮 */
.ai-speak-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.4;
    color: #606266;
    background-color: transparent;
    border: 1px solid #dcdfe6;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.ai-speak-btn:hover {
    opacity: 1;
    border-color: #2563eb;
    color: #2563eb;
    background-color: rgba(74, 144, 226, 0.05);
}

.ai-speak-btn:active {
    transform: scale(0.95);
}

.ai-speak-btn.speaking {
    background-color: #f0f9eb;
    border-color: #67c23a;
    color: #67c23a;
    opacity: 1;
}

/* 全局自动朗读按钮激活状态 */
.ai-chat-btn.speaking-active {
    background: rgba(74, 144, 226, 0.4);
}

/* 旧的消息评价按钮样式（兼容性保留） */
.ai-message-rating {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-left: 52px;
}

.ai-rating-btn {
    background: transparent;
    border: 1px solid var(--ai-border-color);
    border-radius: 12px;
    padding: 4px 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.ai-rating-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.ai-rating-like:hover {
    background: #f0f9eb;
    border-color: #1d4ed8;
}

.ai-rating-dislike:hover {
    background: #fef0f0;
    border-color: #f56c6c;
}

.ai-rating-btn.active {
    opacity: 1;
}

.ai-rating-btn.active.ai-rating-like {
    background: #1d4ed8;
    color: white;
}

.ai-rating-btn.active.ai-rating-dislike {
    background: #f56c6c;
    color: white;
}
