/* ===== 海洋智能体悬浮助手 v2.0 ===== */

/* 容器 */
#agent-helper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== 悬浮按钮 ===== */
#agent-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 60%, #6366f1 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.45);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

#agent-avatar:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 28px rgba(37, 99, 235, 0.65);
}

.agent-avatar-img {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    object-fit: cover;
}

.agent-avatar-fallback {
    font-size: 26px;
    display: none;
}

/* 呼吸脉冲 */
.agent-pulse {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, 0.5);
    animation: agentPulse 2.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes agentPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.15); opacity: 0; }
}

/* ===== 聊天窗口 ===== */
#agent-chat {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 360px;
    height: 520px;
    max-height: calc(100vh - 100px);
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.agent-chat-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(12px) scale(0.95) !important;
}

.agent-chat-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* 标题栏 */
.agent-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 70%, #6366f1 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.agent-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.agent-header-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.agent-header-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.agent-header-sub {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 1px;
}

.agent-close {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.15s;
    flex-shrink: 0;
}

.agent-close:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ===== 消息区域 ===== */
.agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.agent-messages::-webkit-scrollbar {
    width: 4px;
}

.agent-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* 消息布局 */
.agent-msg {
    display: flex;
    max-width: 100%;
}

.agent-msg-user {
    justify-content: flex-end;
}

.agent-msg-assistant {
    justify-content: flex-start;
}

/* 气泡 */
.agent-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

.agent-bubble-user {
    background: linear-gradient(135deg, #2563eb, #6366f1);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.agent-bubble-assistant {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-bottom-left-radius: 4px;
}

.agent-bubble-error {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: 12.5px;
}

/* 引用高亮 */
.agent-ref {
    background: rgba(96, 165, 250, 0.2);
    color: #93c5fd;
    padding: 1px 4px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
}

/* 加载动画 */
.agent-bubble-loading {
    display: flex;
    gap: 4px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== 快捷问题 ===== */
.agent-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.agent-quick-btn {
    background: rgba(37, 99, 235, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: 16px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.agent-quick-btn:hover {
    background: rgba(37, 99, 235, 0.3);
    border-color: rgba(37, 99, 235, 0.5);
    color: #bfdbfe;
}

/* ===== 输入区域 ===== */
.agent-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    flex-shrink: 0;
}

.agent-input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.agent-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.agent-input:focus {
    border-color: rgba(37, 99, 235, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.agent-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #2563eb, #6366f1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, transform 0.15s;
    flex-shrink: 0;
}

.agent-send-btn:hover {
    transform: scale(1.08);
    opacity: 0.9;
}

.agent-footer-hint {
    text-align: center;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.2);
    padding: 4px 0 8px;
    flex-shrink: 0;
}

/* ===== 移动端适配 ===== */
@media (max-width: 480px) {
    #agent-helper {
        bottom: 16px;
        right: 16px;
    }

    #agent-avatar {
        width: 46px;
        height: 46px;
    }

    .agent-avatar-img {
        width: 32px;
        height: 32px;
    }

    #agent-chat {
        position: fixed;
        bottom: 0;
        right: 0;
        left: 0;
        top: 60px;
        width: 100%;
        height: auto;
        max-height: none;
        border-radius: 16px 16px 0 0;
    }

    .agent-bubble {
        max-width: 90%;
        font-size: 14px;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    #agent-chat {
        width: 320px;
        height: 460px;
    }
}
