/* ============================================================
   IronGrid Agents — global stylesheet.
   Loads after css/tokens.css (canonical ramps) + css/fonts.css.
   This file maps the component-level variable names used across
   style.css / chat.css onto the token ramps, then styles the base
   chrome, auth screens, and shared primitives (buttons, brand).
   ============================================================ */

:root {
  /* --- Legacy app names (kept so older rules still resolve) --------- */
  --card: var(--surface-card);
  --ink: var(--text-primary);
  --muted: var(--text-muted);
  --ms: var(--accent); /* primary action is the trust-blue accent now */
  /* --bg, --border, --accent are defined canonically in tokens.css */

  /* --- Redesign component language (from redesign.css) ------------- */
  --ink-2: var(--neutral-700);
  --faint: var(--text-faint);
  --line: var(--border);
  /* --line-soft comes from tokens.css */
  --canvas: var(--neutral-50); /* app canvas — the airy cool ground */
  --panel: var(--surface-card);
  --panel-2: var(--neutral-100); /* sunken fill: search box, subtle hovers */

  --accent-ink: var(--blue-700);
  --accent-wash: var(--blue-100);
  --accent-soft: var(--blue-50);

  --ok: var(--green-600);
  --ok-wash: var(--green-50);
  --ok-line: var(--green-200);
  --amber: var(--amber-700);
  --amber-wash: var(--amber-50);
  --amber-line: var(--amber-300);
  --danger: var(--red-600);
  --danger-wash: var(--red-50);
  --danger-line: var(--red-200);

  --radius: var(--radius-md); /* 12px in the modern theme */
  --radius-pill: 999px; /* real pills (suggestion chips, status pills) */

  --sans: var(--font-sans);
  --mono: var(--font-mono);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  background: var(--canvas);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Shared brand mark + wordmark (sidebar head + auth) -----------------
   The mark is the real Iron Grid Networks lockup mark (full-colour
   silver + azure) sitting on the light surface — no blue tile, echoing
   the company lockup. The wordmark renders "IRON GRID" (Raleway 800,
   uppercase) + "Alloy" (Raleway 600, muted). */
.mark {
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.mark svg { width: 33px; height: auto; display: block; }
.wordmark {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.wordmark b { font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em; }
.wordmark span { color: var(--muted); font-weight: 600; }

/* Base chrome (fallback pages: e.g. "no tenant yet") ---------------- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand {
  font-family: var(--font-heading);
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.1rem;
  letter-spacing: -0.005em;
}
.site-header nav { display: flex; align-items: center; gap: 0.75rem; }
.user { color: var(--muted); font-size: 0.9rem; }

/* The full-screen app + auth screens supply their own chrome. */
body:has(.chat-layout) .site-header,
body:has(.auth) .site-header { display: none; }

.container { max-width: 960px; margin: 0 auto; padding: 2rem 1.25rem; }
.container:has(.auth) { max-width: none; padding: 0; }

.muted { color: var(--muted); }

/* Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--sans);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--panel-2); }
.btn.primary,
.btn-ms {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-ink);
}
.btn.primary:hover,
.btn-ms:hover { background: var(--accent-ink); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  font-family: var(--sans);
}
.inline { display: inline; }

/* Django messages --------------------------------------------------- */
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent-wash);
}
.messages li.error {
  background: var(--danger-wash);
  border-color: var(--danger-line);
  color: var(--danger-text);
}

code {
  background: var(--surface-fill);
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  font-size: 0.85em;
}

/* Empty state (no-tenant fallback) ---------------------------------- */
.empty-state { margin: auto; text-align: center; padding: 3rem 1.5rem; }
.empty-state h1 {
  font-family: var(--font-heading);
  margin-bottom: 0.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ============================================================
   Auth / access-denied (login.html, access_denied.html)
   ============================================================ */
.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--canvas);
  /* Cool brand-azure glow — airy, Iron Grid Networks logo blue. */
  background-image:
    radial-gradient(48% 44% at 20% 10%, rgba(24, 128, 248, 0.14), transparent 70%),
    radial-gradient(46% 42% at 82% 20%, rgba(24, 128, 248, 0.11), transparent 70%),
    radial-gradient(52% 46% at 60% 100%, rgba(24, 128, 248, 0.10), transparent 72%);
  padding: 40px 20px;
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.auth-brand .wordmark { font-size: 19px; }
.auth-card {
  width: 400px;
  max-width: calc(100vw - 40px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 30px;
  text-align: center;
}
.auth-card h1 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}
.auth-card p { font-size: 14px; color: var(--muted); margin: 0 0 22px; line-height: 1.5; }
.auth-card code {
  font-size: 0.8em;
}
.ms-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent-ink);
  background: var(--accent);
  color: #fff;
  font-family: var(--sans);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
}
.ms-btn:hover { background: var(--accent-ink); }
.ms-btn.secondary {
  background: var(--panel);
  color: var(--ink-2);
  border-color: var(--line);
}
.ms-btn.secondary:hover { background: var(--panel-2); }
.ms-btn.secondary svg { width: 16px; height: 16px; }
.ms-logo {
  width: 17px;
  height: 17px;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.ms-logo i { display: block; width: 100%; height: 100%; }
.ms-logo i:nth-child(1) { background: #f25022; }
.ms-logo i:nth-child(2) { background: #7fba00; }
.ms-logo i:nth-child(3) { background: #00a4ef; }
.ms-logo i:nth-child(4) { background: #ffb900; }
.auth-note { font-size: 12.5px; color: var(--faint); margin-top: 18px; line-height: 1.5; }
.auth-foot { margin-top: 22px; font-size: 12.5px; color: var(--faint); }
.denied-ico {
  width: 52px;
  height: 52px;
  border-radius: 13px;
  background: var(--danger-wash);
  border: 1px solid var(--danger-line);
  color: var(--danger);
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
}
.denied-ico svg { width: 26px; height: 26px; }
