/* =========================================================
   Brand variables & Bootstrap overrides
   (matches core-modules/core_app/static/css/core.css)
========================================================= */
:root {
  --brand-color: #132046;
  --brand-accent: #ff574e;
  --brand-light: #edf1f9;
}

body {
  background-color: #f7f9fc;
  color: #1f2430;
}

.main-content-wrap {
  max-width: 1500px;
  margin-left: auto;
  margin-right: auto;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--brand-color);
}

.header-module {
  margin-bottom: 1.5rem;
}

.header-actions {
  gap: 0.5rem;
}

.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 30, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
  z-index: 1000;
}

.popup-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.popup-card {
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}

.popup-card .form-check-label {
  cursor: pointer;
}

.module-card {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.module-card .card-header {
  background-color: var(--brand-light);
  color: var(--brand-color);
  font-weight: 600;
}

.brand-logo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(19, 32, 70, 0.15);
  text-decoration: none;
}

.brand-logo {
  max-height: 42px;
  width: auto;
  object-fit: contain;
}

.brand-logo-fallback {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--brand-color);
}

.brand-footer {
  background-color: #0f1833;
  color: #f5f7ff;
  margin-top: 2rem;
}

.compact-footer {
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}

.btn-primary {
  background-color: var(--brand-color);
  border-color: var(--brand-color);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--brand-accent);
  border-color: var(--brand-accent);
}

/* =========================================================
   Utilities
========================================================= */
.hidden {
  display: none !important;
}

/* =========================================================
   Global loading indicator
========================================================= */
.global-loading {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: var(--brand-color);
  color: #fff;
  border-radius: 999px;
  padding: 0.5rem 0.85rem;
  font-size: 0.88rem;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  z-index: 9999;
}

/* =========================================================
   Employee list
========================================================= */
.employee-list {
  list-style: none;
  padding: 0;
  margin: 0;
  columns: 2;
  column-gap: 1rem;
}

.employee-list li {
  break-inside: avoid;
  margin: 0 0 0.4rem 0;
  padding: 0.45rem 0.6rem;
  border: 1px solid #d9e2ec;
  border-radius: 8px;
}

/* =========================================================
   Paycode legend
========================================================= */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.75rem 0 0.95rem;
}

.legend-item {
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid rgba(16, 42, 67, 0.2);
}

/* =========================================================
   Year grid (single-employee view)
========================================================= */
.year-grid-wrap {
  overflow-x: auto;
  border: 1px solid #dee2e6;
  border-radius: 0 0 6px 6px;
}

.year-grid {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  table-layout: fixed;
}

.year-grid th,
.year-grid td {
  border: 1px solid #cfd8e3;
  text-align: center;
}

.month-col {
  min-width: 140px;
  width: 140px;
  background: var(--brand-light);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: left !important;
  padding: 0.35rem 0.45rem;
  position: sticky;
  left: 0;
  z-index: 1;
}

.month-col a {
  color: var(--brand-color);
  text-decoration: none;
}

.month-col a:hover {
  color: var(--brand-accent);
}

.weekday-col {
  width: 22px;
  min-width: 22px;
  font-size: 0.6rem;
  font-weight: 600;
  background: #f8fafc;
  color: #718096;
  padding: 0.15rem;
}

.year-cell {
  width: 22px;
  min-width: 22px;
  height: 24px;
  padding: 0;
  vertical-align: top;
  background: #ffffff;
}

.year-empty {
  background: #dfe4ea;
}

.year-day-num {
  display: block;
  font-size: 0.52rem;
  line-height: 1;
  margin-top: 0.12rem;
}

.year-code {
  display: block;
  font-size: 0.5rem;
  line-height: 1;
  margin-top: 0.08rem;
  font-weight: 700;
}

/* =========================================================
   Month grid
========================================================= */
.calendar-grid {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.calendar-grid th,
.calendar-grid td {
  border: 1px solid #dee2e6;
  vertical-align: top;
}

.calendar-grid th {
  font-size: 0.88rem;
  font-weight: 600;
  background: var(--brand-light);
  padding: 0.4rem;
  text-align: center;
  color: var(--brand-color);
}

.day-cell {
  min-height: 82px;
  height: 110px;
  padding: 0.2rem;
}

.month-zoom-grid .day-cell {
  height: 132px;
  overflow-y: auto;
}

.out-of-month {
  background: #f6f7f9;
}

.day-num {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.2rem;
  color: var(--brand-color);
}

.entry-list {
  margin: 0.2rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.entry-list li {
  font-size: 0.75rem;
  border: 1px solid rgba(16, 42, 67, 0.15);
  border-radius: 6px;
  padding: 0.2rem 0.3rem;
}

.entry-meta {
  opacity: 0.85;
  font-size: 0.7rem;
}

/* Team month grid: large, near-square day cells (like the employee month view).
   On a <td>, height acts as a minimum, so busy days still grow to fit pills. */
.team-month-grid .day-cell {
  height: 150px;
  vertical-align: top;
}

/* One employee per pill: initials + paycode, coloured by pay-code group. */
.tc-pill {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.72rem;
  line-height: 1.25;
  border: 1px solid rgba(16, 42, 67, 0.15);
  border-radius: 6px;
  padding: 0.2rem 0.35rem;
  cursor: pointer;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}
.tc-pill-meta {
  opacity: 0.8;
  font-size: 0.68rem;
}
/* Spacer holding a member's row slot on days they're not off; height is set by the
   per-week equalization pass so rows line up across Mon–Sun. */
.tc-pill-empty {
  box-sizing: border-box;
}
.pill-grid {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-top: 0.2rem;
}

/* =========================================================
   Error details
========================================================= */
.error-details {
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  background: #1f2933;
  color: #d9e2ec;
  padding: 0.7rem;
  border-radius: 8px;
  font-size: 0.82rem;
}

/* =========================================================
   Team Calendar
========================================================= */
.tc-page-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--brand-color);
  display: flex;
  align-items: center;
}

.tc-page-subtitle {
  font-size: 0.78rem;
  color: #718096;
  margin-left: 8px;
  font-weight: 400;
}
.date-range-toggle {
  cursor: pointer;
  text-decoration: underline dotted;
}
.date-range-toggle:hover {
  color: var(--brand-color);
}
#date-edit {
  align-items: center;
  gap: 0.4rem;
  margin-left: 8px;
  vertical-align: middle;
}
.date-range-form {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.date-range-input {
  width: 7.2rem;
  font-size: 0.78rem;
  padding: 0.15rem 0.4rem;
}
.date-range-arrow {
  font-size: 0.78rem;
  color: #718096;
}

.cal-outer {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.07);
}

.cal-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid #dee2e6;
  background: var(--brand-light);
}

.filter-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brand-color);
  margin-right: 2px;
}

.tc-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  user-select: none;
  transition: opacity 0.15s;
}

.tc-chip.off { opacity: 0.25; }
.tc-dimmed { opacity: 0.18; filter: saturate(0.15); }

.cal-scroll { overflow-x: auto; }

/* 66 px label + 138 px member + 37 × 32 px = 1388 px */
.tc-grid {
  border-collapse: collapse;
  table-layout: fixed;
  width: 1388px;
}

.tc-col-label  { width: 66px; }
.tc-col-member { width: 138px; }
.tc-col-day    { width: 32px; }

/* DOW header row */
.tc-dow-row th {
  font-size: 0.6rem;
  font-weight: 600;
  color: #718096;
  text-align: center;
  padding: 5px 0 4px;
  border-right: 1px solid #dee2e6;
  border-bottom: 1px solid #dee2e6;
  background: var(--brand-light);
  position: sticky;
  top: 0;
  z-index: 10;
}
.tc-dow-row th:last-child { border-right: none; }
.tc-th-label { border-right: 1px solid #dee2e6; }
.tc-th-member { text-align: left; padding-left: 8px; }

/* Month name cell */
.tc-month-name {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--brand-color);
  padding: 5px 6px 4px;
  border-right: 1px solid #dee2e6;
  border-bottom: 1px solid #dee2e6;
  vertical-align: top;
  white-space: nowrap;
  background: var(--brand-light);
}

/* Member name cell (one per member, may span overlap lanes) */
.tc-member-name {
  font-size: 0.66rem;
  font-weight: 600;
  color: #344054;
  padding: 3px 8px;
  border-right: 1px solid #dee2e6;
  border-bottom: 1px solid #dee2e6;
  vertical-align: top;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 138px;
}
.tc-member-name.tc-member-empty {
  background: #fff;
  border-bottom: 1px solid #dee2e6;
}

/* Day-number row cells */
td.tc-day-cell {
  border-right: 1px solid #e4eaf2;
  border-bottom: 1px solid #dee2e6;
  vertical-align: top;
  padding: 0;
}
td.tc-day-cell:last-child { border-right: none; }
td.tc-day-cell.out { background: #edf1f9; }

/* Absence bar row cells */
td.tc-bar-cell {
  border-right: 1px solid #e4eaf2;
  border-bottom: none;
  vertical-align: top;
  padding: 0;
}
td.tc-bar-cell:last-child { border-right: none; }
td.tc-bar-cell.out { background: #edf1f9; }

/* Last packed row in a month gets the bottom border */
tr.tc-last-bar-row td.tc-bar-cell {
  border-bottom: 1px solid #dee2e6;
}

/* Spacer row (months with no absences) */
td.tc-spacer-cell {
  border-right: 1px solid #e4eaf2;
  border-bottom: 1px solid #dee2e6;
  height: 6px;
}
td.tc-spacer-cell:last-child { border-right: none; }
td.tc-spacer-cell.out { background: #edf1f9; }

.tc-day-num {
  font-size: 0.6rem;
  font-weight: 600;
  color: #93a4be;
  text-align: center;
  padding: 3px 0 2px;
  line-height: 1;
}

td.tc-day-cell .tc-abs-bar { margin-bottom: 1px; }

.tc-abs-bar {
  height: 18px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  padding: 0 4px;
  overflow: hidden;
  white-space: nowrap;
  font-size: 0.6rem;
  font-weight: 600;
  width: 100%;
  letter-spacing: 0;
  margin: 2px 1px 1px;
  cursor: pointer;
}

/* =========================================================
   Responsive
========================================================= */
@media (max-width: 860px) {
  .employee-list {
    columns: 1;
  }

  .day-cell {
    height: 72px;
  }

  .month-zoom-grid .day-cell {
    height: 160px;
  }

  .month-col {
    min-width: 108px;
    width: 108px;
  }

  .weekday-col,
  .year-cell {
    width: 18px;
    min-width: 18px;
  }
}
