/*
 * The Care Desk - prescription medicines editor + Masters page
 * Used by js/rx-medicines.js and js/rx-masters.js
 */

/* ---------- Medicines editor ---------- */

.rx-editor {
    margin-bottom: 1.25rem;
}

.rx-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: .5rem;
}

.rx-head-actions {
    display: flex;
    gap: .5rem;
}

.rx-templates {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: .75rem;
}

/* One medicine per row */
.rx-table {
    border: 1px solid var(--tblr-border-color, #dadfe5);
    border-radius: 6px;
    background: var(--tblr-bg-surface, #fff);
}

.rx-row {
    display: grid;
    grid-template-columns: 32px minmax(200px, 2.4fr) 1fr 1.1fr .8fr 1.4fr 40px;
    gap: 8px;
    align-items: center;
    padding: 6px 8px;
    border-bottom: 1px solid var(--tblr-border-color, #e6e8eb);
}

.rx-row:last-child {
    border-bottom: 0;
}

.rx-row-head {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--tblr-secondary, #667382);
    background: var(--tblr-bg-surface-secondary, #f6f8fb);
    border-radius: 6px 6px 0 0;
}

.rx-row-active {
    background: rgba(32, 107, 196, .04);
}

.rx-num {
    color: var(--tblr-secondary, #667382);
    text-align: center;
}

.rx-cell {
    position: relative;
    min-width: 0;
}

.rx-remove {
    font-size: 20px;
    line-height: 1;
    padding: 2px 8px;
}

/* Medicine search list */
.rx-search {
    position: relative;
}

.rx-search-list {
    position: absolute;
    z-index: 1060;
    top: calc(100% + 4px);
    left: 0;
    width: max(100%, 460px);
    max-width: 90vw;
    background: var(--tblr-bg-surface, #fff);
    border: 1px solid var(--tblr-border-color, #dadfe5);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    overflow: hidden;
}

.rx-search-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
}

.rx-search-item.active {
    background: rgba(32, 107, 196, .1);
}

.rx-search-name {
    font-weight: 500;
}

.rx-search-content {
    color: #0b6bcb;
}

.rx-content {
    margin-top: 3px;
    color: #0b6bcb;
    font-size: 12px;
    font-weight: 500;
}

.rx-search-meta {
    color: var(--tblr-secondary, #667382);
    font-size: 12px;
    text-align: right;
}

.rx-search-add {
    color: var(--tblr-primary, #206bc4);
    border-top: 1px solid var(--tblr-border-color, #e6e8eb);
}

/* Quick buttons */
.rx-quick {
    margin-top: .75rem;
    padding: .5rem .75rem;
    border: 1px solid var(--tblr-border-color, #e6e8eb);
    border-radius: 6px;
    background: var(--tblr-bg-surface-secondary, #fbfcfd);
}

.rx-quick-hint {
    font-size: 12px;
    color: var(--tblr-secondary, #667382);
    margin-bottom: .25rem;
}

.rx-quick-row {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
}

.rx-quick-label {
    flex: none;
    width: 80px;
    padding-top: 4px;
    font-size: 12px;
    color: var(--tblr-secondary, #667382);
}

.rx-templates .rx-quick-label {
    width: auto;
}

.rx-quick-chips {
    display: flex;
    flex-wrap: wrap;
}

.rx-chip {
    border: 1px solid var(--tblr-border-color, #dadfe5);
    background: var(--tblr-bg-surface, #fff);
    color: inherit;
    border-radius: 16px;
    padding: 3px 11px;
    margin: 0 6px 6px 0;
    font-size: 13px;
    line-height: 1.4;
    cursor: pointer;
}

.rx-chip:hover {
    border-color: var(--tblr-primary, #206bc4);
}

.rx-chip.active {
    background: var(--tblr-primary, #206bc4);
    border-color: var(--tblr-primary, #206bc4);
    color: #fff;
}

.rx-chip-template {
    border-style: dashed;
}

.rx-foot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
    margin-top: .75rem;
}

/* Phones / small tablets: each medicine becomes a small card */
@media (max-width: 767.98px) {
    .rx-row {
        grid-template-columns: 1fr 1fr;
        padding: 10px 8px;
    }

    .rx-row-head {
        display: none;
    }

    .rx-num {
        grid-column: 1 / -1;
        text-align: left;
        font-weight: 600;
    }

    .rx-num::before {
        content: "Medicine ";
    }

    .rx-cell-medicine {
        grid-column: 1 / -1;
    }

    .rx-search-list {
        width: 100%;
    }

    .rx-search-item {
        flex-direction: column;
        gap: 2px;
    }

    .rx-search-meta {
        text-align: left;
    }

    .rx-cell-remove {
        grid-column: 1 / -1;
        text-align: right;
    }

    .rx-quick-label {
        width: 64px;
    }
}

/* ---------- Masters page ---------- */

.rxm-tabs .nav-link {
    background: none;
    border-top: 0;
    border-left: 0;
    border-right: 0;
}

.rxm-add {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 1rem;
    max-width: 520px;
}

.rxm-add > input {
    flex: 1 1 160px;
}

.rxm-add-medicine {
    max-width: none;
}

.rxm-add-medicine > input:first-child {
    flex: 2 1 220px;
}

.rxm-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: .75rem;
}

.rxm-toolbar input[type="search"] {
    max-width: 280px;
}

.rxm-table td,
.rxm-table th {
    padding-left: .5rem;
    padding-right: .5rem;
}

.rxm-off td {
    opacity: .55;
}
