/* ========== AI智能体浮窗样式 ========== */

/* 悬浮按钮 */
.ai-float-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4aa, #00a884);
    color: #000;
    border: none;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 20px rgba(0, 212, 170, 0.4);
    z-index: 99999;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.ai-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0, 212, 170, 0.6);
}
.ai-float-btn .ai-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4757;
    color: #fff;
    font-size: 10px;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    padding: 0 4px;
}

/* 浮窗面板 */
.ai-panel {
    position: fixed;
    bottom: 90px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #131826;
    border: 1px solid #1e2538;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: aiSlideUp 0.3s ease;
}
.ai-panel.open {
    display: flex;
}
@keyframes aiSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* 面板头部 */
.ai-panel-header {
    background: linear-gradient(135deg, #1a2030, #131826);
    border-bottom: 1px solid #1e2538;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.ai-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-panel-title .ai-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4aa, #00a884);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #000;
}
.ai-panel-title .ai-name {
    font-size: 15px;
    font-weight: 700;
    color: #e4e7ed;
}
.ai-panel-title .ai-status {
    font-size: 11px;
    color: #00d4aa;
    display: flex;
    align-items: center;
    gap: 4px;
}
.ai-panel-title .ai-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00d4aa;
    animation: aiPulse 2s infinite;
}
@keyframes aiPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.ai-panel-actions {
    display: flex;
    gap: 6px;
}
.ai-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: transparent;
    border: 1px solid #1e2538;
    color: #8b949e;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.ai-icon-btn:hover {
    border-color: #00d4aa;
    color: #00d4aa;
}

/* 消息区域 */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}
.ai-messages::-webkit-scrollbar {
    width: 4px;
}
.ai-messages::-webkit-scrollbar-track {
    background: transparent;
}
.ai-messages::-webkit-scrollbar-thumb {
    background: #1e2538;
    border-radius: 2px;
}

/* 消息气泡 */
.ai-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
    animation: aiMsgIn 0.2s ease;
}
@keyframes aiMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-msg.bot {
    background: #1a2030;
    border: 1px solid #1e2538;
    color: #e4e7ed;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.ai-msg.user {
    background: linear-gradient(135deg, #00d4aa, #00a884);
    color: #000;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}
.ai-msg.system {
    background: rgba(240, 185, 11, 0.1);
    border: 1px solid rgba(240, 185, 11, 0.3);
    color: #f0b90b;
    align-self: center;
    font-size: 12px;
    text-align: center;
    max-width: 90%;
}

/* 消息中的链接/按钮 */
.ai-msg .ai-link {
    color: #00d4aa;
    text-decoration: underline;
    cursor: pointer;
}
.ai-msg .ai-action-btn {
    display: inline-block;
    background: rgba(0, 212, 170, 0.15);
    border: 1px solid #00d4aa;
    color: #00d4aa;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    margin: 4px 4px 0 0;
    transition: all 0.2s;
}
.ai-msg .ai-action-btn:hover {
    background: #00d4aa;
    color: #000;
}

/* 快捷问题 */
.ai-quick-questions {
    padding: 0 16px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}
.ai-quick-btn {
    background: #1a2030;
    border: 1px solid #1e2538;
    color: #8b949e;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-quick-btn:hover {
    border-color: #00d4aa;
    color: #00d4aa;
}

/* 输入区域 */
.ai-input-area {
    border-top: 1px solid #1e2538;
    padding: 12px;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
    background: #131826;
}
.ai-input {
    flex: 1;
    background: #1a2030;
    border: 1px solid #1e2538;
    color: #e4e7ed;
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 13px;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}
.ai-input:focus {
    border-color: #00d4aa;
}
.ai-input::placeholder {
    color: #5a6474;
}
.ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4aa, #00a884);
    color: #000;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.ai-send-btn:hover {
    transform: scale(1.05);
}
.ai-send-btn:disabled {
    background: #1e2538;
    color: #5a6474;
    cursor: not-allowed;
    transform: none;
}

/* 打字指示器 */
.ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: #1a2030;
    border: 1px solid #1e2538;
    border-radius: 12px;
    align-self: flex-start;
    width: fit-content;
}
.ai-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00d4aa;
    animation: aiTyping 1.4s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 高亮引导遮罩 */
.ai-highlight-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9990;
    display: none;
    pointer-events: none;
}
.ai-highlight-overlay.active {
    display: block;
}
.ai-highlight-box {
    position: absolute;
    border: 2px solid #00d4aa;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.7), 0 0 20px rgba(0, 212, 170, 0.5);
    transition: all 0.3s ease;
    pointer-events: auto;
}
.ai-guide-tip {
    position: fixed;
    background: #131826;
    border: 1px solid #00d4aa;
    border-radius: 10px;
    padding: 12px 16px;
    color: #e4e7ed;
    font-size: 13px;
    max-width: 280px;
    z-index: 9991;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    line-height: 1.6;
}
.ai-guide-tip .ai-guide-title {
    color: #00d4aa;
    font-weight: 700;
    margin-bottom: 6px;
    font-size: 14px;
}
.ai-guide-tip .ai-guide-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.ai-guide-tip .ai-guide-btn {
    background: #00d4aa;
    color: #000;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}
.ai-guide-tip .ai-guide-btn.secondary {
    background: transparent;
    border: 1px solid #1e2538;
    color: #8b949e;
}

/* 设置面板 */
.ai-settings-panel {
    padding: 16px;
}
.ai-settings-panel h4 {
    color: #00d4aa;
    margin-bottom: 16px;
    font-size: 15px;
}
.ai-settings-group {
    margin-bottom: 16px;
}
.ai-settings-group label {
    display: block;
    font-size: 12px;
    color: #8b949e;
    margin-bottom: 6px;
}
.ai-settings-group input,
.ai-settings-group select {
    width: 100%;
    background: #1a2030;
    border: 1px solid #1e2538;
    color: #e4e7ed;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
}
.ai-settings-group input:focus,
.ai-settings-group select:focus {
    border-color: #00d4aa;
}
.ai-settings-hint {
    font-size: 11px;
    color: #5a6474;
    margin-top: 6px;
    line-height: 1.5;
}

/* 模型选择按钮样式 */
.ai-model-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.ai-model-option {
    padding: 12px;
    background: #1a2030;
    border: 2px solid #1e2538;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}
.ai-model-option:hover {
    border-color: #00d4aa;
    background: rgba(0, 212, 170, 0.05);
}
.ai-model-option.active {
    border-color: #00d4aa;
    background: rgba(0, 212, 170, 0.1);
}
.ai-model-option.active::after {
    content: '✓';
    float: right;
    color: #00d4aa;
    font-weight: bold;
    font-size: 16px;
}
.ai-model-name {
    font-size: 14px;
    font-weight: 600;
    color: #e4e7ed;
    margin-bottom: 4px;
}
.ai-model-option.active .ai-model-name {
    color: #00d4aa;
}
.ai-model-desc {
    font-size: 12px;
    color: #8b949e;
}

/* 响应式 */
@media (max-width: 768px) {
    .ai-panel {
        width: 100vw;
        height: 100vh;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        border-radius: 0;
        max-height: none;
    }
    .ai-float-btn {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px));
        right: 16px;
        width: 52px;
        height: 52px;
        font-size: 22px;
        box-shadow: 0 4px 16px rgba(0, 212, 170, 0.5);
    }
    .ai-messages {
        padding: 16px;
    }
    .ai-message {
        max-width: 88%;
        font-size: 15px;
        line-height: 1.6;
    }
    .ai-input-area {
        padding: 12px 16px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }
    /* 设置面板手机端优化 */
    #aiSettingsContainer {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
    .ai-settings-panel {
        padding: 0;
        min-height: 100%;
    }
    .ai-settings-group select {
        appearance: none;
        -webkit-appearance: none;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 36px;
        min-height: 44px;
        font-size: 14px;
    }
    .ai-settings-group select option {
        background: #1a2030;
        color: #e4e7ed;
        padding: 8px;
    }
    .ai-settings-group input {
        min-height: 44px;
        font-size: 14px;
    }
    .ai-input {
        font-size: 15px;
        min-height: 44px;
    }
    .ai-send-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    .ai-quick-questions button {
        padding: 10px 16px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .ai-float-btn {
        bottom: calc(90px + env(safe-area-inset-bottom, 0px));
        right: 14px;
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    .ai-panel-header {
        padding: 16px;
    }
    .ai-name {
        font-size: 16px;
    }
    .ai-icon-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* 确保按钮在所有情况下都可见 */
.ai-float-btn {
    visibility: visible !important;
    opacity: 1 !important;
}
