/* Goobers Internal Operations - local control panel
 *
 * Dark by default, because this is an operations console that sits open on a
 * second monitor. Light mode follows the OS so it is readable in daylight.
 * Every colour is a token on :root so the two themes cannot drift apart.
 */

:root {
  color-scheme: dark;

  --bg:            #0c0f16;
  --bg-elev:       #141924;
  --surface:       #171d2a;
  --surface-2:     #1e2533;
  --surface-hover: #232b3c;
  --line:          #28303f;
  --line-strong:   #37415480;

  --text:          #e8ecf4;
  --text-dim:      #9aa5b8;
  --text-faint:    #6b7589;

  --accent:        #5b7cfa;
  --accent-hover:  #6e8bff;
  --accent-soft:   #5b7cfa1f;

  --danger:        #e5484d;
  --danger-hover:  #f05055;
  --danger-soft:   #e5484d1c;

  --warn:          #e09b3d;
  --warn-soft:     #e09b3d1c;

  --ok:            #3fb27f;
  --ok-soft:       #3fb27f1c;

  --radius:   10px;
  --radius-sm: 6px;
  --gap:      16px;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --shadow: 0 1px 2px #0006, 0 8px 24px -12px #0009;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;

    --bg:            #f4f6fa;
    --bg-elev:       #ffffff;
    --surface:       #ffffff;
    --surface-2:     #f7f9fc;
    --surface-hover: #eef2f8;
    --line:          #dde3ec;
    --line-strong:   #c6cedb;

    --text:          #141924;
    --text-dim:      #5a6476;
    --text-faint:    #8b95a7;

    --accent-soft:   #5b7cfa16;
    --danger-soft:   #e5484d14;
    --warn-soft:     #e09b3d16;
    --ok-soft:       #3fb27f16;

    --shadow: 0 1px 2px #0f172a0f, 0 8px 24px -16px #0f172a24;
  }
}

* { box-sizing: border-box; }

/* The UA rule for [hidden] is display:none at class-level specificity, so any
 * class here that sets display (.login-shell, .view, .inline-form) silently
 * beats it and the element stays on screen. Everything in this panel is shown
 * and hidden through the hidden attribute, so this has to win outright. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: 1.1rem; }
h2 { font-size: 1rem; }
h3 { font-size: 0.95rem; }

p { margin: 0; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.08em 0.36em;
}

.muted  { color: var(--text-dim); }
.fine   { font-size: 0.82rem; }
.empty  { color: var(--text-faint); padding: 24px 0; text-align: center; }

/* ------------------------------------------------------------------ brand */

.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--accent), #8b5cf6);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------ login */

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-text h1 { font-size: 1rem; }
.brand-text p  { font-size: 0.82rem; }

/* ----------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: 12px 20px;
  background: var(--bg-elev);
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.topbar-title {
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------------- tabs */

.tabs {
  position: sticky;
  top: 57px;
  z-index: 19;
  display: flex;
  gap: 2px;
  padding: 0 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.9rem;
  padding: 11px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.12s, border-color 0.12s;
}
.tab:hover { color: var(--text); }
.tab.is-active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 550;
}

/* ---------------------------------------------------------------- content */

.content {
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 20px 72px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-danger { border-color: #e5484d4d; }
.card-alert {
  border-color: var(--danger);
  background: linear-gradient(180deg, var(--danger-soft), transparent 90px), var(--surface);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head h2 { margin-right: auto; }

.card-lead {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 14px;
  max-width: 68ch;
}

/* ------------------------------------------------------------ stat tiles */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
  box-shadow: var(--shadow);
}
.stat-label {
  display: block;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stat-value {
  display: block;
  margin-top: 3px;
  font-size: 1.22rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.stat-sub {
  display: block;
  color: var(--text-faint);
  font-size: 0.76rem;
  font-family: var(--mono);
}

/* ----------------------------------------------------- chips and badges */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.76rem;
  font-weight: 550;
  white-space: nowrap;
}
.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.chip-plain::before { display: none; }

.chip-ok     { color: var(--ok);     background: var(--ok-soft);     border-color: #3fb27f4d; }
.chip-safe   { color: var(--ok);     background: var(--ok-soft);     border-color: #3fb27f4d; }
.chip-danger { color: var(--danger); background: var(--danger-soft); border-color: #e5484d4d; }
.chip-warn   { color: var(--warn);   background: var(--warn-soft);   border-color: #e09b3d4d; }
.chip-idle   { color: var(--text-faint); }

.badge-row, .prereq-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.prereq-row { margin-bottom: 16px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 0.8rem;
  font-family: var(--mono);
  color: var(--text-dim);
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--text-faint);
}
.badge.on       { color: var(--ok);     border-color: #3fb27f40; background: var(--ok-soft); }
.badge.on::before     { background: var(--ok); }
.badge.danger   { color: var(--danger); border-color: #e5484d40; background: var(--danger-soft); }
.badge.danger::before { background: var(--danger); }
.badge.warn     { color: var(--warn);   border-color: #e09b3d40; background: var(--warn-soft); }
.badge.warn::before   { background: var(--warn); }

/* ------------------------------------------------------------- vote bar */

.vote-bar {
  height: 8px;
  margin: 4px 0 9px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow: hidden;
}
.vote-bar > span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text-faint);
  transition: width 0.3s ease;
}
/* Threshold met: this request is on its way to the owner. */
.vote-bar > span.is-met { background: var(--danger); }

/* ---------------------------------------------------------------- stepper */

.stepper {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-reset: step;
}

.step {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
  transition: border-color 0.15s, opacity 0.15s;
}

.step-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
}

.step-num {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.step-title { margin-right: auto; min-width: 0; }
.step-title p { font-size: 0.82rem; margin-top: 2px; max-width: 58ch; }

.step-state {
  flex: none;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.step-body {
  padding: 0 15px 15px 51px;
}

/* Active: the one you can act on now. */
.step.is-active { border-color: var(--accent); background: var(--surface); }
.step.is-active .step-num { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.step.is-active .step-state { color: var(--accent); border-color: #5b7cfa4d; background: var(--accent-soft); }

/* Done. The digit is hidden and replaced by a tick, rather than sitting
 * next to one. font-size: 0 on the box collapses the text node; the
 * pseudo-element sets its own size back. */
.step.is-done .step-num {
  border-color: #3fb27f66;
  color: var(--ok);
  background: var(--ok-soft);
  font-size: 0;
}
.step.is-done .step-num::after {
  content: "\2713";
  font-size: 0.82rem;
  font-weight: 700;
}
.step.is-done .step-state { color: var(--ok); border-color: #3fb27f4d; background: var(--ok-soft); }

/* Locked: visible, so you can see what is coming, but inert. */
.step.is-locked { opacity: 0.55; }
.step.is-locked .step-body { pointer-events: none; filter: grayscale(0.4); }

/* The final step is red once it is reachable. */
.step.is-final.is-active { border-color: var(--danger); }
.step.is-final.is-active .step-num,
.step.is-final.is-active .step-state {
  color: var(--danger);
  border-color: #e5484d66;
  background: var(--danger-soft);
}

/* ----------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.field > label, .config-row > label {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 550;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.9rem;
  transition: border-color 0.12s, box-shadow 0.12s;
}
input:focus-visible, select:focus-visible, button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-faint); }

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
  flex: none;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.inline-form {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}
.inline-form .field { min-width: 190px; }

.btn-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* --------------------------------------------------------------- buttons */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-sm    { padding: 5px 11px; font-size: 0.82rem; }
.btn-block { width: 100%; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }

.btn-warn { background: var(--warn-soft); color: var(--warn); border-color: #e09b3d59; }
.btn-warn:hover:not(:disabled) { background: #e09b3d2e; }

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-dim);
  border-color: var(--line-strong);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-hover); color: var(--text); }

/* ---------------------------------------------------------------- alerts */

.alert {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #e5484d40; }
.alert-ok    { background: var(--ok-soft);     color: var(--ok);     border-color: #3fb27f40; }

.form-msg { font-size: 0.86rem; color: var(--text-dim); }
.form-msg.is-error { color: var(--danger); }
.form-msg.is-ok    { color: var(--ok); }

/* --------------------------------------------------------------- console */

.console {
  margin: 0;
  padding: 13px 15px;
  max-height: 420px;
  overflow: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.code-chip {
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  border: 1px dashed #5b7cfa73;
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  user-select: all;
}

/* -------------------------------------------------------- config layout */

.config-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.config-group {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}
.config-group > legend {
  grid-column: 1 / -1;
  padding: 0 0 8px;
  margin-bottom: 2px;
  width: 100%;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.config-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.config-row.wide { grid-column: 1 / -1; }
.config-row.inline {
  flex-direction: row;
  align-items: center;
  gap: 9px;
}
.config-row.inline > label { order: 2; }

.config-path {
  display: block;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 400;
}

/* Whether a setting belongs to the selected server or to all of them. The
   difference matters enough to label every row rather than group them. */
.config-scope {
  display: inline-block;
  margin-top: 4px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.config-scope.is-server {
  color: var(--accent);
  background: var(--accent-soft);
}
.config-scope.is-shared {
  color: var(--text-faint);
  background: var(--surface-2);
}

/* ---- server switcher (topbar) ---- */

.server-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.server-switch-label {
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
#server-select {
  max-width: 15rem;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 600;
}
#server-select:hover {
  background: var(--surface-hover);
}
#server-select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

@media (max-width: 720px) {
  .server-switch-label { display: none; }
  #server-select { max-width: 9rem; }
}

.picker {
  max-height: 210px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-elev);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}
.picker > label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 11px;
  font-size: 0.86rem;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.picker > label:last-child { border-bottom: 0; }
.picker > label:hover { background: var(--surface-hover); }
.picker .meta {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 0.74rem;
  font-family: var(--mono);
  white-space: nowrap;
}

.sticky-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* ----------------------------------------------------------------- table */

.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.table th {
  text-align: left;
  padding: 8px 11px;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td {
  padding: 9px 11px;
  border-bottom: 1px solid var(--line);
  color: var(--text-dim);
}
.table tbody tr:hover td { background: var(--surface-2); }
.table td:first-child {
  font-family: var(--mono);
  color: var(--text);
}

/* ------------------------------------------------------------ responsive */

@media (max-width: 620px) {
  .content   { padding: 16px 13px 64px; }
  .card      { padding: 15px; }
  .step-body { padding-left: 15px; }
  .topbar-title { display: none; }
  .tabs      { top: 53px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------------------------------------------------------- discord gate */

/* Discord's own blurple, so the button reads as "this goes to Discord"
   rather than as another panel action. */
.btn-discord {
  display: block;
  background: #5865f2;
  border-color: #5865f2;
  color: #fff;
  text-align: center;
  text-decoration: none;
}
.btn-discord:hover,
.btn-discord:focus-visible {
  background: #4752c4;
  border-color: #4752c4;
  color: #fff;
}

/* Ids are long digit strings that get compared by eye. */
.id-cell {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: nowrap;
}
