/* EZ GPS admin page. One file, no fonts or images fetched from anywhere else (see _headers). */

:root {
  --bg: #f6f5f8;
  --surface: #ffffff;
  --surface-2: #efedf3;
  --text: #1b1a1f;
  --muted: #5f5c69;
  --border: #dcd9e3;
  --accent: #a800bc; /* the logo purple */
  --accent-strong: #86009a;
  --on-accent: #ffffff;
  --accent-soft: #f6e4f9;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --ok: #1b7a3d;
  --ok-soft: #e4f4ea;
  --warn: #8a5300;
  --warn-soft: #fdf0d8;
  --team-bubble: #efe3f2;
  --user-bubble: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 10, 30, 0.08), 0 2px 8px rgba(20, 10, 30, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131217;
    --surface: #1c1b22;
    --surface-2: #26242d;
    --text: #efedf3;
    --muted: #a9a5b5;
    --border: #35323f;
    --accent: #d36be3;
    --accent-strong: #e48df1;
    --on-accent: #1a0620;
    --accent-soft: #3a1f40;
    --danger: #f2b8b5;
    --danger-soft: #3d1f1d;
    --ok: #8fd7a8;
    --ok-soft: #1b3326;
    --warn: #f1c27a;
    --warn-soft: #3a2b12;
    --team-bubble: #35203b;
    --user-bubble: #26242d;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

a {
  color: var(--accent-strong);
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: 1.5rem;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- Top bar ---------------------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 20px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 800;
}

.nav {
  display: flex;
  gap: 4px;
  flex: 1;
}

.nav a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.nav a:hover {
  background: var(--surface-2);
}

.nav a[aria-current='page'] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.75rem;
  line-height: 20px;
  text-align: center;
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.875rem;
}

/* ---- Layout ----------------------------------------------------------------------------- */

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 64px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.stack > * + * {
  margin-top: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.card > h2 {
  margin-bottom: 12px;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 860px) {
  .two-col {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- Controls --------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

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

.btn.primary:hover:not(:disabled) {
  background: var(--accent-strong);
}

.btn.danger {
  color: var(--danger);
  border-color: var(--danger);
}

.btn.small {
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.875rem;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field label {
  font-weight: 600;
  font-size: 0.9rem;
}

input[type='text'],
input[type='email'],
input[type='password'],
input[type='search'],
input[type='date'],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.inline-form .field {
  flex: 1 1 220px;
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.segmented button {
  min-height: 36px;
  padding: 4px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.segmented button[aria-pressed='true'] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
  font-weight: 700;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.toolbar input[type='search'] {
  flex: 1 1 220px;
  max-width: 340px;
}

/* ---- Lists ------------------------------------------------------------------------------ */

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.list > li + li {
  border-top: 1px solid var(--border);
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 16px;
  padding: 12px 16px;
  color: inherit;
  text-decoration: none;
}

a.row:hover {
  background: var(--surface-2);
}

.row-title {
  font-weight: 700;
  overflow-wrap: anywhere;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.875rem;
}

.row-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  color: var(--muted);
  font-size: 0.875rem;
  white-space: nowrap;
}

.snippet {
  color: var(--muted);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.chip {
  display: inline-block;
  padding: 1px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.chip.waiting,
.chip.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.chip.answered,
.chip.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.chip.person {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.chip.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

.empty,
.loading,
.error-box {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

.error-box {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.notice {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.9rem;
}

.notice.bad {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---- Conversation ----------------------------------------------------------------------- */

.thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble {
  max-width: 85%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--user-bubble);
  overflow-wrap: anywhere;
  white-space: pre-wrap; /* keeps the line breaks people typed */
}

.bubble.team {
  align-self: flex-end;
  background: var(--team-bubble);
}

.bubble.user {
  align-self: flex-start;
}

.bubble.system {
  align-self: stretch;
  max-width: none;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.875rem;
  border-style: dashed;
}

.bubble-meta {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: normal;
}

.composer {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.composer-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

dl.facts {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0;
}

dl.facts dt {
  color: var(--muted);
}

dl.facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

/* ---- Tables (account page, audit log) --------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

td.break {
  overflow-wrap: anywhere;
}

pre.meta {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
}

/* ---- Sign-in ---------------------------------------------------------------------------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.login .card {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.login form {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

/* ---- Message toast ---------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 20;
  max-width: min(92vw, 520px);
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  font-weight: 600;
}

.toast.bad {
  background: #b3261e;
  color: #ffffff;
}

.toast[hidden] {
  display: none;
}
