/* On call (Pages/OnCall/*, Shared/BranchOpeningHoursDialog.razor, Shared/CopyRotaWeekDialog.razor).
   Green is covered, red is nobody, amber is "no backup", grey is hours that don't apply. The same colours
   as the rest of the app's status chips. */

.oncall {
    --oc-ok: #0f9d63;
    --oc-bad: #d92d20;
    --oc-warn: #d97706;
    --oc-grey: #94a3b8;
    --oc-line: #e6ebf2;
    --oc-ink: #1f2937;
    --oc-muted: #64748b;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.oncall-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.oncall-branch-select {
    min-width: 200px;
}

.oncall-muted {
    color: var(--oc-muted);
}

.oncall-panel {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ---- Who is on call now ---- */

.oncall-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.oncall-card {
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-left: 4px solid var(--oc-grey);
}

.oncall-card--closed {
    border-left-color: var(--oc-warn);
}

.oncall-card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.oncall-card-name {
    font-weight: 700;
    font-size: 1.05rem;
}

.oncall-badge {
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid;
}

.oncall-badge--open {
    color: #0b7a4d;
    background: rgba(15, 157, 99, 0.1);
    border-color: rgba(15, 157, 99, 0.3);
}

.oncall-badge--closed {
    color: #92600a;
    background: rgba(217, 119, 6, 0.1);
    border-color: rgba(217, 119, 6, 0.3);
}

.oncall-badge--unset {
    color: #4a5768;
    background: #f1f4f9;
    border-color: #dde3ec;
}

.oncall-seat {
    display: grid;
    grid-template-columns: 130px 1fr;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--oc-line);
}

.oncall-seat-role {
    display: flex;
    flex-direction: column;
    font-weight: 600;
}

.oncall-seat-role small,
.oncall-seat-person small {
    font-weight: 400;
    color: var(--oc-muted);
}

.oncall-seat-person {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.oncall-phone {
    color: inherit;
    text-decoration: underline;
}

.oncall-nobody {
    color: var(--oc-muted);
}

.oncall-nobody--closed {
    color: var(--oc-bad);
    font-weight: 600;
}

.oncall-shift-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.oncall-shift {
    display: grid;
    grid-template-columns: 110px 1fr auto;
    gap: 12px;
    padding: 8px 0;
    border-top: 1px solid var(--oc-line);
}

.oncall-shift:first-child {
    border-top: none;
}

.oncall-shift-role {
    font-weight: 600;
}

.oncall-shift-branch {
    color: var(--oc-muted);
}

/* ---- Settings ---- */

.oncall-branch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--oc-line);
}

.oncall-branch-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.oncall-branch-name {
    font-weight: 600;
}

.oncall-branch-state {
    color: var(--oc-muted);
    font-size: 0.875rem;
}

.oncall-branch-state--off {
    color: var(--oc-warn);
}

.hours-row {
    display: grid;
    grid-template-columns: 110px 56px 1fr 1fr;
    align-items: center;
    gap: 8px;
}

.hours-day {
    font-weight: 600;
}

.hours-closed {
    grid-column: span 2;
    color: var(--oc-muted);
}

/* ---- The rota grid ---- */

.oncall-summary {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.oncall-chip {
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    border: 1px solid;
}

.oncall-chip--ok { color: #0b7a4d; background: rgba(15, 157, 99, 0.1); border-color: rgba(15, 157, 99, 0.3); }
.oncall-chip--bad { color: #b42318; background: rgba(217, 45, 32, 0.08); border-color: rgba(217, 45, 32, 0.3); }
.oncall-chip--warn { color: #92600a; background: rgba(217, 119, 6, 0.1); border-color: rgba(217, 119, 6, 0.3); }

.oncall-selection {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 16px;
    position: sticky;
    top: 8px;
    z-index: 3;
}

.oncall-selection-text {
    flex: 1 1 200px;
}

.oncall-person-select {
    min-width: 240px;
}

.oncall-grid-wrap {
    overflow-x: auto;
    border: 1px solid var(--oc-line);
    border-radius: 10px;
    background: var(--mud-palette-surface, #fff);
}

.oncall-grid {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    min-width: calc(150px + var(--oncall-days, 7) * 132px);
    table-layout: fixed;
}

.oncall-grid th,
.oncall-grid td {
    border-bottom: 1px solid var(--oc-line);
    border-right: 1px solid var(--oc-line);
    vertical-align: top;
    padding: 6px;
}

.oncall-grid tr:last-child th,
.oncall-grid tr:last-child td {
    border-bottom: none;
}

.oncall-grid-corner,
.oncall-role-head {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 150px;
    background: var(--mud-palette-surface, #fff);
    text-align: left;
}

.oncall-role-head {
    display: table-cell;
    font-weight: 600;
}

.oncall-role-head small {
    display: block;
    font-weight: 400;
    color: var(--oc-muted);
    font-size: 0.75rem;
}

.oncall-day-head {
    text-align: left;
    font-weight: 600;
    font-size: 0.8125rem;
    background: #f8fafc;
}

.oncall-day-head--today {
    box-shadow: inset 0 -3px 0 var(--mud-palette-primary, #2563eb);
}

.oncall-day-head--weekend,
.oncall-cell--weekend {
    background-color: rgba(100, 116, 139, 0.05);
}

.oncall-day-name {
    display: block;
}

.oncall-day-holiday {
    display: block;
    font-weight: 500;
    color: #92600a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.oncall-cell {
    min-height: 56px;
}

.oncall-seg {
    display: flex;
    flex-direction: column;
    gap: 3px;
    width: 100%;
    margin-bottom: 4px;
    padding: 5px 7px;
    text-align: left;
    font: inherit;
    font-size: 0.8125rem;
    color: var(--oc-ink);
    background: #fff;
    border: 1px solid var(--oc-line);
    border-left-width: 4px;
    border-radius: 6px;
    cursor: pointer;
}

.oncall-seg:last-child {
    margin-bottom: 0;
}

.oncall-seg--ok { border-left-color: var(--oc-ok); background: rgba(15, 157, 99, 0.06); }
.oncall-seg--bad { border-left-color: var(--oc-bad); background: rgba(217, 45, 32, 0.06); }
.oncall-seg--warn { border-left-color: var(--oc-warn); background: rgba(217, 119, 6, 0.07); }

.oncall-seg--selected {
    outline: 2px solid var(--mud-palette-primary, #2563eb);
    outline-offset: 1px;
}

.oncall-seg--past {
    opacity: 0.5;
    cursor: default;
}

.oncall-seg:focus-visible {
    outline: 2px solid var(--mud-palette-primary, #2563eb);
}

.oncall-seg-label {
    font-size: 0.72rem;
    color: var(--oc-muted);
}

.oncall-slice {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    font-weight: 700;
}

.oncall-slice small {
    font-weight: 400;
    color: var(--oc-muted);
}

.oncall-slice--gap {
    color: #b42318;
}

.oncall-slice--unreachable {
    color: #92600a;
    text-decoration: line-through;
}

.oncall-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.8125rem;
    color: var(--oc-muted);
}

.oncall-key {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 3px;
}

.oncall-key--ok { background: var(--oc-ok); }
.oncall-key--bad { background: var(--oc-bad); }
.oncall-key--warn { background: var(--oc-warn); }
.oncall-key--unreachable { background: var(--oc-warn); opacity: 0.5; }

/* ---- The app bar chip ---- */

.oncall-now-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    border: 1px solid;
}

.oncall-now-chip--covered {
    color: #92600a;
    background: rgba(217, 119, 6, 0.1);
    border-color: rgba(217, 119, 6, 0.3);
}

.oncall-now-chip--nobody {
    color: #b42318;
    background: rgba(217, 45, 32, 0.08);
    border-color: rgba(217, 45, 32, 0.35);
}

/* ---- The alert banner ---- */

.oncall-banner {
    position: sticky;
    top: 8px;
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.oncall-banner-item {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    color: #fff;
    background: #c5261c;
    border-radius: 10px;
    box-shadow: 0 6px 18px rgba(197, 38, 28, 0.35);
}

.oncall-banner-item--escalated {
    background: #8f1d15;
    animation: oncall-pulse 1.6s ease-in-out infinite;
}

@keyframes oncall-pulse {
    50% { box-shadow: 0 6px 24px rgba(197, 38, 28, 0.75); }
}

@media (prefers-reduced-motion: reduce) {
    .oncall-banner-item--escalated {
        animation: none;
    }
}

.oncall-banner-icon {
    flex: none;
}

.oncall-banner-text {
    display: flex;
    flex-direction: column;
    flex: 1 1 220px;
    min-width: 0;
}

.oncall-banner-text span {
    opacity: 0.9;
    font-size: 0.8125rem;
}

/* White on the red strip so both buttons read: Got it is the main one, filled; Open is outlined. */
.oncall-banner .oncall-banner-ack.mud-button-root {
    background: #fff;
    color: #8f1d15;
    font-weight: 700;
}

.oncall-banner .oncall-banner-ack.mud-button-root:hover {
    background: #fde8e6;
}

.oncall-banner .oncall-banner-open.mud-button-root {
    border-color: rgba(255, 255, 255, 0.8);
    color: #fff;
}

.oncall-banner-more {
    color: #8f1d15;
    font-size: 0.8125rem;
    text-align: right;
}

/* ---- Raising an alert and the alerts list ---- */

.raise-done-person {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-top: 1px solid var(--oc-line, #e6ebf2);
}

.oncall-alert {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 0;
    border-top: 1px solid var(--oc-line);
}

.oncall-alert:first-child {
    border-top: none;
}

.oncall-alert--focus {
    background: rgba(37, 99, 235, 0.06);
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: 8px;
}

.oncall-alert-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    flex-wrap: wrap;
}

.oncall-alert-title {
    font-weight: 600;
}

.oncall-alert-meta {
    color: var(--oc-muted);
    font-size: 0.8125rem;
}

.oncall-alert-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.oncall-tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    margin-right: 6px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    border: 1px solid;
}

.oncall-tag--open { color: #b42318; background: rgba(217, 45, 32, 0.08); border-color: rgba(217, 45, 32, 0.3); }
.oncall-tag--taken { color: #0b7a4d; background: rgba(15, 157, 99, 0.1); border-color: rgba(15, 157, 99, 0.3); }
.oncall-tag--done { color: #4a5768; background: #f1f4f9; border-color: #dde3ec; }
.oncall-tag--warn { color: #92600a; background: rgba(217, 119, 6, 0.1); border-color: rgba(217, 119, 6, 0.3); }

.oncall-stale {
    margin-bottom: 4px;
}

/* ---- The Fitter Schedule badge ---- */

.oncall-lane-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    flex: 0 1 auto;
    min-width: 0;
    max-width: 48%;
    padding: 1px 7px 1px 5px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 600;
    color: #92600a;
    background: rgba(217, 119, 6, 0.12);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.oncall-lane-badge .mud-icon-root {
    width: 0.95rem;
    height: 0.95rem;
    flex: none;
}

@media (max-width: 720px) {
    .oncall-cards {
        grid-template-columns: 1fr;
    }

    .oncall-seat {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .oncall-shift {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .hours-row {
        grid-template-columns: 90px 52px 1fr 1fr;
    }

    .oncall-now-chip-text {
        display: none;
    }
}
