/* ============================================
   DFM ECRF 系统样式表 v2.0
   递法明片真实世界研究 - 电子病例报告表
   新增：服药方案高亮、文件上传区域、依从性状态
   ============================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    background-color: #f5f6fa;
}

a {
    color: #1890ff;
    text-decoration: none;
}

a:hover {
    color: #40a9ff;
}

/* ============================================
   导航栏
   ============================================ */
.navbar {
    background-color: #fff;
    border-bottom: 1px solid #e8e8e8;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-brand a {
    font-size: 18px;
    font-weight: 600;
    color: #1890ff;
}

.nav-subtitle {
    font-size: 12px;
    color: #8c8c8c;
    font-weight: normal;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-links a {
    color: #595959;
    font-size: 14px;
}

.nav-links a:hover {
    color: #1890ff;
}

.btn-new {
    background-color: #1890ff;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.btn-new:hover {
    background-color: #40a9ff;
}

/* ============================================
   主容器
   ============================================ */
.container {
    max-width: 1200px;
    margin: 24px auto;
    padding: 0 24px;
    min-height: calc(100vh - 120px);
}

/* ============================================
   Flash消息
   ============================================ */
.flash-messages {
    margin-bottom: 16px;
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.alert-success {
    background-color: #f6ffed;
    border: 1px solid #b7eb8f;
    color: #52c41a;
}

.alert-warning {
    background-color: #fffbe6;
    border: 1px solid #ffe58f;
    color: #faad14;
}

.alert-danger {
    background-color: #fff2f0;
    border: 1px solid #ffccc7;
    color: #ff4d4f;
}

/* ============================================
   标题
   ============================================ */
h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #262626;
}

h2 {
    font-size: 16px;
    color: #595959;
    margin-bottom: 20px;
    font-weight: normal;
}

h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: #262626;
    border-left: 3px solid #1890ff;
    padding-left: 10px;
}

h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #434343;
}

/* ============================================
   数据表格
   ============================================ */
.data-table {
    width: 100%;
    background-color: #fff;
    border-collapse: collapse;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table thead {
    background-color: #fafafa;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #262626;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f0f0f0;
    color: #595959;
}

.data-table tbody tr:hover {
    background-color: #f6ffed;
}

.data-table tbody tr.status-fail {
    background-color: #fff2f0;
}

.center {
    text-align: center;
}

.subject-list-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 18px;
    margin-bottom: 14px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
}

.subject-filter-form {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.subject-filter-form label,
.current-center-label,
.subject-result-count {
    color: #595959;
    font-size: 13px;
}

.subject-filter-form select {
    min-height: 36px;
    padding: 6px 30px 6px 10px;
    color: #262626;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 5px;
}

.subject-result-count {
    margin-left: auto;
}

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

.pagination-link,
.pagination-ellipsis {
    display: inline-flex;
    min-width: 36px;
    min-height: 36px;
    padding: 6px 10px;
    align-items: center;
    justify-content: center;
    color: #1890ff;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 5px;
}

.pagination-link:hover {
    border-color: #1890ff;
}

.pagination-link.active {
    color: #fff;
    font-weight: 600;
    background: #1890ff;
    border-color: #1890ff;
}

.pagination-link.disabled {
    color: #bfbfbf;
    cursor: not-allowed;
    background: #fafafa;
}

.pagination-ellipsis {
    min-width: 24px;
    padding: 6px 2px;
    color: #8c8c8c;
    background: transparent;
    border-color: transparent;
}

/* ============================================
   标签
   ============================================ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background-color: #f6ffed;
    color: #52c41a;
    border: 1px solid #b7eb8f;
}

.badge-danger {
    background-color: #fff2f0;
    color: #ff4d4f;
    border: 1px solid #ffccc7;
}

.badge-pending {
    background-color: #f5f5f5;
    color: #8c8c8c;
    border: 1px solid #d9d9d9;
}

.badge-warning {
    background-color: #fffbe6;
    color: #faad14;
    border: 1px solid #ffe58f;
}

/* ============================================
   状态标记
   ============================================ */
.check {
    color: #52c41a;
    font-weight: bold;
}

.cross {
    color: #ff4d4f;
}

.text-danger {
    color: #ff4d4f;
}

/* ============================================
   操作按钮
   ============================================ */
.actions {
    white-space: nowrap;
}

.btn-view, .btn-edit, .btn-small {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 12px;
    margin-right: 4px;
}

.btn-view {
    background-color: #e6f7ff;
    color: #1890ff;
    border: 1px solid #91d5ff;
}

.btn-edit {
    background-color: #f6ffed;
    color: #52c41a;
    border: 1px solid #b7eb8f;
}

.btn-small {
    background-color: #f5f5f5;
    color: #595959;
    border: 1px solid #d9d9d9;
    font-size: 11px;
    padding: 2px 8px;
}

/* ============================================
   CRF表单
   ============================================ */
.crf-form {
    background-color: #fff;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.form-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.form-section:last-of-type {
    border-bottom: none;
}

/* v2.0：绿色高亮 - 服药方案 */
.form-section.highlight {
    background-color: #f6ffed;
    padding: 16px;
    border-radius: 8px;
    border: 2px solid #52c41a;
}

/* v2.0：黄色高亮 - 依从性评估 */
.form-section.highlight-yellow {
    background-color: #fffbe6;
    padding: 16px;
    border-radius: 8px;
    border: 2px solid #faad14;
}

.section-hint {
    color: #8c8c8c;
    font-size: 13px;
    margin-bottom: 12px;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group.full-width {
    flex: 100%;
    min-width: 100%;
}

.form-group.flex-grow {
    flex: 2;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #434343;
    font-size: 13px;
}

.required {
    color: #ff4d4f;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="tel"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
    background-color: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.1);
}

.form-group input.readonly {
    background-color: #f5f5f5;
    color: #262626;
    font-weight: 600;
}

.form-group .hint {
    display: block;
    margin-top: 4px;
    color: #8c8c8c;
    font-size: 12px;
}

.form-group .hint.report-requirement {
    margin-top: 7px;
    padding: 7px 9px;
    color: #cf1322;
    line-height: 1.5;
    background: #fff1f0;
    border-left: 3px solid #ff4d4f;
    border-radius: 3px;
}

/* 文件输入框样式 */
.form-group input[type="file"] {
    padding: 6px 10px;
    cursor: pointer;
}

.form-group input[type="file"]:hover {
    border-color: #1890ff;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #1890ff;
}

/* 眼科左右眼分组 */
.eye-row {
    background-color: #fafafa;
    padding: 12px;
    border-radius: 6px;
}

/* AE项目网格 */
.ae-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.ae-item {
    min-width: auto;
}

/* ============================================
   文件上传区域（v2.0）
   ============================================ */
.upload-item {
    margin-bottom: 16px;
    padding: 16px;
    background-color: #fafafa;
    border-radius: 8px;
    border: 1px solid #e8e8e8;
}

.upload-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.upload-title {
    font-weight: 600;
    font-size: 14px;
    color: #262626;
}

.upload-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 4px;
}

.upload-status.status-done {
    background-color: #f6ffed;
    color: #52c41a;
    border: 1px solid #b7eb8f;
}

.upload-status.status-pending {
    background-color: #f5f5f5;
    color: #8c8c8c;
    border: 1px solid #d9d9d9;
}

.upload-info {
    margin-bottom: 10px;
    padding: 8px 12px;
    background-color: #e6f7ff;
    border-radius: 4px;
    border-left: 3px solid #1890ff;
}

.upload-info p {
    margin: 4px 0;
    font-size: 13px;
}

.upload-info code {
    background-color: #f5f5f5;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 12px;
    color: #595959;
}

.attachment-preview {
    margin: 8px 0;
}

.attachment-preview-image {
    display: inline-flex;
    max-width: 260px;
    margin-right: 10px;
    padding: 7px;
    flex-direction: column;
    vertical-align: top;
    background: #fff;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
}

.attachment-thumbnail {
    display: block;
    overflow: hidden;
    background: #f5f5f5;
    border-radius: 4px;
}

.attachment-thumbnail img {
    display: block;
    width: 100%;
    max-width: 244px;
    height: 180px;
    object-fit: contain;
}

.attachment-caption {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.attachment-caption code {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* ============================================
   表单操作按钮
   ============================================ */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
}

.btn-submit {
    background-color: #52c41a;
    color: #fff;
    border: none;
    padding: 10px 32px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
}

.btn-submit:hover {
    background-color: #73d13d;
}

.btn-cancel {
    background-color: #fff;
    color: #595959;
    border: 1px solid #d9d9d9;
    padding: 10px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 15px;
    text-decoration: none;
    display: inline-block;
}

.btn-cancel:hover {
    color: #1890ff;
    border-color: #1890ff;
}

/* ============================================
   详情页
   ============================================ */
.detail-section {
    background-color: #fff;
    padding: 20px 24px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 16px;
}

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

.detail-table th,
.detail-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    text-align: left;
}

.detail-table th {
    width: 180px;
    color: #8c8c8c;
    font-weight: 500;
    background-color: #fafafa;
}

.detail-table.compact th {
    width: 140px;
    font-size: 13px;
}

.detail-table.compact td {
    font-size: 13px;
}

.visit-block {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px dashed #e8e8e8;
}

.visit-block:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.empty-text {
    color: #8c8c8c;
    font-style: italic;
    padding: 8px 0;
}

.empty-state {
    text-align: center;
    padding: 48px;
    color: #8c8c8c;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ============================================
   页脚
   ============================================ */
.footer {
    text-align: center;
    padding: 20px;
    color: #8c8c8c;
    font-size: 12px;
    border-top: 1px solid #e8e8e8;
    margin-top: 40px;
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 12px;
    }

    .form-group {
        min-width: 100%;
    }

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

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

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

    .actions {
        white-space: normal;
    }

    .nav-subtitle {
        display: none;
    }
}

/* ============================================================
   新增：删除按钮样式（v2.1 - 删除未入组受试者）
   ============================================================ */

.btn-delete {
    background-color: #ff4d4f;
    color: #fff;
    border: none;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-right: 4px;
    display: inline-block;
}

.btn-delete:hover {
    background-color: #ff7875;
}

/* ============================================================
   手机端适配（v2.6）
   ============================================================ */

.table-scroll {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
}

.table-scroll:focus {
    outline: 2px solid rgba(24, 144, 255, 0.35);
    outline-offset: 2px;
}

@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        -webkit-text-size-adjust: 100%;
    }

    .navbar {
        height: auto;
        min-height: 56px;
        padding: 8px 12px;
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 6px;
    }

    .nav-brand {
        width: 100%;
        min-width: 0;
    }

    .nav-brand a {
        font-size: 17px;
        line-height: 32px;
    }

    .nav-links {
        width: 100%;
        gap: 4px !important;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .nav-user-info {
        min-height: 34px;
        margin-right: 2px !important;
        overflow-wrap: anywhere;
    }

    .nav-links a {
        min-height: 36px;
        padding: 7px 9px !important;
        display: inline-flex;
        align-items: center;
    }

    .container {
        width: 100%;
        margin: 12px auto;
        padding: 0 12px;
        min-height: calc(100vh - 150px);
    }

    h1 {
        font-size: 20px;
        line-height: 1.35;
    }

    h2 {
        font-size: 14px;
        line-height: 1.5;
        margin-bottom: 14px;
    }

    h3 {
        font-size: 15px;
    }

    .page-header,
    .subject-list-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px;
        margin-bottom: 16px !important;
    }

    .subject-list-header > div:last-child {
        margin-top: 0 !important;
        width: 100%;
    }

    .subject-create-form {
        display: flex !important;
        width: 100%;
    }

    .subject-create-form select {
        flex: 1;
        min-width: 0;
        font-size: 16px !important;
    }

    .subject-create-form .btn-new {
        min-height: 42px;
        white-space: nowrap;
    }

    .subject-list-toolbar {
        align-items: stretch;
        gap: 10px;
        padding: 10px;
    }

    .subject-filter-form {
        width: 100%;
    }

    .subject-filter-form label {
        width: 72px;
    }

    .subject-filter-form select {
        flex: 1;
        min-width: 100px;
        min-height: 42px;
        font-size: 16px;
    }

    .subject-page-size-form label {
        width: auto;
    }

    .subject-result-count {
        width: 100%;
        margin-left: 0;
        line-height: 1.5;
    }

    .pagination {
        gap: 5px;
    }

    .pagination-link {
        min-width: 40px;
        min-height: 40px;
    }

    .table-scroll,
    .user-table {
        width: 100%;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        border-radius: 8px;
    }

    .data-table {
        min-width: 880px;
        font-size: 12px;
        overflow: visible;
    }

    .user-table table {
        min-width: 900px;
    }

    .data-table th,
    .data-table td,
    .user-table th,
    .user-table td {
        padding: 9px 10px !important;
        white-space: nowrap;
    }

    .actions {
        min-width: 240px;
        white-space: normal;
    }

    .actions form,
    .actions-cell form {
        margin-bottom: 5px;
    }

    .btn-view,
    .btn-edit,
    .btn-small,
    .btn-delete,
    .btn-action {
        min-height: 34px;
        padding: 6px 10px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 4px;
    }

    .crf-form {
        padding: 14px 12px;
        border-radius: 8px;
    }

    .form-section {
        margin-bottom: 18px;
        padding-bottom: 12px;
    }

    .form-section.highlight,
    .form-section.highlight-yellow {
        padding: 12px;
    }

    .form-row {
        flex-direction: column;
        gap: 10px;
        margin-bottom: 10px;
    }

    .form-group,
    .form-group.full-width {
        width: 100%;
        min-width: 0;
    }

    .form-group input[type="text"],
    .form-group input[type="password"],
    .form-group input[type="number"],
    .form-group input[type="date"],
    .form-group input[type="tel"],
    .form-group input[type="file"],
    .form-group select,
    .form-group textarea,
    .login-form input[type="text"],
    .login-form input[type="password"] {
        min-height: 44px;
        font-size: 16px !important;
    }

    .form-group textarea {
        min-height: 96px;
    }

    .eye-row {
        padding: 10px;
    }

    .ae-row {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .criteria-item {
        padding: 10px;
    }

    .criteria-label {
        gap: 7px;
    }

    .criteria-text {
        overflow-wrap: anywhere;
    }

    .section-note {
        display: block;
        margin: 4px 0 0;
        line-height: 1.4;
    }

    .upload-item {
        padding: 12px;
    }

    .upload-header {
        gap: 8px;
        flex-wrap: wrap;
    }

    .upload-info {
        padding: 8px 10px;
        overflow-wrap: anywhere;
    }

    .upload-info p {
        display: flex;
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 6px;
    }

    .upload-info code {
        max-width: 100%;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .attachment-preview-image {
        display: flex;
        width: 100%;
        max-width: 100%;
        margin-right: 0;
    }

    .attachment-thumbnail img {
        max-width: 100%;
        height: auto;
        max-height: 320px;
    }

    .form-actions {
        gap: 8px;
    }

    .btn-submit,
    .btn-cancel {
        min-height: 44px;
        padding: 10px 18px;
        text-align: center;
    }

    .detail-section {
        padding: 14px 12px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .detail-table {
        min-width: 540px;
    }

    .detail-table th,
    .detail-table td {
        padding: 8px 9px;
        vertical-align: top;
    }

    .empty-state {
        padding: 32px 16px;
    }

    .alert {
        padding: 10px 12px;
        overflow-wrap: anywhere;
    }

    .search-box input {
        width: 100%;
        max-width: none !important;
        min-height: 44px;
        font-size: 16px !important;
    }

    .btn-new-crc {
        width: 100%;
        min-height: 44px;
        justify-content: center;
    }

    .account-title-row {
        align-items: flex-start !important;
    }

    .account-create-layout {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 16px !important;
    }

    .form-card {
        width: 100%;
        max-width: none !important;
        padding: 18px !important;
    }

    .info-card,
    .warning-box,
    .permission-box {
        padding: 14px !important;
    }

    .login-container {
        width: 100%;
        max-width: none !important;
        margin: 24px auto !important;
        padding: 28px 20px !important;
        border-radius: 12px !important;
    }

    .footer {
        margin-top: 24px;
        padding: 16px 12px;
        line-height: 1.5;
    }
}

@media (max-width: 480px) {
    .navbar {
        position: static;
    }

    .nav-user-info {
        width: 100%;
        min-height: 28px;
    }

    .nav-links a {
        flex: 1;
        justify-content: center;
        border: 1px solid #f0f0f0;
    }

    .version-badge {
        display: inline-block;
        margin-left: 4px;
    }

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

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

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

    .detail-table {
        min-width: 480px;
    }

    .login-logo-icon {
        width: 56px !important;
        height: 56px !important;
    }
}
