/* The השבוע tab: the stepper, the banners, the four week screens (צוות, מטופלים, פעילויות, שיבוץ) and the alerts panel.
   No inline styles anywhere: widths of bars and colors of swatches are set through the CSSOM (custom properties). */

:root {
  /* the stepper is sticky under the header: views that have sticky parts of their own sit below both */
  --stepper-h: 56px;
}

/* ---------- stepper ---------- */

.stepper {
  position: sticky;
  top: var(--header-h);
  z-index: 9;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--stepper-h);
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.step {
  padding: 6px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: #52606d;
  font-size: 13.5px;
  white-space: nowrap;
  cursor: pointer;
}

.step:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.step:focus-visible {
  outline: 3px solid #9db9de;
  outline-offset: 1px;
}

.step.done {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.step.on {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(47, 93, 155, 0.35);
}

/* a chevron pointing left, the way the steps go in a right-to-left page */
.step-arrow {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 3px;
  border-bottom: 2px solid #9aa5b1;
  border-left: 2px solid #9aa5b1;
  transform: rotate(45deg);
}

.stepper-spacer {
  flex: 1;
}

/* ---------- banners ---------- */

.week-banners:empty {
  display: none;
}

.week-banners {
  padding: 10px 24px 0;
}

.week-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 38px;
  padding: 4px 12px;
  border-radius: var(--radius);
  font-size: 0.93rem;
}

.week-banner.dirty {
  border: 1px solid var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn);
}

.week-banner.dirty .btn {
  margin-inline-start: auto;
  border-color: #d9bd36;
  background: #fff;
  color: var(--warn);
}

.week-banner.info {
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}

.week-banner-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #f0c000;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.soon {
  padding-top: 48px;
  text-align: center;
}

/* ---------- small pieces ---------- */

.local-marker {
  display: inline-block;
  padding: 0 8px;
  border: 1px solid var(--warn-line);
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.scope-check {
  color: var(--muted);
  font-size: 12px;
}

.scope-check input[type='checkbox'] {
  width: 14px;
  height: 14px;
}

.day-badge {
  display: inline-block;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.day-badge.closed {
  background: #e6e6e6;
  color: #3a4651;
}

.day-badge.short {
  background: var(--warn-soft);
  color: var(--warn);
}

.notice-line {
  margin: 8px 0 0;
  padding: 8px 12px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.notice-line.warn {
  border-color: var(--warn-line);
  background: var(--warn-soft);
  color: var(--warn);
}

.notice-line.bad {
  border-color: var(--danger-line);
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- צוות השבוע ---------- */

.week-table-card {
  padding: 0;
  /* clip, not hidden: a scroll container would make the sticky header stick to the card instead of the page */
  overflow: clip;
}

.week-staff-table {
  table-layout: fixed;
}

.week-staff-table .staff-col,
.week-staff-table .staff-cell {
  width: 160px;
}

.week-staff-table thead th {
  position: sticky;
  top: calc(var(--header-h) + var(--stepper-h));
  z-index: 3;
  vertical-align: top;
}

.week-staff-table .day-col {
  padding: 8px 10px 10px;
  border-inline-start: 1px solid var(--line);
  white-space: normal;
}

.week-staff-table .day-col.is-closed {
  background: #e6e6e6;
}

.day-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.day-title strong {
  font-size: 1rem;
}

.day-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.day-toggle.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.day-actions .time-text {
  flex: 0 1 62px;
  width: 62px;
  min-width: 48px;
  min-height: 30px;
  padding: 0 4px;
}

.week-staff-table .staff-cell {
  padding: 8px 12px;
  font-weight: 400;
  vertical-align: top;
}

.staff-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.week-staff-table .day-cell {
  padding: 6px 10px 8px;
  border-inline-start: 1px solid var(--line);
  vertical-align: top;
}

.day-cell.closed {
  background: #e6e6e6;
  text-align: center;
}

.day-cell.absent {
  background: var(--danger-soft);
}

.day-cell.inactive-note {
  text-align: center;
}

tr.inactive .staff-cell {
  opacity: 0.6;
}

.cell-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 18px;
  margin-bottom: 2px;
}

.cell-bottom {
  margin-top: 4px;
}

.absent-check {
  font-size: 12.5px;
}

.week-staff-table .time-text-wide {
  max-width: none;
  width: 100%;
  min-height: 0;
  padding: 4px 6px;
  font-size: 13px;
  line-height: 1.35;
  resize: none;
}

.effective {
  margin: 4px 0 0;
}

/* a window ("08:00-12:00") never breaks at its hyphen; the line breaks between windows */
.effective bdi {
  white-space: nowrap;
}

/* ---------- מטופלים השבוע ---------- */

.week-patients .master {
  /* the stepper is sticky under the header, so the list sticks below both */
  top: calc(var(--header-h) + var(--stepper-h) + 12px);
  max-height: calc(100vh - var(--header-h) - var(--stepper-h) - 36px);
}

.master .scope-check {
  margin: 0 2px 8px;
}

.patient-title {
  margin: 0;
}

.week-patients .patient-head {
  align-items: center;
}

.week-patients .avail-row > .local-marker {
  grid-column: 2;
  justify-self: start;
}

/* a day that is ticked but does not count this week (discharged, closed, short): the tick stays, the reason shows */
.week-patients .avail-row > .avail-cut {
  grid-column: 2;
  justify-self: start;
  color: var(--warn);
  font-size: 12px;
  font-weight: 700;
}

/* the form of a new patient: a name and his days, one column */
.week-patients .add-form {
  max-width: 440px;
}

.week-patients .add-form .field {
  margin-bottom: 14px;
}

.week-patients .add-form .add-name {
  width: 100%;
}

.week-patients .add-form .add-error {
  margin: 8px 0 0;
}

.req-marker {
  grid-column: 1 / -1;
  margin: -4px 0 0;
}

.discharge-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.discharge-label {
  margin: 0;
}

.discharge-date {
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
}

.discharge-pending {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--warn);
  font-weight: 600;
}

.patient-detail .scope-check,
.week-patients .columns .scope-check {
  margin-bottom: 6px;
}

/* ---------- פעילויות השבוע ---------- */

.activities-table td {
  vertical-align: middle;
}

.ltr-cell {
  direction: ltr;
  unicode-bidi: isolate;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.type-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.source-tag {
  display: inline-block;
  margin-inline-end: 6px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef1f4;
  color: #3a4651;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.source-tag.copied {
  background: var(--warn-soft);
  color: var(--warn);
}

tr.is-copied td {
  background: #fffdf2;
}

.radio-row {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
}

.add-activity-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
}

.add-activity-fields .field {
  min-width: 150px;
}

.add-activity-fields select {
  min-width: 170px;
}

.add-activity-btn {
  align-self: flex-end;
}

/* ---------- שיבוץ ---------- */

.run-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 16px;
  align-items: start;
}

.run-aside {
  position: sticky;
  top: calc(var(--header-h) + var(--stepper-h) + 12px);
}

.run-aside .alerts-panel {
  max-height: calc(100vh - 270px);
}

.run-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 230px));
  gap: 20px 24px;
}

.run-action {
  min-width: 0;
}

.run-action .btn {
  min-width: 140px;
}

.run-action p {
  margin: 6px 0 0;
}

.run-running-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.run-progress {
  height: 12px;
  overflow: hidden;
  border-radius: 6px;
  background: #cdd9ea;
}

.run-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 6px;
  background: var(--accent);
  transition: width 0.25s linear;
}

.run-running-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
}

.run-progress-label {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.run-card .stat-row {
  margin-top: 20px;
}

.run-summary {
  margin-top: 16px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.run-summary h3 {
  margin-bottom: 8px;
}

.run-summary > .notice-line:first-child {
  margin-top: 0;
}

.run-headline {
  margin: 0 0 6px;
  font-size: 1.15rem;
  font-weight: 700;
}

.moved-box {
  max-height: 340px;
  margin-top: 10px;
  padding: 8px 14px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.moved-box h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}

.moved-box h4 {
  margin: 10px 0 2px;
  color: var(--muted);
  font-size: 0.85rem;
}

.moved-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.moved-list li {
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 0.93rem;
}

.moved-list li:last-child {
  border-bottom: 0;
}

.moved-from {
  color: var(--muted);
  text-decoration: line-through;
}

.moved-to {
  font-weight: 600;
}

/* ---------- alerts panel (inline and drawer) ---------- */

.alerts-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--panel-2);
  box-shadow: var(--shadow);
}

.alerts-head {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-strong);
  background: #fff;
}

.alerts-head h2 {
  margin: 0;
  font-size: 1rem;
}

.alerts-total {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.alerts-total.zero {
  background: var(--ok-soft);
  color: var(--ok);
}

.alerts-total-small {
  height: 18px;
  min-width: 20px;
  font-size: 12px;
}

.alerts-close {
  margin-inline-start: auto;
}

.alerts-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
}

.alerts-empty {
  margin: 12px 4px;
  color: var(--ok);
  font-weight: 600;
}

.alerts-note {
  margin: 4px 4px 0;
  padding: 8px 10px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.88rem;
  line-height: 1.4;
}

.alert-card {
  --cc: #9aa5b1;
  padding: 8px 10px 9px;
  border: 1px solid var(--line);
  border-inline-start: 4px solid var(--cc);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}

.alert-card.tone-bad {
  --cc: #e11d2e;
  border-color: var(--danger-line);
  border-inline-start-color: #e11d2e;
  background: #fff1f1;
}

.alert-card.tone-bad .alert-card-head {
  color: #b3141f;
}

.alert-card.tone-few {
  --cc: #5b7fb0;
}

.alert-card.tone-info {
  --cc: #7a8591;
}

.alert-card.tone-subst {
  --cc: #f08c00;
}

.alert-card.tone-lack {
  --cc: #8a63d2;
}

.alert-card.tone-amber {
  --cc: #e0a100;
  border-color: #f0d58a;
  border-inline-start-color: #e0a100;
  background: #fff5d9;
}

.alert-card.tone-neutral {
  --cc: #b8c0c9;
}

.alert-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: #2a343e;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  text-align: start;
  cursor: pointer;
}

.alert-card-head:focus-visible,
.alert-link:focus-visible {
  outline: 3px solid #9db9de;
  outline-offset: 1px;
}

.alert-card-title {
  flex: 1;
}

.alert-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef1f4;
  color: #3a4651;
  font-size: 12px;
  font-weight: 700;
}

.alert-list {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
}

.alert-list[hidden] {
  display: none;
}

.alert-entry {
  font-size: 13px;
  line-height: 18px;
}

.alert-entry + .alert-entry {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px dashed #e3e7ec;
}

.alert-link {
  display: block;
  width: 100%;
  padding: 2px 4px;
  border: 0;
  border-radius: 4px;
  background: none;
  text-align: start;
  cursor: pointer;
}

.alert-link:hover {
  background: var(--accent-soft);
}

.alert-text {
  display: block;
}

.alert-why {
  display: block;
  color: #7a8591;
  font-size: 12px;
  line-height: 16px;
}

.week-body.drawer-open,
.week-banners.drawer-open {
  padding-left: 392px;
}

/*
 * The open drawer leaves the step about 870px at the 1280px minimum, so the steps laid out in columns give way: the
 * page's own side padding shrinks, the patient list narrows, and a patient's days and requirements stack instead of
 * sharing a row (side by side the requirements column was 22px wide and its selects fell under the drawer).
 */
.week-body.drawer-open .screen {
  padding-inline: 16px;
}

.week-body.drawer-open .master-detail {
  grid-template-columns: 260px minmax(0, 1fr);
}

.week-body.drawer-open .patient-detail .columns {
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.alerts-drawer {
  position: fixed;
  top: calc(var(--header-h) + var(--stepper-h));
  bottom: 0;
  left: 0;
  z-index: 8;
  display: flex;
  width: 380px;
  background: var(--panel-2);
  box-shadow: 4px 0 18px rgba(16, 24, 40, 0.18);
}

.alerts-drawer[hidden] {
  display: none;
}

.alerts-drawer .alerts-panel {
  flex: 1;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.alerts-toggle {
  gap: 8px;
}
