/* ===========================================================================
 * admin.css — branded super-admin theme (Story 5.3 / BIMERGE-57).
 * ---------------------------------------------------------------------------
 * Consumes the shared OKLCH design tokens (tokens.css — the single :root source,
 * also inlined into the React dashboard's application.css). Light app surface,
 * dark-teal header chrome (sidebar-* tokens), teal-primary actions, gold focus
 * ring, destructive-red errors.
 *
 * This is "classless" CSS: it targets bare HTML elements so the admin ERB views
 * need no markup classes (the one exception is .admin-header, added in
 * app/views/layouts/admin.html.erb). Colors are driven by var(--token); the only
 * non-token colors left are the documented green success-flash exception (no
 * "success" token exists in the brand set yet — see Story 5.3 Decisions).
 *
 * tokens.css is linked alongside this file in app/views/layouts/admin.html.erb
 * and registered in app/assets/config/manifest.js.
 * =========================================================================== */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--muted);
  padding: 2rem clamp(1rem, 5vw, 3rem);
}

main, form, section, article { max-width: 60rem; margin-inline: auto; }

h1, h2, h3 { line-height: 1.2; margin: 1.25rem 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; color: var(--muted-foreground); }

p { margin: 0.5rem 0; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.5rem 0; }
small { color: var(--muted-foreground); }

/* Dark-teal header bar (Story 5.3, Task 3). Full-bleeds the body padding. */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin: -2rem calc(-1 * clamp(1rem, 5vw, 3rem)) 2rem;
  padding: 0.85rem clamp(1rem, 5vw, 3rem);
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-bottom: 1px solid var(--sidebar-border);
}
.admin-header .brand { display: flex; align-items: baseline; gap: 0.5rem; font-weight: 700; font-size: 1.15rem; }
.admin-header .brand small { color: var(--sidebar-foreground); opacity: 0.7; font-weight: 400; font-size: 0.8rem; }
.admin-header a { color: var(--sidebar-foreground); text-decoration: none; }
.admin-header a:hover { color: var(--sidebar-accent-foreground); text-decoration: underline; }
.admin-nav { display: flex; align-items: center; gap: 1.1rem; font-size: 0.95rem; }
/* Neutralize button_to's wrapping <form> so the Sign-out button sits inline. */
.admin-header form { background: none; border: 0; border-radius: 0; padding: 0; margin: 0; max-width: none; display: inline; }
/* In-header Sign out: transparent/outlined to read on the dark bar (not the light-surface primary button). */
.admin-header button, .admin-header input[type="submit"] {
  margin: 0;
  padding: 0.35rem 0.8rem;
  color: var(--sidebar-foreground);
  background: transparent;
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius);
}
.admin-header button:hover, .admin-header input[type="submit"]:hover { background: var(--sidebar-accent); filter: none; }

/* Forms */
form { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 1.25rem 1.5rem; margin: 1rem auto; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 0.75rem 0 0.25rem; }
input[type="text"], input[type="email"], input[type="password"],
input[type="url"], input[type="search"], select, textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--foreground);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 40%, transparent);
}

/* Buttons (incl. Rails button_to → <button>/<input type=submit>) */
button, input[type="submit"], input[type="button"], .button, a[role="button"] {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--primary-foreground);
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  cursor: pointer;
}
button:hover, input[type="submit"]:hover, input[type="button"]:hover { filter: brightness(1.07); }

/* Tables (tenants / tenant-admins index) */
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 1rem auto; }
th, td { text-align: left; padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border); }
th { font-size: 0.78rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted-foreground); background: var(--muted); }
tr:last-child td { border-bottom: 0; }

/* Flash / validation messaging (best-effort, since markup is classless) */
[role="alert"], .notice, .alert, .flash { max-width: 60rem; margin: 1rem auto; padding: 0.7rem 1rem; border-radius: var(--radius); }
/* Documented exception (Story 5.3 AC4): no success/notice token exists in the
   brand set yet, so the green success flash is kept as-is until a semantic-token
   extension (success/warning/info) — see Story 5.3 Decisions. */
.notice, [role="alert"] { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; }
.alert, .error {
  background: color-mix(in oklab, var(--destructive) 12%, transparent);
  border: 1px solid color-mix(in oklab, var(--destructive) 40%, transparent);
  color: var(--destructive);
}
ul.errors, .field_with_errors { color: var(--destructive); }

/* Provisioning checklist (Story 2.5b). */
.provisioning .checklist { list-style: none; padding: 0; margin: 1rem auto; max-width: 60rem; }
.provisioning .step { display: flex; align-items: baseline; gap: 0.6rem; padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--border); }
.provisioning .step:last-child { border-bottom: 0; }
.provisioning .step-marker { font-weight: 700; color: var(--muted-foreground); }
.provisioning .step.done .step-marker { color: var(--primary); }
.provisioning .step.current .step-label { font-weight: 600; }
.provisioning .step-action { margin-left: auto; font-size: 0.9rem; }
.provisioning .credential-status code { background: var(--muted); padding: 0.1rem 0.35rem; border-radius: 4px; }
