/* =====================================================
   ILR Absence Tracker — Levitech Style
   Fonts: Montserrat (headings), Open Sans (body)
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700;800&family=Open+Sans:wght@400;500;600&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-bg:         #f6f6f6;
  --c-white:      #ffffff;
  --c-text:       #1b1b1b;
  --c-muted:      #5e5e5e;
  --c-border:     #e2e2e2;
  --c-hover:      #857272;
  --c-dark:       #2c2c2c;
  --c-success:    #2d6a4f;
  --c-success-bg: #e8f5ef;
  --c-warn:       #92600a;
  --c-warn-bg:    #fef3cd;
  --c-danger:     #a33535;
  --c-danger-bg:  #fdeaea;
  --c-accent:     #1b1b1b;
  --radius:       6px;
  --shadow:       0 2px 12px rgba(0,0,0,0.07);
  --shadow-lg:    0 4px 24px rgba(0,0,0,0.11);
  --font-head:    'Montserrat', sans-serif;
  --font-body:    'Open Sans', Helvetica, Arial, sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── NAVBAR ── */
.navbar {
  background: var(--c-white);
  border-bottom: 1px solid var(--c-border);
  padding: 0 40px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar-brand {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 20px;
  color: var(--c-text);
  text-decoration: none;
  letter-spacing: -0.5px;
}
.navbar-right { display: flex; align-items: center; gap: 24px; }
.navbar-user { font-size: 13px; color: var(--c-muted); }
.btn-ghost {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-body); font-size: 13px;
  color: var(--c-muted); padding: 6px 12px;
  border-radius: var(--radius); transition: background 0.2s, color 0.2s;
}
.btn-ghost:hover { background: var(--c-bg); color: var(--c-text); }

/* ── PAGE WRAPPER ── */
.page-wrapper {
  max-width: 1160px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── CARDS ── */
.card {
  background: var(--c-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  margin-bottom: 24px;
}
.card-sm { padding: 24px; }
.card-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 17px;
  margin-bottom: 20px;
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title .step-badge {
  background: var(--c-dark);
  color: #fff;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

/* ── DISCLAIMER BAR ── */
.disclaimer-bar {
  background: #fffbeb;
  border-bottom: 1px solid #f0d070;
  padding: 10px 40px;
  font-size: 12.5px;
  color: #7a5c00;
  line-height: 1.5;
}
.disclaimer-bar strong { color: #5a4200; }

/* ── ROUTE SELECTOR ── */
.route-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.route-card {
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  padding: 24px 20px;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}
.route-card:hover { border-color: var(--c-hover); box-shadow: var(--shadow); }
.route-card.selected { border-color: var(--c-dark); box-shadow: 0 0 0 3px rgba(44,44,44,0.08); }
.route-card h3 {
  font-family: var(--font-head); font-weight: 700; font-size: 15px;
  margin-bottom: 6px;
}
.route-card p { font-size: 13px; color: var(--c-muted); line-height: 1.5; }
.route-card .route-rule {
  margin-top: 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--c-muted);
  background: var(--c-bg);
  padding: 6px 10px;
  border-radius: 4px;
  display: inline-block;
  line-height: 1.5;
}
.route-check {
  position: absolute; top: 12px; right: 12px;
  width: 20px; height: 20px;
  border: 2px solid var(--c-border);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: transparent;
  transition: all 0.2s;
}
.route-card.selected .route-check {
  background: var(--c-dark); border-color: var(--c-dark); color: #fff;
}

/* ── FORM ELEMENTS ── */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  align-items: end;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label {
  font-size: 12px; font-weight: 600;
  color: var(--c-muted); text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group input, .form-group select {
  padding: 10px 12px;
  border: 1.5px solid var(--c-border);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--c-text);
  background: var(--c-white);
  transition: border-color 0.2s;
  width: 100%;
}
.form-group input:focus, .form-group select:focus {
  outline: none;
  border-color: var(--c-dark);
}
.form-group input.error { border-color: var(--c-danger); }
.form-group .hint { font-size: 11px; color: var(--c-muted); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--c-dark); color: #fff; }
.btn-primary:hover { background: #444; }
.btn-secondary {
  background: var(--c-white); color: var(--c-text);
  border: 1.5px solid var(--c-border);
}
.btn-secondary:hover { background: var(--c-bg); }
.btn-danger {
  background: var(--c-danger-bg); color: var(--c-danger);
  border: 1.5px solid #f5c6c6;
}
.btn-danger:hover { background: #f5c6c6; }
.btn-success { background: var(--c-success); color: #fff; }
.btn-success:hover { background: #255f45; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ── TRIPS TABLE ── */
.trips-table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 520px;
}
table.trips-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.trips-table thead th {
  text-align: left; padding: 10px 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--c-muted); background: var(--c-bg);
  border-bottom: 1.5px solid var(--c-border);
  position: sticky; top: 0; z-index: 2;
}
.trips-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
  vertical-align: middle;
}
.trips-table tr:last-child td { border-bottom: none; }
.trips-table tr:hover td { background: #fcfcfc; }
/* Worst 12-month window row */
.trips-table tr.worst-window-row td { background: #fff3e8; }
.trips-table tr.worst-window-row:hover td { background: #ffe8d5; }
.worst-window-badge {
  display: inline-block; font-size: 10px;
  background: #fde8c0; color: #7a4a00;
  border: 1px solid #f5c98a;
  border-radius: 3px; padding: 1px 6px;
  margin-left: 5px; vertical-align: middle;
  white-space: nowrap;
}
/* April 2024 rule-change divider row */
.trips-table tr.rule-divider td {
  background: #f2eeff;
  border-top: 2px solid #b094d8;
  border-bottom: 2px solid #b094d8;
  text-align: center;
  font-size: 11.5px; font-weight: 700;
  color: #5a3a96;
  padding: 8px 12px;
  white-space: normal;
  line-height: 1.5;
}
.days-badge {
  display: inline-flex; align-items: center;
  background: var(--c-bg);
  border-radius: 12px;
  padding: 3px 10px;
  font-weight: 700; font-size: 13px;
}
.days-badge.warn { background: var(--c-warn-bg); color: var(--c-warn); }

/* ── RESULTS PANEL ── */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--c-bg);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-card .stat-value {
  font-family: var(--font-head);
  font-size: 32px; font-weight: 800;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card .stat-label {
  font-size: 12px; color: var(--c-muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  line-height: 1.4;
}
.stat-card.danger .stat-value { color: var(--c-danger); }
.stat-card.warn .stat-value   { color: var(--c-warn); }
.stat-card.success .stat-value { color: var(--c-success); }

/* ── COMPLIANCE STATUS BANNER ── */
.compliance-banner {
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex; align-items: flex-start; gap: 14px;
  margin-bottom: 20px;
}
.compliance-banner.compliant     { background: var(--c-success-bg); border-left: 4px solid var(--c-success); }
.compliance-banner.at-risk       { background: var(--c-warn-bg);    border-left: 4px solid #d4a017; }
.compliance-banner.non-compliant { background: var(--c-danger-bg);  border-left: 4px solid var(--c-danger); }
.compliance-banner .banner-icon  { font-size: 22px; flex-shrink: 0; margin-top: 2px; }
.compliance-banner .banner-title { font-family: var(--font-head); font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.compliance-banner .banner-body  { font-size: 13px; line-height: 1.5; }
.compliance-banner.compliant .banner-title     { color: var(--c-success); }
.compliance-banner.at-risk   .banner-title     { color: var(--c-warn); }
.compliance-banner.non-compliant .banner-title { color: var(--c-danger); }

/* ── YEAR BREAKDOWN TABLE ── */
.year-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.year-table th {
  text-align: left; padding: 9px 12px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--c-muted); background: var(--c-bg);
  border-bottom: 1.5px solid var(--c-border);
}
.year-table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); }
.year-table tr:last-child td { border-bottom: none; }
.progress-bar-wrap {
  background: var(--c-border); border-radius: 100px;
  height: 8px; width: 140px; overflow: hidden; display: inline-block;
}
.progress-bar-fill {
  height: 100%; border-radius: 100px; background: var(--c-dark); transition: width 0.4s;
}
.progress-bar-fill.warn   { background: #d4a017; }
.progress-bar-fill.danger { background: var(--c-danger); }
.pill {
  display: inline-block; padding: 2px 9px;
  border-radius: 12px; font-size: 11px; font-weight: 700;
}
.pill.ok      { background: var(--c-success-bg); color: var(--c-success); }
.pill.warn    { background: var(--c-warn-bg);    color: var(--c-warn); }
.pill.danger  { background: var(--c-danger-bg);  color: var(--c-danger); }

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--c-muted);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── ACTION BAR ── */
.action-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.action-bar-left  { display: flex; gap: 10px; flex-wrap: wrap; }
.action-bar-right { display: flex; gap: 10px; }

/* ── PAGE HEADER ── */
.page-header { margin-bottom: 32px; }
.page-header h1 {
  font-family: var(--font-head);
  font-size: 28px; font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.page-header p { font-size: 14px; color: var(--c-muted); max-width: 560px; }

/* ── GUIDANCE BOX ── */
.guidance-box {
  background: #f8f4f4;
  border: 1px solid #e8dede;
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 13px; color: var(--c-muted);
  line-height: 1.6;
  margin-bottom: 20px;
}
.guidance-box strong { color: var(--c-text); }
.guidance-box ul { margin: 8px 0 0 18px; }
.guidance-box li { margin-bottom: 4px; }

/* ── LOGIN PAGE ── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-bg);
}
.login-box {
  background: var(--c-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
}
.login-logo {
  font-family: var(--font-head);
  font-weight: 800; font-size: 22px;
  margin-bottom: 8px;
  text-align: center;
  color: var(--c-text);
}
.login-subtitle {
  text-align: center; color: var(--c-muted);
  font-size: 14px; margin-bottom: 32px;
  font-weight: 600;
}
.login-box h2 {
  font-family: var(--font-head); font-weight: 700; font-size: 20px;
  margin-bottom: 24px;
}
.form-group + .form-group { margin-top: 16px; }
.login-btn { width: 100%; margin-top: 24px; justify-content: center; padding: 12px; }
.login-switch {
  margin-top: 20px; text-align: center;
  font-size: 13px; color: var(--c-muted);
}
.login-switch a {
  color: var(--c-text); font-weight: 600; text-decoration: none; cursor: pointer;
}
.login-switch a:hover { text-decoration: underline; }
.login-error {
  background: var(--c-danger-bg); color: var(--c-danger);
  padding: 10px 14px; border-radius: var(--radius);
  font-size: 13px; margin-top: 12px;
  display: none;
}
.login-error.show { display: block; }

/* ── MODAL ── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  align-items: center; justify-content: center;
  overflow-y: auto;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--c-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  width: 100%; max-width: 480px;
  position: relative;
  margin: auto;
}
.modal-header {
  font-family: var(--font-head); font-weight: 700; font-size: 17px;
  margin-bottom: 20px;
  display: flex; justify-content: space-between; align-items: center;
}
.modal-close {
  background: none; border: none; cursor: pointer;
  font-size: 20px; color: var(--c-muted); line-height: 1;
}
.modal-footer { margin-top: 24px; display: flex; gap: 10px; justify-content: flex-end; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--c-border); border-radius: 3px; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .navbar { padding: 0 16px; height: auto; min-height: 56px; flex-wrap: wrap; gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .disclaimer-bar { padding: 10px 16px; }
  .page-wrapper { padding: 20px 14px 60px; }
  .route-grid { grid-template-columns: 1fr; }
  .card { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
  .login-box { padding: 32px 20px; }
  .results-grid { grid-template-columns: 1fr 1fr; }
  .action-bar { flex-direction: column; align-items: stretch; }
  .action-bar-left, .action-bar-right { width: 100%; }
}
@media (max-width: 480px) {
  .results-grid { grid-template-columns: 1fr; }
}

/* ── APPLICANT TYPE TOGGLE ── */
.applicant-type-row { display: flex; gap: 12px; flex-wrap: wrap; }
.applicant-type-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  background: var(--c-white); color: var(--c-text);
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
}
.applicant-type-btn input[type=radio] { display: none; }
.applicant-type-btn.selected { border-color: var(--c-dark); background: var(--c-bg); }
.applicant-type-btn:hover { border-color: var(--c-hover); }

/* ── EARLIEST DATE BOX ── */
.earliest-date-box {
  background: #f0f7ff;
  border: 1px solid #b8d4f0;
  border-left: 4px solid #3a7fc1;
  border-radius: var(--radius);
  padding: 14px 18px;
  font-size: 13px;
  line-height: 1.7;
}
.earliest-date-box strong { color: #1a4a7a; }

/* ── HEATMAP CALENDAR ── */
.heatmap-calendar { display: flex; flex-direction: column; gap: 6px; min-width: 600px; }
.heatmap-year { display: flex; align-items: center; gap: 6px; }
.heatmap-year-label {
  font-size: 11px; font-weight: 700; color: var(--c-muted);
  width: 38px; flex-shrink: 0; text-align: right;
}
.heatmap-months { display: flex; gap: 4px; }
.heatmap-month {
  width: 50px; height: 42px;
  border-radius: 4px; padding: 3px 5px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  font-size: 10px;
  background: var(--c-border); color: #aaa;
  cursor: default;
}
.heatmap-month .hm-label { font-weight: 700; font-size: 10px; }
.heatmap-month .hm-count { font-size: 12px; font-weight: 800; margin-top: 1px; }
.heatmap-month.hm-ok     { background: #d4edda; color: #1a5c33; }
.heatmap-month.hm-low    { background: #fef9e7; color: #7a6000; }
.heatmap-month.hm-warn   { background: var(--c-warn-bg); color: var(--c-warn); }
.heatmap-month.hm-risk   { background: #fde8c0; color: #7a4a00; }
.heatmap-month.hm-danger { background: var(--c-danger-bg); color: var(--c-danger); }
.heatmap-legend {
  display: flex; gap: 14px; margin-top: 14px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--c-muted);
}
.heatmap-legend-item { display: flex; align-items: center; gap: 5px; }
.heatmap-legend-swatch { width: 13px; height: 13px; border-radius: 3px; flex-shrink: 0; }

/* ── ADVISER CONTACT CARD ── */
.adviser-card {
  background: #f8f6f6;
  border: 1px solid var(--c-border);
  border-left: 4px solid var(--c-hover);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 24px;
}
.adviser-card h4 {
  font-family: var(--font-head); font-weight: 700; font-size: 15px;
  margin-bottom: 8px; color: var(--c-text);
}
.adviser-card p { font-size: 13px; color: var(--c-muted); margin-bottom: 12px; }
.adviser-contact-info { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.adviser-contact-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--c-white); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 8px 16px;
  font-size: 13px; color: var(--c-text);
}
.contact-icon { font-size: 17px; }

/* ── DIVIDER ── */
.divider { border: none; border-top: 1px solid var(--c-border); margin: 24px 0; }

/* ── TABS ── */
.tabs { display: flex; border-bottom: 1.5px solid var(--c-border); margin-bottom: 24px; gap: 0; overflow-x: auto; }
.tab-btn {
  background: none; border: none; cursor: pointer;
  padding: 10px 20px;
  font-family: var(--font-body); font-size: 13px; font-weight: 600;
  color: var(--c-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1.5px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--c-text); }
.tab-btn.active { color: var(--c-text); border-bottom-color: var(--c-dark); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── FLATPICKR CUSTOMISATION ── */
.flatpickr-input {
  background: var(--c-white) !important;
  cursor: pointer !important;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover {
  background: var(--c-dark) !important;
  border-color: var(--c-dark) !important;
}
.flatpickr-day.today { border-color: var(--c-hover) !important; }

/* ── PRINT UTILITIES ── */
.no-print  { /* visible on screen */ }
.print-only { display: none; }

/* ── PRINT STYLES ── */
@media print {
  .navbar, .disclaimer-bar, .action-bar, .tabs,
  #btn-download, #btn-reset, #btn-add-trip, #btn-import-excel,
  #reminder-section, .adviser-card, .modal-overlay,
  .route-grid, .no-print { display: none !important; }

  body { background: #fff; font-size: 11pt; color: #000; }
  .page-wrapper { padding: 0; max-width: 100%; margin: 0; }
  .card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    margin-bottom: 14px !important;
    padding: 14px 18px !important;
    page-break-inside: avoid;
  }
  .card-title { font-size: 13pt; }
  .tab-panel { display: block !important; margin-bottom: 16px; }
  .trips-table-wrap { max-height: none !important; overflow: visible !important; }
  .trips-table thead th { position: static; }
  .compliance-banner { border: 1px solid #ccc; }
  .results-grid { grid-template-columns: repeat(4, 1fr) !important; }
  .print-only { display: block !important; }

  .page-header h1::after {
    content: " — Compliance Report";
    font-size: 12pt; font-weight: 400; color: #555;
  }
}
