/* My Work — Schedule Preview */

.mw-schedule-preview {
  margin-top: 28px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  min-width: 0;
}

.mw-schedule-preview h3 {
  margin: 0 0 5px;
  font-size: 15px;
  font-weight: 650;
}

.mw-schedule-preview > p {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 12px;
}

[data-schedule-preview] {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding-bottom: 5px;
}

.mw-schedule-preview-grid {
  display: grid;
  grid-template-columns:
    minmax(145px, 1.6fr)
    repeat(var(--preview-days), minmax(35px, 1fr));
  gap: 5px;
  min-width: 780px;
  align-items: center;
}

.mw-preview-heading,
.mw-preview-day {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-align: center;
  padding: 8px 2px;
}

.mw-preview-heading {
  text-align: left;
}

.mw-preview-name {
  font-size: 11px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mw-preview-cell {
  display: grid;
  place-items: center;
  height: 32px;
  border-radius: 7px;
  background: var(--surface-hover);
  color: var(--muted);
  font-size: 11px;
}

.mw-preview-cell.is-working {
  background: var(--interactive-highlight);
  color: var(--blue);
  font-weight: 700;
}

@media (max-width: 768px) {
  .mw-schedule-preview {
    padding: 14px;
    margin-top: 20px;
  }
}

/* Preview header and distribution */

.mw-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.mw-schedule-preview .mw-preview-header h3 {
  margin: 0;
}

.mw-preview-distribution {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mw-preview-distribution label {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.mw-preview-distribution select {
  width: auto;
  min-width: 150px;
  height: 36px;
  font-size: 12px;
}

/* Preview daily coverage */

.mw-preview-total-label {
  padding-top: 10px;
  font-size: 11px;
  font-weight: 700;
}

.mw-preview-total {
  display: grid;
  place-items: center;
  height: 30px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
}

.mw-preview-total.is-covered {
  color: var(--blue);
  background: var(--interactive-highlight);
}

.mw-preview-total.is-overlap {
  color: var(--text);
  background: var(--surface-hover);
}

.mw-preview-total.is-empty {
  color: #d97706;
  background: rgba(245, 158, 11, 0.12);
}

.mw-preview-name {
  min-width: 0;
}

@media (max-width: 600px) {
  .mw-preview-distribution {
    width: 100%;
    justify-content: space-between;
  }
}

/* --- Distribution switch --- */
.mw-preview-distribution {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mw-preview-distribution > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.mw-preview-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.mw-preview-switch input[type='checkbox'] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mw-preview-switch-ui {
  position: relative;
  width: 46px;
  height: 26px;
  flex: 0 0 46px;
  border-radius: 999px;
  background: var(--field-border);
  transition: background 0.2s ease;
}

.mw-preview-switch-ui::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.18);
  transition: transform 0.2s ease;
}

.mw-preview-switch input[type='checkbox']:checked + .mw-preview-switch-ui {
  background: var(--blue);
}

.mw-preview-switch input[type='checkbox']:checked + .mw-preview-switch-ui::after {
  transform: translateX(20px);
}

.mw-preview-switch-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

/* --- Preview cells --- */
.mw-preview-cell {
  background: transparent !important;
  color: var(--muted);
  box-shadow: none !important;
}

.mw-preview-cell.is-working {
  background: var(--interactive-highlight) !important;
  color: var(--blue);
  font-weight: 700;
}

.mw-preview-cell.is-off {
  background: transparent !important;
  color: var(--muted);
}

.mw-preview-total {
  background: transparent !important;
  box-shadow: none !important;
}

.mw-preview-total:not(.is-empty) {
  background: var(--interactive-highlight) !important;
  color: var(--blue);
  font-weight: 700;
}

.mw-preview-total.is-empty {
  background: transparent !important;
  color: var(--muted);
}

/* Distribution toggle */
.mw-preview-switch {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.mw-preview-switch input {
  position: absolute;
  opacity: 0;
}
.mw-preview-switch-ui {
  width: 42px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 20px;
  position: relative;
  transition: background 0.2s;
}
.mw-preview-switch-ui::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}
.mw-preview-switch input:checked + .mw-preview-switch-ui {
  background: var(--blue);
}
.mw-preview-switch input:checked + .mw-preview-switch-ui::after {
  transform: translateX(18px);
}
.mw-preview-cell:not(.is-working) {
  background: transparent;
}
.mw-preview-switch input:focus-visible + .mw-preview-switch-ui {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.mw-cycle-offset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mw-cycle-offset span {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.mw-cycle-offset select {
  width: auto;
  min-width: 100px;
  height: 36px;
  font-size: 12px;
}

.mw-continuation-auto {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.mw-continuation-auto input {
  accent-color: var(--blue);
}

.mw-continuation-status {
  margin: 2px 0 12px;
  font-size: 12px;
  color: var(--muted);
}

.mw-preview-header {
  justify-content: flex-start;
}

.mw-preview-header .mw-preview-distribution {
  margin-left: auto;
}

@media (max-width: 768px) {
  .mw-preview-header .mw-preview-distribution {
    margin-left: 0;
  }
}

/* Preview controls layout */
.mw-schedule-preview .mw-preview-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 12px 24px;
}

.mw-schedule-preview .mw-preview-header h3 {
  flex: 1 0 100%;
  margin: 0;
}

.mw-preview-header .mw-continuation-auto {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  white-space: nowrap;
}

.mw-preview-header .mw-continuation-auto span {
  white-space: nowrap;
}

.mw-preview-header .mw-cycle-offset {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.mw-preview-header .mw-preview-distribution {
  margin-left: auto;
}

.mw-cycle-offset select {
  min-width: 110px;
  width: auto;
}

@media (max-width: 850px) {
  .mw-preview-header .mw-preview-distribution {
    margin-left: 0;
  }
}

/* Compact schedule preview */
.mw-schedule-preview-grid .mw-preview-heading,
.mw-schedule-preview-grid .mw-preview-day,
.mw-schedule-preview-grid .mw-preview-name,
.mw-schedule-preview-grid .mw-preview-cell,
.mw-schedule-preview-grid .mw-preview-total-label,
.mw-schedule-preview-grid .mw-preview-total {
  font-size: 12px;
}

/* Summary row separator */
.mw-schedule-preview-grid .mw-preview-summary {
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding-top: 10px;
}

/* Summary numbers without background */
.mw-schedule-preview-grid .mw-preview-total,
.mw-schedule-preview-grid .mw-preview-total.is-covered,
.mw-schedule-preview-grid .mw-preview-total.is-overlap,
.mw-schedule-preview-grid .mw-preview-total.is-empty {
  background: transparent !important;
  box-shadow: none !important;
}

.mw-schedule-preview-grid .mw-preview-total {
  font-weight: 700;
}

/* Continuous separator above shift totals */
.mw-schedule-preview-grid {
  position: relative;
}

.mw-schedule-preview-grid .mw-preview-summary {
  border-top: 1px solid var(--line);
  border-radius: 0;
  position: relative;
}

.mw-schedule-preview-grid .mw-preview-summary::before {
  content: '';
  position: absolute;
  top: -1px;
  left: -5px;
  width: 5px;
  border-top: 1px solid var(--line);
}

.mw-schedule-preview-grid .mw-preview-summary:first-of-type::before {
  display: none;
}
