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

:root {
  --bg:       #0f1117;
  --surface:  #1a1d27;
  --border:   #2a2d3e;
  --text:     #e8eaf0;
  --muted:    #6b6f85;
  --accent:   #5865f2;
  --accent-h: #4752c4;
  --radius:   8px;
  --cell-h:   88px;
}

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

/* ── Header ─────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 1.25rem; font-weight: 700; }

.last-checked {
  font-size: .75rem;
  color: var(--muted);
  margin-left: .75rem;
}

/* ── Layout ──────────────────────────────────────────────────── */
.layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 57px);
}

aside.filters {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 1rem;
  overflow-y: auto;
}

aside h2 { font-size: .9rem; font-weight: 600; margin-bottom: 1rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

main {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .5rem 1rem;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-h); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

/* ── Filter elements ─────────────────────────────────────────── */
.filter-label {
  display: block;
  font-size: .75rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 1rem 0 .4rem;
}

.week-buttons { display: flex; gap: .4rem; flex-wrap: wrap; }
.week-btn {
  background: var(--border);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .3rem .75rem;
  font-size: .8rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.week-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.people-count {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
}
.count-btn {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--border);
  color: var(--text);
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.count-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.people-list { display: flex; flex-direction: column; gap: .4rem; }
.person-toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .875rem;
  user-select: none;
}
.person-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: opacity .15s;
}
.person-toggle.excluded .person-dot { opacity: .25; }
.person-toggle.excluded { color: var(--muted); }

/* ── Calendar grid ───────────────────────────────────────────── */
.calendar-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.calendar-header span {
  text-align: center;
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .3rem 0;
}

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

/* ── Calendar cells ──────────────────────────────────────────── */
.cal-cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-height: var(--cell-h);
  padding: .5rem .45rem .45rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  position: relative;
  transition: border-color .15s;
}

.cal-cell.empty {
  opacity: .25;
}

.cal-cell.has-slot {
  border-color: var(--border);
}

/* Heat map: ratio of unavailable people — amber → orange → red */
.cal-cell.heat-1 { border-color: #f59e0b99; background: #f59e0b10; } /* ≤20% unavail */
.cal-cell.heat-2 { border-color: #f97316aa; background: #f9731615; } /* ≤40% unavail */
.cal-cell.heat-3 { border-color: #ef4444aa; background: #ef444418; } /* ≤60% unavail */
.cal-cell.heat-4 { border-color: #dc2626bb; background: #dc262620; } /* ≤80% unavail */
.cal-cell.heat-5 { border-color: #b91c1ccc; background: #b91c1c28; } /* >80%  unavail */

.cal-cell.all-available {
  border-color: #34a853 !important;
  background: #34a85322 !important;
}

.cell-date {
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
}
.cell-date .day-num {
  font-size: 1rem;
  color: var(--text);
  display: block;
  line-height: 1;
}

.cell-time {
  font-size: .65rem;
  color: var(--muted);
}

.cell-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: auto;
}

.cell-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cell-dot.busy { opacity: .18; }

.cell-count {
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  margin-top: .1rem;
}

.no-slot-label {
  font-size: .65rem;
  color: var(--muted);
  margin-top: auto;
}

/* ── Today marker ────────────────────────────────────────────── */
.cal-cell.today {
  border-color: var(--accent) !important;
}
.cal-cell.today .cell-date .day-num { color: var(--accent); }

/* ── Legend ──────────────────────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  color: var(--muted);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: .6rem 1.2rem;
  border-radius: 20px;
  font-size: .875rem;
  z-index: 100;
  transition: opacity .3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }
.toast.error { border-color: #ea4335; color: #ea4335; background: #1a0d0d; }

/* ── Empty state ─────────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-size: .9rem;
}

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  transition: opacity .2s;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  width: 320px;
  max-width: calc(100vw - 2rem);
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
}

.modal-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: .2rem .4rem;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--border); }

.modal-date {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .15rem;
}
.modal-time {
  font-size: .8rem;
  color: var(--muted);
  margin-bottom: 1.25rem;
}

.modal-section { margin-bottom: 1rem; }
.modal-section:last-child { margin-bottom: 0; }

.modal-section-title {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .5rem;
}
.modal-section-title.available { color: #34a853; }
.modal-section-title.busy      { color: var(--muted); }

.modal-people { display: flex; flex-direction: column; gap: .4rem; }

.modal-person {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-size: .9rem;
}
.modal-person .person-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.modal-person.busy-person { color: var(--muted); }
.modal-person.busy-person .person-dot { opacity: .3; }

.modal-empty { font-size: .85rem; color: var(--muted); font-style: italic; }

.cal-cell.has-slot { cursor: pointer; }
.cal-cell.has-slot:hover { border-color: var(--accent); }

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