/* ========== 全局样式 ========== */
:root {
    --primary: #4F7DF7;
    --primary-dark: #3A62D4;
    --primary-light: #6B93FF;
    --bg-dark: #0F1923;
    --bg-card: #162231;
    --bg-input: #1A2B3D;
    --bg-ai: #1E3048;
    --bg-user: #4F7DF7;
    --text-primary: #E8EDF5;
    --text-secondary: #8899AA;
    --text-ai: #E0E8F5;
    --text-user: #FFFFFF;
    --border: #253546;
    --shadow: rgba(0, 0, 0, 0.3);
    --success: #00D68F;
    --warning: #FFAA00;
    --danger: #FF4D6A;
    --wechat-green: #07C160;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* ========== 聊天容器 ========== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg-dark);
    position: relative;
}

/* ========== 顶部栏 ========== */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 4px 20px rgba(79, 125, 247, 0.3);
    z-index: 10;
}

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

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.header-info h1 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    margin-right: 4px;
    animation: pulse 2s infinite;
}

.status-text {
    font-size: 12px;
    color: rgba(255,255,255,0.8);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.btn-reset {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-reset:hover {
    background: rgba(255,255,255,0.25);
    transform: rotate(90deg);
}

/* ========== 用户头像区域 ========== */
.user-avatar-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 20px;
    background: rgba(255,255,255,0.15);
    transition: background 0.2s;
}

.user-avatar-wrap:hover {
    background: rgba(255,255,255,0.25);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}

.user-name {
    font-size: 13px;
    color: #fff;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========== 用户菜单弹窗 ========== */
.user-menu {
    position: absolute;
    top: 68px;
    right: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 100;
    min-width: 200px;
    animation: fadeInDown 0.2s ease;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-menu-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-menu-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary);
}

.user-menu-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-menu-id {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ========== 微信提示条 ========== */
.wechat-hint {
    padding: 8px 16px;
    background: rgba(7, 193, 96, 0.1);
    border-bottom: 1px solid rgba(7, 193, 96, 0.2);
}

.wechat-hint-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--wechat-green);
    font-size: 12px;
}

.wechat-hint-content svg {
    flex-shrink: 0;
    opacity: 0.8;
}

/* ========== 聊天消息区 ========== */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    scroll-behavior: smooth;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* ========== 消息样式 ========== */
.message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.ai-message .message-avatar {
    background: var(--bg-ai);
    border: 1px solid var(--border);
    padding: 0;
}

.ai-message .message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 10px;
    object-fit: cover;
}

.user-message .message-avatar {
    background: var(--primary);
    font-size: 14px;
    color: #fff;
    border-radius: 50%;
    overflow: hidden;
}

.user-message .message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-message .message-avatar .avatar-initial {
    font-size: 14px;
    color: #fff;
    font-weight: 600;
}

.message-content {
    max-width: 75%;
    min-width: 40px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 15px;
    word-break: break-word;
    position: relative;
}

.ai-message .message-bubble {
    background: var(--bg-ai);
    color: var(--text-ai);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border);
}

.user-message .message-bubble {
    background: var(--bg-user);
    color: var(--text-user);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(79, 125, 247, 0.3);
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    padding: 0 4px;
}

.user-message .message-time {
    text-align: right;
}

/* ========== 分诊结果卡片样式 ========== */
.message-bubble .triage-card {
    background: rgba(79, 125, 247, 0.1);
    border: 1px solid rgba(79, 125, 247, 0.3);
    border-radius: 12px;
    padding: 14px;
    margin-top: 10px;
}

.triage-card .card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-light);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.triage-card .card-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.5;
}

.triage-card .card-item:last-child {
    margin-bottom: 0;
}

.triage-card .card-icon {
    font-size: 16px;
    flex-shrink: 0;
}

/* ========== 快捷症状按钮 ========== */
.quick-symptoms {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 46px;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

.symptom-btn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.symptom-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 125, 247, 0.3);
}

.symptom-btn:active {
    transform: translateY(0);
}

/* ========== 输入区 ========== */
.chat-input {
    padding: 12px 16px 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    align-items: end;
    gap: 10px;
    background: var(--bg-input);
    border-radius: 20px;
    padding: 8px 8px 8px 18px;
    border: 1px solid var(--border);
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 125, 247, 0.15);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    max-height: 100px;
    padding: 4px 0;
    font-family: inherit;
}

.input-wrapper textarea::placeholder {
    color: var(--text-secondary);
}

.btn-send {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 14px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-send:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
}

.input-hint {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* ========== 加载动画 ========== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

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

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

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========== 响应式 ========== */
@media (max-width: 480px) {
    .chat-container {
        max-width: 100%;
    }
    .message-content {
        max-width: 80%;
    }
    .user-name {
        max-width: 40px;
    }
}

@media (min-width: 768px) {
    .chat-container {
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
    }
}
