/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4A90E2;
    --secondary-color: #50C878;
    --danger-color: #E74C3C;
    --warning-color: #F39C12;
    --text-dark: #2C3E50;
    --text-light: #7F8C8D;
    --bg-light: #F8F9FA;
    --border-color: #E0E0E0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-light);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* 页面容器 */
.page {
    display: none;
    min-height: 100vh;
}

.page.active {
    display: flex;
}

.container {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

/* 登录页面 */
#loginPage {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

#loginPage .container {
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    padding: 40px 30px;
}

.logo {
    text-align: center;
    margin-bottom: 20px;
}

#loginPage h1 {
    text-align: center;
    color: var(--text-dark);
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.subtitle {
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 30px;
}

/* 表单 */
.form {
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    outline: none;
    transition: all 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-group input::placeholder {
    color: #BDC3C7;
}

/* 按钮 */
.btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    outline: none;
}

.btn-primary {
    width: 100%;
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #3a7bc8;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-send {
    background: var(--primary-color);
    color: white;
    padding: 8px 20px;
    font-size: 14px;
}

.btn-send:hover {
    background: #3a7bc8;
}

.btn-send:disabled {
    background: #BDC3C7;
    cursor: not-allowed;
}

.icon-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-dark);
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.icon-btn:active {
    background: rgba(0, 0, 0, 0.1);
}

/* 通知 */
.notice {
    background: #FFF3CD;
    border: 1px solid #FFE69C;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
}

.notice p {
    font-size: 13px;
    color: #856404;
    margin-bottom: 5px;
}

.notice p:last-child {
    margin-bottom: 0;
}

/* 对话页面 */
#chatPage {
    background: white;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-info {
    flex: 1;
    margin: 0 12px;
}

.header-info h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.status {
    font-size: 12px;
    color: var(--secondary-color);
}

.status::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--secondary-color);
    border-radius: 50%;
    margin-right: 4px;
}

/* 消息列表 */
.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-light);
}

.message {
    display: flex;
    margin-bottom: 16px;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--secondary-color);
}

.message-content {
    max-width: 70%;
    margin: 0 12px;
}

.message-bubble {
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--primary-color);
    color: white;
}

.message-time {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
    text-align: right;
}

.message.assistant .message-time {
    text-align: left;
}

.message-image {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 8px;
    cursor: pointer;
}

.message-file {
    display: flex;
    align-items: center;
    padding: 12px;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    margin-top: 8px;
}

.message-file svg {
    margin-right: 8px;
}

/* 输入区域 */
.chat-input {
    display: flex;
    align-items: flex-end;
    padding: 12px 16px;
    background: white;
    border-top: 1px solid var(--border-color);
    gap: 8px;
}

#messageInput {
    flex: 1;
    padding: 10px 12px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    outline: none;
    resize: none;
    max-height: 120px;
    font-family: inherit;
}

#messageInput:focus {
    border-color: var(--primary-color);
}

/* 病历页面 */
#recordPage {
    background: white;
}

.page-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-header h2 {
    flex: 1;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.record-content {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.record-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.record-section h3 {
    font-size: 18px;
    color: var(--text-dark);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-color);
}

.record-item {
    display: flex;
    margin-bottom: 12px;
    line-height: 1.8;
}

.record-label {
    font-weight: 500;
    color: var(--text-dark);
    min-width: 100px;
}

.record-value {
    flex: 1;
    color: var(--text-dark);
}

.record-value.highlight {
    color: var(--danger-color);
    font-weight: 500;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.overlay.show {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.overlay p {
    color: white;
    margin-top: 16px;
    font-size: 16px;
}

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s;
    max-width: 80%;
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--secondary-color);
}

.toast.error {
    background: var(--danger-color);
}

.toast.warning {
    background: var(--warning-color);
}

/* 响应式 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    #loginPage .container {
        padding: 30px 20px;
    }
    
    .message-content {
        max-width: 80%;
    }
    
    .record-item {
        flex-direction: column;
    }
    
    .record-label {
        margin-bottom: 4px;
    }
}

/* ============ 选择题选项区 ============ */
.options-bar {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 12px 16px;
    max-height: 45vh;
    overflow-y: auto;
}

.hint-text {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 8px;
}

.option-btn {
    display: block;
    width: 100%;
    margin: 6px 0;
    padding: 12px 14px;
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    background: #fff;
    border-radius: 10px;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s;
}

.option-btn:active {
    transform: scale(0.98);
}

.option-btn.selected {
    background: var(--primary-color);
    color: #fff;
}

.options-confirm {
    margin-top: 10px;
}

/* 医生消息 */
.message.doctor .message-avatar {
    background: var(--secondary-color);
}

.message.doctor .message-bubble {
    background: #E8F8EE;
    border: 1px solid #B7E4C7;
}

.doctor-name {
    font-size: 12px;
    color: #27AE60;
    font-weight: 600;
    margin-bottom: 2px;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}
