/* admin/app/static/app.css — rolein.ai admin design system.
   Brand tokens mirror the marketing site's DARK theme so the admin panel
   feels like the same product. Loaded on top of the Tailwind CDN. */

:root {
  /* Brand palette (landing DARK theme) */
  --canvas: 240 10% 4%;      /* #0A0A0F deep page background */
  --surface: 240 12% 9%;     /* #14141B raised cards */
  --surface-2: 240 11% 12%;  /* inputs / nested panels */
  --ink: 240 10% 96%;        /* #F4F4F5 text */
  --muted: 240 6% 60%;       /* #8E8E9C secondary text */
  --line: 240 9% 18%;        /* #292932 hairline borders */
  --primary: 350 72% 60%;    /* brand red */
  --primary-hover: 350 78% 66%;
  --link: 355 85% 72%;       /* light red link on dark */

  /* Primary raised CTA button — brand red face, white text, deep-red lip. */
  --btn-face: 350 72% 60%;
  --btn-face-hover: 350 78% 66%;
  --btn-lip: 350 50% 36%;
  --btn-text: 0 0% 100%;

  /* Orange/amber accent button (used for Delete user). */
  --amber-face: 36 82% 54%;
  --amber-face-hover: 36 85% 49%;
  --amber-lip: 33 78% 40%;
  --amber-text: 0 0% 0%;

  /* Logo / brand mark badge */
  --brand: 350 72% 60%;

  /* Status / semantic (dark) */
  --ok-bg: 152 55% 14%;  --ok-fg: 151 70% 65%;
  --err-bg: 0 50% 17%;   --err-fg: 0 90% 78%;

  /* Render native widgets (scrollbars, date/number spinners, autofill) dark. */
  color-scheme: dark;
}

html { background: hsl(var(--canvas)); }
body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: hsl(var(--canvas));
  color: hsl(var(--ink));
}

/* Chrome paints autofilled inputs bright by default — force them dark. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: hsl(var(--ink));
  -webkit-box-shadow: 0 0 0 1000px hsl(var(--surface-2)) inset;
  caret-color: hsl(var(--ink));
  transition: background-color 9999s ease-in-out 0s;
}

/* ─────────────────────────  Layout shell  ───────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 14rem;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: hsl(var(--surface));
  color: hsl(var(--ink));
  border-right: 1px solid hsl(var(--line));
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1.1rem 1.25rem;
}
.sidebar__brand-name {
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: hsl(var(--ink));
}
.sidebar__nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.nav-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  color: hsl(var(--muted));
  transition: background-color 0.12s ease, color 0.12s ease;
}
.nav-link:hover { background: hsl(var(--surface-2)); color: hsl(var(--ink)); }
.nav-link.is-active {
  background: hsl(var(--primary) / 0.16);
  color: hsl(var(--ink));
  font-weight: 600;
  box-shadow: inset 2px 0 0 0 hsl(var(--primary));
}
/* Sign-out block pinned to the bottom of the rail, always visible. */
.sidebar__footer {
  margin-top: auto;
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-top: 1px solid hsl(var(--line));
  font-size: 0.75rem;
}
.sidebar__email {
  color: hsl(var(--muted));
  margin-bottom: 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Sign-out uses the same raised brand button as the rest of the app. */
.sidebar__signout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 100%;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  color: hsl(var(--btn-text));
  background: hsl(var(--btn-face));
  border: 1px solid hsl(var(--btn-lip));
  box-shadow: 0 2px 0 0 hsl(var(--btn-lip));
  transition: transform 0.12s cubic-bezier(0.2,0.7,0.2,1), box-shadow 0.12s ease, background-color 0.12s ease;
}
.sidebar__signout:hover { background: hsl(var(--btn-face-hover)); transform: translateY(-1px); box-shadow: 0 3px 0 0 hsl(var(--btn-lip)); }
.sidebar__signout:active { transform: translateY(1px); box-shadow: 0 1px 0 0 hsl(var(--btn-lip)); }

.app-main { flex: 1 1 auto; padding: 1.75rem; overflow-x: auto; }

/* ─────────────────────────  Typography  ───────────────────────── */
.page-title { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
.page-sub { font-size: 0.875rem; color: hsl(var(--muted)); }
.section-title { font-weight: 600; font-size: 0.95rem; }

a.link, .link {
  color: hsl(var(--link));
  text-decoration: none;
  font-weight: 500;
}
a.link:hover, .link:hover { text-decoration: underline; }

/* ─────────────────────────  Cards  ───────────────────────── */
.card {
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--line));
  border-radius: 0.75rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.card-pad { padding: 1rem 1.25rem; }
.card-title { font-weight: 600; margin-bottom: 0.75rem; color: hsl(var(--ink)); }

/* ─────────────────────────  Forms  ───────────────────────── */
.field { display: block; }
.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: hsl(var(--muted));
  margin-bottom: 0.3rem;
}

/* Equal-width responsive create/edit form: fields share a column track and
   align; the submit button spans the full row at the bottom. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-items: end;
}
.form-grid .field { width: 100%; }
.form-grid .field .input,
.form-grid .field .select { width: 100%; }
.form-grid .form-actions { grid-column: 1 / -1; }
@media (max-width: 768px) {
  .form-grid { grid-template-columns: 1fr; }
}
.input,
.select {
  width: 100%;
  font-size: 0.875rem;
  color: hsl(var(--ink));
  background: hsl(var(--surface-2));
  border: 1px solid hsl(var(--line));
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.input::placeholder { color: hsl(var(--muted) / 0.7); }
.input:focus,
.select:focus {
  outline: none;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.22);
}

/* Custom select: kill native arrow, draw a roomy muted chevron. */
.select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 2.25rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8E9C' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 0.75rem;
}
.select option { background: hsl(var(--surface)); color: hsl(var(--ink)); }

/* Beautiful custom checkbox — drawn box + animated check, brand-tinted. */
.checkrow { display: inline-flex; align-items: center; gap: 0.6rem; font-size: 0.875rem; cursor: pointer; user-select: none; }
.checkrow input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
  flex-shrink: 0;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 0.4rem;
  border: 1.5px solid hsl(var(--line));
  background: hsl(var(--surface-2));
  cursor: pointer;
  position: relative;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.checkrow input[type="checkbox"]:hover { border-color: hsl(var(--primary) / 0.7); }
.checkrow input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.25);
}
.checkrow input[type="checkbox"]:checked {
  background: hsl(var(--primary));
  border-color: hsl(var(--primary));
}
.checkrow input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 0.36rem;
  top: 0.16rem;
  width: 0.3rem;
  height: 0.55rem;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ─────────────────────────  Buttons  ─────────────────────────
   ONE raised-button template. Every action uses .btn .btn-primary
   (brand red). The only exception is Delete user, which uses the
   orange .btn-amber. Same shape, size and lift everywhere. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.55rem 0.95rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: transform 0.12s cubic-bezier(0.2, 0.7, 0.2, 1),
              box-shadow 0.12s ease, background-color 0.12s ease;
}
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

.btn-primary {
  color: hsl(var(--btn-text));
  background: hsl(var(--btn-face));
  border-color: hsl(var(--btn-lip));
  box-shadow: 0 2px 0 0 hsl(var(--btn-lip));
}
.btn-primary:hover { background: hsl(var(--btn-face-hover)); transform: translateY(-1px); box-shadow: 0 3px 0 0 hsl(var(--btn-lip)); }
.btn-primary:active { transform: translateY(1px); box-shadow: 0 1px 0 0 hsl(var(--btn-lip)); }

/* Orange CTA — Delete user only. */
.btn-amber {
  color: hsl(var(--amber-text));
  background: hsl(var(--amber-face));
  border-color: hsl(var(--amber-lip));
  box-shadow: 0 2px 0 0 hsl(var(--amber-lip));
}
.btn-amber:hover { background: hsl(var(--amber-face-hover)); transform: translateY(-1px); box-shadow: 0 3px 0 0 hsl(var(--amber-lip)); }
.btn-amber:active { transform: translateY(1px); box-shadow: 0 1px 0 0 hsl(var(--amber-lip)); }

/* Subtle "paper" face for low-emphasis links-as-buttons (e.g. Clear). */
.btn-ghost {
  color: hsl(var(--ink));
  background: hsl(var(--surface-2));
  border-color: hsl(var(--line));
}
.btn-ghost:hover { background: hsl(var(--surface)); }

/* ─────────────────────────  Tables  ───────────────────────── */
.table { width: 100%; font-size: 0.875rem; border-collapse: collapse; }
.table thead th {
  background: hsl(var(--surface-2));
  color: hsl(var(--muted));
  text-align: left;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid hsl(var(--line));
}
.table tbody td { padding: 0.6rem 1rem; border-top: 1px solid hsl(var(--line)); }
.table tbody tr:hover { background: hsl(var(--surface-2) / 0.6); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: hsl(var(--muted)); }

/* ─────────────────────────  Flashes & badges  ───────────────────────── */
.flash { font-size: 0.875rem; padding: 0.6rem 0.9rem; border-radius: 0.5rem; margin-bottom: 0.75rem; }
.flash-ok { background: hsl(var(--ok-bg)); color: hsl(var(--ok-fg)); }
.flash-err { background: hsl(var(--err-bg)); color: hsl(var(--err-fg)); }

.danger-zone { border: 1px solid hsl(var(--err-bg)); }
.danger-zone .card-title { color: hsl(var(--err-fg)); }

.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}
.pill-on { background: hsl(var(--ok-bg)); color: hsl(var(--ok-fg)); }
.pill-off { background: hsl(var(--surface-2)); color: hsl(var(--muted)); }

/* Definition grid (e.g. billing status) */
.status-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  font-size: 0.875rem;
}
.status-grid dt { color: hsl(var(--muted)); }
.status-grid dd { color: hsl(var(--ink)); word-break: break-all; }

/* Stat tiles (dashboard) */
.stat { padding: 1rem 1.25rem; }
.stat__label { font-size: 0.7rem; color: hsl(var(--muted)); text-transform: uppercase; letter-spacing: 0.04em; }
.stat__value { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }

/* Range / filter chips */
.chip {
  display: inline-flex; align-items: center;
  font-size: 0.8rem; font-weight: 500;
  padding: 0.3rem 0.7rem; border-radius: 999px;
  border: 1px solid hsl(var(--line)); background: hsl(var(--surface-2)); color: hsl(var(--ink));
}
.chip:hover { background: hsl(var(--surface)); }
.chip.is-active { background: hsl(var(--primary)); border-color: hsl(var(--primary)); color: #fff; }

/* ─────────────────────────  Verified badge (Facebook-style)  ───────────── */
.verified {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  background: hsl(var(--primary));
  color: #fff;
  flex-shrink: 0;
}
.verified svg { width: 0.7rem; height: 0.7rem; }
.email-head { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* ─────────────────────────  Inline table filters  ───────────────────────── */
.filter-row th { padding: 0.5rem 1rem; background: hsl(var(--surface)); border-bottom: 1px solid hsl(var(--line)); }
.filter-input,
.filter-select {
  width: 100%;
  min-width: 6rem;
  font-size: 0.8rem;
  color: hsl(var(--ink));
  background: hsl(var(--surface-2));
  border: 1px solid hsl(var(--line));
  border-radius: 0.4rem;
  padding: 0.35rem 0.55rem;
}
.filter-input::placeholder { color: hsl(var(--muted) / 0.7); }
.filter-input:focus,
.filter-select:focus { outline: none; border-color: hsl(var(--primary)); box-shadow: 0 0 0 2px hsl(var(--primary) / 0.2); }
.filter-select {
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  padding-right: 1.8rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8E9C' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.5rem center; background-size: 0.7rem;
}
.filter-select option { background: hsl(var(--surface)); color: hsl(var(--ink)); }

/* Numeric "more/less" filter: a compact op-select + number input. */
.num-filter { display: flex; gap: 0.3rem; align-items: stretch; min-width: 7rem; }
.num-filter .num-op {
  flex: 0 0 2.6rem;
  width: 2.6rem; min-width: 2.6rem;
  text-align: center;
  font-size: 0.85rem; font-weight: 700;
  color: hsl(var(--ink));
  background: hsl(var(--surface-2));
  border: 1px solid hsl(var(--line));
  border-radius: 0.4rem;
  padding: 0.35rem 0;
  cursor: pointer;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
}
.num-filter .num-op:focus { outline: none; border-color: hsl(var(--primary)); }
.num-filter .num-op option { background: hsl(var(--surface)); color: hsl(var(--ink)); }
.num-filter .filter-input { min-width: 0; flex: 1 1 auto; }
/* hide number spinners for a cleaner look */
.num-filter input[type="number"]::-webkit-outer-spin-button,
.num-filter input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-filter input[type="number"] { -moz-appearance: textfield; }

/* ─────────────────────────  Pagination  ───────────────────────── */
.pager {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  padding: 0.6rem 1rem; border-top: 1px solid hsl(var(--line));
  font-size: 0.8rem; color: hsl(var(--muted));
}
.pager__info { margin-right: auto; }
.pager__page { color: hsl(var(--ink)); font-weight: 600; }
.pager__btn {
  font-size: 0.8rem; font-weight: 600; color: hsl(var(--ink));
  background: hsl(var(--surface-2)); border: 1px solid hsl(var(--line));
  border-radius: 0.4rem; padding: 0.3rem 0.7rem; cursor: pointer;
  transition: background-color 0.12s ease;
}
.pager__btn:hover:not(:disabled) { background: hsl(var(--surface)); }
.pager__btn:disabled { opacity: 0.4; cursor: default; }

/* ─────────────────────────  Toast notifications  ───────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  width: min(92vw, 22rem);
  pointer-events: none;
}
.toast {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  pointer-events: auto;
  background: hsl(var(--surface));
  border: 1px solid hsl(var(--line));
  border-radius: .75rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  padding: .75rem 1rem;
  opacity: 0;
  transform: translateY(.5rem);
  transition: opacity 180ms ease, transform 180ms ease;
}
.toast.toast--in {
  opacity: 1;
  transform: translateY(0);
}
.toast.toast--leaving {
  opacity: 0;
  transform: translateY(.5rem);
}
.toast--success { border-left: 3px solid hsl(var(--ok-fg)); }
.toast--error   { border-left: 3px solid hsl(var(--err-fg)); }
.toast__icon { flex-shrink: 0; margin-top: .05rem; }
.toast--success .toast__icon { color: hsl(var(--ok-fg)); }
.toast--error   .toast__icon { color: hsl(var(--err-fg)); }
.toast__body { flex: 1 1 auto; font-size: .875rem; color: hsl(var(--ink)); line-height: 1.4; }
.toast__dismiss {
  flex-shrink: 0;
  background: none; border: none; padding: 0; cursor: pointer;
  color: hsl(var(--muted)); font-size: 1rem; line-height: 1;
  transition: color .12s ease;
}
.toast__dismiss:hover { color: hsl(var(--ink)); }

/* ─────────────────────────  Mobile menu toggle  ───────────────────────── */
.mobile-bar { display: none; }
.menu-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.4rem; height: 2.4rem; border-radius: 0.5rem;
  background: hsl(var(--surface-2)); border: 1px solid hsl(var(--line)); color: hsl(var(--ink));
  cursor: pointer;
}
.scrim { display: none; }

/* ─────────────────────────  Responsive  ───────────────────────── */
@media (max-width: 768px) {
  .app-shell { flex-direction: column; }

  /* Sidebar becomes an off-canvas drawer toggled from the mobile bar. */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    height: 100vh; width: 16rem;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,0.55);
  }

  .mobile-bar {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: hsl(var(--surface)); border-bottom: 1px solid hsl(var(--line));
    position: sticky; top: 0; z-index: 30;
  }
  .mobile-bar .sidebar__brand-name { font-size: 1.05rem; }

  .app-main { padding: 1rem; }
  .page-title { font-size: 1.25rem; }

  /* Cards/forms stack; control rows wrap. */
  .grid { display: block; }
  .grid > * + * { margin-top: 1.25rem; }
  .status-grid { grid-template-columns: 1fr; gap: 0.15rem 0; }
  .status-grid dt { margin-top: 0.5rem; }

  /* Tables scroll horizontally inside their card instead of overflowing. */
  .table { font-size: 0.8rem; }
  .table thead th, .table tbody td { padding: 0.5rem 0.6rem; }
  .filter-input, .filter-select { min-width: 4.5rem; }

  .btn { width: 100%; }                       /* full-width tap targets */
  .btn-inline, .btn-sm { width: auto; }       /* opt back out where buttons share a row */
  .num-filter { min-width: 5.5rem; }
}
