/* Attendance (Module 6): the Check in / Check out button, its timer, and today's card. */

.attendance-button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
}

.attendance-today .card-body { border-left: 4px solid var(--lb-accent); border-radius: 8px; }

.attendance-punches li {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin-right: 1rem;
  font-variant-numeric: tabular-nums;
}

.attendance-steps {
  padding: 0.75rem 1rem;
  background: var(--lb-bg);
  border-radius: 8px;
}

/* My attendance: month calendar (Monday first). Colours follow the status badges in theme.md:
   full day teal, half day amber, absent and missed check-out red, holiday navy tint, weekend grey. */
.attendance-month-name { min-width: 8.5rem; text-align: center; }

.attendance-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.attendance-calendar-head {
  padding-bottom: 2px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--lb-muted);
}

.attendance-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 54px;
  padding: 5px 7px;
  color: var(--lb-ink);
  text-decoration: none;
  background: var(--lb-surface);
  border: 1px solid var(--lb-border-soft);
  border-radius: 8px;
}

.attendance-cell:hover { border-color: var(--lb-accent); color: var(--lb-ink); }
.attendance-cell-blank { background: transparent; border: 0; }
.attendance-cell.is-today { box-shadow: inset 0 0 0 2px var(--lb-primary); }
.attendance-cell.is-selected { border-color: var(--lb-primary); background-image: linear-gradient(rgba(var(--lb-primary-rgb), 0.06), rgba(var(--lb-primary-rgb), 0.06)); }

.attendance-cell-date { display: flex; align-items: center; gap: 4px; font-size: 0.8125rem; font-weight: 600; line-height: 1.2; }
.attendance-cell-label {
  overflow: hidden;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attendance-cell-times { font-size: 0.65rem; line-height: 1.2; color: var(--lb-muted); font-variant-numeric: tabular-nums; }

/* Times only where the cells are wide enough; the day's details card shows them anyway. */
@media (max-width: 1399.98px) {
  .attendance-cell-times { display: none; }
}

.status-full_day { background: var(--lb-accent-soft); border-color: var(--bs-success-border-subtle); }
.status-full_day .attendance-cell-label { color: var(--lb-accent-ink); }
.status-overtime { background: var(--lb-accent-soft); border-color: var(--lb-accent); border-width: 1.5px; }
.status-overtime .attendance-cell-label { color: var(--lb-accent-strong); }
.status-short_day { background: rgba(var(--lb-accent-rgb), 0.07); border-color: var(--bs-success-border-subtle); border-style: dashed; }
.status-short_day .attendance-cell-label { color: var(--lb-accent-ink); }
.status-half_day { background: #FDF1D6; border-color: #F3DDA4; }
.status-half_day .attendance-cell-label { color: #7A5200; }
.status-absent { background: #FDECEA; border-color: #F5C2BD; }
.status-absent .attendance-cell-label,
.status-missed_checkout .attendance-cell-label { color: #B42318; }
.status-missed_checkout { background: var(--lb-surface); border: 1px dashed #B42318; }
.status-wfh_pending { background: #FFF7E0; border: 1px dashed #E0A800; }
.status-wfh_pending .attendance-cell-label { color: #7A5200; }
.attendance-home { margin-left: 2px; font-size: 0.7rem; color: var(--lb-accent-strong); }
.status-holiday { background: var(--lb-primary-soft); }
.status-holiday .attendance-cell-label { color: var(--lb-primary); }
.status-weekend { background: var(--lb-hover); }
.status-weekend .attendance-cell-label { color: var(--lb-muted); }
.status-checked_in,
.status-not_checked_in { border-style: dashed; border-color: var(--lb-accent); }

.attendance-late-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #B42318;
  border-radius: 50%;
}

.attendance-legend { display: flex; flex-wrap: wrap; gap: 0.35rem 0.9rem; font-size: 0.75rem; color: var(--lb-muted); }
.attendance-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.attendance-swatch { display: inline-block; width: 14px; height: 14px; border: 1px solid var(--lb-border); border-radius: 4px; }

/* Month totals in one slim row (wraps to two on small screens). */
.totals-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.6rem;
}

.totals-item { padding: 0.65rem 0.9rem; }
.totals-item .stat-value { font-size: 1.25rem; }
.totals-item .stat-label { font-size: 0.75rem; }

@media (max-width: 767.98px) {
  .totals-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Phones: day number and colour only; details open below. */
@media (max-width: 575.98px) {
  .attendance-calendar { gap: 3px; }
  .attendance-cell { min-height: 40px; padding: 4px; align-items: center; }
  .attendance-cell-label,
  .attendance-cell-times { display: none; }
}

/* Corrections list: keep long reasons readable. */
.correction-reason { min-width: 12rem; max-width: 22rem; }

/* My attendance: a small mark on corrected or pending days. */
.attendance-cell-mark { margin-left: auto; font-size: 0.75rem; color: var(--lb-muted); }

/* Company attendance (Feature 6). */
.attendance-stat-active { border-color: var(--lb-primary); box-shadow: inset 0 0 0 1px var(--lb-primary); }
.company-attendance-table td { white-space: normal; }

/* Month grid: one small coloured square per day, a red corner when late. */
.attendance-grid th,
.attendance-grid td { font-size: 0.8125rem; }
.attendance-grid-name { min-width: 11rem; position: sticky; left: 0; background: var(--lb-surface); z-index: 1; }
.attendance-grid-weekday { font-size: 0.65rem; font-weight: 500; color: var(--lb-muted); }
.attendance-grid-today { color: var(--lb-primary); }

.attendance-grid-cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--lb-ink);
  text-decoration: none;
  background: var(--lb-surface);
  border: 1px solid var(--lb-border-soft);
  border-radius: 6px;
}

.attendance-grid-cell.status-full_day { color: #fff; background: var(--lb-accent-strong); border-color: var(--lb-accent-strong); }
.attendance-grid-cell.status-overtime { color: #fff; background: var(--lb-accent-strong); }
.attendance-grid-cell.status-short_day { color: var(--lb-accent-ink); }
.attendance-grid-cell.status-half_day { color: #7A5200; }
.attendance-grid-cell.status-absent { color: #fff; background: #B42318; border-color: #B42318; }
.attendance-grid-cell.status-missed_checkout { color: #B42318; }
.attendance-grid-cell.status-holiday { color: var(--lb-primary); }
.attendance-grid-cell.status-weekend { color: var(--lb-muted); }
.attendance-grid-cell.is-late::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  border-top: 8px solid #B42318;
  border-left: 8px solid transparent;
  border-top-right-radius: 6px;
}

/* Overview (Feature 7): late bars in the "problem" red. */
.attendance-bar-late { background: #B42318; }

/* Overtime on the calendar (CR-27): "+2h" for extra time not yet approved, a teal "OT 2h" once approved. */
.attendance-ot {
  padding: 0 4px;
  font-size: 0.625rem;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  color: var(--lb-warning-ink);
  background: var(--lb-warning-soft);
  border-radius: 4px;
}

.attendance-ot.is-approved { color: #fff; background: var(--lb-accent-strong); }


/* ---- Redesign: date switcher, status cards, calendar and grid polish ---- */

/* Previous / label / next in one rounded white bar. */
.date-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 0.25rem;
  background: var(--lb-surface);
  border: 1px solid var(--lb-border);
  border-radius: 999px;
  box-shadow: var(--lb-shadow);
}

.date-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  color: var(--lb-ink);
  text-decoration: none;
  border-radius: 50%;
  transition: background-color 0.15s ease;
}

a.date-switch-btn:hover { background: var(--lb-hover); color: var(--lb-primary); }
.date-switch-btn.is-disabled { color: var(--lb-border); cursor: not-allowed; }
.date-switch-label { min-width: 8.5rem; padding: 0 0.6rem; font-weight: 600; text-align: center; white-space: nowrap; }

/* The day's count cards (Present, Late, …): a coloured icon, and a ring on the one that filters the table. */
.attendance-stat-active { border-color: var(--lb-primary); box-shadow: 0 0 0 2px rgba(var(--lb-primary-rgb), 0.18), var(--lb-shadow); }
.attendance-stat .stat-value { margin-top: 0.1rem; }

/* People in the day table: a photo or initials beside the name. */
.person-cell { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.person-cell .avatar { width: 38px; height: 38px; font-size: 0.8125rem; }

/* Calendar: rounder, airier cells and a clear "today". */
.attendance-calendar { gap: 6px; }
.attendance-cell { min-height: 60px; padding: 7px 9px; border-radius: 12px; transition: transform 0.15s var(--lb-ease), box-shadow 0.15s var(--lb-ease), border-color 0.15s ease; }
.attendance-cell:hover { transform: translateY(-1px); box-shadow: var(--lb-shadow); }
.attendance-cell.is-today { box-shadow: inset 0 0 0 2px var(--lb-primary); }
.attendance-cell-blank:hover { transform: none; box-shadow: none; }
.attendance-calendar-head { padding-bottom: 6px; }
.attendance-swatch { border-radius: 5px; }

/* Month grid squares */
.attendance-grid-cell { width: 26px; height: 26px; border-radius: 8px; }

/* The totals strip: compact cards without the top line. */
.totals-item.stat-card::before { display: none; }
.totals-item { padding: 0.75rem 1rem; border-radius: 14px; }

/* Check in / Check out: the accent teal with a soft top-to-bottom shade, a faint top highlight and a teal glow. */
.attendance-button {
  padding-right: 1.25rem;
  padding-left: 1.25rem;
}


/* Calendar hover and keyboard focus: the cell lifts, its border turns teal, and a navy ring shows on focus. */
.attendance-cell:not(.attendance-cell-blank):hover { border-color: var(--lb-accent); box-shadow: var(--lb-shadow); }
.attendance-cell:focus-visible,
.attendance-grid-cell:focus-visible { outline: 2px solid var(--lb-primary); outline-offset: 2px; }
a.attendance-grid-cell { transition: transform 0.15s var(--lb-ease), box-shadow 0.15s var(--lb-ease); }
a.attendance-grid-cell:hover { transform: scale(1.15); box-shadow: var(--lb-shadow); }
.attendance-calendar-head,
.attendance-grid-today { cursor: default; }

/* My attendance: the calendar is centred and compact, so a month fits on screen without scrolling. */
.my-attendance-calendar { max-width: 960px; margin: 0 auto; }
.my-attendance-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 1rem; align-items: start; }
@media (max-width: 991.98px) { .my-attendance-layout { grid-template-columns: 1fr; } }
.my-attendance-calendar .attendance-calendar { gap: 5px; }
.my-attendance-calendar .attendance-cell { min-height: 50px; padding: 5px 8px; }
.my-attendance-calendar .attendance-calendar-head { padding-bottom: 2px; }
.my-attendance-calendar .attendance-legend { justify-content: center; }
.my-attendance-calendar .attendance-cell-times { display: none; }
.my-attendance-calendar .totals-strip { margin-bottom: 0.75rem; }
.attendance-cell { position: relative; }
.attendance-cell:hover, .attendance-cell:focus-within, .attendance-cell:focus-visible { z-index: 6; }
div.attendance-cell { cursor: default; }
a.attendance-cell[data-turbo-frame] { cursor: pointer; }

/* The card that appears when a day is hovered or focused: its details, nothing to click. */
.attendance-pop {
  position: absolute;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 15.5rem;
  padding: 0.7rem 0.8rem;
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.3;
  color: var(--lb-ink);
  text-align: left;
  white-space: normal;
  background: var(--lb-surface);
  border: 1px solid var(--lb-border);
  border-radius: var(--lb-radius);
  box-shadow: var(--lb-shadow-lg);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
}
.attendance-cell:hover > .attendance-pop,
.attendance-cell:focus > .attendance-pop,
.attendance-cell:focus-visible > .attendance-pop { opacity: 1; visibility: visible; transform: none; }
.attendance-pop.pop-above { bottom: calc(100% + 6px); }
.attendance-pop.pop-below { top: calc(100% + 6px); }
.attendance-pop.pop-mid { left: 50%; margin-left: -7.75rem; }
.attendance-pop.pop-start { left: 0; }
.attendance-pop.pop-end { right: 0; }
.attendance-pop-title { font-size: 0.875rem; }
.attendance-pop-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }
.attendance-pop-row { display: flex; justify-content: space-between; gap: 0.75rem; color: var(--lb-muted); }
.attendance-pop-row b { color: var(--lb-ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.attendance-pop-note { color: var(--lb-muted); font-size: 0.78rem; }
.attendance-pop-hint { padding-top: 0.35rem; color: var(--lb-primary); font-weight: 600; border-top: 1px solid var(--lb-border-soft); }
@media (hover: none) { .attendance-pop { display: none; } .attendance-cell:focus > .attendance-pop { display: flex; } }

/* The month's totals in a small box beside the calendar. */
.month-box-list { margin: 0; padding: 0.35rem 1rem; }
.month-box-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; padding: 0.4rem 0; border-top: 1px solid var(--lb-border-soft); font-size: 0.875rem; }
.month-box-row:first-child { border-top: 0; }
.month-box-row dt { font-weight: 500; color: var(--lb-muted); }
.month-box-row dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.month-box-note { margin: 0 1rem 1rem; padding: 0.55rem 0.7rem; font-size: 0.78rem; color: var(--lb-muted); background: var(--lb-hover); border-radius: var(--lb-radius); }
.month-box-note.is-warning { color: #7A5200; background: #FDF1D6; }

/* The hover card touches its day (the gap is bridged), so the pointer can move onto it and click its button. */
.attendance-pop { pointer-events: none; }
.attendance-cell:hover > .attendance-pop,
.attendance-cell:focus-within > .attendance-pop,
.attendance-cell:focus > .attendance-pop { pointer-events: auto; }
.attendance-pop::before { content: ""; position: absolute; left: 0; right: 0; height: 10px; }
.attendance-pop.pop-above::before { top: 100%; }
.attendance-pop.pop-below::before { bottom: 100%; }
.attendance-pop-action { align-self: flex-start; margin-top: 0.2rem; }
.attendance-cell:focus-within > .attendance-pop { opacity: 1; visibility: visible; transform: none; }

/* Company attendance, one day: the table, with the day's counts in a small box at the side. */
.attendance-day-layout { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 1rem; align-items: start; }
@media (max-width: 1199.98px) { .attendance-day-layout { grid-template-columns: 1fr; } .attendance-day-layout > .day-box { order: -1; } }
.day-box-list { margin: 0; padding: 0.35rem 0.5rem 0.5rem; list-style: none; }
.day-box-row { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; font-size: 0.875rem; color: var(--lb-ink); text-decoration: none; border-radius: 10px; transition: background-color 0.12s ease; }
.day-box-row i { color: var(--lb-muted); }
.day-box-label { flex: 1; color: var(--lb-muted); }
.day-box-row strong { font-variant-numeric: tabular-nums; }
.day-box-row:hover { background: var(--lb-hover); color: var(--lb-ink); }
.day-box-row.is-active { background: var(--lb-primary-soft); box-shadow: inset 0 0 0 1px rgba(var(--lb-primary-rgb), 0.25); }
.day-box-row.is-active .day-box-label, .day-box-row.is-active i { color: var(--lb-primary); }

/* The month grid: a date before someone's attendance started shows a muted dash; date columns sit close together. */
.attendance-grid-cell.is-none { color: var(--lb-border); background: transparent; border-color: transparent; font-weight: 400; }
.attendance-grid th.text-center,
.attendance-grid td.text-center { padding-inline: 2px; }
.attendance-grid-name { min-width: 9rem; }

/* The Approved tab's Reject dialog: every approved request with a tick box, one reason below. */
.reject-picker { width: min(720px, 94vw); max-height: 86vh; padding: 0; overflow: hidden; color: var(--lb-ink); background: var(--lb-surface); border: 0; border-radius: var(--lb-radius-lg); box-shadow: var(--lb-shadow-lg); }
.reject-picker[open] { display: flex; }
.reject-picker form { display: flex; flex-direction: column; width: 100%; max-height: 86vh; }
.reject-picker::backdrop { background: rgba(var(--lb-primary-rgb), 0.6); backdrop-filter: blur(2px); }
.reject-picker-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; padding: 1.1rem 1.25rem 0.6rem; }
.reject-picker .alert { margin: 0 1.25rem 0.5rem; }
.reject-picker-list { flex: 1; overflow-y: auto; padding: 0 0.75rem; }
.reject-picker-row { display: flex; align-items: center; gap: 0.8rem; margin: 0; padding: 0.65rem 0.5rem; cursor: pointer; border-top: 1px solid var(--lb-border-soft); border-radius: 8px; }
.reject-picker-row:hover { background: var(--lb-hover); }
.reject-picker-row.is-all { border-top: 0; background: var(--lb-bg); }
.reject-picker-who { display: flex; flex-direction: column; min-width: 9rem; }
.reject-picker-who small { color: var(--lb-muted); }
.reject-picker-reason { flex: 1; min-width: 0; overflow: hidden; font-size: 0.85rem; color: var(--lb-muted); text-overflow: ellipsis; white-space: nowrap; }
.reject-picker-foot { padding: 0.9rem 1.25rem 1.1rem; border-top: 1px solid var(--lb-border-soft); }
