/* ============================================================
   Birkdale Village Care Home — Compliance Portal
   Main stylesheet — mobile-first
   ============================================================ */

:root {
  --primary:   #1d4ed8;
  --primary-h: #1e40af;
  --success:   #16a34a;
  --warning:   #d97706;
  --danger:    #dc2626;
  --info:      #0891b2;
  --bg:        #f1f5f9;
  --card:      #ffffff;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --muted:     #64748b;
  --radius:    12px;
  --shadow:    0 1px 4px rgba(0,0,0,.08), 0 2px 12px rgba(0,0,0,.06);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Navigation ─────────────────────────────────────────────── */
.nav {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.nav-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  gap: 12px;
}
.nav-brand {
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-brand span { font-weight: 400; color: var(--muted); font-size: 13px; display: block; }
.nav-links {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  justify-content: flex-end;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active { background: #eff6ff; color: var(--primary); }
.nav-user {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.btn-logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  color: var(--muted);
  transition: background .15s;
}
.btn-logout:hover { background: #fee2e2; color: var(--danger); border-color: var(--danger); }

/* ── Page container ─────────────────────────────────────────── */
.page { max-width: 900px; margin: 0 auto; padding: 20px 16px 80px; }
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.page-sub { font-size: 14px; color: var(--muted); margin-bottom: 24px; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-header {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-body { padding: 16px 20px; }

/* ── Stat cards ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  text-align: center;
}
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat-card.danger  .stat-num { color: var(--danger); }
.stat-card.warning .stat-num { color: var(--warning); }
.stat-card.success .stat-num { color: var(--success); }
.stat-card.info    .stat-num { color: var(--info); }

/* ── Custom checkboxes (no input[type=checkbox]) ─────────────── */
.cb-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  cursor: pointer;
  border-radius: 8px;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  border-bottom: 1px solid #f8fafc;
}
.cb-row:last-child { border-bottom: none; }
.cb-row:hover .cb-box { border-color: var(--primary); }
.cb-box {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border: 2px solid #cbd5e1;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: transparent;
  background: #fff;
  transition: all .15s;
  flex-shrink: 0;
}
.cb-row[data-checked="true"] .cb-box {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.cb-row[data-checked="true"] .cb-label { color: var(--muted); text-decoration: line-through; }
.cb-label { font-size: 14px; flex: 1; }
.cb-flag .cb-box { border-color: var(--warning); }
.cb-row[data-checked="true"].cb-flag .cb-box { background: var(--warning); border-color: var(--warning); }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-h); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #15803d; }
.btn-danger  { background: var(--danger); color: white; }
.btn-outline {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 14px; font-size: 13px; min-height: 36px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; display: block; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--text);
  min-height: 44px;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,78,216,.12);
}
.form-control[readonly] { background: var(--bg); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 18px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  min-height: 44px;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-btn:hover { color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Status badges ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #e0f2fe; color: #0369a1; }
.badge-neutral { background: #f1f5f9; color: #475569; }

/* ── Status dot ─────────────────────────────────────────────── */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green  { background: var(--success); }
.dot-orange { background: var(--warning); }
.dot-red    { background: var(--danger); }
.dot-gray   { background: #94a3b8; }

/* ── Room grid ───────────────────────────────────────────────── */
.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}
.room-btn {
  aspect-ratio: 1;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.room-btn:hover { border-color: var(--primary); }
.room-btn.done  { background: #dcfce7; border-color: var(--success); color: var(--success); }
.room-btn.overdue { background: #fee2e2; border-color: var(--danger); color: var(--danger); }
.room-btn .room-tick { font-size: 16px; }

/* ── File upload ─────────────────────────────────────────────── */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  color: var(--muted);
  font-size: 13px;
}
.file-upload-area:hover { border-color: var(--primary); background: #eff6ff; }
.file-upload-area .upload-icon { font-size: 28px; margin-bottom: 6px; }
.file-upload-area.has-file { border-color: var(--success); background: #f0fdf4; color: var(--success); }
.file-input { display: none; }

/* ── Table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfd; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-icon { flex-shrink: 0; font-size: 16px; margin-top: 1px; }
.alert-danger  { background: #fee2e2; color: #991b1b; border-left: 3px solid var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 3px solid var(--warning); }
.alert-success { background: #dcfce7; color: #166534; border-left: 3px solid var(--success); }
.alert-info    { background: #e0f2fe; color: #075985; border-left: 3px solid var(--info); }

/* ── Saved pill ──────────────────────────────────────────────── */
#saved-pill {
  position: fixed;
  bottom: 24px;
  right: 20px;
  background: var(--success);
  color: white;
  padding: 8px 18px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(12px);
  transition: all .25s ease;
  pointer-events: none;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
#saved-pill.visible { opacity: 1; transform: translateY(0); }
#offline-pill {
  position: fixed;
  bottom: 24px;
  left: 20px;
  background: var(--warning);
  color: white;
  padding: 8px 18px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  display: none;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
#offline-pill.visible { display: flex; align-items: center; gap: 6px; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }
@media (min-width: 600px) { .modal-backdrop { align-items: center; } }
.modal {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 -8px 40px rgba(0,0,0,.2);
}
@media (min-width: 600px) { .modal { border-radius: var(--radius); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg); }

/* ── Misc helpers ────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-muted { color: var(--muted); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ── Login page ──────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, #1e3a5f 0%, #1d4ed8 100%);
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--primary); line-height: 1.2; }
.login-logo p { font-size: 12px; color: var(--muted); margin-top: 4px; }
.login-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 10px; display: none; }

/* ── Section heading ─────────────────────────────────────────── */
.section-heading {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin: 24px 0 10px;
}

/* ── Staff list ──────────────────────────────────────────────── */
.staff-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: background .15s;
}
.staff-item:last-child { border-bottom: none; }
.staff-item:hover { background: #fafbfd; }
.staff-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.staff-info { flex: 1; min-width: 0; }
.staff-name { font-weight: 600; font-size: 14px; }
.staff-role { font-size: 12px; color: var(--muted); }
.staff-badges { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Repair item ─────────────────────────────────────────────── */
.repair-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.repair-item:last-child { border-bottom: none; }
.repair-item:hover { background: #fafbfd; }

/* ── Cert item ───────────────────────────────────────────────── */
.cert-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .15s;
}
.cert-item:last-child { border-bottom: none; }
.cert-item:hover { background: #fafbfd; }
.cert-icon {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: #eff6ff;
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* ── Dashboard alert list ────────────────────────────────────── */
.alert-list .alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.alert-list .alert-item:last-child { border-bottom: none; }
.alert-list .alert-item .ai-label { flex: 1; }
.alert-list .alert-item .ai-date { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Cost summary ────────────────────────────────────────────── */
.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.cost-row:last-child { border-bottom: none; }
.cost-amount { font-weight: 700; }

/* ── Toast/snackbar ──────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: white;
  padding: 10px 20px;
  border-radius: 100px;
  font-size: 13px;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  z-index: 9998;
  white-space: nowrap;
}
#toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Due soon indicators ─────────────────────────────────────── */
.due-overdue { color: var(--danger); font-weight: 600; }
.due-soon    { color: var(--warning); font-weight: 600; }
.due-ok      { color: var(--success); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 600px) {
  .page { padding: 16px 12px 80px; }
  .card-body { padding: 14px 16px; }
  .card-header { padding: 14px 16px 10px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-link span { display: none; }
  .table-wrap { font-size: 13px; }
}

/* ── Signoff banner ──────────────────────────────────────────── */
.signoff-banner {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.signoff-banner.signed { background: #dcfce7; }

/* ── Period label ────────────────────────────────────────────── */
.period-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 100px;
}

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

/* ── Temp reading ────────────────────────────────────────────── */
.temp-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.temp-row label { flex: 1; font-size: 14px; }
.temp-row input {
  width: 90px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  text-align: right;
}
.temp-unit { font-size: 13px; color: var(--muted); }

/* ── Section separator ───────────────────────────────────────── */
.sec-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 12px;
}
.sec-sep span {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  white-space: nowrap;
}
.sec-sep::before, .sec-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
