/* WallHit Admin — "gym display" palette, mirrors app/Sources/DesignSystem/Theme.swift */

:root {
  --bg: #0B0E14;
  --bg-top: #07090D;
  --surface: #161B22;
  --surface-hi: #20272F;
  --inset: #10141B;
  --text: #FFFFFF;
  --text-2: #9BA4B0;
  --text-3: #5B6472;
  --divider: rgba(255, 255, 255, 0.08);
  --accent: #2BE08B;
  --accent-dim: rgba(43, 224, 139, 0.14);
  --amber: #FFB020;
  --danger: #FF4D4F;
  --topbar-bg: rgba(11, 14, 20, 0.86);
  --glow: rgba(43, 224, 139, 0.07);
  /* Primary-button fill stays the bright brand green in both themes (dark text on it). */
  --accent-fill: #2BE08B;
  --accent-fill-text: #05130C;
  --radius: 14px;
  --font: "Rubik", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

[data-theme="light"] {
  --bg: #F2F4F7;
  --bg-top: #E9EDF1;
  --surface: #FFFFFF;
  --surface-hi: #E8ECF1;
  --inset: #F3F5F8;
  --text: #10151C;
  --text-2: #46515D;
  --text-3: #7B8794;
  --divider: rgba(15, 23, 32, 0.10);
  --accent: #0B9D61;           /* darker green — readable on white */
  --accent-dim: rgba(11, 157, 97, 0.10);
  --amber: #B97A00;
  --danger: #D92D2F;
  --topbar-bg: rgba(242, 244, 247, 0.86);
  --glow: rgba(11, 157, 97, 0.06);
}
html[data-theme="light"] { color-scheme: light; }

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

/* Author display rules (e.g. .login-wrap { display:grid }) would beat the UA's
   [hidden] { display:none } — force it so view switching works. */
[hidden] { display: none !important; }

html { color-scheme: dark; }

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 500px at 50% -180px, var(--glow), transparent 65%),
    linear-gradient(180deg, var(--bg-top), var(--bg) 320px);
  background-color: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--mono); }

/* ---------- buttons ---------- */

.btn {
  font: 600 0.9rem/1 var(--font);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  color: var(--text);
  background: var(--surface-hi);
  transition: transform 0.06s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent-fill);
  color: var(--accent-fill-text);
  font-weight: 700;
  box-shadow: 0 0 22px rgba(43, 224, 139, 0.22);
}
[data-theme="light"] .btn-primary { box-shadow: 0 2px 12px rgba(11, 157, 97, 0.28); }
.btn-secondary {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: rgba(43, 224, 139, 0.35);
}
.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--divider);
}
.btn-icon { padding: 0.55rem 0.65rem; display: inline-flex; align-items: center; }
.btn-block { width: 100%; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: rgba(255, 77, 79, 0.35); }

.btn.busy { pointer-events: none; opacity: 0.6; }

/* ---------- fields ---------- */

.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field > span {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.field > span em { font-style: normal; text-transform: none; letter-spacing: 0; font-weight: 500; }

input, select {
  font: 500 0.95rem/1.3 var(--font);
  color: var(--text);
  background: var(--inset);
  border: 1px solid var(--divider);
  border-radius: 10px;
  padding: 0.7rem 0.85rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input.mono { font-family: var(--mono); text-transform: uppercase; }
input::placeholder { color: var(--text-3); text-transform: none; }
input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(43, 224, 139, 0.15);
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 18px) 55%, calc(100% - 13px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }

/* ---------- login ---------- */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: 20px;
  padding: 2.4rem 2.1rem 1.8rem;
  text-align: center;
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

.login-logo { display: flex; justify-content: center; margin-bottom: 1rem; }
.login-logo svg { filter: drop-shadow(0 0 18px rgba(43, 224, 139, 0.35)); }

.login-title { font-size: 1.7rem; font-weight: 900; letter-spacing: -0.01em; }
.login-title span { color: var(--accent); }
.login-sub { color: var(--text-3); font-size: 0.85rem; margin: 0.3rem 0 1.7rem; }

#login-form { display: flex; flex-direction: column; gap: 0.9rem; text-align: left; }
.login-status { min-height: 1.2em; font-size: 0.82rem; color: var(--danger); text-align: center; }
.login-foot { margin-top: 1.4rem; font-size: 0.72rem; color: var(--text-3); line-height: 1.5; }
.login-foot code { font-family: var(--mono); color: var(--text-2); }

/* ---------- topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 4vw, 2.2rem);
  background: var(--topbar-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--divider);
}
.topbar-brand { display: flex; align-items: center; gap: 0.55rem; font-size: 1.05rem; }
.topbar-brand strong { font-weight: 900; }
.topbar-admin {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--accent);
  border: 1px solid rgba(43, 224, 139, 0.4);
  border-radius: 99px;
  padding: 0.18rem 0.5rem;
}
.topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.topbar-who { color: var(--text-3); font-size: 0.8rem; max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- layout ---------- */

.content { padding: clamp(1rem, 4vw, 2.2rem); max-width: 1180px; margin: 0 auto; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; margin-bottom: 1.4rem; }
.stat {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}
.stat-num { font-size: 2.1rem; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-num.accent { color: var(--accent); text-shadow: 0 0 24px rgba(43, 224, 139, 0.35); }
[data-theme="light"] .stat-num.accent { text-shadow: none; }
.stat-label { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-3); margin-top: 0.2rem; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; align-items: start; }
.card-wide { grid-column: 1 / -1; }

.card {
  background: var(--surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.2rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.9rem; }
.card-head h2 { font-size: 0.78rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; color: var(--text-2); }
.count { color: var(--text-3); font-weight: 600; }
.filter { max-width: 260px; padding: 0.5rem 0.75rem; font-size: 0.85rem; }

.hint { font-size: 0.76rem; color: var(--text-3); line-height: 1.5; margin-bottom: 0.8rem; }
.hint code { font-family: var(--mono); color: var(--text-2); }
.empty { color: var(--text-3); font-size: 0.85rem; padding: 0.6rem 0; }

/* ---------- rows ---------- */

.rows { list-style: none; }
.rows li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.25rem;
  border-bottom: 1px solid var(--divider);
}
.rows li:last-child { border-bottom: none; }
.rows li.editing { flex-wrap: wrap; background: var(--inset); border-radius: 10px; padding: 0.65rem 0.6rem; }

.row-main { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 0.55rem; flex-wrap: wrap; }
.row-code { font-family: var(--mono); font-weight: 600; font-size: 0.92rem; }
.row-name { font-weight: 600; font-size: 0.92rem; }
.row-sub { color: var(--text-3); font-size: 0.78rem; }
.row-chip {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-hi);
  border-radius: 99px;
  padding: 0.18rem 0.55rem;
  white-space: nowrap;
}
.row-chip.unassigned { color: var(--amber); background: rgba(255, 176, 32, 0.12); }

/* active/off toggle pill */
.pill {
  font: 700 0.72rem/1 var(--font);
  padding: 0.32rem 0.7rem;
  border-radius: 99px;
  border: 1px solid var(--divider);
  background: var(--inset);
  color: var(--text-3);
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.06s ease;
}
.pill:hover { filter: brightness(1.25); }
.pill:active { transform: scale(0.95); }
.pill.on {
  color: var(--accent);
  border-color: rgba(43, 224, 139, 0.45);
  box-shadow: 0 0 12px rgba(43, 224, 139, 0.18);
}
.pill:disabled { opacity: 0.5; cursor: wait; }

.row-edit-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); padding: 0.3rem; border-radius: 8px; display: inline-flex;
}
.row-edit-btn:hover { color: var(--text); background: var(--surface-hi); }

/* inline row editor */
.row-editor {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  padding-top: 0.6rem;
}
.row-editor .actions { grid-column: 1 / -1; display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ---------- forms ---------- */

.inline-form { display: flex; gap: 0.55rem; margin-top: 0.8rem; }
.inline-form input { flex: 1; }
.stack-form { display: flex; flex-direction: column; gap: 0.85rem; }

/* ---------- resolve result ---------- */

.resolve-result {
  margin-top: 0.9rem;
  border-radius: 10px;
  padding: 0.85rem 1rem;
  background: var(--inset);
  border: 1px solid var(--divider);
  font-size: 0.88rem;
  line-height: 1.6;
  animation: rise 0.25s ease both;
}
.resolve-result .verdict { font-weight: 800; font-size: 1rem; }
.resolve-result.ok { border-color: rgba(43, 224, 139, 0.4); }
.resolve-result.ok .verdict { color: var(--accent); }
.resolve-result.bad { border-color: rgba(255, 77, 79, 0.4); }
.resolve-result.bad .verdict { color: var(--danger); }
.resolve-result.warn { border-color: rgba(255, 176, 32, 0.4); }
.resolve-result.warn .verdict { color: var(--amber); }
.resolve-result dl { display: grid; grid-template-columns: auto 1fr; gap: 0.1rem 1rem; margin-top: 0.4rem; }
.resolve-result dt { color: var(--text-3); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 700; align-self: center; }
.resolve-result dd { font-family: var(--mono); font-size: 0.84rem; }

/* ---------- theme toggle ---------- */

.theme-float { position: fixed; top: 1rem; right: 1rem; z-index: 20; }
.icon-moon { display: none; }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="light"] .icon-moon { display: block; }

/* ---------- toast / footer ---------- */

.toast {
  position: fixed;
  bottom: 1.4rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-hi);
  border: 1px solid var(--divider);
  border-radius: 12px;
  padding: 0.75rem 1.2rem;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.55);
  z-index: 50;
  animation: toast-in 0.25s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
[data-theme="light"] .toast { box-shadow: 0 10px 30px rgba(20, 30, 40, 0.18); }
.toast.err { border-color: rgba(255, 77, 79, 0.5); color: var(--danger); }
.toast.ok { border-color: rgba(43, 224, 139, 0.5); color: var(--accent); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 12px); } }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem clamp(1rem, 4vw, 2.2rem) 2rem;
  color: var(--text-3);
  font-size: 0.72rem;
  max-width: 1180px;
  margin: 0 auto;
}
.foot .mono { overflow: hidden; text-overflow: ellipsis; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
  .stat-num { font-size: 1.5rem; }
  .row-editor { grid-template-columns: 1fr; }
  .card-head { flex-wrap: wrap; }
  .filter { max-width: 100%; width: 100%; }
  .topbar-who { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
