/**
 * 闲鱼运营助手 - 答疑AI页面样式
 * 仅样式与结构重构（不影响业务逻辑）
 */

/* 答疑页面禁止全局滚动 */
html:has(.qa-container),
html:has(.qa-container) body {
    overflow: hidden !important;
    height: 100vh !important;
    height: 100dvh !important;
}

body:has(.qa-container) .app-container {
    overflow: hidden !important;
}

/* 页面整体布局 */
.qa-container,
.qa-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: #0a0a0a;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.9);
}

/* 顶部导航栏 */
.qa-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.qa-back-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    z-index: 1;
}

.qa-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.qa-header-title,
.qa-title {
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    white-space: nowrap;
}

.qa-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    z-index: 1;
}

.qa-round-badge,
.qa-rounds {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    white-space: nowrap;
}

.qa-clear-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.4);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.qa-clear-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
}

/* 聊天消息区域 */
.qa-chat-area,
.qa-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px 12px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.qa-chat-area::-webkit-scrollbar,
.qa-messages::-webkit-scrollbar {
    width: 3px;
}

.qa-chat-area::-webkit-scrollbar-thumb,
.qa-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

/* 欢迎区域 */
.qa-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px 40px;
    text-align: center;
}

.qa-welcome-avatar {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    margin-bottom: 20px;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.25);
}

.qa-welcome-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 8px;
}

.qa-welcome-subtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.4);
    margin: 0 0 28px;
    line-height: 1.6;
}

.qa-quick-questions,
.qa-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 400px;
}

.qa-quick-btn,
.qa-suggestion {
    padding: 10px 18px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.75);
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.qa-quick-btn:hover,
.qa-suggestion:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: translateY(-1px);
}

.qa-quick-btn:active,
.qa-suggestion:active {
    transform: translateY(0);
}

/* 消息样式 */
.qa-message {
    margin-bottom: 16px;
    animation: qaFadeIn 0.25s ease;
}

@keyframes qaFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.qa-message-content {
    word-break: break-word;
}

.qa-message-user {
    display: flex;
    justify-content: flex-end;
}

.qa-msg-user {
    max-width: 78%;
    margin-left: auto;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #4A90D9, #357ABD);
    color: #fff;
    border-radius: 18px 18px 4px 18px;
    font-size: 15px;
    line-height: 1.6;
    word-break: break-word;
}

.qa-msg-ai-wrapper,
.qa-message-assistant {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}

.qa-msg-ai-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    margin-top: 2px;
}

.qa-msg-ai {
    max-width: 85%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px 18px 18px 4px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    line-height: 1.8;
    word-break: break-word;
}

/* AI 消息内部 Markdown 样式 */
.qa-msg-ai h3,
.qa-msg-ai h4 {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    margin: 14px 0 6px;
}

.qa-msg-ai strong {
    color: #7EB8FF;
    font-weight: 600;
}

.qa-msg-ai ul,
.qa-msg-ai ol {
    padding-left: 18px;
    margin: 6px 0;
}

.qa-msg-ai li {
    margin-bottom: 4px;
}

.qa-msg-ai p {
    margin: 6px 0;
}

.qa-msg-ai code {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

.qa-msg-ai a {
    color: #7EB8FF;
    text-decoration: none;
}

.qa-list-num {
    color: #7EB8FF;
    font-weight: 600;
}

/* AI 思考中动画 */
.qa-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 18px 18px 18px 4px;
    max-width: 80px;
}

.qa-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    animation: qaTyping 1.2s infinite;
}

.qa-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.qa-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes qaTyping {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.3;
    }

    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* 对话结束卡片 */
.qa-end-message {
    text-align: center;
    padding: 18px;
    margin: 8px 0 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.qa-end-icon {
    font-size: 26px;
    margin-bottom: 8px;
}

.qa-end-message p {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 12px;
}

.qa-restart-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 14px;
    color: #fff;
    font-size: 13px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    cursor: pointer;
}

/* 底部输入区域 */
.qa-input-bar {
    flex-shrink: 0;
    background: #0a0a0a;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.qa-kb-status,
.qa-input-status {
    text-align: center;
    padding: 6px 0;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.25);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    min-height: 28px;
    box-sizing: border-box;
}

.qa-input-status .kb-status-ok {
    color: rgba(255, 255, 255, 0.38);
}

.qa-input-status .kb-status-empty {
    color: rgba(255, 255, 255, 0.45);
}

.qa-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 14px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.02);
}

.qa-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    padding: 11px 18px;
    font-size: 15px;
    color: #fff;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    line-height: 1.5;
    min-height: 42px;
    max-height: 120px;
}

.qa-input:focus {
    border-color: rgba(102, 126, 234, 0.5);
}

.qa-input::placeholder {
    color: rgba(255, 255, 255, 0.25);
}

.qa-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.15s;
    opacity: 0.85;
}

.qa-send-btn svg {
    display: block;
    pointer-events: none;
}

.qa-send-btn:hover {
    opacity: 1;
}

.qa-send-btn:active {
    transform: scale(0.92);
}

.qa-send-btn:disabled,
.qa-send-btn.disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .qa-header {
        padding: 12px 12px;
    }

    .qa-header-title,
    .qa-title {
        font-size: 16px;
    }

    .qa-chat-area,
    .qa-messages {
        padding: 12px 10px;
    }

    .qa-welcome {
        padding: 42px 14px 28px;
    }

    .qa-welcome-avatar {
        width: 64px;
        height: 64px;
        border-radius: 18px;
        font-size: 30px;
    }

    .qa-welcome-title {
        font-size: 18px;
    }

    .qa-welcome-subtitle {
        font-size: 13px;
    }

    .qa-quick-btn,
    .qa-suggestion {
        width: 100%;
        text-align: center;
    }

    .qa-msg-user {
        max-width: 84%;
        font-size: 14px;
    }

    .qa-msg-ai {
        max-width: calc(100% - 44px);
        font-size: 14px;
    }
}
