/**
 * 电子病历系统 - 样式文件
 * 包含: 宠物信息卡片、病历列表、病历详情、筛选器等
 */

/* ========== 1. 宠物信息卡片 (侧边栏) ========== */
.pet-info-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    padding: 1.5rem;
    color: white;
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
    margin-bottom: 1.5rem;
}

.pet-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.pet-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.pet-basic h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.pet-basic p {
    font-size: 0.875rem;
    opacity: 0.9;
    margin: 0.125rem 0;
}

.medical-id {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    margin-top: 0.5rem;
}

/* ========== 2. 快捷功能按钮 (2x2网格) ========== */
.pet-quick-actions h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 1rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
}

.action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

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

.action-btn i {
    font-size: 1.5rem;
    font-style: normal;
}

.action-btn span {
    text-align: center;
    line-height: 1.2;
}

/* 按钮特定颜色 */
.emergency-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.3);
}

.hospital-btn:hover {
    background: rgba(59, 130, 246, 0.2);
    border-color: rgba(59, 130, 246, 0.3);
}

.medical-record-btn:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.3);
}

.health-profile-btn:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.3);
}

/* ========== 3. 电子病历弹窗 ========== */
.medical-records-container {
    max-width: 1200px;
    width: 95%;
    max-height: 90vh;
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.medical-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex-shrink: 0;
}

.medical-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.pet-summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    justify-content: center;
}

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

.pet-summary strong {
    font-weight: 600;
}

.pet-summary span {
    font-size: 0.875rem;
    opacity: 0.9;
    margin-left: 0.5rem;
}

.medical-header .modal-close {
    color: white;
    opacity: 0.9;
}

.medical-header .modal-close:hover {
    opacity: 1;
}

/* ========== 4. 筛选栏 ========== */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1.5rem 2rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.filter-bar input[type="text"],
.filter-bar input[type="date"],
.filter-bar select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
    transition: all 0.2s;
}

.filter-bar input[type="text"]:focus,
.filter-bar input[type="date"]:focus,
.filter-bar select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.filter-bar input[type="text"] {
    flex: 1;
    min-width: 200px;
}

.filter-bar select {
    min-width: 130px;
}

.filter-bar input[type="date"] {
    min-width: 140px;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* ========== 5. 统计卡片 ========== */
.stats-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 1.5rem 2rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.stat-card {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    padding: 1.25rem;
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.stat-card:nth-child(1) {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

.stat-card:nth-child(2) {
    background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
}

.stat-card:nth-child(3) {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
}

.stat-card:nth-child(4) {
    background: linear-gradient(135deg, #fce7f3 0%, #fbcfe8 100%);
}

.stat-number {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ========== 6. 病历时间线 ========== */
.medical-timeline {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: white;
}

.timeline-item {
    position: relative;
    padding-left: 2.5rem;
    padding-bottom: 2rem;
    border-left: 2px solid var(--border-color);
    margin-left: 0.5rem;
}

.timeline-item:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.record-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
}

.record-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateX(4px);
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.record-title {
    flex: 1;
}

.record-title h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.record-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.record-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.badge-emergency {
    background: #fee2e2;
    color: #dc2626;
}

.badge-routine {
    background: #dbeafe;
    color: #2563eb;
}

.badge-follow_up {
    background: #fef3c7;
    color: #d97706;
}

.badge-vaccination {
    background: #dcfce7;
    color: #16a34a;
}

.badge-physical_exam {
    background: #f3e8ff;
    color: #9333ea;
}

.record-body {
    margin-bottom: 1rem;
}

.record-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.info-icon {
    color: var(--text-secondary);
}

.info-value {
    color: var(--text-primary);
    font-weight: 500;
}

.record-diagnosis {
    background: var(--bg-secondary);
    padding: 0.75rem;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.record-diagnosis strong {
    font-size: 0.875rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.25rem;
}

.record-diagnosis p {
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin: 0;
}

.record-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.record-cost {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-color);
}

.record-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--bg-secondary);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ========== 7. 病历详情弹窗 ========== */
.record-detail-container {
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.detail-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.detail-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 400;
}

.detail-value.highlight {
    font-weight: 600;
    color: var(--primary-color);
}

.detail-full {
    grid-column: 1 / -1;
}

.detail-text-block {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* 处方和检查列表 */
.prescription-list,
.lab-test-list,
.imaging-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.prescription-item,
.lab-test-item,
.imaging-item {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.prescription-item h5,
.lab-test-item h5,
.imaging-item h5 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.prescription-details,
.test-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.875rem;
}

.prescription-details span,
.test-details span {
    color: var(--text-secondary);
}

.prescription-details strong,
.test-details strong {
    color: var(--text-primary);
}

.detail-footer {
    display: flex;
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.detail-footer .btn-secondary {
    flex: 1;
}

/* ========== 8. 分页 ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border-color);
    background: white;
    flex-shrink: 0;
}

.btn-page {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-page:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 120px;
    text-align: center;
}

/* ========== 9. 加载状态 ========== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

/* ========== 10. 响应式设计 ========== */
@media (max-width: 1024px) {
    .stats-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .action-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .action-btn {
        padding: 0.75rem 0.5rem;
        font-size: 0.7rem;
    }

    .action-btn i {
        font-size: 1.25rem;
    }

    .medical-records-container {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }

    .medical-header,
    .filter-bar,
    .stats-cards,
    .medical-timeline,
    .pagination,
    .detail-header,
    .detail-content,
    .detail-footer {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .stats-cards {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .filter-bar {
        flex-direction: column;
    }

    .filter-bar input[type="text"],
    .filter-bar select,
    .filter-bar input[type="date"] {
        width: 100%;
        min-width: 0;
    }

    .record-info {
        grid-template-columns: 1fr;
    }

    .record-header {
        flex-direction: column;
        gap: 0.5rem;
    }

    .prescription-details,
    .test-details {
        grid-template-columns: 1fr;
    }

    .detail-footer {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .pet-header {
        flex-direction: column;
        text-align: center;
    }

    .pet-avatar {
        width: 80px;
        height: 80px;
    }

    .action-grid {
        grid-template-columns: 1fr;
    }
}

/* ========== 11. 病历分享弹窗 ========== */

/* 分享设置弹窗 */
.share-modal-content {
    max-width: 600px;
    width: 90%;
}

.share-settings-form {
    padding: 1rem 0;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9375rem;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background 0.2s;
}

.checkbox-label:hover {
    background: var(--bg-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    flex: 1;
    font-size: 0.9375rem;
}

/* 分享结果弹窗 */
.share-result-content {
    max-width: 500px;
    width: 90%;
}

.share-result-body {
    padding: 1rem 0;
}

.qr-code-container {
    text-align: center;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 1.5rem;
}

.qr-code-image {
    max-width: 200px;
    width: 100%;
    height: auto;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: white;
    padding: 0.5rem;
}

.qr-code-hint {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.share-link-group,
.auth-code-group,
.share-info-group {
    margin-bottom: 1.5rem;
}

.share-link-group label,
.auth-code-group label,
.share-info-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.link-input-wrapper {
    display: flex;
    gap: 0.5rem;
}

.link-input-wrapper .form-control {
    flex: 1;
    font-size: 0.875rem;
    font-family: monospace;
}

.btn-copy {
    padding: 0.75rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-copy:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

.auth-code-display {
    display: inline-block;
    font-size: 2rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    padding: 1rem 2rem;
    border-radius: 12px;
    letter-spacing: 0.5rem;
    border: 2px solid var(--primary-color);
    text-align: center;
}

.share-info-group .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.share-info-group .info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.info-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.share-notice {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1.5rem;
}

.share-notice p {
    margin: 0.5rem 0;
    font-size: 0.875rem;
    color: #92400e;
}

.share-notice p:first-child {
    margin-top: 0;
}

.share-notice p:last-child {
    margin-bottom: 0;
}

.btn-block {
    width: 100%;
}

/* ========== 12. 分享访问页面样式 ========== */

.shared-record-view {
    min-height: 100vh;
    background: var(--bg-secondary);
    padding: 2rem;
}

.auth-required {
    max-width: 500px;
    margin: 5rem auto;
    background: white;
    padding: 3rem 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.auth-required h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.auth-form {
    margin-top: 2rem;
}

.auth-form label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 500;
    text-align: left;
}

.auth-form input {
    width: 100%;
    padding: 1rem;
    font-size: 1.5rem;
    font-family: 'Courier New', monospace;
    text-align: center;
    letter-spacing: 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    transition: all 0.2s;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.record-display {
    max-width: 900px;
    margin: 2rem auto;
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    position: relative;
}

.watermark {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    font-size: 5rem;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.03);
    pointer-events: none;
    z-index: 1;
    white-space: nowrap;
}

.record-display > * {
    position: relative;
    z-index: 2;
}

/* 响应式 - 分享弹窗 */
@media (max-width: 768px) {
    .share-modal-content,
    .share-result-content {
        width: 95%;
        max-width: none;
    }

    .qr-code-image {
        max-width: 160px;
    }

    .auth-code-display {
        font-size: 1.5rem;
        padding: 0.75rem 1.5rem;
        letter-spacing: 0.25rem;
    }

    .link-input-wrapper {
        flex-direction: column;
    }

    .btn-copy {
        width: 100%;
    }

    .auth-required {
        margin: 2rem auto;
        padding: 2rem 1.5rem;
    }

    .auth-form input {
        font-size: 1.25rem;
        letter-spacing: 0.25rem;
    }

    .watermark {
        font-size: 3rem;
    }
}
