﻿/* ════════════════════════════════════════════
   AI 助手 v3 样式 - 商业医疗蓝白
   仿 Perplexity / Claude / ChatGPT 网页聊天风格
   ════════════════════════════════════════════ */

* {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
    box-sizing: border-box;
}

/* ─── 悬浮按钮 ─── */
.ai-chat-float-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(37, 99, 235, .35);
    z-index: 1000;
    background-image: url('../images/douyan.png');
    background-size: 100%;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform .25s, box-shadow .25s;
}
.ai-chat-float-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 32px rgba(37, 99, 235, .45);
}
.ai-chat-float-btn:active { transform: translateY(-1px); }

/* ─── 聊天主窗口（弹窗模式） ─── */
.ai-chat-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    width: min(960px, 95vw);
    height: min(720px, 88vh);
    max-width: 95vw;
    max-height: 90vh;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, .25);
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s, visibility .25s, transform .3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ai-chat-container.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

/* ─── 遮罩 ─── */
.ai-chat-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .25s, visibility .25s;
}
.ai-chat-overlay.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ─── 顶部 ─── */
.ai-chat-header {
    flex-shrink: 0;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    background: #fff;
}
.ai-chat-close {
    justify-self: start;
    background: transparent;
    border: none;
    color: #6b7280;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    transition: background .15s, color .15s;
}
.ai-chat-close:hover { background: #f3f4f6; color: #111827; }
.ai-chat-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}
.ai-chat-name {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    line-height: 1.2;
}
.ai-chat-subtitle {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 2px;
}
.ai-chat-actions {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ai-chat-model-select {
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 8px;
    padding: 5px 8px;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    outline: none;
    transition: border-color .15s;
}
.ai-chat-model-select:hover { border-color: #2563EB; }
.ai-chat-clear,
.ai-chat-img-remove {
    background: transparent;
    border: none;
    color: #6b7280;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s, color .15s;
}
.ai-chat-clear:hover,
.ai-chat-img-remove:hover { background: #f3f4f6; color: #2563EB; }

/* ─── 消息区 ─── */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    background: #fff;
    scroll-behavior: smooth;
}
.ai-chat-messages::-webkit-scrollbar { width: 6px; }
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}
.ai-chat-messages::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.chat-message {
    display: flex;
    gap: 14px;
    padding: 18px 24px;
    max-width: 800px;
    margin: 0 auto;
    animation: fadeIn .2s ease;
}
.chat-message + .chat-message {
    margin-top: 4px;
}
.chat-message.user { background: #f9fafb; }
.chat-message.assistant { background: #fff; }

.chat-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
}
.chat-avatar.user { background: #2563EB; }
.chat-avatar.assistant {
    background-image: url('../images/douyan.png');
    background-size: cover;
    background-position: center;
}

.chat-bubble {
    flex: 1;
    min-width: 0;
    color: #1f2937;
    line-height: 1.7;
    font-size: 15px;
    word-wrap: break-word;
}
.chat-bubble p { margin: 6px 0; }
.chat-bubble p:first-child { margin-top: 0; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble h1,
.chat-bubble h2,
.chat-bubble h3,
.chat-bubble h4 {
    margin: 14px 0 6px;
    font-weight: 600;
    color: #111827;
    line-height: 1.3;
}
.chat-bubble h1 { font-size: 20px; }
.chat-bubble h2 { font-size: 18px; }
.chat-bubble h3 { font-size: 16px; }
.chat-bubble h4 { font-size: 15px; }
.chat-bubble ul,
.chat-bubble ol { margin: 6px 0 6px 24px; }
.chat-bubble li { margin: 3px 0; }
.chat-bubble code {
    background: #f3f4f6;
    color: #d6336c;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.chat-bubble pre {
    background: #1f2937;
    color: #f3f4f6;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-size: 13px;
    line-height: 1.5;
}
.chat-bubble pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}
.chat-bubble strong { font-weight: 600; color: #111827; }
.chat-bubble em { font-style: italic; }
.chat-bubble a { color: #2563EB; text-decoration: none; }
.chat-bubble a:hover { text-decoration: underline; }
.chat-bubble hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 12px 0;
}

.message-image-container {
    margin: 4px 0 8px;
    max-width: 240px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}
.message-image { width: 100%; height: auto; display: block; }

/* 图片识图加载状态 */
.message-loading {
    color: #2563EB;
    font-size: 14px;
    padding: 4px 0;
    animation: pulseSoft 1.5s ease-in-out infinite;
}
@keyframes pulseSoft {
    0%, 100% { opacity: .55; }
    50% { opacity: 1; }
}

/* ─── 欢迎区 ─── */
.welcome-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px 40px;
    min-height: 100%;
    text-align: center;
}
.welcome-avatar-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.welcome-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-image: url('../images/douyan.png');
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 16px rgba(37, 99, 235, .2);
}
.welcome-avatar i { display: none; }
.welcome-name {
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}
.welcome-desc {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.6;
    max-width: 480px;
    margin: 0 0 24px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(160px, 200px));
    gap: 10px;
    max-width: 440px;
    width: 100%;
}
.quick-action-btn {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    text-align: left;
    transition: all .15s;
}
.quick-action-btn:hover {
    border-color: #2563EB;
    color: #2563EB;
    background: #f0f7ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, .12);
}

/* ─── 输入区 ─── */
.ai-chat-composer {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    padding: 12px 20px 16px;
}
.ai-chat-composer-inner {
    max-width: 800px;
    margin: 0 auto;
}

.ai-chat-img-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    padding: 6px 10px 6px 8px;
    background: #f3f4f6;
    border-radius: 12px;
}
.ai-chat-img-preview[hidden] { display: none; }
.ai-chat-img-preview img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
}
.ai-chat-img-info {
    flex: 1;
    font-size: 12px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ai-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 6px;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.ai-chat-input:focus-within {
    border-color: #2563EB;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.ai-chat-attach {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: transparent;
    color: #6b7280;
    font-size: 16px;
    transition: background .15s, color .15s;
}
.ai-chat-attach:hover {
    background: rgba(37, 99, 235, .1);
    color: #2563EB;
}
.chat-input-field {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    font-size: 15px;
    line-height: 1.5;
    color: #1f2937;
    padding: 8px 4px;
    max-height: 160px;
    min-height: 24px;
}
.chat-input-field::placeholder { color: #9ca3af; }
.ai-chat-send {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: #2563EB;
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .1s;
}
.ai-chat-send:hover { background: #1d4ed8; }
.ai-chat-send:active { transform: scale(.95); }
.ai-chat-send:disabled {
    background: #d1d5db;
    color: #fff;
    cursor: not-allowed;
}
.ai-chat-hint {
    text-align: center;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 8px;
}

/* ─── 错误提示 ─── */
.error-message {
    max-width: 800px;
    margin: 0 auto;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    animation: shake .3s ease;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

/* ─── 动画 ─── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0% { box-shadow: 0 6px 24px rgba(37, 99, 235, .35); }
    50% {
        box-shadow: 0 6px 24px rgba(37, 99, 235, .6),
                    0 0 0 8px rgba(37, 99, 235, .12);
    }
    100% { box-shadow: 0 6px 24px rgba(37, 99, 235, .35); }
}
.ai-chat-float-btn.pulse { animation: pulse 2s infinite; }

/* ─── 响应式 ─── */
@media (max-width: 768px) {
    .ai-chat-header { padding: 10px 12px; }
    .chat-message { padding: 12px 14px; }
    .ai-chat-composer { padding: 10px 12px 12px; }
    .quick-actions { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .welcome-wrapper { padding: 40px 16px 24px; }
    .welcome-avatar { width: 56px; height: 56px; }
    .quick-actions { grid-template-columns: 1fr; }
    .ai-chat-actions { gap: 4px; }
    .ai-chat-model-select { font-size: 11px; padding: 4px 6px; }
}
