/* DEV-1.07B | ME-04 Header Patient Search */

.global-header__search {
    position: relative;
}

.global-header__search-candidates.mh02-candidate-list {
    top: calc(100% + 4px);
    left: 0;

    width: 100%;
    max-height: 360px;

    margin-top: 0;

    z-index: 52000;
}

.global-header__search-button:disabled {
    cursor: wait;
    opacity: 0.78;
}

.patient-search-summary {
    min-width: 0;
}

.patient-search-summary__primary {
    display: flex;
    align-items: baseline;
    gap: 4px;

    min-width: 0;

    color: #1f3f50;

    font-size: 13px;
    line-height: 1.4;
}

.patient-search-summary__primary strong,
.patient-search-summary__primary span {
    min-width: 0;
}

.patient-search-summary__primary strong {
    flex: 0 0 auto;
    font-size: 14px;
}

.patient-search-summary__primary span:not(.patient-search-summary__approx) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.patient-search-summary__secondary {
    margin-top: 3px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color: #758895;

    font-size: 11px;
    line-height: 1.35;
}

.patient-search-summary__approx {
    flex: 0 0 auto;

    margin-right: 2px;
    padding: 1px 5px;

    border-radius: 999px;

    background: #fff3e7;
    color: #a45b16;

    font-size: 10px;
    font-weight: 800;
}

@media (max-width: 900px) {
    .global-header__search-candidates.mh02-candidate-list {
        width: min(
            560px,
            calc(100vw - 32px)
        );
    }
}


/* DEV-1.14C | Global Search Foundation */

.v2-theme .global-header__search {
    --global-search-shortcut-width:
        84px;
}

.v2-theme .global-header__search-input {
    padding-right:
        calc(
            var(--global-search-shortcut-width)
            + 12px
        );

    border-right:
        1px solid
        var(--v2-color-border);

    border-radius:
        var(--v2-radius-lg);
}

.v2-theme .global-header__search-shortcut {
    position: absolute;
    top: 50%;
    right: 9px;
    z-index: 4;

    width:
        var(--global-search-shortcut-width);
    min-width: 0;
    height: 34px;

    transform:
        translateY(-50%);

    padding:
        0
        10px;

    border:
        1px solid
        var(--v2-color-border-soft);
    border-radius:
        var(--v2-radius-pill);

    background:
        var(--v2-color-surface-muted);
    color:
        var(--v2-color-ink-700);

    box-shadow:
        none;

    font-size:
        var(--v2-font-size-11);
    font-weight:
        var(--v2-font-weight-medium);

    cursor: pointer;
}

.v2-theme .global-header__search-shortcut:hover {
    border-color:
        var(--v2-color-border-strong);

    background:
        var(--v2-color-brand-050);
    color:
        var(--v2-color-brand-900);
}

.v2-theme .global-header__search.is-busy
.global-header__search-shortcut {
    cursor: wait;

    color:
        var(--v2-color-brand-800);
}

.global-header__search-submit-sr {
    position: absolute !important;

    width: 1px !important;
    height: 1px !important;

    padding: 0 !important;
    margin: -1px !important;

    overflow: hidden !important;

    clip: rect(0, 0, 0, 0) !important;
    clip-path: inset(50%) !important;

    border: 0 !important;

    white-space: nowrap !important;
}

.v2-theme .global-header__search-candidates.mh02-candidate-list {
    top:
        calc(100% + 7px);

    max-height:
        min(
            420px,
            calc(100vh - 120px)
        );

    border:
        1px solid
        var(--v2-color-border);
    border-radius:
        var(--v2-radius-lg);

    background:
        var(--v2-color-surface);

    box-shadow:
        var(--v2-shadow-floating);
}

.v2-theme .global-header__search-candidates
.mh02-candidate-list__item {
    min-height: 58px;

    padding:
        9px
        12px;

    border-bottom:
        1px solid
        var(--v2-color-border-soft);
}

.v2-theme .global-header__search-candidates
.mh02-candidate-list__item:last-child {
    border-bottom: 0;
}

.v2-theme .global-header__search-candidates
.mh02-candidate-list__item:hover,
.v2-theme .global-header__search-candidates
.mh02-candidate-list__item.is-active {
    background:
        var(--v2-color-brand-050);
}

.v2-theme .patient-search-summary__primary {
    color:
        var(--v2-color-ink-900);
}

.v2-theme .patient-search-summary__secondary {
    color:
        var(--v2-color-ink-600);
}

.v2-theme .global-search-result__primary {
    display: flex;
    align-items: center;
    gap: 7px;

    min-width: 0;

    color:
        var(--v2-color-ink-900);

    font-size:
        var(--v2-font-size-13);
}

.v2-theme .global-search-result__type {
    flex: 0 0 auto;

    padding:
        2px
        7px;

    border-radius:
        var(--v2-radius-pill);

    background:
        var(--v2-color-brand-100);
    color:
        var(--v2-color-brand-800);

    font-size:
        var(--v2-font-size-10);
    font-weight:
        var(--v2-font-weight-bold);
}

.v2-theme .global-search-result__badge {
    flex: 0 0 auto;

    color:
        var(--v2-color-warning);

    font-size:
        var(--v2-font-size-10);
    font-weight:
        var(--v2-font-weight-bold);
}

.v2-theme .global-search-result__secondary {
    margin-top:
        4px;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    color:
        var(--v2-color-ink-600);

    font-size:
        var(--v2-font-size-11);
}


/* Standalone smoke support */
.global-search-smoke .global-header__search {
    position: relative;

    max-width: 760px;
}

.global-search-smoke .global-header__search-input {
    width: 100%;
    height: 54px;

    padding:
        0
        100px
        0
        18px;

    border:
        1px solid
        var(--v2-color-border);
    border-radius:
        var(--v2-radius-lg);

    background: #fff;

    font:
        14px
        var(--v2-font-sans);
}


/* ============================================================
   DEV-1.14D-2 | Header Search Final Control
   Visible control returns to the V2 dark teal "搜尋" button.
   Ctrl+K remains a keyboard shortcut only.
   ============================================================ */

.v2-theme .global-header__search {
    --global-search-shortcut-width: 82px;
}

.v2-theme .global-header__search-input {
    padding-right: 96px;
}

.v2-theme .global-header__search-submit {
    position: absolute;
    top: 50%;
    right: 6px;
    z-index: 5;

    width: 80px;
    min-width: 80px;
    height: 42px;

    transform: translateY(-50%);

    padding: 0 16px;

    border: 1px solid var(--v2-color-brand-800);
    border-radius: var(--v2-radius-md);

    background:
        linear-gradient(
            180deg,
            var(--v2-color-brand-700) 0%,
            var(--v2-color-brand-900) 100%
        );

    color: #fff;

    box-shadow:
        0 5px 12px
        rgba(2, 74, 89, 0.18);

    font-size: var(--v2-font-size-13);
    font-weight: var(--v2-font-weight-bold);
    line-height: 1;

    cursor: pointer;
}

.v2-theme .global-header__search-submit:hover {
    border-color: var(--v2-color-brand-900);

    background:
        linear-gradient(
            180deg,
            var(--v2-color-brand-800) 0%,
            var(--v2-color-brand-950) 100%
        );

    color: #fff;
}

.v2-theme .global-header__search-submit:focus-visible {
    outline: var(--v2-focus-outline);
    outline-offset: 2px;
}

.v2-theme .global-header__search-submit:disabled {
    opacity: 0.74;
    cursor: wait;
}


/* Standalone DEV smoke compatibility */
.global-search-smoke .global-header__search-submit {
    position: absolute;
    top: 50%;
    right: 6px;

    width: 80px;
    height: 42px;

    transform: translateY(-50%);

    border: 1px solid var(--v2-color-brand-800);
    border-radius: var(--v2-radius-md);

    background: var(--v2-color-brand-800);
    color: #fff;

    font-weight: 700;
}
