/* =============================================================================
 * Toverhacks admin — light, friendly, mobile-first
 * Designed to be glanceable on a phone in the middle of a keynote.
 * ============================================================================= */

:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --bg-input: #f5f5f7;
  --line: #d2d2d7;
  --line-soft: #e8e8ed;
  --fg: #1d1d1f;
  --fg-soft: #515154;
  --fg-mute: #86868b;
  --acc: #007aff;
  --acc-hi: #0a84ff;
  --acc-soft: #e5f1ff;
  --err: #ff3b30;
  --warn: #ff9500;
  --ok: #34c759;
  --shadow: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.05);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--acc); text-decoration: none; }
a:hover { color: var(--acc-hi); }

/* ---- Buttons ---- */
button {
  appearance: none;
  background: var(--acc);
  color: #fff;
  border: 0;
  border-radius: 10px;
  padding: 12px 18px;
  font: 600 0.97rem/1 inherit;
  cursor: pointer;
  min-height: 44px;
  letter-spacing: -0.01em;
  transition: background 0.12s, transform 0.05s;
  touch-action: manipulation;
}
button:hover { background: var(--acc-hi); }
button:active { transform: scale(0.98); }
button[disabled] { opacity: 0.4; cursor: not-allowed; }
button.ghost {
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--line);
}
button.ghost:hover { background: var(--line-soft); color: var(--fg); }
button.warn { background: var(--err); }
button.warn:hover { background: #e0312a; }

/* ---- Inputs ---- */
input, textarea, select {
  width: 100%;
  background: var(--bg-card);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 14px;
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--acc);
  box-shadow: 0 0 0 3px var(--acc-soft);
}
textarea { resize: vertical; min-height: 7rem; }
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fg-soft);
  margin: 14px 0 6px;
}
label.inline {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  color: var(--fg);
  font-size: 0.95rem;
  margin: 14px 0;
}
label.inline input[type="checkbox"] {
  width: auto;
  width: 22px;
  height: 22px;
  accent-color: var(--acc);
}
.muted { color: var(--fg-mute); font-size: 0.86rem; margin: 6px 0; }
.muted code { background: var(--line-soft); padding: 1px 6px; border-radius: 4px; font-size: 0.88em; }
.err-msg { color: var(--err); margin-top: 8px; min-height: 1.2em; font-size: 0.9rem; }

/* ---- Top bar ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(255,255,255,0.92);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid var(--line);
}
.topbar h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--fg);
}
.topbar .right { display: flex; align-items: center; gap: 12px; }
.topbar #who { color: var(--fg-mute); font-size: 0.85rem; }
.topbar button {
  background: transparent;
  color: var(--acc);
  padding: 8px 10px;
  font-weight: 500;
  font-size: 0.92rem;
  min-height: 36px;
}
.topbar button:hover { background: var(--line-soft); }

/* ---- Tab bar ---- */
.tabbar {
  position: sticky;
  top: 53px;          /* below topbar */
  z-index: 19;
  background: var(--bg);
  border-bottom: 0.5px solid var(--line);
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 8px 8px 0;
  gap: 4px;
}
.tabbar::-webkit-scrollbar { display: none; }
.tabbar button.tab {
  background: transparent;
  color: var(--fg-mute);
  border-radius: 10px 10px 0 0;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 500;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  min-width: 64px;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.tabbar button.tab:hover { background: transparent; color: var(--fg); }
.tabbar button.tab.is-active {
  color: var(--acc);
  border-bottom-color: var(--acc);
}
.tabbar .icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* ---- Tab panels ---- */
main { padding: 16px; max-width: 720px; margin: 0 auto; }
.panel { display: none; }
.panel.is-active { display: block; }

.section {
  background: var(--bg-card);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
}
.section h2 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.section h3 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-mute);
  margin: 18px 0 8px;
}
.section > h3:first-child { margin-top: 4px; }

/* ---- iOS-style segmented control ---- */
.seg {
  display: inline-flex;
  background: var(--bg-input);
  border-radius: 9px;
  padding: 3px;
  gap: 0;
  border: 1px solid var(--line);
}
.seg button {
  background: transparent;
  color: var(--fg-soft);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 0.93rem;
  font-weight: 500;
  min-height: 36px;
  letter-spacing: -0.005em;
}
.seg button.is-active {
  background: #fff;
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.seg button:hover { background: rgba(255,255,255,0.5); color: var(--fg); }
.seg button.is-active:hover { background: #fff; }

/* ---- Row helper ---- */
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; margin-top: 10px; }
.row > * { flex: 1 1 auto; }
.row .grow { flex: 2 1 auto; }
.row button { flex: 0 0 auto; }

.status-line {
  font-size: 0.86rem;
  color: var(--fg-mute);
  margin-top: 10px;
  min-height: 1.2em;
}
.status-line.ok { color: var(--ok); }
.status-line.err { color: var(--err); }

/* ---- BB picker ---- */
.bb-block { margin-bottom: 14px; }
.bb-block label.head {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-mute);
  margin: 0 0 8px;
}
.bb-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.bb-buttons button {
  background: var(--bg-input);
  color: var(--fg-soft);
  border: 1px solid var(--line);
  padding: 0;
  min-width: 50px;
  min-height: 50px;
  border-radius: 10px;
  font-size: 1.2rem;
  font-weight: 600;
}
.bb-buttons button.is-active {
  background: var(--acc);
  color: #fff;
  border-color: var(--acc);
}
.bb-buttons button:hover { color: var(--fg); border-color: var(--acc); background: var(--acc-soft); }
.bb-buttons button.is-active:hover { background: var(--acc-hi); color: #fff; }

/* ---- Big call-to-action broadcast buttons ---- */
.broadcast-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
}
.broadcast-grid button {
  padding: 16px;
  font-size: 1.02rem;
  text-align: left;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.broadcast-grid button .b-icon {
  font-size: 1.4rem;
  line-height: 1;
}
.broadcast-grid button .b-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}
.broadcast-grid button .b-title { font-weight: 600; }
.broadcast-grid button .b-sub { font-size: 0.82rem; opacity: 0.85; font-weight: 400; }
.broadcast-grid button.send-article { background: var(--ok); }
.broadcast-grid button.send-article:hover { background: #2eb350; }
.broadcast-grid button.send-form { background: var(--acc); }
.broadcast-grid button.send-form:hover { background: var(--acc-hi); }

/* ---- GPS tab ---- */
.gps-search {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.gps-search input {
  flex: 1 1 auto;
  font-size: 1.05rem;
  padding: 14px 16px;
  border-radius: 12px;
}
.gps-search button {
  flex: 0 0 auto;
  padding: 0 18px;
  border-radius: 12px;
  min-width: 110px;
  font-size: 0.97rem;
}

.gps-now {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  background: var(--acc-soft);
  border-radius: 12px;
}
.gps-now .pin {
  font-size: 1.8rem;
  line-height: 1;
}
.gps-now .text { flex: 1; min-width: 0; }
.gps-now .head {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--acc);
  margin-bottom: 2px;
}
.gps-now .place {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gps-now .coords {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: var(--fg-mute);
  margin-top: 2px;
}
.gps-now.is-searching .place::after {
  content: " …";
  color: var(--fg-mute);
  font-weight: 400;
}

.gps-map-wrap {
  position: relative;
  padding: 6px;
}
#gps-map {
  width: 100%;
  height: 52vh;
  min-height: 280px;
  max-height: 480px;
  border-radius: 10px;
  background: #e8e8ed;
  overflow: hidden;
}
.gps-map-hint {
  color: var(--fg-mute);
  font-size: 0.86rem;
  margin-top: 8px;
  text-align: center;
}
#gps-map-fallback {
  display: none;
  padding: 32px 16px;
  text-align: center;
  color: var(--fg-mute);
  font-size: 0.9rem;
}
#gps-map-wrap.no-leaflet #gps-map { display: none; }
#gps-map-wrap.no-leaflet #gps-map-fallback { display: block; }

details.advanced {
  padding: 0;
  overflow: hidden;
}
details.advanced summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 500;
  color: var(--fg-soft);
  user-select: none;
}
details.advanced summary::-webkit-details-marker { display: none; }
details.advanced summary::after {
  content: "▾";
  color: var(--fg-mute);
  transition: transform 0.18s;
}
details.advanced[open] summary::after { transform: rotate(180deg); }
details.advanced .advanced-body { padding: 0 18px 18px; }

/* ---- Services panel ---- */
.svc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.svc-card {
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 96px;
}
.svc-card .svc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.svc-card .svc-name {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.svc-card .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--fg-mute);
}
.svc-card.up    .dot { background: var(--ok); }
.svc-card.down  .dot { background: var(--err); }
.svc-card.warn-stale .dot { background: var(--warn); }
.svc-card .meta { font-size: 0.78rem; color: var(--fg-mute); }
.svc-card .restart {
  margin-top: auto;
  background: transparent;
  color: var(--acc);
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-size: 0.85rem;
  font-weight: 500;
  min-height: 34px;
  border-radius: 8px;
}
.svc-card .restart:hover {
  background: var(--acc-soft);
  border-color: var(--acc);
}
.svc-card .restart[disabled] {
  opacity: 0.6;
}

/* ---- Logs ---- */
.log-toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.log-toolbar input, .log-toolbar select { flex: 1 1 8rem; min-width: 0; }
.log-toolbar button { flex: 0 0 auto; }
pre#logs {
  background: #1d1d1f;
  color: #e5e5e7;
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  height: 60vh;
  max-height: 60vh;
  min-height: 18rem;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
#logs .l-info  { color: #e5e5e7; }
#logs .l-warn  { color: #ffd60a; }
#logs .l-error { color: #ff453a; }
#logs .l-fatal { color: #ff453a; font-weight: 700; }
#logs .l-debug { color: #98989d; }
#logs .l-trace { color: #6e6e73; }
#logs .svc { color: #5ac8fa; }
#logs .ts  { color: #6e6e73; }

/* ---- Login screen ---- */
body.login {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 22rem;
  background: var(--bg-card);
  border-radius: 16px;
  padding: 28px 24px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 4px;
  text-align: center;
  letter-spacing: -0.01em;
}
.login-card .sub {
  text-align: center;
  color: var(--fg-mute);
  font-size: 0.92rem;
  margin-bottom: 24px;
}
.login-card button { width: 100%; margin-top: 12px; }

/* ---- iPhone safe area ---- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  main { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
