/* ============================================================
   Nuffield Health Physio Availability Dashboard — Styles
   Brand colours: green #00a200, teal #0a5c6a, font: Poppins
   ============================================================ */

/* ----- Reset & base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Nuffield Health brand */
  --nh-green:       #00a200;
  --nh-green-dark:  #007a00;
  --nh-green-light: #e6f7e6;
  --nh-teal:        #0a5c6a;
  --nh-teal-dark:   #07414c;
  --nh-teal-light:  #e0f0f3;

  /* Semantic colours */
  --amber:          #d97706;
  --amber-light:    #fef3c7;
  --blue:           #2563eb;
  --blue-light:     #dbeafe;
  --purple:         #7c3aed;
  --purple-light:   #ede9fe;
  --red:            #dc2626;

  /* Neutrals */
  --bg:             #f4f4f4;
  --surface:        #ffffff;
  --border:         #e0e0e0;
  --text:           #333333;
  --text-muted:     #666666;
  --text-light:     #999999;

  --radius:         6px;
  --radius-lg:      10px;
  --shadow:         0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.12);

  --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, monospace;
}

html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: #f0f0f0;
  padding: 0.15em 0.4em;
  border-radius: 3px;
}

/* ----- Header ----- */
.site-header {
  background: var(--nh-teal);
  color: #fff;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-inner {
  max-width: 1500px;
  margin: 0 auto;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon { flex-shrink: 0; width: 38px; height: 38px; border-radius: 4px; }

.brand-name {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.brand-subtitle {
  display: block;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.7);
  font-weight: 400;
  letter-spacing: 0.02em;
}

.header-meta {
  display: flex;
  align-items: center;
}

.last-updated {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  font-weight: 400;
}

/* ----- Stats bar ----- */
.stats-bar {
  background: var(--surface);
  border-bottom: 3px solid var(--nh-green);
  padding: 0 1.5rem;
}

.stats-bar {
  display: flex;
  max-width: 1500px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.stat-card {
  flex: 1 1 140px;
  padding: 1rem 1.1rem;
  text-align: center;
  border-right: 1px solid var(--border);
  position: relative;
}
.stat-card:last-child { border-right: none; }

.stat-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--nh-teal);
  line-height: 1.1;
}
.stat-card--green  .stat-value { color: var(--nh-green); }
.stat-card--teal   .stat-value { color: var(--nh-teal); }
.stat-card--blue   .stat-value { color: var(--blue); }
.stat-card--amber  .stat-value { color: var(--amber); }
.stat-card--purple .stat-value { color: var(--purple); }

.stat-label {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  line-height: 1.35;
}

/* ----- Controls ----- */
.controls {
  max-width: 1500px;
  margin: 1.25rem auto 0;
  padding: 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.search-wrap {
  position: relative;
  flex: 1 1 220px;
  min-width: 180px;
}

.search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.55rem 0.75rem 0.55rem 2.3rem;
  border: 1.5px solid var(--border);
  border-radius: 48px;
  font-size: 0.88rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  outline: none;
  border-color: var(--nh-green);
  box-shadow: 0 0 0 3px rgba(0,162,0,0.12);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.filter-label {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-select {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1.5px solid var(--border);
  border-radius: 48px;
  font-size: 0.85rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23666'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.55rem center;
  background-size: 1em;
}
.filter-select:focus {
  outline: none;
  border-color: var(--nh-green);
  box-shadow: 0 0 0 3px rgba(0,162,0,0.12);
}

.controls-right { margin-left: auto; }

.showing-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

/* ----- Table ----- */
.table-container {
  max-width: 1500px;
  margin: 1rem auto 3rem;
  padding: 0 1.5rem;
}

.sites-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sites-table thead {
  background: var(--nh-teal);
  color: #fff;
}

.sites-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 3px solid var(--nh-green);
  user-select: none;
  font-family: var(--font);
}

.sites-table th.sortable { cursor: pointer; }
.sites-table th.sortable:hover { background: rgba(255,255,255,0.08); }
.sites-table th.sort-active::after  { content: " ↑"; }
.sites-table th.sort-active.sort-desc::after { content: " ↓"; }

.sites-table td {
  padding: 0.7rem 1rem;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.sites-table tbody tr:last-child td { border-bottom: none; }
.sites-table tbody tr:hover { background: #fafafa; }

/* Column widths */
.col-name     { min-width: 160px; }
.col-type     { width: 90px; }
.col-physios  { width: 80px; text-align: center; }
.col-bookable { width: 110px; text-align: center; }
.col-next     { width: 140px; }
.col-slots    { width: 90px; text-align: center; }
.col-actions  { width: 140px; }

/* Site name cell */
.site-name {
  font-weight: 600;
  color: var(--nh-teal);
  line-height: 1.3;
}
.site-address {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Type badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 48px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge--gym      { background: var(--nh-green-light); color: var(--nh-green-dark); }
.badge--hospital { background: var(--nh-teal-light);  color: var(--nh-teal-dark); }

/* Physio count cell */
.physio-count-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.25rem 0.55rem;
  background: var(--nh-teal-light);
  border: 1.5px solid transparent;
  border-radius: 48px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--nh-teal);
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.physio-count-btn:hover {
  background: #c5e5ea;
  border-color: var(--nh-teal);
}
.physio-count-btn--zero {
  color: var(--text-light);
  background: #f5f5f5;
  cursor: default;
  pointer-events: none;
}

/* Bookable indicator */
.bookable-yes {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--nh-green);
  font-weight: 600;
  font-size: 0.82rem;
}
.bookable-no {
  color: var(--text-light);
  font-size: 0.82rem;
}

/* Next available */
.next-date { font-weight: 600; color: var(--text); }
.next-time { font-size: 0.75rem; color: var(--text-muted); }
.next-none { color: var(--text-light); font-style: italic; font-size: 0.8rem; }

/* Slots badge */
.slots-badge {
  display: inline-block;
  padding: 0.2rem 0.65rem;
  border-radius: 48px;
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 2.2rem;
  text-align: center;
}
.slots-badge--none { background: #f0f0f0; color: var(--text-muted); }
.slots-badge--low  { background: var(--amber-light); color: var(--amber); }
.slots-badge--mid  { background: var(--nh-green-light); color: var(--nh-green-dark); }
.slots-badge--high { background: #bbf7bb; color: #005200; }

/* Action links */
.action-links {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.action-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.77rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--nh-teal);
  transition: color 0.15s;
  white-space: nowrap;
}
.action-link:hover { color: var(--nh-teal-dark); text-decoration: underline; }

.action-link--book {
  color: var(--nh-green);
  font-weight: 600;
}
.action-link--book:hover { color: var(--nh-green-dark); }

.action-link--disabled {
  color: var(--text-light);
  cursor: default;
  pointer-events: none;
}

/* ----- Loading / error / no results ----- */
.loading-state,
.error-state,
.no-results {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--nh-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Responsive ----- */
@media (max-width: 1000px) {
  .stat-card { flex: 1 1 calc(33.33% - 1px); border-bottom: 1px solid var(--border); }
}

@media (max-width: 700px) {
  .header-inner { height: auto; padding: 0.75rem 0; flex-direction: column; align-items: flex-start; }
  .controls { flex-direction: column; }
  .search-wrap { width: 100%; }
  .stat-card { flex: 1 1 50%; }
  .sites-table th, .sites-table td { padding: 0.5rem 0.6rem; font-size: 0.8rem; }
}
