/* ============================================
   杭州大区患者信息管理系统 - 样式表
   断点: mobile ≤768px / tablet 769-1024px / desktop >1024px
   ============================================ */

:root {
    /* 主题色 */
    --primary: #2d7af0;
    --primary-light: #e8f2ff;
    --primary-dark: #1a5fd0;
    --success: #28a745;
    --success-light: #d4edda;
    --warning: #ffc107;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --info: #17a2b8;
    --info-light: #d1ecf1;

    /* 中性色 */
    --text-primary: #1a1a2e;
    --text-secondary: #6c757d;
    --text-light: #adb5bd;
    --bg-main: #f5f7fa;
    --bg-card: #ffffff;
    --bg-hover: #f0f4f8;
    --border: #e0e6ed;
    --border-light: #eef2f6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;

    /* 布局 */
    --nav-height: 60px;
    --container-max: 1400px;
}

/* ─── Reset & Base ─── */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-main);
    line-height: 1.6;
}

a {
    color: var(--primary);
    text-decoration: none;
}

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

/* ─── Navbar ─── */

.navbar {
    background: var(--bg-card);
    height: var(--nav-height);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: var(--container-max);
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-icon {
    font-size: 22px;
}

.nav-title {
    white-space: nowrap;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
    align-items: center;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s;
}

/* ─── Main Content ─── */

.main-content {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - var(--nav-height) - 50px);
}

/* ─── Page Header ─── */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}

/* 管理员查看他人数据时的提示 banner */
.viewing-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #fff7e6 0%, #ffe7ba 100%);
    border: 1px solid #ffd591;
    border-left: 4px solid #fa8c16;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 14px;
    color: #874d00;
    flex-wrap: wrap;
    gap: 12px;
}
.viewing-banner #viewingBannerText {
    flex: 1;
    min-width: 200px;
}

.page-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ─── Buttons ─── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

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

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* ─── Inputs ─── */

.input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.input:read-only {
    background: var(--bg-hover);
    cursor: not-allowed;
}

select.input {
    cursor: pointer;
}

/* ─── Filter Bar ─── */

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.filter-box {
    min-width: 160px;
}

.view-toggle {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.btn-toggle {
    padding: 8px 16px;
    background: var(--bg-card);
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.btn-toggle.active {
    background: var(--primary);
    color: #fff;
}

/* ─── Table ─── */

.table-container {
    overflow-x: auto;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead {
    background: var(--bg-hover);
}

.data-table th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 2px solid var(--border);
    font-size: 13px;
}

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-light);
}

.data-table tbody tr:hover {
    background: var(--primary-light);
}

.data-table .col-actions {
    white-space: nowrap;
}

.data-table .col-actions .btn {
    margin-right: 4px;
}

.loading-cell {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 0;
}

/* ─── Cards ─── */

.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.patient-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.patient-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.patient-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.patient-card-name {
    font-size: 16px;
    font-weight: 700;
}

.patient-card-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.patient-card-info > div {
    margin-bottom: 4px;
}

.patient-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

/* ─── Pagination ─── */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.page-btn {
    min-width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s;
    padding: 0 8px;
}

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

.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

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

.page-info {
    margin: 0 12px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ─── Empty State ─── */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

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

/* ─── Forms ─── */

.patient-form {
    max-width: 800px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}

.form-section {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.form-section legend {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    padding: 0 8px;
    margin-bottom: 16px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group textarea.input {
    resize: vertical;
    min-height: 60px;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-label.required::after {
    content: " *";
    color: var(--danger);
}

.form-hint {
    font-size: 12px;
    color: var(--text-light);
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

/* ─── Schedule Timeline ─── */

.schedule-info {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.info-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
}

.info-card-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.info-card-value {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.schedule-timeline {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
    overflow-x: auto;
}

.timeline-track {
    position: relative;
    padding: 20px 0;
    min-width: 600px;
}

.timeline-line {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    transform: translateY(-50%);
}

.timeline-nodes {
    display: flex;
    justify-content: space-between;
    position: relative;
    z-index: 1;
}

.timeline-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    width: 120px;
}

.timeline-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--bg-card);
    box-shadow: 0 0 0 2px var(--primary);
    position: relative;
    z-index: 1;
}

.timeline-dot.first {
    background: var(--success);
    box-shadow: 0 0 0 2px var(--success);
}

.timeline-dot.last {
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--danger);
}

.timeline-dot.review {
    background: var(--warning);
    box-shadow: 0 0 0 2px var(--warning);
}

.timeline-date {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.timeline-label {
    font-size: 11px;
    color: var(--text-light);
}

.schedule-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ─── Footer ─── */

.footer {
    text-align: center;
    padding: 16px;
    color: var(--text-light);
    font-size: 13px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
}

/* ─── Badge ─── */

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: var(--success-light);
    color: var(--success);
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

.badge-info {
    background: var(--info-light);
    color: var(--info);
}

.badge-danger {
    background: var(--danger-light);
    color: var(--danger);
}

/* ─── Toast ─── */

.toast {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    font-size: 14px;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: var(--success);
    color: #fff;
}

.toast-error {
    background: var(--danger);
    color: #fff;
}

/* ════════════════════════════════════════════
   响应式断点
   ════════════════════════════════════════════ */

/* ─── Tablet: 769px ~ 1024px ─── */
@media (max-width: 1024px) {
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .card-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .data-table {
        font-size: 13px;
    }

    .data-table th,
    .data-table td {
        padding: 10px;
    }
}

/* ─── Mobile: ≤768px ─── */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .nav-menu {
        display: none;
        position: absolute;
        top: var(--nav-height);
        left: 0;
        right: 0;
        background: var(--bg-card);
        flex-direction: column;
        padding: 8px;
        box-shadow: var(--shadow);
        gap: 0;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-link {
        display: block;
        padding: 12px 16px;
    }

    .nav-title {
        font-size: 14px;
    }

    .main-content {
        padding: 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-actions {
        width: 100%;
        flex-direction: column;
    }

    .page-actions .btn {
        width: 100%;
    }

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

    .search-box,
    .filter-box {
        width: 100%;
        min-width: 0;
    }

    .view-toggle {
        align-self: flex-end;
    }

    .table-container {
        display: none;
    }

    .table-container.mobile-show {
        display: block;
    }

    .card-container {
        grid-template-columns: 1fr;
    }

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

    .patient-form {
        padding: 16px;
    }

    .form-section {
        padding: 16px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
    }

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

    .schedule-stats {
        grid-template-columns: 1fr 1fr;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
    }

    .pagination {
        gap: 2px;
    }

    .page-btn {
        min-width: 32px;
        height: 32px;
    }
}

/* ─── Small Mobile: ≤480px ─── */
@media (max-width: 480px) {
    .schedule-info,
    .schedule-stats {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 24px;
    }

    .timeline-node {
        width: 80px;
    }
}

/* ─── Auth Pages (Login/Register) ─── */

.auth-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: calc(100vh - var(--nav-height) - 60px);
    padding: 40px 20px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

.auth-header {
    text-align: center;
    margin-bottom: 32px;
}

.auth-header .nav-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 12px;
}

.auth-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.auth-form .form-group {
    margin-bottom: 20px;
}

.auth-submit {
    width: 100%;
    height: 44px;
    font-size: 16px;
    margin-top: 8px;
}

.auth-link-text {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-link-text a {
    font-weight: 500;
}

/* ─── Nav User Area ─── */

.nav-user-area {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
}

.nav-user-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
    padding: 4px 8px;
}
