/* DEV-3.10 | Shared E~J read-only Drawer + Patient Workspace action visual owner. */

/* 04-B16 action alignment: Back / Edit / Add Follow / every View share one visual. */
.patient-workspace__back,
.patient-workspace__secondary-action,
.patient-workspace__view-button {
    min-height: 40px !important;
    padding: 9px 16px !important;
    border: 1px solid #2a7885 !important;
    border-radius: 10px !important;
    background: #2a7885 !important;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    line-height: 1.15 !important;
    box-shadow: 0 2px 5px rgba(21, 78, 88, .16) !important;
    cursor: pointer;
    transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
}

.patient-workspace__back:hover,
.patient-workspace__secondary-action:hover,
.patient-workspace__view-button:hover {
    filter: brightness(.95);
    box-shadow: 0 4px 10px rgba(21, 78, 88, .2) !important;
}

.patient-workspace__back:active,
.patient-workspace__secondary-action:active,
.patient-workspace__view-button:active {
    transform: translateY(1px);
}

.patient-workspace__secondary-action:disabled,
.patient-workspace__view-button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.patient-workspace__header-actions {
    gap: 10px !important;
}

.patient-workspace__card-actions {
    gap: 9px !important;
}

/* Shared E~J read-only Drawer content.
   Position / width / slide direction are intentionally NOT owned here.
   The exact same PatientWorkLayer DR owner used by the Indication drawer
   anchors the surface to the browser right edge and slides it right -> left. */
.patient-history-drawer {
    padding: 0;
    overflow: hidden;
    background: #f7fafb;
}

.patient-history-drawer[hidden] {
    display: none !important;
}

.patient-history-drawer__panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: #f7fafb;
}

.patient-history-drawer__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 24px 17px;
    background: #fff;
    border-bottom: 1px solid #dce7e9;
}

.patient-history-drawer__eyebrow {
    margin: 0 0 5px;
    color: #58808a;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
}

.patient-history-drawer__header h2 {
    margin: 0;
    color: #154f59;
    font-size: 23px;
}

.patient-history-drawer__header p:last-child {
    margin: 5px 0 0;
    color: #6e8790;
    font-size: 13px;
}

.patient-history-drawer__close {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border: 1px solid #b8cfd4;
    border-radius: 10px;
    background: #fff;
    color: #2a6672;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.patient-history-drawer__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 24px;
    color: #5d7780;
    background: #eef7f8;
    border-bottom: 1px solid #d8e7e9;
    font-size: 13px;
}

.patient-history-drawer__summary strong {
    color: #225e69;
    white-space: nowrap;
}

.patient-history-drawer__state,
.patient-history-drawer__empty {
    margin: 16px 24px;
    padding: 18px;
    border: 1px dashed #bfd3d7;
    border-radius: 12px;
    background: #fff;
    color: #6b8087;
    text-align: center;
}

.patient-history-drawer__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: 16px 24px 24px;
}

.patient-history-drawer__record {
    margin-bottom: 13px;
    overflow: hidden;
    border: 1px solid #d8e4e7;
    border-radius: 13px;
    background: #fff;
    box-shadow: 0 2px 7px rgba(15, 64, 73, .05);
}

.patient-history-drawer__record-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid #e3ebed;
}

.patient-history-drawer__record-head > div:first-child {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
}

.patient-history-drawer__record-index {
    color: #789198;
    font-size: 12px;
    font-weight: 700;
}

.patient-history-drawer__record h3 {
    margin: 0;
    overflow-wrap: anywhere;
    color: #173f48;
    font-size: 16px;
}

.patient-history-drawer__record-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.patient-history-drawer__badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e9f5f6;
    color: #276a75;
    font-size: 11px;
    font-weight: 700;
}

.patient-history-drawer__badge--gray { background:#f1f3f4; color:#67757a; }
.patient-history-drawer__badge--blue { background:#edf4ff; color:#376aa1; }
.patient-history-drawer__badge--green { background:#edf8f2; color:#34765a; }

.patient-history-drawer__details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.patient-history-drawer__detail {
    min-width: 0;
    padding: 12px 16px;
    border-right: 1px solid #edf1f2;
    border-bottom: 1px solid #edf1f2;
}

.patient-history-drawer__detail:nth-child(2n) {
    border-right: 0;
}

.patient-history-drawer__detail--wide {
    grid-column: 1 / -1;
    border-right: 0;
}

.patient-history-drawer__label,
.patient-history-drawer__value {
    display: block;
}

.patient-history-drawer__label {
    margin-bottom: 4px;
    color: #70868d;
    font-size: 12px;
}

.patient-history-drawer__value {
    color: #243d44;
    font-size: 14px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.patient-history-drawer__footer {
    flex: 0 0 auto;
    display: flex;
    justify-content: flex-end;
    padding: 14px 24px 18px;
    background: #fff;
    border-top: 1px solid #dce7e9;
}

.patient-history-drawer__action {
    min-width: 96px;
    min-height: 40px;
    padding: 9px 18px;
    border: 1px solid #2a7885;
    border-radius: 10px;
    background: #2a7885;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

@media (max-width: 900px) {
    .patient-history-drawer__panel { width: min(760px, calc(100% - 18px)); }
}

@media (max-width: 620px) {
    .patient-history-drawer__panel { width: calc(100% - 8px); }
    .patient-history-drawer__details { grid-template-columns: 1fr; }
    .patient-history-drawer__detail,
    .patient-history-drawer__detail:nth-child(2n) { border-right: 0; }
    .patient-history-drawer__record-head,
    .patient-history-drawer__summary { align-items: flex-start; flex-direction: column; }
    .patient-history-drawer__record-badges { justify-content: flex-start; }
}

/* DEV-3.10G | Lead History content only; Drawer placement remains DR-owned. */
.patient-history-drawer__lead-table-shell {
    overflow-x: auto;
    border-top: 1px solid #e3ebed;
}

.patient-history-drawer__lead-table {
    width: 100%;
    min-width: 610px;
    border-collapse: collapse;
    color: #29434a;
    font-size: 13px;
}

.patient-history-drawer__lead-table th,
.patient-history-drawer__lead-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #edf1f2;
    text-align: left;
    vertical-align: top;
}

.patient-history-drawer__lead-table th {
    background: #f5f9fa;
    color: #627d85;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.patient-history-drawer__lead-model,
.patient-history-drawer__lead-sub {
    display: block;
}

.patient-history-drawer__lead-model {
    color: #203f47;
}

.patient-history-drawer__lead-sub {
    margin-top: 3px;
    color: #70868d;
    font-size: 12px;
}

.patient-history-drawer__lead-detail-row td {
    padding-top: 0;
    background: #fbfdfd;
}

.patient-history-drawer__lead-detail {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px 14px;
    padding: 8px 0 2px;
    color: #687f86;
    font-size: 12px;
}

.patient-history-drawer__lead-detail span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.patient-history-drawer__lead-detail b {
    color: #526c74;
}

@media (max-width: 620px) {
    .patient-history-drawer__lead-detail { grid-template-columns: 1fr; }
}


/* DEV-3.10I | Device/FU Test History content. DEV-3.10I1 moves this content to a WP full page. */
.patient-history-drawer__test-layout {
    display: grid;
    grid-template-columns: minmax(190px, 230px) minmax(0, 1fr);
    gap: 14px;
    min-height: 0;
}

.patient-history-drawer__test-list {
    min-width: 0;
    max-height: calc(100vh - 190px);
    overflow-y: auto;
    padding-right: 8px;
    border-right: 1px solid #dde8ea;
}

.patient-history-drawer__test-list-item {
    width: 100%;
    margin: 0 0 8px;
    padding: 10px 11px;
    border: 1px solid #d7e4e7;
    border-radius: 10px;
    background: #fff;
    color: #29434a;
    text-align: left;
    cursor: pointer;
}

.patient-history-drawer__test-list-item:hover {
    border-color: #8db5bd;
    background: #f7fbfb;
}

.patient-history-drawer__test-list-item.is-active {
    border-color: #2a7885;
    background: #eef7f8;
    box-shadow: inset 3px 0 0 #2a7885;
}

.patient-history-drawer__test-list-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.patient-history-drawer__test-list-top strong {
    color: #23444c;
}

.patient-history-drawer__test-list-top small,
.patient-history-drawer__test-list-meta {
    color: #70868d;
    font-size: 11px;
}

.patient-history-drawer__test-list-type,
.patient-history-drawer__test-list-meta {
    display: block;
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.patient-history-drawer__test-list-type {
    color: #385b64;
    font-size: 12px;
    font-weight: 700;
}

.patient-history-drawer__test-detail {
    min-width: 0;
}

.patient-history-drawer__test-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.patient-history-drawer__test-toolbar strong,
.patient-history-drawer__test-toolbar small {
    display: block;
}

.patient-history-drawer__test-toolbar small {
    margin-top: 3px;
    color: #70868d;
}

.patient-history-drawer__test-export {
    flex: 0 0 auto;
    min-height: 36px;
    padding: 7px 11px;
    border: 1px solid #2a7885;
    border-radius: 9px;
    background: #fff;
    color: #2a7885;
    font-weight: 700;
    cursor: pointer;
}

.patient-history-drawer__test-export:hover {
    background: #eef7f8;
}

.patient-history-drawer__test-section {
    padding: 12px 14px 14px;
    border-top: 1px solid #e3ebed;
}

.patient-history-drawer__test-section-title {
    margin: 0 0 10px;
    color: #2c5059;
    font-size: 13px;
}

.patient-history-drawer__test-empty {
    padding: 10px 0;
    color: #7c8f94;
    font-size: 12px;
}

.patient-history-drawer__measurement-shell {
    max-width: 100%;
    overflow-x: auto;
}

.patient-history-drawer__measurement-table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    color: #29434a;
    font-size: 12px;
}

.patient-history-drawer__measurement-table th,
.patient-history-drawer__measurement-table td {
    padding: 8px 9px;
    border: 1px solid #e1e9eb;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

.patient-history-drawer__measurement-table th {
    background: #f5f9fa;
    color: #627d85;
    font-size: 11px;
}

@media (max-width: 760px) {
    .patient-history-drawer__test-layout { grid-template-columns: 1fr; }
    .patient-history-drawer__test-list {
        max-height: 230px;
        padding-right: 0;
        padding-bottom: 6px;
        border-right: 0;
        border-bottom: 1px solid #dde8ea;
    }
    .patient-history-drawer__test-toolbar { align-items: flex-start; flex-direction: column; }
}


/* DEV-3.10I1 | I is a full Patient Workspace page; E-H remain the shared right Drawer. */
.patient-test-history-page {
    min-height: 100%;
    background: #f7fafb;
    color: #243d44;
}

.patient-test-history-page[hidden] { display: none !important; }

.patient-test-history-page__header {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 18px 24px 16px;
    background: #fff;
    border-bottom: 1px solid #dce7e9;
}

.patient-test-history-page__back,
.patient-test-history-page__action {
    min-height: 40px;
    padding: 9px 16px;
    border: 1px solid #2a7885;
    border-radius: 10px;
    background: #2a7885;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.patient-test-history-page__identity { min-width: 0; }
.patient-test-history-page__eyebrow {
    margin: 0 0 3px;
    color: #58808a;
    font-size: 12px;
    font-weight: 700;
}
.patient-test-history-page__identity h1 {
    margin: 0;
    color: #154f59;
    font-size: 24px;
}
.patient-test-history-page__identity p:last-child {
    margin: 4px 0 0;
    color: #6e8790;
    font-size: 13px;
}
.patient-test-history-page__count {
    color: #225e69;
    white-space: nowrap;
}
.patient-test-history-page__summary {
    padding: 11px 24px;
    background: #eef7f8;
    border-bottom: 1px solid #d8e7e9;
    color: #5d7780;
    font-size: 13px;
}
.patient-test-history-page__body {
    padding: 18px 24px 24px;
}
.patient-test-history-page__footer {
    display: flex;
    justify-content: flex-end;
    padding: 14px 24px 18px;
    background: #fff;
    border-top: 1px solid #dce7e9;
}

.patient-test-history-page .patient-history-drawer__test-layout {
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 20px;
    align-items: start;
}
.patient-test-history-page .patient-history-drawer__test-list {
    max-height: none;
    padding-right: 14px;
}
.patient-test-history-page .patient-history-drawer__test-detail {
    min-width: 0;
}
.patient-test-history-page .patient-history-drawer__record {
    margin-bottom: 0;
}
.patient-test-history-page .patient-history-drawer__details {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}
.patient-test-history-page .patient-history-drawer__detail:nth-child(2n) {
    border-right: 1px solid #edf1f2;
}
.patient-test-history-page .patient-history-drawer__detail:nth-child(3n) {
    border-right: 0;
}
.patient-test-history-page .patient-history-drawer__detail--wide {
    grid-column: 1 / -1;
    border-right: 0 !important;
}
.patient-test-history-page .patient-history-drawer__measurement-shell { overflow-x: visible; }
.patient-test-history-page .patient-history-drawer__measurement-table {
    min-width: 0;
    table-layout: auto;
}
.patient-test-history-page .patient-history-drawer__measurement-table th,
.patient-test-history-page .patient-history-drawer__measurement-table td {
    white-space: normal;
    overflow-wrap: anywhere;
}

@media (max-width: 1050px) {
    .patient-test-history-page .patient-history-drawer__details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .patient-test-history-page .patient-history-drawer__detail:nth-child(3n) { border-right: 1px solid #edf1f2; }
    .patient-test-history-page .patient-history-drawer__detail:nth-child(2n) { border-right: 0; }
}
@media (max-width: 820px) {
    .patient-test-history-page__header { grid-template-columns: 1fr; align-items: start; }
    .patient-test-history-page__back { justify-self: start; }
    .patient-test-history-page__count { justify-self: start; }
    .patient-test-history-page .patient-history-drawer__test-layout { grid-template-columns: 1fr; }
    .patient-test-history-page .patient-history-drawer__test-list {
        max-height: 260px;
        padding-right: 0;
        padding-bottom: 10px;
        border-right: 0;
        border-bottom: 1px solid #dde8ea;
    }
}


/* DEV-3.10J | Full-page Audit History */
.patient-audit-history-page[hidden] { display:none !important; }
.patient-audit-history-page { min-height:100%; padding:20px 22px; background:#f5f8fa; box-sizing:border-box; }
.patient-audit-history-page__header { display:grid; grid-template-columns:auto 1fr auto; gap:16px; align-items:center; margin-bottom:14px; }
.patient-audit-history-page__toolbar { display:grid; grid-template-columns:minmax(240px,1fr) 160px 190px 110px auto; gap:10px; margin-bottom:14px; }
.patient-audit-history-page__toolbar input,.patient-audit-history-page__toolbar select,.patient-audit-history-page__toolbar button { min-height:40px; border:1px solid #ccd8de; border-radius:10px; background:#fff; padding:0 12px; }
.patient-audit-history-page__content { display:grid; grid-template-columns:minmax(300px,360px) minmax(0,1fr); gap:16px; min-height:520px; }
.patient-audit-history-page__list { background:#fff; border:1px solid #dce5e9; border-radius:14px; overflow:auto; padding:8px; max-height:65vh; }
.patient-audit-history-page__item { display:flex; width:100%; flex-direction:column; gap:4px; text-align:left; border:0; border-bottom:1px solid #edf1f3; background:#fff; padding:12px; cursor:pointer; }
.patient-audit-history-page__item:last-child { border-bottom:0; }
.patient-audit-history-page__item.is-active { background:#eaf5f4; border-radius:10px; }
.patient-audit-history-page__item span,.patient-audit-history-page__item small { color:#56666d; }
.patient-audit-history-page__detail { background:#fff; border:1px solid #dce5e9; border-radius:14px; padding:18px; min-width:0; overflow:auto; max-height:65vh; }
.patient-audit-history-page__detail-head { display:flex; justify-content:space-between; gap:16px; align-items:flex-start; border-bottom:1px solid #e6ecef; padding-bottom:12px; margin-bottom:14px; }
.patient-audit-history-page__detail-head h3 { margin:0; }
.patient-audit-history-page__detail-title { margin:20px 0 8px; }
.patient-audit-history-page__detail-table { width:100%; border-collapse:collapse; table-layout:fixed; }
.patient-audit-history-page__detail-table th { width:180px; text-align:left; vertical-align:top; background:#f5f8fa; }
.patient-audit-history-page__detail-table th,.patient-audit-history-page__detail-table td { border:1px solid #dde5e9; padding:9px 10px; overflow-wrap:anywhere; }
.patient-audit-history-page__footer { display:flex; justify-content:space-between; align-items:center; margin-top:14px; }
.patient-audit-history-page__pagination { display:flex; align-items:center; gap:10px; }
.patient-audit-history-page__pagination button { min-height:36px; border:1px solid #ccd8de; border-radius:9px; background:#fff; padding:0 12px; }
@media (max-width:1050px) { .patient-audit-history-page__toolbar { grid-template-columns:1fr 1fr; } .patient-audit-history-page__content { grid-template-columns:1fr; } .patient-audit-history-page__list,.patient-audit-history-page__detail { max-height:none; } }
