/* Calendar tab — Figma "Calendar / Month" (106:7519) and "Calendar / Leave" (76:4452) */

.cal { display: flex; flex-direction: column; gap: var(--ds-spacing-l); }

.cal__toolbar { display: flex; align-items: center; gap: var(--ds-spacing-m); }
.cal__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 32px;
  padding: 0;
  border: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
  border-radius: var(--ds-border-radius-m);
  background: var(--ds-palette-background-primary);
  color: var(--ds-palette-content-primary);
  cursor: pointer;
}
.cal__nav svg { fill: currentColor; }
.cal__nav:hover { background-image: linear-gradient(var(--ds-palette-interactive-hover), var(--ds-palette-interactive-hover)); }
.cal__nav:focus-visible { outline: none; background-image: linear-gradient(var(--ds-palette-interactive-focus), var(--ds-palette-interactive-focus)); }
.cal__title { min-width: 136px; margin: 0; text-align: center; }

.cal__grid {
  border: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
  border-radius: var(--ds-border-radius-m);
  overflow: hidden;
}

.cal__head {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  height: 28px;
  border-bottom: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
  color: var(--ds-palette-content-secondary);
}
.cal__head span {
  display: flex;
  align-items: center;
  padding-left: var(--ds-spacing-m);
  border-right: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
}
.cal__head span:last-child { border-right: 0; }

/* Week row: day cells fill the grid; bars sit in lanes (rows 2, 3, …) over them */
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  /* 32 (day number) + 2 lanes × 28 + gaps = 112, as in Figma; more lanes grow the row */
  grid-template-rows: 32px 28px 28px;
  grid-auto-rows: 28px;
  row-gap: var(--ds-spacing-s);
  padding-bottom: var(--ds-spacing-s);
  border-bottom: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
}
.cal-week:last-child { border-bottom: 0; }

.cal-day {
  grid-row: 1 / -1;
  margin-bottom: calc(-1 * var(--ds-spacing-s));
  padding: var(--ds-spacing-m);
  border-right: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
  background: var(--ds-palette-background-primary);
}
.cal-day:nth-child(7) { border-right: 0; }
/* Weekends shaded (Figma: background/secondary) */
.cal-day.is-weekend { background: var(--ds-palette-background-secondary); }
.cal-day__num { display: inline-flex; color: var(--ds-palette-content-primary); }
.cal-day.is-outside .cal-day__num { color: var(--ds-palette-content-tertiary); }
/* Today badge (Figma 106:7556): brand outline circle, bold number — matches the drawer picker */
.cal-day__num.is-today {
  align-items: center;
  justify-content: center;
  width: 32px; /* Figma 2007:15798: 32×26 rounded rectangle, like the picker's today */
  height: 26px;
  margin: calc(-1 * var(--ds-spacing-xs));
  border: var(--ds-border-width-xxs) solid var(--ds-palette-border-brand);
  border-radius: var(--ds-border-radius-m);
  background: var(--ds-palette-background-primary);
  color: var(--ds-palette-content-primary);
}

/* ---------- Leave bar (Calendar / Leave) ---------- */
.leave-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  height: 28px;
  margin: 0 var(--ds-spacing-s);
  padding: var(--ds-spacing-xs) var(--ds-spacing-s);
  border: var(--ds-border-width-xxs) solid transparent;
  border-radius: var(--ds-border-radius-m);
}
.leave-bar__label { display: flex; align-items: center; gap: var(--ds-spacing-xs); min-width: 0; }
.leave-bar__label > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leave-bar--approved { background: var(--ds-palette-background-success-low); color: var(--ds-palette-content-success); }
.leave-bar .icon { fill: currentColor; flex: none; }
.leave-bar--pending {
  background: var(--ds-palette-background-alert-low);
  color: var(--ds-palette-content-alert);
}
.leave-bar--declined { background: var(--ds-palette-background-error-low); color: var(--ds-palette-content-error); }
.leave-bar[data-editable] { cursor: pointer; }
.leave-bar[data-editable]:hover { background-image: linear-gradient(var(--ds-palette-interactive-hover), var(--ds-palette-interactive-hover)); }
.leave-bar[data-editable]:focus-visible { outline: none; background-image: linear-gradient(var(--ds-palette-interactive-focus), var(--ds-palette-interactive-focus)); }
/* Leave that continues across weeks: square, edge-to-edge on the continuing side */
.leave-bar.cont-l { margin-left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; border-left-width: 0; }
.leave-bar.cont-r { margin-right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; border-right-width: 0; }

/* ---------- Legend ---------- */
.cal__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-spacing-l);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--ds-palette-content-secondary);
}
.cal__legend li { display: flex; align-items: center; gap: 6px; }
/* Legend marks = a mini leave bar: the bar's tint + its icon in the status colour */
.cal__mark { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; border-radius: var(--ds-border-radius-xs); }
.cal__mark .icon { fill: currentColor; }
.cal__mark--approved { background: var(--ds-palette-background-success-low); color: var(--ds-palette-content-success); }
.cal__mark--pending { background: var(--ds-palette-background-alert-low); color: var(--ds-palette-content-alert); }
.cal__mark--declined { background: var(--ds-palette-background-error-low); color: var(--ds-palette-content-error); }

/* ---------- Click an empty day (Figma "Calendar · Click empty day") ---------- */
.cal-day { position: relative; }
.cal-day__add {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: var(--ds-spacing-m);
  border: 0;
  background: transparent;
  color: transparent;
  cursor: pointer;
}
.cal-day__add:hover { background: var(--ds-palette-interactive-hover); color: var(--ds-palette-content-brand); }
.cal-day__add:focus-visible { outline: none; background: var(--ds-palette-interactive-hover); box-shadow: inset 0 0 0 var(--ds-border-width-xxs) var(--ds-palette-border-brand); color: var(--ds-palette-content-brand); }
/* Light on purpose (feedback 23 Nov): keyboard focus keeps the hover tint and adds a thin brand frame */
.cal-day__num { position: relative; z-index: 1; pointer-events: none; }
