@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* ============================================================
   SAMH Treatment — global styling.

   Everything here is app-wide on purpose. Blazor scoped CSS
   (Component.razor.css) is the right home for anything one
   component owns; this file holds the pieces that must look
   identical wherever they appear — the data grid above all,
   which is the single biggest source of visual drift once two
   pages start styling their own tables.
   ============================================================ */

html,
body {
    background: #eef3f8;
    color: #243447;
    font-family: Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14.5px;
    max-width: 100%;
    overflow-x: hidden;
}

h1:focus {
    outline: none;
}

a,
.btn-link {
    color: #15588e;
}

.btn {
    border-radius: 5px;
    font-weight: 700;
}

.btn-primary {
    background-color: #15588e;
    border-color: #15588e;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #0f4775;
    border-color: #0f4775;
}

.content {
    padding-top: 1.5rem;
}

/* ---- Page headings ---- */
.page-heading {
    align-items: flex-end;
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.eyebrow {
    color: #488f4d;
    font-size: .78rem;
    font-weight: 900;
    letter-spacing: .08em;
    margin: 0 0 .2rem;
    text-transform: uppercase;
}

.page-heading h2 {
    color: #0b2e63;
    font-size: clamp(1.55rem, 2.2vw, 2.15rem);
    font-weight: 900;
    letter-spacing: 0;
    margin: 0;
}

.page-description {
    color: #526272;
    font-size: .98rem;
    line-height: 1.55;
    margin: .45rem 0 0;
    max-width: 54rem;
}

/* ---- Forms ---- */
.form-label {
    color: #334155;
    font-weight: 800;
}

.form-control {
    border-radius: 5px;
}

.form-control:focus {
    border-color: #15588e;
    box-shadow: 0 0 0 .2rem rgba(21, 88, 142, .16);
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #b32121;
}

.validation-message {
    color: #b32121;
}

/* ---- Status badge (a heading's companion, not a grid cell) ---- */
.status-badge {
    background: #e9f6ec;
    border: 1px solid #b7dec0;
    border-radius: 999px;
    color: #276832;
    font-size: .78rem;
    font-weight: 800;
    padding: .3rem .65rem;
    white-space: nowrap;
}

/* ============================================================
   IN-PAGE MESSAGE BANNER
   Errors, save confirmations and longer advisory notices. Full
   width and left-aligned, because every use is a page-level
   banner rather than a one-line status.
   ============================================================ */

.status-bar {
    align-items: flex-start;
    background: #eaf7fb;
    border: 1px solid #b9e7f3;
    border-radius: 6px;
    color: #07516c;
    display: flex;
    font-weight: 700;
    gap: .6rem;
    justify-content: flex-start;
    line-height: 1.4;
    min-height: 2.8rem;
    padding: .7rem .9rem;
    width: 100%;
}

.status-dot {
    background: #1f9d55;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(31, 157, 85, .14);
    flex: 0 0 auto;
    height: .55rem;
    /* Nudged down to sit on the first line of text — a centred dot floats oddly
       beside a three-line message. */
    margin-top: .4rem;
    width: .55rem;
}

.status-bar.is-working .status-dot {
    animation: status-pulse 1.2s ease-in-out infinite;
    background: #0b6aa2;
}

.status-bar.is-success {
    background: #ebf8ee;
    border-color: #b7dec0;
    color: #276832;
}

.status-bar.is-warning {
    background: #fff9e9;
    border-color: #eadca7;
    color: #704b12;
}

.status-bar.is-warning .status-dot {
    background: #b7791f;
    box-shadow: 0 0 0 4px rgba(183, 121, 31, .12);
}

.status-bar.is-error {
    background: #fff1f1;
    border-color: #efc0c0;
    color: #8b1d1d;
}

.status-bar.is-error .status-dot {
    background: #b32121;
    box-shadow: 0 0 0 4px rgba(179, 33, 33, .12);
}

@keyframes status-pulse {
    50% {
        opacity: .45;
        transform: scale(.82);
    }
}

/* Banners stack: a month can be Submitted AND have a reopen request
   waiting, and each says something different. */
.status-bar + .status-bar { margin-top: .5rem; }

/* The message grows; the buttons stay together at the right. */
.status-text { flex: 1 1 auto; }

/* Somebody else's words - a justification or a denial reason - set apart
   from the application's own, so it is clear who is speaking. */
.status-quote {
    display: block;
    font-style: italic;
    font-weight: 600;
    margin-top: .2rem;
    white-space: pre-line;
}

.status-actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: .5rem;
    margin-left: auto;
}

/* ---- Standards flags in a grid cell ----
   is-bad   blocks submission (an abbreviated address)
   is-check advisory, for the reviewer (a facility name that may be abbreviated) */
.cell-flag {
    align-items: center;
    display: inline-flex;
    font-size: .74rem;
    font-weight: 700;
    gap: .3rem;
    margin-top: .15rem;
}

.cell-flag.is-bad   { color: #a02b25; }
.cell-flag.is-check { color: #8a5b12; }

/* Free text in a grid cell - a justification, a denial reason. Wraps rather
   than truncating like .cell-sub, because the words ARE the content, and is
   capped so one long reason does not stretch the whole table. */
.cell-wrap {
    color: #334155;
    font-size: .85rem;
    max-width: 28rem;
    min-width: 12rem;
    white-space: pre-line;
}

/* ---- Auth / notice panel ---- */
.auth-message-panel {
    background: #ffffff;
    border: 1px solid #d7e0ea;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(15, 40, 64, .08);
    margin: 0 auto;
    max-width: 48rem;
    padding: 1.5rem;
}

.auth-message-panel h2 {
    color: #0b2e63;
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 0;
    margin: 0 0 .4rem;
}

.auth-message-panel h2 i {
    margin-right: .5rem;
}

.auth-message-panel p {
    color: #526272;
    line-height: 1.55;
    margin: 0 0 1rem;
}

.auth-message-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
}

/* ============================================================
   PRE-LOGIN HERO
   The landing screen for an anonymous visitor.

   The negative margins cancel .app-main's padding (1.5rem 2rem
   3rem, in MainLayout.razor.css) so the banner spans the full
   width of the content area rather than sitting in a padded box
   with white gutters. KEEP THE TWO IN SYNC — if that padding
   changes, these margins have to change with it.
   ============================================================ */

.pre-login {
    display: flex;
    justify-content: center;
    margin: -1.5rem -2rem 0;
    overflow: hidden;
}

/* The artwork is a wide banner (roughly 8:3). Width-driven rather than
   height-capped: letting it fill the content area keeps the title legible,
   and the height follows. max-height is a guard for very wide monitors, where
   an unconstrained banner would push everything below it off screen. */
.pre-login-hero {
    display: block;
    height: auto;
    max-height: 62vh;
    max-width: 100%;
    object-fit: cover;
    width: 100%;
}

.pre-login-actions {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 2.25rem 1rem 1rem;
    text-align: center;
}

.pre-login-lead {
    color: #526272;
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 0;
    max-width: 38rem;
}

.pre-login-actions .btn-lg {
    padding: .7rem 1.75rem;
}

@media (max-width: 800px) {
    /* .app-main drops to 1rem padding at this width. */
    .pre-login {
        margin: -1rem -1rem 0;
    }

    .pre-login-hero {
        max-height: none;
    }

    .pre-login-actions {
        padding-top: 1.75rem;
    }
}

/* ============================================================
   CARD SHELL
   The container every list and detail page sits in: gradient
   header band, white body, one shadow. Global rather than
   per-page so a new page cannot invent a second card look.
   ============================================================ */

.list-card {
    background: #ffffff;
    border: 1px solid #d7e0ea;
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(15, 40, 64, .08);
    overflow: hidden;
}

.list-card-header {
    align-items: center;
    background: linear-gradient(180deg, #eef4fb, #e6eefa);
    border-bottom: 1px solid #d7e0ea;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    padding: 1rem 1.25rem;
}

.list-card-header h2 {
    color: #0b2e63;
    font-size: 1.3rem;
    font-weight: 900;
    margin: 0;
}

.list-card-header h2 > i {
    color: #15588e;
    margin-right: .5rem;
}

/* ---- Toolbar (filters + search) ---- */
.list-toolbar {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    padding: 1rem 1.25rem;
}

.list-toolbar .form-select {
    max-width: 15rem;
}

.search-box {
    flex: 1 1 16rem;
    position: relative;
}

.search-box .fa-magnifying-glass {
    color: #94a3b8;
    left: .8rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.search-box .form-control {
    padding-left: 2.2rem;
}

/* ============================================================
   MONTH BAR
   The strip above a grid that scopes what is on screen — which
   Managing Entity, which month — plus the actions that act on
   it. Shared by the entry screen and the months list, so it
   lives here rather than in either one's scoped stylesheet.
   ============================================================ */

.month-bar {
    align-items: flex-end;
    background: #fff;
    border: 1px solid #d7e0ea;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(15, 40, 64, .06);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
}

.month-field {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    min-width: 0;
}

.month-field .form-label {
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .06em;
    margin: 0;
    text-transform: uppercase;
}

.month-field .form-select,
.month-field .form-control {
    min-width: 12rem;
}

/* Derived values — fiscal year, status, the ME an ME user is fixed to — read
   as data rather than as inputs somebody could change. */
.month-field.is-static {
    justify-content: flex-end;
    padding-bottom: .4rem;
}

.month-static {
    color: #0b2e63;
    font-size: .95rem;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
}

/* Pushed to the right edge, so actions never sit among the selectors. */
.month-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    margin-left: auto;
}

/* Secondary text beside a card heading — the ME name, usually. */
.card-sub {
    color: #64748b;
    font-size: .85rem;
    font-weight: 600;
    margin-left: .6rem;
}

/* Figures summarised in a card header. */
.totals {
    color: #526272;
    font-size: .88rem;
    font-variant-numeric: tabular-nums;
}

.totals strong {
    color: #0b2e63;
}

/* Bed counts and other figures line up down the column. A proportional font
   makes a column of numbers impossible to scan. */
.num {
    font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
    .month-actions {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 560px) {
    .month-field {
        flex: 1 1 100%;
    }

    .month-field .form-select,
    .month-field .form-control {
        min-width: 0;
        width: 100%;
    }
}

/* ============================================================
   SHARED DATA-GRID STYLING
   Apply to a table:  class="table data-table"
   and to its head:   class="custom-table-header"
   Optionally wrap in: <div class="data-table-wrap">

   NOTE ON SPECIFICITY: Bootstrap paints cell backgrounds through
   `.table > :not(caption) > * > *` (--bs-table-bg), which beats a
   plain `tr` background. The striping/hover rules below therefore
   target `> td` so they actually win, and hover is declared after
   striping so it takes precedence on equal specificity.
   ============================================================ */

/* Navy header band. */
.custom-table-header {
    background-color: #183866 !important;
    color: #ffffff !important;
}

.custom-table-header th {
    background-color: #183866 !important;
    border-color: #183866 !important;
    color: #ffffff !important;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
    padding: .7rem .75rem;
    vertical-align: middle;
    white-space: nowrap;
}

/* Header icons sit just before the label. */
.custom-table-header th > i,
.custom-table-header th > .fa-solid,
.custom-table-header th > .fa-regular {
    margin-right: .4rem;
    opacity: .95;
}

/* Sortable headers. */
.custom-table-header th[role="button"] {
    cursor: pointer;
    user-select: none;
}

.custom-table-header th[role="button"]:hover {
    background-color: #1f4a80 !important;
}

.custom-table-header th .fa-sort {
    opacity: .55;
}

/* ---- Body ---- */
.data-table {
    margin-bottom: 0;
    width: 100%;
}

.data-table > tbody > tr > td {
    border-top: 1px solid #e8edf3;
    padding: .6rem .75rem;
    vertical-align: middle;
}

/* Zebra striping. */
.data-table > tbody > tr:nth-of-type(even) > td {
    background-color: #f5f8fc;
}

/* Hover — declared after striping so it wins. */
.data-table > tbody > tr:hover > td {
    background-color: #e9f1fb;
}

/* Rounded, clipped container with a subtle lift. */
.data-table-wrap {
    background: #fff;
    border: 1px solid #d7e0ea;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(15, 40, 64, .06);
    overflow: auto;
}

/* Scrollable variant keeps the navy header pinned. */
.data-table-wrap.is-scrollable {
    max-height: 24rem;
}

.data-table-wrap.is-scrollable .custom-table-header th {
    position: sticky;
    top: 0;
    z-index: 2;
}

/* ---- Cell decorations ---- */
/* Pill for identifiers (episode #, provider id, …). */
.cell-id {
    background: #eef2f7;
    border: 1px solid #d7e0ea;
    border-radius: 5px;
    color: #183866;
    display: inline-block;
    font-size: .78rem;
    font-weight: 700;
    padding: .18rem .5rem;
    text-decoration: none;
    white-space: nowrap;
}

a.cell-id:hover {
    background: #dfe8f4;
    color: #0b2e63;
}

/* DCF blue variant — episode numbers and other primary identifiers. */
.cell-id.is-blue {
    background: #003467;
    border-color: #003467;
    color: #fff;
}

a.cell-id.is-blue:hover {
    background: #002748;
    border-color: #002748;
    color: #fff;
}

/* Green variant. Deliberately kept apart from the blue one: they are different
   things, and one colour for both makes a provider id look like an episode
   number in a grid that shows both. */
.cell-id.is-green {
    background: #48854d;
    border-color: #48854d;
    color: #fff;
}

a.cell-id.is-green:hover {
    background: #3b6f3f;
    border-color: #3b6f3f;
    color: #fff;
}

/* Stops a short column being widened by its own heading. A table lays out to
   fit the widest cell in each column, header included, so a long heading over a
   column of four-character values reserves space the values never use. Not a
   fixed width: this caps what the header can claim and lets the content decide
   the rest. */
.data-table th.col-narrow {
    width: 1%;
    white-space: nowrap;
}

/* A date as a rounded pill, for grids where a column of plain MM/dd/yyyy takes
   more width than the value deserves. Fully rounded rather than the 5px of
   .cell-id, so a date is distinguishable from an identifier without reading it.
   Tabular figures keep the columns of digits aligned down the grid. */
.date-pill {
    background: #eef4fb;
    border: 1px solid #d7e0ea;
    border-radius: 999px;
    color: #31465c;
    display: inline-block;
    font-size: .74rem;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    padding: .12rem .5rem;
    white-space: nowrap;
}

/* Emphasised primary column (names/titles). */
.cell-strong {
    color: #1f2937;
    font-weight: 700;
}

/* Two values in one cell: the second line set small and grey, so a row still
   scans as one line of information rather than two. */
.cell-stack {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.cell-sub {
    color: #64748b;
    font-size: .74rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Nothing to show yet. Same grey as the amount column's empty state, so a blank
   cell reads the same way wherever it appears. */
.cell-none {
    color: #94a3b8;
}

/* Green pill for money in a grid. Tabular numerals keep the digits aligned down
   the column despite the pill background. */
.cell-amount {
    background: #48854d;
    border-radius: 999px;
    color: #ffffff;
    display: inline-block;
    font-size: .78rem;
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    padding: .2rem .65rem;
    white-space: nowrap;
}

/* No amount recorded. A green pill around a blank reads as a real figure of
   zero, so an absent value drops the pill and shows a muted dash. */
.cell-amount.is-none {
    background: transparent;
    color: #a3adba;
    font-weight: 500;
    padding-left: 0;
    padding-right: 0;
}

/* Solid pill — counts. */
.count-badge {
    background: #48854d;
    border-radius: 5px;
    color: #fff;
    display: inline-block;
    font-size: .76rem;
    font-weight: 700;
    min-width: 1.9rem;
    padding: .16rem .45rem;
    text-align: center;
}

/* ---- Status badges (grid cells) ----
   One colour per state, used by every grid so a status means the same thing
   wherever it is read. */
.badge-status {
    border-radius: 999px;
    display: inline-block;
    font-size: .76rem;
    font-weight: 700;
    padding: .22rem .6rem;
    white-space: nowrap;
}

.badge-status.is-active    { background: #dcfce7; color: #14653a; }
.badge-status.is-pending   { background: #fdf0d5; color: #8a5b12; }
.badge-status.is-closed    { background: #e8eef6; color: #33507a; }
.badge-status.is-attention { background: #fdecea; color: #a02b25; }
.badge-status.is-review    { background: #e0ecfb; color: #15588e; }

/* Muted "empty grid" row. */
.data-table .grid-empty {
    color: #64748b;
    padding: 2rem .75rem;
    text-align: center;
}

/* ---- Row actions ---- */
.grid-actions {
    display: inline-flex;
    gap: .35rem;
    white-space: nowrap;
}

.btn-grid {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 5px;
    display: inline-flex;
    font-size: .8rem;
    font-weight: 600;
    gap: .3rem;
    line-height: 1.2;
    padding: .3rem .6rem;
    text-decoration: none;
}

.btn-grid-view {
    background: #1268c3;
    border-color: #1268c3;
    color: #fff;
}

.btn-grid-view:hover {
    background: #0f579f;
    color: #fff;
}

/* DCF blue — the "work on this row" action. */
.btn-grid-edit {
    background: #fff;
    border-color: #003467;
    color: #003467;
}

.btn-grid-edit:hover {
    background: #e9f3ff;
    border-color: #002748;
    color: #002748;
}

.btn-grid-danger {
    background: #fff;
    border-color: #c1362f;
    color: #c1362f;
}

.btn-grid-danger:hover {
    background: #fdecea;
    color: #a02b25;
}

/* ---- Footer: "Showing 1 to 10 of N entries" + pagination ---- */
.grid-footer {
    align-items: center;
    border-top: 1px solid #eef2f7;
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    justify-content: space-between;
    padding: .85rem 1.25rem;
}

.grid-footer .grid-count {
    color: #526272;
    font-size: .88rem;
}

.grid-footer .grid-count strong {
    color: #183866;
}

/* ============================================================
   CIRCUIT FAILURE
   Shown when an unhandled exception has killed the circuit.
   Everything on the page still looks normal at that point but
   nothing responds, so this bar is the only thing saying why.

   Block layout, not flex: Blazor reveals it by setting an inline
   style.display = "block", which beats anything declared here.
   Above SweetAlert2 (1060) on purpose — if a dialog is open when
   the circuit dies, the dialog is the dead thing and this has to
   be readable over it.
   ============================================================ */

#blazor-error-ui {
    background: #8a1c16;
    bottom: 0;
    box-shadow: 0 -2px 14px rgba(0, 0, 0, .35);
    color: #ffffff;
    display: none;
    font-size: 1rem;
    font-weight: 600;
    left: 0;
    padding: .9rem 3rem 1rem 1.25rem;
    position: fixed;
    text-align: center;
    width: 100%;
    z-index: 2000;
}

#blazor-error-ui .reload {
    background: #ffffff;
    border-radius: 6px;
    color: #8a1c16;
    display: inline-block;
    font-weight: 700;
    margin-left: 1rem;
    padding: .35rem .95rem;
    text-decoration: none;
    white-space: nowrap;
}

#blazor-error-ui .reload:hover {
    background: #ffe9e7;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
    top: .5rem;
}

.blazor-error-boundary {
    background: #b32121;
    color: #ffffff;
    padding: 1rem;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ---- DCF footer ---- */
.dcf-ext-template-footer {
    background-color: #003467 !important;
    color: #ffffff !important;
}

.dcf-ext-template-prefooter-row {
    background-color: #003467 !important;
}

.dcf-ext-template-edgesection {
    background-color: #115ba4 !important;
    color: #ffffff !important;
}

.dcf-ext-template-footer h5,
.dcf-ext-template-footer a.dcf-ext-template-link {
    color: #ffffff !important;
}

.dcf-ext-template-footer a.dcf-ext-template-link:hover {
    color: #e9f3ff !important;
}

.emergency-card {
    background-color: #ffffff !important;
    color: #243447 !important;
}

.emergency-card-header {
    background-color: #951c1a !important;
    color: #ffffff !important;
}

.emergency-card .list-group-item {
    background-color: #ffffff !important;
    color: #243447 !important;
}
