/**
 * 全人健康报告模块样式
 * v1.0
 */

/* ==================== 模态框基础样式 ==================== */
.fr-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fr-modal-overlay.show {
    opacity: 1;
}

.fr-modal {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(-20px);
    transition: transform 0.2s ease;
}

.fr-modal-overlay.show .fr-modal {
    transform: translateY(0);
}

.fr-modal-sm { width: 400px; }
.fr-modal-md { width: 600px; }
.fr-modal-lg { width: 800px; }

.fr-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.fr-modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.fr-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 24px;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.fr-modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.fr-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* ==================== 步骤指示器 ==================== */
.fr-steps {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
    padding: 0 20px;
}

.fr-step {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #999;
}

.fr-step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 6px;
}

.fr-step.active .fr-step-num {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.fr-step.completed .fr-step-num {
    background: #27ae60;
    color: white;
}

.fr-step-line {
    width: 40px;
    height: 2px;
    background: #e0e0e0;
    margin: 0 8px;
}

.fr-step.completed + .fr-step .fr-step-line,
.fr-step.active + .fr-step .fr-step-line {
    background: #667eea;
}

/* ==================== 表单元素 ==================== */
.fr-form-group {
    margin-bottom: 20px;
}

.fr-form-group label {
    display: block;
    font-weight: 500;
    color: #333;
    margin-bottom: 8px;
}

.fr-form-group .required {
    color: #e74c3c;
    margin-left: 2px;
}

.fr-input,
.fr-select,
.fr-textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.fr-input:focus,
.fr-select:focus,
.fr-textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.fr-textarea {
    min-height: 100px;
    resize: vertical;
}

.fr-select {
    appearance: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E") no-repeat right 12px center;
    background-color: white;
    cursor: pointer;
}

/* ==================== 患者选择卡片 ==================== */
.fr-patient-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
}

.fr-patient-card {
    padding: 12px 16px;
    border: 2px solid #eee;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.fr-patient-card:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.fr-patient-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.fr-patient-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.fr-patient-info {
    font-size: 12px;
    color: #666;
}

/* ==================== 匹配结果展示 ==================== */
.fr-match-result {
    padding: 20px;
    background: linear-gradient(135deg, #f8f9ff 0%, #fff5f5 100%);
    border-radius: 12px;
    margin-bottom: 20px;
}

.fr-match-best {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.fr-match-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.fr-match-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.fr-match-confidence {
    display: inline-block;
    padding: 4px 10px;
    background: #27ae60;
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    margin-left: 8px;
}

.fr-match-desc {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

/* 候选类型列表 */
.fr-candidates {
    margin-top: 16px;
}

.fr-candidates-title {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.fr-candidate-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: white;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.fr-candidate-item:hover {
    border-color: #667eea;
}

.fr-candidate-item.selected {
    border-color: #667eea;
    background: #f8f9ff;
}

/* ==================== 信息收集表单 ==================== */
.fr-collect-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.fr-progress-bar {
    flex: 1;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
}

.fr-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.fr-progress-text {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
}

.fr-field-group {
    margin-bottom: 20px;
    padding: 16px;
    background: #fafafa;
    border-radius: 10px;
    border: 1px solid #eee;
}

.fr-field-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: #333;
    margin-bottom: 10px;
}

.fr-field-required {
    color: #e74c3c;
    font-size: 12px;
}

.fr-field-hint {
    font-size: 12px;
    color: #999;
    margin-top: 6px;
}

/* 多选框组 */
.fr-checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.fr-checkbox-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.fr-checkbox-item:hover {
    border-color: #667eea;
}

.fr-checkbox-item.checked {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

.fr-checkbox-item input {
    display: none;
}

/* ==================== 提交确认页 ==================== */
.fr-summary {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.fr-summary-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.fr-summary-row:last-child {
    border-bottom: none;
}

.fr-summary-label {
    color: #666;
}

.fr-summary-value {
    font-weight: 500;
    color: #333;
}

.fr-cost-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #fff5e6 0%, #fff9f0 100%);
    border: 1px solid #f5af19;
    border-radius: 10px;
    margin-bottom: 20px;
}

.fr-cost-label {
    color: #996600;
    font-weight: 500;
}

.fr-cost-value {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
    color: #f5af19;
}

.fr-vip-notice {
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ==================== 状态页面 ==================== */
.fr-status-container {
    text-align: center;
    padding: 40px 20px;
}

.fr-status-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.fr-status-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.fr-status-desc {
    color: #666;
    margin-bottom: 24px;
}

.fr-status-progress {
    max-width: 300px;
    margin: 0 auto 24px;
}

/* 加载动画 */
.fr-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: fr-spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes fr-spin {
    to { transform: rotate(360deg); }
}

/* ==================== 报告详情页 ==================== */
.fr-report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.fr-report-meta {
    font-size: 13px;
    color: #666;
}

.fr-report-actions {
    display: flex;
    gap: 8px;
}

.fr-report-content {
    line-height: 1.8;
    color: #333;
}

.fr-report-content h3 {
    color: #667eea;
    margin: 20px 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #667eea;
}

.fr-report-content ul,
.fr-report-content ol {
    margin: 10px 0;
    padding-left: 24px;
}

.fr-report-content li {
    margin: 6px 0;
}

/* ==================== 历史列表 ==================== */
.fr-history-list {
    max-height: 400px;
    overflow-y: auto;
}

.fr-history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.fr-history-item:hover {
    background: #f0f2f5;
    transform: translateX(4px);
}

.fr-history-item-info {
    flex: 1;
}

.fr-history-item-title {
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
}

.fr-history-item-question {
    font-size: 12px;
    color: #666;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fr-history-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.fr-history-status {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.fr-status-pending { background: #ffeaa7; color: #996600; }
.fr-status-collecting { background: #81ecec; color: #006666; }
.fr-status-generating { background: #74b9ff; color: #0055aa; }
.fr-status-completed { background: #55efc4; color: #006633; }
.fr-status-failed { background: #fab1a0; color: #993300; }
.fr-status-cancelled { background: #dfe6e9; color: #666; }
.fr-status-reviewing { background: #a29bfe; color: #4a4480; }
.fr-status-reviewed { background: #55efc4; color: #006633; }

.fr-history-time {
    font-size: 11px;
    color: #999;
}

/* ==================== 空状态 ==================== */
.fr-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.fr-empty-state p {
    margin-bottom: 16px;
}

.fr-error-state {
    text-align: center;
    padding: 20px;
    color: #e74c3c;
    background: #fdf0ef;
    border-radius: 8px;
}

/* ==================== 按钮样式 ==================== */
.fr-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.fr-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.fr-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.fr-btn-secondary {
    background: #f0f2f5;
    color: #333;
}

.fr-btn-secondary:hover {
    background: #e4e6e9;
}

.fr-btn-success {
    background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
    color: white;
}

.fr-btn-danger {
    background: #e74c3c;
    color: white;
}

.fr-btn-outline {
    background: transparent;
    border: 1px solid #667eea;
    color: #667eea;
}

.fr-btn-outline:hover {
    background: rgba(102, 126, 234, 0.1);
}

.fr-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* 按钮组 */
.fr-btn-group {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

/* ==================== Toast提示 ==================== */
.fr-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10001;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 80%;
    text-align: center;
}

.fr-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.fr-toast-info {
    background: #333;
    color: white;
}

.fr-toast-success {
    background: #27ae60;
    color: white;
}

.fr-toast-error {
    background: #e74c3c;
    color: white;
}

.fr-toast-warning {
    background: #f39c12;
    color: white;
}

/* ==================== 响应式适配 ==================== */
@media (max-width: 768px) {
    .fr-modal-sm,
    .fr-modal-md,
    .fr-modal-lg {
        width: 95%;
        max-width: none;
        margin: 10px;
    }
    
    .fr-modal-header {
        padding: 16px;
    }
    
    .fr-modal-body {
        padding: 16px;
    }
    
    .fr-patient-list {
        grid-template-columns: 1fr;
    }
    
    .fr-steps {
        font-size: 12px;
    }
    
    .fr-step-line {
        width: 20px;
    }
    
    .fr-btn-group {
        flex-direction: column;
    }
    
    .fr-btn-group .fr-btn {
        width: 100%;
    }
    
    .fr-match-best {
        flex-direction: column;
        text-align: center;
    }
    
    .fr-history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .fr-history-item-meta {
        flex-direction: row;
        width: 100%;
        justify-content: space-between;
    }
}

/* ==================== 恢复对话框 ==================== */
.fr-resume-dialog {
    text-align: center;
    padding: 20px;
}

.fr-resume-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.fr-resume-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.fr-resume-desc {
    color: #666;
    margin-bottom: 24px;
}

.fr-resume-info {
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 24px;
    text-align: left;
}

.fr-resume-info-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
}

.fr-resume-info-label {
    color: #666;
}

.fr-resume-info-value {
    color: #333;
    font-weight: 500;
}

/* ==================== 对话模式状态栏（集成在聊天页面） ==================== */
.fr-chat-status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-radius: 0 0 12px 12px;
    margin-bottom: 8px;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.fr-status-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.fr-status-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.fr-status-type {
    font-weight: 600;
    font-size: 14px;
}

.fr-status-patient {
    font-size: 13px;
    opacity: 0.9;
}

.fr-status-patient::before {
    content: '|';
    margin-right: 12px;
    opacity: 0.5;
}

.fr-status-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 150px;
}

.fr-status-progress-bar {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
    overflow: hidden;
}

.fr-status-progress-fill {
    height: 100%;
    background: #55efc4;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.fr-status-progress-text {
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.fr-status-actions {
    display: flex;
    gap: 8px;
}

.fr-status-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.fr-status-btn-exit {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.fr-status-btn-exit:hover {
    background: rgba(255, 255, 255, 0.3);
}

.fr-status-btn-submit {
    background: #55efc4;
    color: #006633;
}

.fr-status-btn-submit:hover {
    background: #00d68f;
}

/* 提交确认区域 */
.fr-submit-confirmation {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    border-top: 2px solid #667eea;
    padding: 16px;
    margin-top: 8px;
}

.fr-submit-confirm-content {
    text-align: center;
}

.fr-submit-confirm-content p {
    margin-bottom: 12px;
    color: #333;
    font-weight: 500;
}

.fr-submit-confirm-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.fr-submit-confirm-actions .btn {
    padding: 10px 24px;
}

/* 对话模式下的消息样式增强 */
.fr-chat-mode .message-assistant .message-content {
    border-left: 3px solid #667eea;
}

.fr-chat-mode .message-system .message-content {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

/* 响应式 */
@media (max-width: 768px) {
    .fr-chat-status-bar {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }
    
    .fr-status-info {
        justify-content: center;
        text-align: center;
    }
    
    .fr-status-patient::before {
        display: none;
    }
    
    .fr-status-progress {
        width: 100%;
    }
    
    .fr-status-actions {
        width: 100%;
        justify-content: center;
    }
    
    .fr-submit-confirm-actions {
        flex-direction: column;
    }
    
    .fr-submit-confirm-actions .btn {
        width: 100%;
    }
}
