/* Phase 2.3 — Solar.Identity design system.
 * Mirrors src/Solar.Web/wwwroot/css/site.css tokens so brand reads continuous
 * across the host hop. Adds auth-form idioms (bottom-border inputs, narrow
 * centered column, label-as-eyebrow) that the portal doesn't need.
 *
 * Until we hoist this into a shared static-asset library, the two files must
 * be kept in sync by hand. Roger's real palette will land in a single edit
 * here + in Solar.Web's site.css.
 */

:root {
  --color-canvas:        #f7f8fa;
  --color-surface:       #ffffff;
  --color-surface-sunk:  #eef1f5;
  --color-ink:           #0c1b2e;
  --color-ink-muted:     #4a5b73;
  --color-line:          #d8dee7;

  --color-accent:        #1859d8;
  --color-accent-deep:   #0a3a9e;
  --color-accent-soft:   #e6edfb;

  --color-success:       #2f8a4a;
  --color-warn:          #c98a16;
  --color-danger:        #b8333d;

  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui:      "Inter Tight", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono:    "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;

  --radius-sm: 2px;
  --radius-md: 4px;

  --header-height: 56px;

  --auth-col: 380px;
}

* { box-sizing: border-box; }

html, body {
  background-color: var(--color-canvas);
  color: var(--color-ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--color-ink);
  font-variation-settings: "opsz" 36, "SOFT" 30;
  margin: 0 0 var(--space-4);
}

h1 { font-size: 2.125rem; line-height: 1.15; }
h2 { font-size: 1.5rem;   line-height: 1.2; }
h3 { font-size: 1.125rem; line-height: 1.3; }

p { margin: 0 0 var(--space-4); color: var(--color-ink); }
.muted { color: var(--color-ink-muted); }

a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease;
}
a:hover { border-bottom-color: currentColor; }

code, .mono {
  font-family: var(--font-mono);
  font-feature-settings: "tnum", "zero";
  font-size: 0.875em;
}

.eyebrow {
  font-family: var(--font-ui);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-ink-muted);
}

/* ── Header ──────────────────────────────────────────── */

.portal-header {
  background-color: var(--color-accent-deep);
  color: #fff;
  height: var(--header-height);
  padding: 0 var(--space-5);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1030;
}

.portal-header .navbar-brand {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: #fff;
  text-decoration: none;
  border: 0;
}

.portal-header .nav-text {
  color: rgba(255,255,255,0.78);
  font-size: 0.8125rem;
}

.portal-header .nav-text strong {
  color: #fff;
  font-weight: 500;
}

.portal-header .btn-ghost {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  font-size: 0.8125rem;
  font-family: var(--font-ui);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.portal-header .btn-ghost:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.55);
  border-bottom-color: rgba(255,255,255,0.55);
}

/* ── Footer ──────────────────────────────────────────── */

.portal-footer {
  background-color: transparent;
  border-top: 1px solid var(--color-line);
  padding: var(--space-4) var(--space-6);
  font-size: 0.75rem;
  color: var(--color-ink-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

/* ── Main containers ─────────────────────────────────── */

main { flex: 1; display: flex; flex-direction: column; }

/* Auth column — narrow centered, pinned to upper-third */
.auth-shell {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: var(--space-8) var(--space-5) var(--space-7);
}

.auth-col {
  width: 100%;
  max-width: var(--auth-col);
}

.auth-col .eyebrow { display: block; margin-bottom: var(--space-3); }

.auth-col h1 {
  margin-bottom: var(--space-6);
}

.auth-col .auth-foot {
  margin-top: var(--space-6);
  font-size: 0.8125rem;
  color: var(--color-ink-muted);
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Page-style container for authenticated pages on Identity host */
.page-shell {
  flex: 1;
  padding: var(--space-6) var(--space-6);
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

/* ── Form field ──────────────────────────────────────── */

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--space-5);
}

.field label {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--color-ink-muted);
  margin-bottom: var(--space-2);
}

.field .input,
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field select {
  font-family: var(--font-ui);
  font-size: 1rem;
  color: var(--color-ink);
  background-color: transparent;
  border: 0;
  border-bottom: 1px solid var(--color-line);
  padding: 8px 0;
  outline: none;
  border-radius: 0;
  transition: border-color 120ms ease;
  width: 100%;
}

.field input:focus,
.field select:focus {
  border-bottom-color: var(--color-accent);
}

.field select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--color-ink-muted) 50%),
                    linear-gradient(135deg, var(--color-ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 50%, calc(100% - 9px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 24px;
}

.field .field-error {
  font-size: 0.75rem;
  color: var(--color-danger);
  margin-top: var(--space-2);
  min-height: 1em;
}

.field-checkbox {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
  font-size: 0.875rem;
  color: var(--color-ink);
}
.field-checkbox label {
  margin: 0;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.875rem;
  color: var(--color-ink);
  font-weight: 400;
}

/* ── Buttons ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-ui);
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
  text-decoration: none;
  line-height: 1;
}
.btn:hover { border-bottom-color: transparent; }

.btn-primary {
  background-color: var(--color-accent-deep);
  color: #fff;
  border-color: var(--color-accent-deep);
}
.btn-primary:hover { background-color: #082f80; border-color: #082f80; }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-block { width: 100%; }

.btn-ghost-ink {
  background: transparent;
  color: var(--color-ink);
  border-color: var(--color-line);
}
.btn-ghost-ink:hover { border-color: var(--color-ink); background-color: var(--color-surface-sunk); }

.btn-link {
  background: transparent;
  color: var(--color-accent);
  border: 0;
  padding: 0;
  font-family: var(--font-ui);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
}
.btn-link:hover { border-bottom: 1px solid currentColor; }

/* ── Validation summary ──────────────────────────────── */

.validation-summary {
  border-left: 3px solid var(--color-danger);
  padding: var(--space-3) var(--space-4);
  background-color: #fdf2f3;
  margin-bottom: var(--space-5);
  font-size: 0.875rem;
  color: var(--color-danger);
}
.validation-summary ul { margin: 0; padding-left: 1.1em; }
.validation-summary:empty,
.validation-summary.validation-summary-valid { display: none; }
/* Hide the always-present hidden li the tag helper writes when there are no errors */
.field-error[data-valmsg-replace="true"]:empty { display: none; }

/* ── Inline panels (success / info) ──────────────────── */

.notice {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  margin-bottom: var(--space-5);
  border: 1px solid var(--color-line);
  background-color: var(--color-surface);
}

.notice-success {
  border-color: #b9dfc6;
  background-color: #ecf7ef;
  color: #1f5e34;
}

.notice-info {
  border-color: #c5d6f5;
  background-color: var(--color-accent-soft);
  color: var(--color-accent-deep);
}

.notice-warn {
  border-color: #f0d6a3;
  background-color: #fdf6e7;
  color: #6b4806;
}

.notice strong { font-weight: 500; }

/* ── Tenant choice (SelectTenant) ────────────────────── */

.tenant-list {
  list-style: none;
  margin: 0 0 var(--space-5);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tenant-option {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.tenant-option:hover { border-color: var(--color-accent); }
.tenant-option input[type="radio"] {
  accent-color: var(--color-accent);
  width: 16px;
  height: 16px;
}
.tenant-option .tenant-name {
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--color-ink);
  flex: 1;
}
.tenant-option .role-chip {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background-color: var(--color-surface-sunk);
  color: var(--color-ink);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}
.tenant-option .root-chip {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background-color: var(--color-warn);
  color: #fff;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

/* ── Page header (Identity authenticated pages) ─────── */

.page-header {
  margin-bottom: var(--space-6);
}
.page-header .eyebrow { display: block; margin-bottom: var(--space-2); }
.page-header h1 { margin: 0 0 var(--space-3); }

/* ── Reduced motion ──────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ── Focus ───────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ── Mobile ──────────────────────────────────────────── */

@media (max-width: 640px) {
  .auth-shell { padding-top: var(--space-6); padding-bottom: var(--space-5); }
  h1 { font-size: 1.75rem; }
}
