/* ============================================================================
   APRÓ Vitinn — admin panel (admin.lighthouse.apro.is)
   Matches the partner login (assets/styles.css): #eef0f0 canvas, white surface,
   APRÓ navy ink, teal accent, Source Serif 4 display + Source Sans 3 body.
   Adds the panel-only parts: user table, status badges, confirm dialog, toasts.
   ========================================================================== */

:root {
  --display: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Source Sans 3", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --canvas: #eef0f0;
  --surface: #ffffff;
  --surface-2: #f4f6f6;
  --navy: #092b3f;
  --line: rgba(9, 43, 63, 0.12);
  --line-strong: rgba(9, 43, 63, 0.22);

  --ink: #092b3f;
  --ink-soft: #3f5159;
  --ink-faint: #66767d;

  --teal: #50c19b;
  --teal-bright: #1f8765;
  --teal-deep: #50c19b;
  --on-teal: #092b3f;

  --danger: #c0392b;
  --danger-soft: rgba(192, 57, 43, 0.08);
  --danger-line: rgba(192, 57, 43, 0.32);
  --warn: #b9770e;
  --warn-soft: rgba(185, 119, 14, 0.1);

  /* tiered radius */
  --r-chip: 6px;
  --r-btn: 9px;
  --r-card: 16px;
  --r-panel: 20px;

  --ease: cubic-bezier(0.25, 1, 0.5, 1);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
  background:
    radial-gradient(900px 480px at 50% -10%, rgba(80, 193, 155, 0.1), transparent 70%),
    var(--canvas);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

/* --- layout ------------------------------------------------------------- */
.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 28px 22px 80px; }

/* Centered single-card layout used for sign-in + not-authorized states. */
.center { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.center .stack { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 20px; }

/* --- topbar ------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-bottom: 20px; margin-bottom: 26px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand img { height: 26px; width: auto; filter: brightness(0) saturate(0); opacity: 0.85; }
.brand .sep { width: 1px; height: 22px; background: var(--line-strong); }
.brand .kicker {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-faint); white-space: nowrap;
}
.session { display: flex; align-items: center; gap: 14px; min-width: 0; }
.session .who { font-size: 13px; color: var(--ink-faint); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session .who strong { color: var(--ink-soft); font-weight: 600; }

/* --- type --------------------------------------------------------------- */
h1, h2, h3 { color: var(--ink); font-family: var(--display); letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(1.7rem, 1.4rem + 1vw, 2.1rem); font-weight: 600; line-height: 1.12; }
h2 { font-size: 1.18rem; font-weight: 600; }
.lede { color: var(--ink-soft); margin: 8px 0 0; max-width: 60ch; }
.muted { color: var(--ink-faint); }
.mono { font-family: var(--mono); }

/* --- cards / panels ----------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: 0 1px 3px rgba(9, 43, 63, 0.05), 0 18px 44px rgba(9, 43, 63, 0.08);
  padding: 28px;
}
.section { margin-top: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-head .count { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }

/* --- forms / inputs ----------------------------------------------------- */
label {
  display: block; font-family: var(--mono); font-size: 12px; font-weight: 500;
  letter-spacing: 0.02em; text-transform: uppercase; color: var(--ink-faint); margin: 0 0 7px;
}
input[type="email"], input[type="text"] {
  width: 100%; padding: 12px 14px; font-size: 16px; font-family: var(--sans); color: var(--ink);
  background: #fbfcfc; border: 1px solid var(--line-strong); border-radius: 10px;
  outline: none; transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
input::placeholder { color: var(--ink-faint); }
input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(80, 193, 155, 0.3); }
input:disabled { opacity: 0.55; cursor: not-allowed; }

.add-form { display: flex; gap: 12px; align-items: flex-start; margin-top: 14px; }
.add-form .field { flex: 1; min-width: 0; }
/* Drop the submit button past the input's label so the two line up. */
.add-form > .btn { margin-top: 26px; }
.hint { margin: 10px 2px 0; font-size: 12.5px; color: var(--ink-faint); }

/* --- buttons ------------------------------------------------------------ */
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 11px 18px; border-radius: var(--r-btn);
  font-family: var(--sans); font-weight: 600; font-size: 15px; white-space: nowrap;
  border: 1px solid transparent; transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.12s var(--ease), opacity 0.15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: progress; transform: none; }

.btn.primary { color: var(--on-teal); background: var(--teal-deep); box-shadow: 0 4px 14px rgba(9, 43, 63, 0.12); }
.btn.primary:hover:not(:disabled) { background: var(--teal); transform: translateY(-1px); }

.btn.ghost { color: var(--ink); background: var(--surface); border-color: var(--line-strong); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--ink-faint); }

.btn.danger { color: var(--danger); background: var(--surface); border-color: var(--danger-line); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); }

.btn.solid-danger { color: #fff; background: var(--danger); }
.btn.solid-danger:hover:not(:disabled) { background: #a93226; transform: translateY(-1px); }

.btn.sm { min-height: 36px; padding: 7px 13px; font-size: 13.5px; font-weight: 600; }
.btn.full { width: 100%; }

.linkbtn { color: var(--ink-faint); text-decoration: underline; font-size: 14px; transition: color 0.15s; }
.linkbtn:hover { color: var(--ink-soft); }

:where(a, button, input, [tabindex]):focus-visible { outline: 2px solid var(--teal-bright); outline-offset: 3px; border-radius: 4px; }

/* --- user list ---------------------------------------------------------- */
.userlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.user {
  display: flex; align-items: center; gap: 14px; padding: 15px 4px; border-top: 1px solid var(--line);
}
.user:first-child { border-top: none; }
.user .id { min-width: 0; flex: 1; }
.user .email { color: var(--ink); font-weight: 500; word-break: break-all; }
.user .meta { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.user .actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user.is-disabled .email { color: var(--ink-faint); }

/* status badge */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: 0.03em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.active { color: var(--teal-bright); background: rgba(80, 193, 155, 0.12); border-color: rgba(80, 193, 155, 0.3); }
.badge.disabled { color: var(--warn); background: var(--warn-soft); border-color: rgba(185, 119, 14, 0.3); }
.badge.pending { color: var(--ink-faint); background: var(--surface-2); border-color: var(--line); }
.badge.admin { color: var(--ink); background: var(--surface-2); border-color: var(--line-strong); }
.badge.admin::before { display: none; }

/* --- states (loading / empty / error) ---------------------------------- */
.state { text-align: center; padding: 48px 20px; color: var(--ink-faint); }
.state .spinner { margin: 0 auto 14px; }
.banner {
  display: flex; gap: 11px; align-items: flex-start; padding: 13px 15px; border-radius: 12px;
  font-size: 14px; line-height: 1.5;
}
.banner.error { background: var(--danger-soft); border: 1px solid var(--danger-line); color: var(--danger); }
.banner.note { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--teal-bright);
  animation: spin 0.7s linear infinite;
}
.spinner.lg { width: 30px; height: 30px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* --- sign-in card ------------------------------------------------------- */
.signin-hero { text-align: center; }
.signin-hero img { height: 30px; width: auto; filter: brightness(0) saturate(0); opacity: 0.85; margin-bottom: 16px; }
.signin-hero .tagline { color: var(--ink-faint); font-size: 0.95rem; margin: 0; }
.step h1 { margin-bottom: 4px; }
.step .muted { margin: 0 0 6px; }
.step .primary { margin-top: 22px; }
.hidden { display: none !important; }
.err-inline { margin: 14px 0 0; padding: 11px 13px; background: var(--danger-soft); border: 1px solid var(--danger-line); border-radius: 10px; color: var(--danger); font-size: 14px; }

/* --- modal (confirm destructive actions) -------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(9, 43, 63, 0.45); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 22px; z-index: 100;
  animation: fade 0.15s var(--ease);
}
.modal {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--r-panel);
  border: 1px solid var(--line); box-shadow: 0 24px 70px rgba(9, 43, 63, 0.28); padding: 26px;
  animation: pop 0.16s var(--ease);
}
.modal h2 { margin-bottom: 8px; }
.modal p { margin: 0 0 6px; color: var(--ink-soft); font-size: 14.5px; }
.modal .target { font-family: var(--mono); font-size: 13px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; margin: 14px 0; word-break: break-all; }
.modal .confirm-field { margin: 16px 0 4px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) { .modal-backdrop, .modal { animation: none; } }

/* --- toasts ------------------------------------------------------------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 10px; z-index: 200; width: calc(100% - 40px); max-width: 420px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 15px; border-radius: 12px;
  background: var(--navy); color: #eef0f0; font-size: 14px; box-shadow: 0 10px 30px rgba(9, 43, 63, 0.3);
  animation: toastin 0.2s var(--ease);
}
.toast.ok { border-left: 3px solid var(--teal); }
.toast.bad { border-left: 3px solid #ff6b5e; }
.toast .x { margin-left: auto; color: rgba(238, 240, 240, 0.6); font-size: 18px; line-height: 1; cursor: pointer; background: none; border: none; }
.toast .x:hover { color: #fff; }
@keyframes toastin { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* --- footer ------------------------------------------------------------- */
.foot { text-align: center; color: var(--ink-faint); font-size: 12.5px; margin-top: 40px; }
.foot a { color: var(--ink-faint); }

/* --- responsive --------------------------------------------------------- */
@media (max-width: 560px) {
  .add-form { flex-direction: column; }
  .add-form .btn { width: 100%; }
  .user { flex-wrap: wrap; }
  .user .actions { width: 100%; justify-content: flex-end; }
}
