/* ==========================================================================
   Calendar styles
   Two layouts coexist here:
   1. Time-grid week view (caregiver's "My Schedule" + manager Weekly Calendar)
   2. Matrix view (Weekly Client/Caregiver Schedule, Unassigned)
   Each is namespaced so they can evolve independently.
   ========================================================================== */

/* --- Common time-grid (hours on left, days across top) ------------------- */

.cal-grid {
  display: grid;
  grid-template-columns: 56px repeat(7, minmax(var(--day-col-min-width), 1fr));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.cal-grid--n-cols-1 { grid-template-columns: 56px repeat(1, minmax(var(--day-col-min-width), 1fr)); }
.cal-grid--n-cols-7 { grid-template-columns: 56px repeat(7, minmax(var(--day-col-min-width), 1fr)); }
.cal-grid--n-cols-14 { grid-template-columns: 56px repeat(14, minmax(var(--day-col-min-width), 1fr)); }
.cal-grid--n-cols-21 { grid-template-columns: 56px repeat(21, minmax(var(--day-col-min-width), 1fr)); }
.cal-grid--n-cols-28 { grid-template-columns: 56px repeat(28, minmax(var(--day-col-min-width), 1fr)); }

.cal-grid__header {
  background: var(--surface-muted);
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  text-align: center;
  font-size: 0.875rem;
  border-left: 1px solid var(--border);
}

.cal-grid__header--corner {
  border-left: none;
}

.cal-grid__timeoff-row {
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  padding: 4px;
  font-size: 0.75rem;
  min-height: 28px;
  border-left: 1px solid var(--border);
}

.cal-grid__hour-cell {
  height: var(--hour-row-height);
  border-bottom: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 2px 6px;
  text-align: right;
  background: var(--surface-muted);
}

.cal-grid__day-col {
  position: relative;
  border-left: 1px solid var(--border);
}

.cal-grid__hour-row {
  height: var(--hour-row-height);
  border-bottom: 1px solid var(--border);
}

.cal-grid__hour-row:nth-child(odd) {
  background: rgba(0, 0, 0, 0.015);
}

/* --- Shift block (positioned inside a day column) ------------------------ */

.shift-block {
  position: absolute;
  left: 2px;
  right: 2px;
  border-radius: var(--r-sm);
  color: #fff;
  padding: 4px 6px;
  font-size: 0.78rem;
  line-height: 1.15;
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 80ms ease, box-shadow 80ms ease;
}

.shift-block:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.shift-block__time {
  font-weight: 600;
  font-size: 0.7rem;
  opacity: 0.95;
}

.shift-block__title {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* When multiple shifts overlap, the parent positions them side-by-side via inline styles. */

/* --- Matrix view (rows = entity, cols = day) ---------------------------- */

.matrix {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}

.matrix__row {
  display: grid;
  border-bottom: 1px solid var(--border);
}

.matrix__row:last-child {
  border-bottom: none;
}

.matrix__row-header {
  padding: 8px 12px;
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  font-size: 0.9rem;
}

.matrix__cell {
  border-right: 1px solid var(--border);
  min-height: var(--grid-cell-min-height);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  position: relative;
}

.matrix__cell:hover {
  background: rgba(127, 216, 88, 0.06);
}

.matrix__cell--drop-active {
  background: rgba(127, 216, 88, 0.18);
  outline: 2px dashed var(--brand-accent);
  outline-offset: -2px;
}

.matrix__cell:last-child {
  border-right: none;
}

.matrix__chip {
  background: var(--shift-scheduled);
  color: white;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  font-size: 0.75rem;
  line-height: 1.2;
  cursor: grab;
  user-select: none;
}

.matrix__chip[draggable='true']:active {
  cursor: grabbing;
}

.matrix__chip--dragging {
  opacity: 0.4;
}

.matrix__timeoff-banner {
  padding: 4px 8px;
  background: rgba(255, 31, 31, 0.08);
  border-bottom: 1px solid var(--border);
  font-size: 0.75rem;
}

.matrix__timeoff-banner button.toggle {
  background: transparent;
  border: none;
  color: var(--brand-primary);
  font-size: 0.75rem;
  padding: 0;
  cursor: pointer;
}

/* --- Responsive ---------------------------------------------------------- */

@media (max-width: 768px) {
  :root {
    --day-col-min-width: 100px;
    --grid-cell-min-height: 60px;
  }
  .cal-grid__header { font-size: 0.75rem; padding: 6px 4px; }
  .shift-block { font-size: 0.68rem; padding: 2px 4px; }
}

/* --- Additions for the Blazor client ------------------------------------ */

/* Full-day time-off banner in the week grid header strip. */
.cal-grid__dayoff {
  background: var(--shift-caregiver-off);
  color: #fff;
  padding: 2px 6px;
  border-radius: var(--r-sm);
  font-size: 0.7rem;
  text-align: center;
}

/* Start time on a matrix chip. */
.matrix__chip-time {
  font-weight: 600;
  font-size: 0.7rem;
  opacity: 0.95;
}

/* The shift block is a <button>; strip the default chrome. */
.shift-block {
  border: none;
  text-align: left;
  font: inherit;
}
