/* public/style.css — AlphaDevs SSO Broker design system.
   No external fonts/scripts (matches this project's zero-dependency, strict-CSP posture —
   style-src/script-src are both 'self', so nothing here could load a CDN font anyway). Type
   is a serif-for-headings / system-sans-for-UI pairing instead of one face for everything —
   it reads as a real console for something as institutional as an identity broker, not
   another SaaS card kit. */
:root {
  --bg: #14171f;
  --panel: #1b1f29;
  --panel-2: #20242f;
  --border: #2a2f3d;
  --text: #edeff5;
  --text-dim: #8b92a8;
  --brass: #c89b4a;
  --brass-dim: #9c7a38;
  --brass-ink: #241a06;
  --sage: #5fa88f;
  --danger: #e5726b;
  --danger-bg: rgba(229, 114, 107, 0.1);
  --danger-border: rgba(229, 114, 107, 0.28);
  --focus: rgba(200, 155, 74, 0.35);
  --font-display: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-ui: -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", "Segoe UI Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: 0.01em; margin: 0 0 0.5em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; margin-top: 2rem; }

a { color: var(--brass); }

:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ---------- Pre-auth pages: login + MFA challenge (centered, single task) ---------- */

body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at 12% 8%, rgba(200, 155, 74, 0.08), transparent 42%),
    radial-gradient(circle at 88% 92%, rgba(95, 168, 143, 0.06), transparent 45%),
    var(--bg);
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.55);
  padding: 2.5rem;
  border-radius: 10px;
  width: 100%;
  max-width: 360px;
}

.brand { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 1.5rem; }
.brand .mark {
  width: 2.25rem; height: 2.25rem; border-radius: 7px; flex-shrink: 0;
  background: linear-gradient(155deg, var(--brass), var(--brass-dim));
  color: var(--brass-ink); font-weight: 700; font-size: 0.9rem; font-family: var(--font-ui);
  display: flex; align-items: center; justify-content: center;
}
.brand h1 { margin: 0; font-size: 1.2rem; }

.sub { margin: 0 0 1.75rem; color: var(--text-dim); font-size: 0.92rem; line-height: 1.45; }

label { display: block; margin-bottom: 1.1rem; font-size: 0.85rem; font-weight: 500; color: var(--text-dim); }

input, select, textarea {
  display: block; width: 100%; margin-top: 0.4rem; padding: 0.65rem 0.75rem; border-radius: 7px;
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  font-size: 0.95rem; font-family: inherit; line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brass); box-shadow: 0 0 0 3px var(--focus);
}
input[name="mfaCode"], input[autocomplete="one-time-code"] {
  letter-spacing: 0.3em; text-align: center; font-variant-numeric: tabular-nums; font-family: var(--font-mono);
}

button {
  padding: 0.7rem 1.1rem; border: none; border-radius: 7px; background: var(--brass);
  color: var(--brass-ink); font-weight: 600; font-size: 0.95rem; font-family: inherit; cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}
button:hover { background: #d6ac5c; }
button:active { transform: translateY(1px); }
.auth-card button { width: 100%; }

.error {
  color: var(--danger); font-size: 0.87rem; margin: 0 0 1.25rem; padding: 0.65rem 0.8rem;
  background: var(--danger-bg); border: 1px solid var(--danger-border); border-radius: 7px;
}
.notice {
  color: var(--sage); font-size: 0.87rem; margin: 0 0 1.25rem; padding: 0.7rem 0.85rem;
  background: rgba(95, 168, 143, 0.1); border: 1px solid rgba(95, 168, 143, 0.3); border-radius: 7px;
  line-height: 1.5;
}
.notice code { color: var(--text); }

.mfa-secret {
  font-size: 0.85rem; color: var(--text-dim); margin: 0 0 1.25rem; line-height: 1.5;
  padding: 0.75rem; background: var(--panel-2); border: 1px solid var(--border); border-radius: 7px;
}
.mfa-secret code { display: inline-block; margin-top: 0.35rem; color: var(--brass); font-family: var(--font-mono); font-size: 0.9rem; letter-spacing: 0.05em; word-break: break-all; }

.mfa-qr { display: flex; justify-content: center; margin: 0 0 1.25rem; background: #fff; border-radius: 7px; padding: 0.75rem; }
.mfa-qr svg { display: block; width: 100%; height: auto; max-width: 200px; }

.footer-note { margin: 1.5rem 0 0; text-align: center; font-size: 0.75rem; color: var(--text-dim); opacity: 0.75; }

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

/* ---------- Authenticated console shell: persistent sidebar + content ---------- */

.shell { display: flex; align-items: flex-start; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--border);
  padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 1.75rem;
}
.sidebar .brand { margin-bottom: 0; padding: 0 0.5rem; }

.nav-section { display: flex; flex-direction: column; gap: 0.15rem; }
.nav-label {
  margin: 0 0 0.4rem; padding: 0 0.5rem; font-size: 0.72rem; font-weight: 600; color: var(--text-dim);
  letter-spacing: 0.03em;
}
.nav-link {
  display: block; padding: 0.5rem 0.6rem; border-radius: 6px; color: var(--text); text-decoration: none;
  font-size: 0.9rem; font-family: inherit; font-weight: 500; text-align: left; background: none; border: none;
  cursor: pointer; width: 100%;
}
.nav-link:hover { background: var(--panel-2); }
.nav-link.active { background: var(--panel-2); color: var(--brass); }

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--border); }
.sidebar-footer .nav-link { color: var(--text-dim); }
.sidebar-footer .nav-link:hover { color: var(--danger); background: var(--danger-bg); }

.content { flex: 1; min-width: 0; padding: 2.5rem clamp(1.25rem, 4vw, 3.5rem); max-width: 960px; }
.content > h2:first-child { margin-top: 0; }

.crumb { display: block; margin: 0 0 1.25rem; font-size: 0.85rem; color: var(--text-dim); text-decoration: none; }
.crumb:hover { color: var(--brass); }

/* Profile page header */
.profile-header { display: flex; align-items: center; gap: 1.25rem; margin: 0 0 1.75rem; }
.avatar {
  flex-shrink: 0; width: 4rem; height: 4rem; border-radius: 50%;
  background: linear-gradient(155deg, var(--brass), var(--brass-dim));
  color: var(--brass-ink); font-weight: 700; font-size: 1.3rem; letter-spacing: 0.02em; font-family: var(--font-ui);
  display: flex; align-items: center; justify-content: center;
}
.profile-name { margin: 0; font-size: 1.3rem; font-weight: 600; font-family: var(--font-display); }
.profile-email { margin: 0.15rem 0 0.4rem; color: var(--text-dim); font-size: 0.9rem; }
.profile-mfa { margin: 0; font-size: 0.85rem; color: var(--text-dim); display: flex; align-items: center; gap: 0.4rem; }

.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; margin: 0.75rem 0 1.5rem; }
.app-card {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.9rem;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 9px;
  transition: border-color 0.15s ease;
}
.app-card:has(a):hover { border-color: var(--brass); }
.app-card-icon {
  flex-shrink: 0; width: 2.25rem; height: 2.25rem; border-radius: 7px;
  background: var(--panel); border: 1px solid var(--border); color: var(--brass);
  font-weight: 700; font-size: 0.8rem; font-family: var(--font-ui);
  display: flex; align-items: center; justify-content: center;
}
.app-card-body { min-width: 0; }
.app-card-name { font-size: 0.9rem; font-weight: 500; margin-bottom: 0.3rem; overflow-wrap: break-word; }
.app-card-name a { color: var(--text); text-decoration: none; }
.app-card-name a:hover { color: var(--brass); text-decoration: underline; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin: 0.75rem 0 1.5rem; }
th, td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
th { color: var(--text-dim); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.01em; }
tbody tr:hover { background: var(--panel-2); }
td form { margin: 0; }
td button { padding: 0.35rem 0.7rem; font-size: 0.82rem; background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
td button:hover { background: var(--border); }

.badge { display: inline-block; padding: 0.2rem 0.55rem; border-radius: 999px; font-size: 0.74rem; font-weight: 600; }
.badge.revoked, .badge.warn { background: var(--danger-bg); color: var(--danger); }
.badge.active { background: rgba(95, 168, 143, 0.15); color: var(--sage); }
.badge.unknown { background: rgba(139, 146, 168, 0.15); color: var(--text-dim); }
.badge.role { background: var(--panel-2); color: var(--text-dim); border: 1px solid var(--border); }

/* Forms inside the console (registration forms etc.) */
.panel-form { background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 1.25rem 1.5rem; max-width: 520px; }
.panel-form label { color: var(--text); }
.panel-form button { margin-top: 0.25rem; }

@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: static; width: 100%; height: auto; flex-direction: row; align-items: center;
    overflow-x: auto; gap: 1rem; padding: 0.85rem 1rem;
  }
  .sidebar .brand { padding: 0; }
  .nav-section { flex-direction: row; }
  .nav-label { display: none; }
  .sidebar-footer { margin-top: 0; padding-top: 0; border-top: none; margin-left: auto; }
  .content { padding: 1.5rem 1.25rem; }
  .profile-header { flex-wrap: wrap; }
}

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