/* ===== AI老师 对话组件（响应式：手机/电脑） ===== */

/* ---- 右下角悬浮按钮 ---- */
.ai-fab {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 3000;
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 0 20px;
    height: 52px;
    line-height: 52px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(231, 76, 60, .45);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all .3s;
}
.ai-fab:hover { transform: translateY(-3px); box-shadow: 0 10px 26px rgba(231, 76, 60, .55); }
.ai-fab i { font-size: 20px; }
.ai-fab .ai-fab-dot { width: 8px; height: 8px; border-radius: 50%; background: #27ae60; display: inline-block; }

/* ---- 悬浮窗 ---- */
.ai-widget {
    position: fixed;
    right: 18px;
    bottom: 82px;
    z-index: 3001;
    width: 390px;
    height: 640px;
    max-height: calc(100vh - 110px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(.98);
    pointer-events: none;
    transition: all .25s ease;
}
.ai-widget.ai-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

/* ---- 页面版对话窗口（modules/ai/index.php） ---- */
.ai-page-wrap { max-width: 860px; margin: 0 auto; }
.ai-page {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, .08);
    height: calc(100vh - 170px);
    min-height: 480px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
@media (max-width: 768px) {
    .ai-page { height: calc(100vh - 120px); min-height: 420px; border-radius: 12px; }
}

/* ---- 头部 ---- */
.ai-header {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 8px;
}
.ai-header-title { font-size: 16px; font-weight: bold; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ai-header-right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.ai-header-right select {
    background: rgba(255, 255, 255, .15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 6px;
    padding: 5px 8px;
    font-size: 12px;
    max-width: 160px;
    outline: none;
}
.ai-header-right select option { color: #333; background: #fff; }
.ai-ico-btn {
    background: rgba(255, 255, 255, .15);
    color: #fff;
    border: none;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
}
.ai-ico-btn:hover { background: rgba(255, 255, 255, .3); }

/* ---- 用量条 ---- */
.ai-usage {
    background: #fdf6ec;
    color: #b37400;
    font-size: 12px;
    padding: 5px 14px;
    border-bottom: 1px solid #f5e6c8;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ai-usage .ai-clear-link { color: #e74c3c; cursor: pointer; text-decoration: underline; }

/* ---- 消息区 ---- */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f7f8fa;
}
.ai-msg { display: flex; margin-bottom: 12px; }
.ai-msg-user { justify-content: flex-end; }
.ai-msg-ai { justify-content: flex-start; }
.ai-bubble {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
}
.ai-msg-user .ai-bubble { background: linear-gradient(135deg, #e74c3c, #d63b2f); color: #fff; border-top-right-radius: 3px; }
.ai-msg-ai .ai-bubble { background: #fff; color: #333; border: 1px solid #e8e8e8; border-top-left-radius: 3px; }
.ai-msg-ai .ai-bubble.ai-loading { color: #999; }
.ai-msg-time { font-size: 11px; color: #aaa; margin-top: 4px; }
.ai-msg-user .ai-msg-time { text-align: right; }

/* 消息内图片 */
.ai-msg-imgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin-top: 7px; }
.ai-msg-imgs img {
    width: 100%;
    aspect-ratio: 1/1;
    object-fit: cover;
    border-radius: 7px;
    cursor: pointer;
    background: #eee;
}
.ai-msg-imgs img.ai-img-single { grid-column: span 1; max-width: 200px; }

/* ---- 输入区 ---- */
.ai-input-area { border-top: 1px solid #eee; padding: 10px 12px 12px; background: #fff; flex-shrink: 0; }
.ai-img-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.ai-img-preview-item { position: relative; }
.ai-img-preview-item img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 1px solid #eee; }
.ai-img-preview-item .ai-img-del {
    position: absolute; top: -6px; right: -6px;
    width: 18px; height: 18px; border-radius: 50%;
    background: #e74c3c; color: #fff; border: none;
    font-size: 11px; line-height: 18px; text-align: center;
    cursor: pointer; padding: 0;
}
.ai-input-row { display: flex; gap: 8px; align-items: flex-end; }
.ai-img-btn {
    background: #f5f5f5; color: #666; border: 1px solid #e5e5e5;
    border-radius: 8px; width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.ai-img-btn:hover { color: #e74c3c; border-color: #e74c3c; }
.ai-input-row textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    resize: none;
    outline: none;
    min-height: 38px;
    max-height: 120px;
    line-height: 1.5;
    font-family: inherit;
}
.ai-input-row textarea:focus { border-color: #e74c3c; box-shadow: 0 0 0 3px rgba(231, 76, 60, .1); }
.ai-send-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: #fff; border: none; border-radius: 8px;
    height: 38px; padding: 0 16px;
    font-size: 14px; cursor: pointer; flex-shrink: 0;
}
.ai-send-btn:hover { opacity: .92; }
.ai-send-btn:disabled { opacity: .55; cursor: not-allowed; }
.ai-tip { font-size: 11px; color: #bbb; margin-top: 6px; text-align: center; }

/* 登录提示条 */
.ai-login-tip {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    gap: 10px;
    background: #f7f8fa;
}

/* ---- 设置弹层 ---- */
.ai-settings-form .form-group { margin-bottom: 14px; }
.ai-settings-form label { display: block; font-size: 13px; color: #555; margin-bottom: 5px; font-weight: 500; }
.ai-settings-form input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 7px;
    font-size: 14px;
    outline: none;
}
.ai-settings-form input:focus { border-color: #e74c3c; }
.ai-secret-hint { font-size: 12px; color: #999; margin-top: 4px; }

/* ---- 移动端 ---- */
@media (max-width: 768px) {
    .ai-fab { right: 14px; bottom: 14px; height: 50px; padding: 0 16px; }
    .ai-widget {
        right: 0; bottom: 0;
        width: 100%;
        height: 100vh;
        max-height: none;
        border-radius: 0;
    }
    .ai-bubble { max-width: 86%; }
    .ai-header-right select { max-width: 130px; }
}
