/* 浮动按钮 */
.ai-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #C9A063, #A67C3D);
    color: white;
    font-size: 1.6rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(201, 160, 99, 0.4);
    z-index: 2147483647;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-fab:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 12px 32px rgba(201, 160, 99, 0.6);
}

/* 侧边栏 */
.ai-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: #FFFFFF;
    box-shadow: -8px 0 32px rgba(30, 58, 95, 0.15);
    z-index: 2147483647;
    transition: right 0.35s ease;
    display: flex;
    flex-direction: column;
    border-left: 2px solid #C9A063;
}

.ai-panel.open {
    right: 0;
}

/* 头部 */
.ai-panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid #F0EBE2;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: linear-gradient(135deg, #FEF9ED, #FBF3E0);
}

.ai-panel-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1E3A5F;
    display: block;
    margin-bottom: 4px;
}

.ai-panel-sub {
    font-size: 0.72rem;
    color: #8A9BB0;
    display: block;
}

.ai-panel-close {
    background: #FFFFFF;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 1rem;
    color: #5D6F88;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-panel-close:hover {
    background: #E8E0D4;
    color: #1E3A5F;
}

/* 上下文 */
.ai-panel-context {
    padding: 12px 24px;
    background: #FBF8F3;
    border-bottom: 1px solid #F0EBE2;
    font-size: 0.8rem;
    min-height: 40px;
}

.ai-context-hint {
    color: #8A9BB0;
    font-size: 0.78rem;
}

.ai-context-label {
    color: #8A9BB0;
}

.ai-context-value {
    color: #A67C3D;
    font-weight: 700;
    background: #FEF9ED;
    padding: 2px 10px;
    border-radius: 20px;
    border: 1px solid #E0C48A;
}

/* 对话区 */
.ai-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-msg {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.86rem;
    line-height: 1.6;
    max-width: 88%;
    word-break: break-word;
}

.ai-msg-bot {
    background: #FBF8F3;
    color: #1E2F4E;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-msg-user {
    background: #1E3A5F;
    color: #FFFFFF;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-msg-loading {
    color: #8A9BB0;
}

.ai-dots {
    display: inline-block;
    animation: aiDotBlink 1.4s infinite;
}

@keyframes aiDotBlink {
    0%, 20% { opacity: 0.3; }
    50% { opacity: 1; }
    80%, 100% { opacity: 0.3; }
}

/* 预设问题 */
.ai-panel-presets {
    padding: 8px 20px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid #F0EBE2;
    background: #FFFFFF;
}

.ai-preset-btn {
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid #E0C48A;
    background: #FEF9ED;
    color: #A67C3D;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.ai-preset-btn:hover {
    background: #C9A063;
    color: #FFFFFF;
    border-color: #C9A063;
}

/* 输入区 */
.ai-panel-input {
    padding: 12px 20px;
    border-top: 1px solid #F0EBE2;
    display: flex;
    gap: 8px;
    background: #FFFFFF;
}

.ai-panel-input input {
    flex: 1;
    padding: 10px 16px;
    border: 1.5px solid #E8E0D4;
    border-radius: 40px;
    font-size: 0.85rem;
    font-family: inherit;
    color: #1E2F4E;
    background: #FBF8F3;
    outline: none;
    transition: all 0.2s;
}

.ai-panel-input input:focus {
    border-color: #C9A063;
    background: #FFFFFF;
}

.ai-panel-input button {
    padding: 10px 20px;
    border-radius: 40px;
    border: none;
    background: linear-gradient(135deg, #1E3A5F, #2C5282);
    color: #FFFFFF;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.ai-panel-input button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

/* 底部按钮 */
.ai-panel-actions {
    padding: 8px 20px 16px;
    display: flex;
    gap: 8px;
    background: #FFFFFF;
}

.ai-action-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 40px;
    border: 1px solid #E8E0D4;
    background: #FBF8F3;
    color: #5D6F88;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.ai-action-btn:hover {
    border-color: #C9A063;
    color: #A67C3D;
    background: #FEF9ED;
}

/* 出题区 */
.ai-quiz-item {
    margin-bottom: 16px;
}

.ai-quiz-q {
    font-weight: 700;
    color: #1E3A5F;
    margin-bottom: 8px;
    font-size: 0.86rem;
}

.ai-quiz-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-quiz-option {
    padding: 8px 12px;
    border-radius: 8px;
    background: #FFFFFF;
    border: 1px solid #E8E0D4;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-quiz-option:hover {
    border-color: #C9A063;
    background: #FEF9ED;
}

.ai-quiz-option.correct {
    background: #E8F5E9;
    border-color: #2E7D32;
    color: #2E7D32;
    font-weight: 700;
}

.ai-quiz-option.wrong {
    background: #FFEBEE;
    border-color: #B23A2E;
    color: #B23A2E;
}

.ai-quiz-explanation {
    margin-top: 8px;
    padding: 8px 12px;
    background: #FEF9ED;
    border-left: 3px solid #C9A063;
    border-radius: 6px;
    font-size: 0.78rem;
    color: #A67C3D;
    line-height: 1.5;
}

/* 响应式 */
@media (max-width: 600px) {
    .ai-fab {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
        bottom: 20px;
        right: 20px;
    }

    .ai-panel {
        width: 90%;
        right: -90%;
    }

    .ai-panel-header {
        padding: 16px 18px;
    }

    .ai-panel-body {
        padding: 12px 16px;
    }

    .ai-panel-input {
        padding: 10px 16px;
    }

    .ai-msg {
        font-size: 0.82rem;
    }
}