/* ==========================================================================
   In-patient department: ward board, room detail, admission, billing and the
   shared charge ledger screens. Fixed-pixel like the rest of the suite so
   browser zoom scales the layout instead of rearranging it.
   ========================================================================== */

/* ---------------------------------------------------------------- listing grid */

.ipd-grid {
    display: flex;
    flex-direction: column;
    border: 1px solid #7ba7cd;
    background: #fff;
    margin: 6px 0;
    min-height: 0;
    overflow-x: auto;
}

.ipd-grid-short .ipd-body { max-height: 156px; }

.ipd-caption {
    background: linear-gradient(#4f8fc0, #2f6f9f);
    color: #fff;
    font-weight: 600;
    font-size: 12px;
    padding: 3px 8px;
    flex: 0 0 auto;
}

.ipd-head,
.ipd-row {
    display: flex;
    align-items: stretch;
    font-size: 12px;
    /* Wider than the pane, the row keeps its real width and the grid scrolls to it. Narrower,
       and the row still fills the pane so the wide column takes up the slack. */
    min-width: max-content;
}

.ipd-head {
    background: linear-gradient(#eef5fb, #d8e8f5);
    border-bottom: 1px solid #7ba7cd;
    font-weight: 600;
    /* Keeps the header aligned with the rows once the body grows a scrollbar. */
    scrollbar-gutter: stable;
    overflow-y: scroll;
    scrollbar-width: none;
    /* Declaring overflow drops a flex item's automatic minimum size to zero, so a
       screen too short for its content would otherwise squeeze the headings to half
       a line. The rows scroll instead - the headings always read in full. */
    flex: 0 0 auto;
}

.ipd-head::-webkit-scrollbar { width: 0; }

.ipd-body {
    overflow-y: auto;
    max-height: 320px;
    scrollbar-gutter: stable;
    flex: 1 1 auto;
    min-height: 0;
}

.ipd-row { border-bottom: 1px solid #e3edf5; cursor: pointer; }
.ipd-row:hover { background: #eaf4fd; }
.ipd-row-selected,
.ipd-row-selected:hover { background: #2f6f9f; color: #fff; }
.ipd-row-current { background: #f2fbe9; }

.ipd-col {
    padding: 3px 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-right: 1px solid #e3edf5;
    /* A column given a width keeps it. Letting these shrink is what clipped a date to
       "28-Jul-26 2..." and pushed the last column off the panel when a grid sat in a narrow
       pane; the wide column below opts back in and absorbs the slack instead. */
    flex-shrink: 0;
}

.ipd-col-sr        { width: 62px; text-align: right; }
.ipd-col-mr        { width: 92px; }
.ipd-col-name      { width: 186px; }
.ipd-col-consultant{ width: 176px; }
.ipd-col-room      { width: 128px; }
.ipd-col-ward      { width: 150px; }
.ipd-col-cat       { width: 148px; }
.ipd-col-status    { width: 96px; }
.ipd-col-src       { width: 104px; }
.ipd-col-date      { width: 142px; }
.ipd-col-user      { width: 132px; }
.ipd-col-contact   { width: 156px; }
.ipd-col-amount    { width: 106px; text-align: right; }
.ipd-col-wide      { flex: 1 1 auto; min-width: 150px; }
.ipd-col-open      { width: 84px; text-align: center; }
.ipd-col-balance   { background: #fffbe6; font-weight: 600; }
.ipd-row-selected .ipd-col-balance { background: transparent; }

.ipd-foot {
    background: linear-gradient(#eef5fb, #d8e8f5);
    border-top: 1px solid #7ba7cd;
    padding: 3px 8px;
    font-size: 11px;
    flex: 0 0 auto;
}

/* Always visible - a row action a clerk has to hover to find is one that is never used. */
.ipd-open-btn {
    font-size: 11px;
    padding: 0 6px;
    border: 1px solid #7ba7cd;
    border-radius: 3px;
    background: linear-gradient(#fbfdff, #e4eff8);
    cursor: pointer;
}

.ipd-open-btn:hover { background: linear-gradient(#fff, #cfe4f5); }

/* ---------------------------------------------------------------- ward filter */

.ipd-ward-filter { display: flex; flex-wrap: wrap; gap: 5px; }

.ipd-ward-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 2px 9px;
    border: 1px solid #7ba7cd;
    border-radius: 11px;
    background: linear-gradient(#fbfdff, #e4eff8);
    cursor: pointer;
}

.ipd-ward-chip-on { background: #2f6f9f; color: #fff; border-color: #24587f; }
.ipd-ward-count { font-size: 11px; opacity: .8; }

/* ---------------------------------------------------------------- bed status */

.ipd-bed {
    display: inline-block;
    min-width: 74px;
    text-align: center;
    font-size: 11px;
    padding: 0 6px;
    border-radius: 3px;
}

.ipd-bed-vacant      { background: #d9f2cf; color: #24571a; }
.ipd-bed-occupied    { background: #ffd9d9; color: #7a1f1f; }
.ipd-bed-maintenance { background: #ffeec2; color: #7a5a10; }

/* ---------------------------------------------------------------- source chips */

.ipd-src {
    display: inline-block;
    min-width: 82px;
    text-align: center;
    font-size: 11px;
    padding: 0 5px;
    border-radius: 3px;
    background: #e8eef4;
    color: #2a4a63;
}

.ipd-src-outpatient { background: #dbeaf7; color: #14456d; }
.ipd-src-emergency  { background: #ffdcdc; color: #7a1f1f; }
.ipd-src-inpatient  { background: #e2dcf7; color: #3b2a7a; }
.ipd-src-pharmacy   { background: #d9f2cf; color: #24571a; }
.ipd-src-radiology  { background: #ffeec2; color: #7a5a10; }
.ipd-src-laboratory { background: #cfeff0; color: #14595c; }
.ipd-src-payment    { background: #efefef; color: #444; }

/* ---------------------------------------------------------------- admission form */

.ipd-admit-form { display: flex; gap: 12px; }
.ipd-admit-left,
.ipd-admit-right { flex: 1 1 0; min-width: 0; }

.sp-grow { flex: 1 1 auto; min-width: 220px; }
.entry-select-grow { flex: 1 1 auto; min-width: 220px; }

/* ---------------------------------------------------------------- bill screens */

.ipd-bill-head { display: flex; gap: 12px; align-items: flex-start; }
.ipd-bill-head .admitted-detail-grid { flex: 1 1 auto; }

.ipd-bill-room {
    text-align: right;
    font-weight: 600;
    color: #a02020;
    font-size: 12px;
    white-space: nowrap;
}

.ipd-bill-body { display: flex; gap: 12px; align-items: flex-start; }
.ipd-bill-heads { flex: 1 1 auto; border: 1px solid #7ba7cd; background: #fff; min-width: 0; }
.ipd-bill-summary { width: 320px; border: 1px solid #7ba7cd; background: #fff; }

.ipd-bill-line {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 8px;
    font-size: 12px;
    border-bottom: 1px solid #e3edf5;
    cursor: pointer;
}

.ipd-bill-line:hover { background: #eaf4fd; }
.ipd-bill-line-on { background: #e4eff8; font-weight: 600; }
.ipd-bill-label { flex: 1 1 auto; }
.ipd-bill-value { width: 96px; text-align: right; background: #fffbe6; padding: 0 5px; }
.ipd-bill-drill { width: 18px; text-align: center; opacity: .55; }

.ipd-bill-drilldown { background: #f7fbff; border-bottom: 1px solid #e3edf5; }

.ipd-bill-drill-row {
    display: flex;
    gap: 8px;
    font-size: 11px;
    padding: 1px 8px 1px 22px;
    border-bottom: 1px dotted #dce8f2;
}

.ipd-drill-date { width: 108px; }
.ipd-drill-src  { width: 84px; }
.ipd-drill-code { width: 72px; }
.ipd-drill-desc { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ipd-drill-qty  { width: 44px; text-align: right; }
.ipd-drill-amt  { width: 82px; text-align: right; }

.ipd-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    padding: 3px 8px;
    border-bottom: 1px solid #e3edf5;
}

.ipd-total-strong { font-weight: 600; background: #dbeaf7; }
.ipd-total-advance { background: #ffe0e6; }
.ipd-total-receivable { background: #ddf3d6; font-weight: 600; }
.ipd-balance { font-weight: 600; }

.ipd-bill-note {
    padding: 6px 8px;
    font-size: 11px;
    color: #55707f;
    line-height: 1.35;
}

/* ---------------------------------------------------------------- service & order screens */

.ipd-service-layout { display: flex; gap: 12px; align-items: flex-start; }
.ipd-service-layout > .ipd-grid { width: 470px; flex: 0 0 auto; }
.ipd-service-input { flex: 1 1 auto; min-width: 0; }

.ipd-patient-band { display: flex; gap: 12px; align-items: flex-start; }
.ipd-patient-band .admitted-detail-grid { flex: 1 1 auto; }

.ipd-collection-layout { display: flex; gap: 12px; align-items: flex-start; }
.ipd-collection-layout > .ipd-grid { flex: 1 1 0; min-width: 0; }

/* ---------------------------------------------------------------- dashboard widget */

.info-box-ipd { font-size: 11px; }

.ipd-widget-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 1px 0;
}

.ipd-widget-label { opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ipd-widget-value { font-weight: 600; white-space: nowrap; }

.ipd-widget-sep {
    margin-top: 5px;
    padding-top: 3px;
    border-top: 1px solid rgba(255, 255, 255, .25);
    font-weight: 600;
}

.ipd-widget-ward { margin-top: 3px; }
.ipd-widget-ward-head { display: flex; justify-content: space-between; gap: 8px; }

.ipd-widget-bar {
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, .25);
    overflow: hidden;
}

.ipd-widget-bar-fill { height: 100%; background: #F0A93B; }

/* Discharge settlement: the box the desk types what it took into, sitting with the totals. */
.ipd-total-settle .ipd-total-input { width: 84px; text-align: right; }
.ipd-total-settle .ipd-total-option { width: 74px; margin-left: 4px; }
