/**
 * ============================================
 * 血压统计系统 - 主样式文件
 * ============================================
 * 文件名称：style.css
 * 文件描述：血压统计系统的全局样式定义，包含布局、组件、响应式等样式
 * 创建日期：2024
 * ============================================
 */

/* ==========================================
   CSS 变量定义
   定义全局使用的颜色、阴影、圆角等变量，便于统一管理和主题切换
   ========================================== */
:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --primary-light: #5dade2;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --success-color: #2ecc71;
    --orange-color: #e67e22;
    --text-primary: #2c3e50;
    --text-secondary: #34495e;
    --text-muted: #666;
    --bg-light: #f8f9fa;
    --bg-white: #fff;
    --border-color: #e9ecef;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.3s ease;
}

/* ==========================================
   全局重置样式
   重置浏览器默认样式，确保跨浏览器一致性
   ========================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==========================================
   页面主体样式
   定义页面的基本字体、背景色和行高
   ========================================== */
body {
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ==========================================
   链接样式
   定义全局链接的颜色和悬停效果
   ========================================== */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* ==========================================
   标题样式
   定义各级标题的字体大小、颜色和间距
   ========================================== */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
}

h1 {
    font-size: 28px;
    text-align: center;
    margin-bottom: 30px;
}

h2 {
    font-size: 20px;
    color: var(--text-secondary);
    margin: 30px 0 15px;
    border-left: 4px solid var(--primary-color);
    padding-left: 10px;
}

h3 {
    font-size: 18px;
    margin-bottom: 15px;
}

/* ==========================================
   容器样式
   定义页面主内容区域的最大宽度和居中布局
   ========================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ==========================================
   导航栏样式
   定义顶部导航栏的布局、背景和交互效果
   ========================================== */
.navbar {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    padding: 0 20px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.navbar-brand {
    color: var(--bg-white);
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-brand:hover {
    color: var(--bg-white);
}

.navbar-nav {
    display: flex;
    list-style: none;
    gap: 5px;
}

.navbar-nav .mobile-user-info {
    display: none;
}

.navbar-nav li a {
    color: rgba(255, 255, 255, 0.9);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    display: block;
    transition: var(--transition);
}

.navbar-nav li a:hover,
.navbar-nav li a.active {
    background: rgba(255, 255, 255, 0.2);
    color: var(--bg-white);
}

/* 移动端导航栏切换按钮 */
.navbar-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 10px;
}

.navbar-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--bg-white);
    margin: 5px 0;
    border-radius: 2px;
    transition: var(--transition);
}

/* 导航栏用户信息区域 */
.navbar-user {
    display: flex;
    align-items: center;
    gap: 15px;
    color: rgba(255, 255, 255, 0.9);
}

.navbar-user .user-name {
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.navbar-user .logout-btn {
    color: rgba(255, 255, 255, 0.9);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.15);
    font-size: 13px;
    transition: var(--transition);
}

.navbar-user .logout-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: var(--bg-white);
}

/* ==========================================
   卡片组件样式
   定义通用卡片容器的外观和悬停效果
   ========================================== */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.card-title {
    font-size: 18px;
    color: var(--text-primary);
    margin: 0;
}

.card-body {
    padding: 5px 0;
}

/* ==========================================
   统计卡片样式
   用于展示血压、心率等统计数据的卡片
   ========================================== */
.stat-card {
    text-align: center;
    padding: 25px 15px;
}

.stat-card .stat-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

.stat-card .stat-value {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat-card .stat-label {
    font-size: 14px;
    color: var(--text-muted);
}

/* 统计卡片不同状态的配色 */
.stat-card.danger .stat-value {
    color: var(--danger-color);
}

.stat-card.warning .stat-value {
    color: var(--warning-color);
}

.stat-card.success .stat-value {
    color: var(--success-color);
}

/* 统计卡片网格布局 */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    align-items: stretch;
}

/* ==========================================
   表格样式
   定义数据表格的外观，包括表头、行悬停效果
   ========================================== */
.table-container {
    overflow-x: auto;
    margin-bottom: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

table th,
table td {
    padding: 12px 15px;
    text-align: center;
    border: 1px solid var(--border-color);
}

table th {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--bg-white);
    font-weight: 600;
    white-space: nowrap;
}

table tbody tr {
    transition: var(--transition);
}

table tbody tr:hover {
    background: rgba(52, 152, 219, 0.05);
}

/* 表格斑马纹效果 */
table tbody tr:nth-child(even) {
    background: var(--bg-light);
}

table tbody tr:nth-child(even):hover {
    background: rgba(52, 152, 219, 0.08);
}

/* ==========================================
   表单样式
   定义表单控件的外观和交互状态
   ========================================== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.form-control::placeholder {
    color: #adb5bd;
}

/* 表单控件验证状态 */
.form-control.is-invalid {
    border-color: var(--danger-color);
}

.form-control.is-valid {
    border-color: var(--success-color);
}

.invalid-feedback {
    color: var(--danger-color);
    font-size: 12px;
    margin-top: 5px;
}

/* 表单行布局 */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

/* 下拉选择框样式 */
.form-select {
    appearance: none;
    background-image: 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='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

/* ==========================================
   按钮样式
   定义各种类型按钮的外观和交互效果
   ========================================== */
.btn {
    display: inline-block;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    text-decoration: none;
}

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

/* 主要按钮 */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: var(--bg-white);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-dark), #1a5276);
    transform: translateY(-1px);
}

/* 成功按钮 */
.btn-success {
    background: linear-gradient(135deg, var(--success-color), #27ae60);
    color: var(--bg-white);
}

.btn-success:hover:not(:disabled) {
    background: linear-gradient(135deg, #27ae60, #1e8449);
}

/* 危险按钮 */
.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #c0392b);
    color: var(--bg-white);
}

.btn-danger:hover:not(:disabled) {
    background: linear-gradient(135deg, #c0392b, #922b21);
}

/* 警告按钮 */
.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #d68910);
    color: var(--bg-white);
}

.btn-warning:hover:not(:disabled) {
    background: linear-gradient(135deg, #d68910, #b9770e);
}

/* 边框按钮 */
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
}

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

/* 按钮尺寸 */
.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.btn-lg {
    padding: 14px 32px;
    font-size: 16px;
}

/* 块级按钮 */
.btn-block {
    display: block;
    width: 100%;
}

/* 按钮组 */
.btn-group {
    display: flex;
    gap: 10px;
}

/* ==========================================
   图表容器样式
   定义图表展示区域的尺寸和外观
   ========================================== */
.chart-container {
    width: 100%;
    height: 400px;
    margin: 20px 0;
    background: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 15px;
    box-shadow: var(--shadow-sm);
}

.chart-box {
    width: 100%;
    height: 100%;
}

/* ==========================================
   提示文本样式
   用于显示辅助说明信息
   ========================================== */
.note {
    color: var(--text-muted);
    font-size: 14px;
    margin: 10px 0;
    line-height: 1.6;
}

/* ==========================================
   警告提示框样式
   用于显示成功、错误、警告等提示信息
   ========================================== */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid var(--success-color);
    color: #1e8449;
}

.alert-danger {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid var(--danger-color);
    color: #c0392b;
}

.alert-warning {
    background: rgba(243, 156, 18, 0.1);
    border: 1px solid var(--warning-color);
    color: #b9770e;
}

.alert-info {
    background: rgba(52, 152, 219, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-dark);
}

/* ==========================================
   徽章样式
   用于显示状态标签或计数
   ========================================== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
}

.badge-primary {
    background: rgba(52, 152, 219, 0.15);
    color: var(--primary-dark);
}

.badge-success {
    background: rgba(46, 204, 113, 0.15);
    color: #1e8449;
}

.badge-danger {
    background: rgba(231, 76, 60, 0.15);
    color: #c0392b;
}

.badge-warning {
    background: rgba(243, 156, 18, 0.15);
    color: #b9770e;
}

/* ==========================================
   分页样式
   定义分页导航的外观和交互效果
   ========================================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin: 20px 0;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
}

.pagination a:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--bg-white);
}

.pagination .active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--bg-white);
}

/* ==========================================
   模态框样式
   定义弹出对话框的外观和动画效果
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(-20px);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ==========================================
   Toast 提示样式
   定义轻量级消息提示的外观和动画
   ========================================== */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 15px 20px;
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 280px;
    animation: slideIn 0.3s ease;
}

/* Toast 滑入动画 */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast.toast-error {
    border-left: 4px solid var(--danger-color);
}

.toast.toast-warning {
    border-left: 4px solid var(--warning-color);
}

.toast.toast-info {
    border-left: 4px solid var(--primary-color);
}

/* ==========================================
   加载状态样式
   定义加载动画和空状态提示
   ========================================== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

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

/* 加载旋转动画 */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 空状态提示 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 60px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 16px;
    margin-bottom: 20px;
}

/* ==========================================
   页脚样式
   定义页面底部信息区域
   ========================================== */
.footer {
    background: var(--text-primary);
    color: rgba(255, 255, 255, 0.7);
    padding: 30px 20px;
    margin-top: 40px;
    text-align: center;
}

.footer a {
    color: rgba(255, 255, 255, 0.9);
}

/* ==========================================
   响应式样式 - 平板设备 (max-width: 768px)
   适配中等屏幕设备，调整布局和字体大小
   ========================================== */
@media (max-width: 768px) {
    .navbar-toggle {
        display: block;
    }

    .navbar-user {
        display: none;
    }

    .navbar-nav {
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        padding: 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .navbar-nav.active {
        max-height: 400px;
    }

    .navbar-nav li a {
        padding: 15px 20px;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-nav .mobile-user-info {
        display: flex;
        flex-direction: column;
        padding: 15px 20px;
        background: rgba(0, 0, 0, 0.1);
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .navbar-nav .mobile-user-info .user-name {
        color: rgba(255, 255, 255, 0.9);
        font-size: 14px;
        margin-bottom: 10px;
    }

    .navbar-nav .mobile-user-info .logout-btn {
        display: inline-block;
        text-align: center;
        padding: 8px 16px;
        background: rgba(255, 255, 255, 0.15);
        border-radius: var(--radius-sm);
        color: rgba(255, 255, 255, 0.9);
        font-size: 13px;
    }

    .navbar-nav .mobile-user-info .logout-btn:hover {
        background: rgba(255, 255, 255, 0.25);
    }

    h1 {
        font-size: 22px;
    }

    h2 {
        font-size: 18px;
    }

    .container {
        padding: 15px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        margin-bottom: 25px;
    }

    .stat-card {
        padding: 20px 12px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        height: 100%;
    }

    .stat-card .stat-value {
        font-size: 26px;
        font-weight: 700;
    }

    .stat-card .stat-icon {
        font-size: 36px;
        margin-bottom: 8px;
    }

    .stat-card .stat-label {
        font-size: 13px;
        line-height: 1.4;
    }

    .chart-container {
        height: 280px;
        padding: 10px;
    }

    .table-container {
        position: relative;
        margin-left: -15px;
        margin-right: -15px;
        padding: 0 15px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-container::before,
    .table-container::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        width: 20px;
        pointer-events: none;
        z-index: 1;
    }

    .table-container::before {
        left: 0;
        background: linear-gradient(to right, var(--bg-light), transparent);
        opacity: 0;
        transition: opacity 0.3s;
    }

    .table-container::after {
        right: 0;
        background: linear-gradient(to left, var(--bg-light), transparent);
        opacity: 1;
        transition: opacity 0.3s;
    }

    .table-container.scrolled-left::before {
        opacity: 1;
    }

    .table-container.scrolled-right::after {
        opacity: 0;
    }

    table {
        min-width: 600px;
    }

    table th,
    table td {
        padding: 12px 10px;
        font-size: 13px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-control {
        font-size: 16px;
        padding: 14px 15px;
    }

    .btn {
        padding: 12px 20px;
        min-height: 44px;
    }

    .btn-sm {
        padding: 10px 14px;
        min-height: 40px;
    }

    .btn-group {
        flex-direction: column;
    }

    .btn-group .btn {
        width: 100%;
    }

    .modal {
        width: 95%;
        margin: 10px;
        max-height: 85vh;
    }

    .modal-header {
        padding: 15px;
    }

    .modal-body {
        padding: 15px;
        max-height: 60vh;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 12px 15px;
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .toast-container {
        left: 10px;
        right: 10px;
        top: 70px;
    }

    .toast {
        min-width: auto;
        padding: 12px 15px;
    }

    .card {
        padding: 15px;
    }

    .card-header {
        padding-bottom: 12px;
        margin-bottom: 12px;
    }

    .pagination {
        flex-wrap: wrap;
        gap: 5px;
    }

    .pagination a,
    .pagination span {
        padding: 8px 12px;
        font-size: 13px;
    }

    .action-btns {
        flex-direction: column;
        gap: 5px;
    }

    .action-btns .btn {
        width: 100%;
        padding: 8px 12px;
    }
}

/* ==========================================
   响应式样式 - 手机设备 (max-width: 480px)
   适配小屏幕设备，进一步优化布局
   ========================================== */
@media (max-width: 480px) {
    .navbar-brand {
        font-size: 16px;
    }

    .navbar-brand .brand-icon {
        font-size: 18px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .stat-card {
        padding: 15px 10px;
    }

    .stat-card .stat-value {
        font-size: 22px;
    }

    .stat-card .stat-icon {
        font-size: 28px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 14px;
    }

    .btn-lg {
        padding: 14px 20px;
        font-size: 15px;
    }

    .chart-container {
        height: 220px;
        padding: 8px;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 20px;
    }

    h2 {
        font-size: 16px;
    }

    h3 {
        font-size: 16px;
    }

    .card {
        padding: 12px;
        margin-bottom: 15px;
    }

    .modal {
        width: 100%;
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
    }

    .modal-header {
        padding: 12px 15px;
    }

    .modal-body {
        padding: 12px 15px;
        max-height: calc(100vh - 120px);
    }

    .modal-footer {
        padding: 10px 15px;
    }

    .toast-container {
        top: 60px;
        left: 5px;
        right: 5px;
    }

    .toast {
        padding: 10px 12px;
        font-size: 13px;
    }

    .empty-state {
        padding: 40px 15px;
    }

    .empty-state-icon {
        font-size: 48px;
    }

    .empty-state-text {
        font-size: 14px;
    }

    table th,
    table td {
        padding: 10px 8px;
        font-size: 12px;
    }

    .pagination a,
    .pagination span {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* ==========================================
   打印样式
   优化打印输出，隐藏不必要的元素
   ========================================== */
@media print {
    .navbar,
    .footer,
    .btn,
    .modal-overlay {
        display: none !important;
    }

    body {
        background: var(--bg-white);
    }

    .card,
    table {
        box-shadow: none;
        border: 1px solid var(--border-color);
    }
}
