/* Issue Ticca portal theme.
   Colours come from CSS custom properties injected by the context processor, so a
   managed app's brand colour flows through without touching this file. The semantic
   status colours are deliberately NOT brand-driven: red must always mean critical.

   The values below are fallbacks for the injected ones - the brand block in the page
   head loads *after* this file, so an app's colour always wins.

   Two tiers per status: the base hue is for dots, bars and fills, and the `-ink`
   variant (the same hue mixed towards black) is for text, so it stays readable on a
   white card. */

:root {
  --it-bg: #f1f5f9;
  --it-surface: #ffffff;
  --it-elevated: #eef2f7;
  --it-border: #d8e2ee;
  --it-text: #16232f;
  --it-muted: #5d6f85;
  --it-accent: #0891b2;
  --it-accent-strong: #0e7490;
  --it-button: #0891b2;
  --it-button-text: #f8fafc;
  --it-healthy: #22c55e;
  --it-warning: #f59e0b;
  --it-critical: #ef4444;
  --it-info: #60a5fa;
  --it-inactive: #64748b;
  --it-accent-ink: color-mix(in srgb, var(--it-accent) 82%, black);
  --it-healthy-ink: color-mix(in srgb, var(--it-healthy) 62%, black);
  --it-warning-ink: color-mix(in srgb, var(--it-warning) 62%, black);
  --it-critical-ink: color-mix(in srgb, var(--it-critical) 68%, black);
  --it-info-ink: color-mix(in srgb, var(--it-info) 62%, black);
  --it-inactive-ink: color-mix(in srgb, var(--it-inactive) 80%, black);
  --it-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  --it-radius: 10px;
  --it-gap: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--it-bg);
  color: var(--it-text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--it-accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0 0 12px; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }

/* ---------- layout ---------- */
.it-shell { display: flex; flex-direction: column; min-height: 100vh; }
.it-main { flex: 1; width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px 20px 48px; }

.it-topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px;
  background: var(--it-surface);
  border-bottom: 1px solid var(--it-border);
}
.it-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.it-brand .dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--it-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--it-accent) 22%, transparent);
}
.it-nav { display: flex; gap: 4px; flex-wrap: wrap; }
.it-nav a {
  padding: 6px 11px; border-radius: 999px; color: var(--it-muted);
  border: 1px solid transparent;
}
.it-nav a:hover { color: var(--it-text); background: var(--it-elevated); text-decoration: none; }
.it-nav a.is-active { color: var(--it-text); background: var(--it-elevated); border-color: var(--it-border); }
.it-topbar .spacer { margin-left: auto; }

/* ---------- cards & grid ---------- */
.it-grid { display: grid; gap: var(--it-gap); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.it-grid.tight { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.it-card {
  background: var(--it-surface);
  border: 1px solid var(--it-border);
  border-radius: var(--it-radius);
  padding: 16px;
  box-shadow: var(--it-shadow);
}
.it-card.accent { border-left: 3px solid var(--it-accent); }
.it-card h2 { margin-bottom: 10px; }
.it-card .subtle { color: var(--it-muted); font-size: 12.5px; }

.it-stat { display: flex; flex-direction: column; gap: 2px; }
.it-stat .value { font-size: 26px; font-weight: 700; line-height: 1.15; }
.it-stat .label { color: var(--it-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

.it-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.it-row.between { justify-content: space-between; }
.it-row.tight { gap: 6px; }

/* ---------- semantic status ---------- */
/* A pill takes its hue from --pill-color: set inline for data-driven colours, or by one
   of the level classes below. The dot keeps the full hue; the text uses the ink tier. */
.it-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600;
  color: color-mix(in srgb, var(--pill-color, var(--it-inactive)) 62%, black);
  background: color-mix(in srgb, var(--pill-color, var(--it-inactive)) 10%, var(--it-surface));
  border: 1px solid color-mix(in srgb, var(--pill-color, var(--it-border)) 38%, transparent);
}
.it-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pill-color, currentColor); }

/* Text uses the ink tier; --pill-color keeps the full hue for dots and borders. */
.it-healthy  { color: var(--it-healthy-ink);  --pill-color: var(--it-healthy); }
.it-warning  { color: var(--it-warning-ink);  --pill-color: var(--it-warning); }
.it-critical { color: var(--it-critical-ink); --pill-color: var(--it-critical); }
.it-info     { color: var(--it-info-ink);     --pill-color: var(--it-info); }
.it-inactive { color: var(--it-inactive-ink); --pill-color: var(--it-inactive); }

.it-bg-healthy  { background: color-mix(in srgb, var(--it-healthy) 16%, transparent); }
.it-bg-warning  { background: color-mix(in srgb, var(--it-warning) 16%, transparent); }
.it-bg-critical { background: color-mix(in srgb, var(--it-critical) 16%, transparent); }
.it-bg-info     { background: color-mix(in srgb, var(--it-info) 16%, transparent); }
.it-bg-inactive { background: color-mix(in srgb, var(--it-inactive) 16%, transparent); }

.it-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--it-muted); }
.it-legend span { display: inline-flex; align-items: center; gap: 6px; }
.it-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- components ---------- */
.it-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  background: var(--it-button); color: var(--it-button-text);
  border: 1px solid color-mix(in srgb, var(--it-button) 70%, black);
  font: inherit; font-weight: 600;
}
.it-btn:hover { filter: brightness(1.08); text-decoration: none; }
.it-btn.ghost {
  background: transparent; color: var(--it-text); border-color: var(--it-border);
}
.it-btn.ghost:hover { background: var(--it-elevated); }
.it-btn.danger { background: transparent; color: var(--it-critical-ink); border-color: color-mix(in srgb, var(--it-critical) 45%, transparent); }
.it-btn.small { padding: 4px 10px; font-size: 12px; }

.it-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.it-table th {
  text-align: left; color: var(--it-muted); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 8px 10px; border-bottom: 1px solid var(--it-border);
}
.it-table td { padding: 9px 10px; border-bottom: 1px solid color-mix(in srgb, var(--it-border) 60%, transparent); }
.it-table tr:hover td { background: color-mix(in srgb, var(--it-accent) 5%, transparent); }

code, pre, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 12.5px; }
code { background: var(--it-elevated); padding: 1px 5px; border-radius: 5px; }
pre {
  background: var(--it-elevated); border: 1px solid var(--it-border); border-radius: 8px;
  padding: 12px 14px; overflow-x: auto;
}

input[type="text"], input[type="email"], input[type="password"], select, textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  background: var(--it-bg); color: var(--it-text);
  border: 1px solid var(--it-border); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--it-accent) 55%, transparent); }
label { display: block; font-size: 12px; color: var(--it-muted); margin: 10px 0 4px; }

.it-messages { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 8px; }
.it-messages li {
  padding: 9px 13px; border-radius: 8px; border: 1px solid var(--it-border);
  background: var(--it-elevated); font-size: 13px;
}
.it-messages li.success {
  background: color-mix(in srgb, var(--it-healthy) 10%, var(--it-surface));
  border-color: color-mix(in srgb, var(--it-healthy) 40%, transparent);
}
.it-messages li.error {
  background: color-mix(in srgb, var(--it-critical) 9%, var(--it-surface));
  border-color: color-mix(in srgb, var(--it-critical) 40%, transparent);
}
.it-messages li.warning {
  background: color-mix(in srgb, var(--it-warning) 12%, var(--it-surface));
  border-color: color-mix(in srgb, var(--it-warning) 42%, transparent);
}

/* ---------- bar chart (no chart library) ---------- */
.it-chart { display: flex; align-items: flex-end; gap: 3px; height: 96px; padding-top: 6px; }
.it-chart .bar {
  flex: 1; min-width: 3px; border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--it-accent), var(--it-accent-strong));
  position: relative;
}
.it-chart .bar.empty { background: color-mix(in srgb, var(--it-border) 80%, transparent); }
.it-chart-x { display: flex; gap: 3px; font-size: 9.5px; color: var(--it-muted); margin-top: 4px; }
.it-chart-x span { flex: 1; text-align: center; overflow: hidden; }

.it-meter { height: 8px; border-radius: 999px; background: var(--it-elevated); overflow: hidden; }
.it-meter > span { display: block; height: 100%; border-radius: 999px; }

/* ---------- breathing interface ---------- */
@keyframes it-breathe {
  0%, 100% { transform: scale(1); opacity: 0.55; }
  50%      { transform: scale(1.06); opacity: 1; }
}
.it-breathe { animation: it-breathe 2.6s ease-in-out infinite; }
.it-breathe.fast { animation-duration: 1.05s; }

@media (prefers-reduced-motion: reduce) {
  .it-breathe { animation: none; opacity: 1; }
  #it-transition { transition: none; }
}

/* Full-screen veil played while switching between apps. */
#it-transition {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--it-accent) 16%, transparent), var(--it-bg) 62%);
  opacity: 0; pointer-events: none; transition: opacity 260ms ease;
}
#it-transition.is-active { opacity: 1; pointer-events: all; }
#it-transition .ring {
  width: 74px; height: 74px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--it-accent) 55%, transparent);
  background: color-mix(in srgb, var(--it-accent) 12%, transparent);
}
#it-transition .caption { color: var(--it-muted); font-size: 13px; letter-spacing: 0.03em; }

/* ---------- footer ---------- */
.it-footer {
  border-top: 1px solid var(--it-border);
  padding: 16px 20px; color: var(--it-muted); font-size: 12px;
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between;
}
.it-footer a { color: var(--it-muted); }
.it-footer a:hover { color: var(--it-accent); }

/* ---------- iframe-embedded ticket portal ---------- */
/* Opaque, not transparent: the portal is light, so it must not inherit a dark host page. */
body.it-embed { background: var(--it-bg); }
body.it-embed .it-main { padding: 14px; max-width: none; }

.it-ticket-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--it-border); border-radius: 9px;
  background: var(--it-surface); margin-bottom: 8px;
}
.it-ticket-row:hover { border-color: color-mix(in srgb, var(--it-accent) 45%, transparent); }

.it-comment {
  border-left: 3px solid var(--it-border); padding: 6px 0 6px 12px; margin-bottom: 12px;
}
.it-comment.resolution { border-left-color: var(--it-healthy); }
.it-comment.system { border-left-color: var(--it-inactive); font-style: italic; }
.it-comment .meta { color: var(--it-muted); font-size: 11.5px; }

.it-timeline { list-style: none; margin: 0; padding: 0; font-size: 12.5px; }
.it-timeline li { padding: 6px 0 6px 14px; border-left: 2px solid var(--it-border); color: var(--it-muted); }
.it-timeline li strong { color: var(--it-text); font-weight: 600; }

/* ---------- sidebar shell ---------- */
.it-layout { display: flex; min-height: 100vh; align-items: stretch; }

.it-sidebar {
  width: 244px; flex: 0 0 244px;
  background: var(--it-surface);
  border-right: 1px solid var(--it-border);
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.it-sidebar .it-brand { font-size: 14px; }
.it-sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.it-sidebar-nav .it-nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 11px; border-radius: 8px; color: var(--it-muted); font-weight: 500;
  border: 1px solid transparent;
}
.it-sidebar-nav .it-nav-item:hover { color: var(--it-text); background: var(--it-elevated); text-decoration: none; }
.it-sidebar-nav .it-nav-item.is-active {
  color: var(--it-text); background: color-mix(in srgb, var(--it-accent) 10%, var(--it-surface));
  border-color: color-mix(in srgb, var(--it-accent) 40%, transparent);
  box-shadow: inset 3px 0 0 var(--it-accent);
}
.it-sidebar-subs { display: flex; flex-direction: column; margin: 2px 0 6px 12px; gap: 1px; }
.it-nav-sub {
  padding: 6px 10px; border-radius: 7px; font-size: 12.5px; color: var(--it-muted);
  border-left: 2px solid var(--it-border);
}
.it-nav-sub:hover { color: var(--it-text); text-decoration: none; background: color-mix(in srgb, var(--it-accent) 7%, transparent); }
.it-nav-sub.is-active { color: var(--it-accent-ink); border-left-color: var(--it-accent); font-weight: 600; }
.it-sidebar-foot {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--it-muted);
  border-top: 1px solid var(--it-border); padding-top: 12px;
}
.it-sidebar-foot a { color: var(--it-muted); }
.it-sidebar-foot a:hover { color: var(--it-accent); }

.it-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.it-content .it-topbar { position: sticky; top: 0; }
.it-content .it-main { max-width: 1180px; margin: 0; padding: 22px 26px 48px; }

/* ---------- app switcher ---------- */
.it-switcher { display: flex; flex-direction: column; gap: 4px; }
.it-switcher-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--it-muted);
}
.it-switcher select {
  background: var(--it-bg); border: 1px solid var(--it-border); border-radius: 8px;
  padding: 7px 9px; font-size: 13px; color: var(--it-text);
}

/* ---------- breadcrumbs + subsection tabs ---------- */
.it-crumbs { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--it-muted); }
.it-crumb-sep { opacity: 0.5; }
.it-crumb-current { color: var(--it-text); font-weight: 600; }
.it-user { font-size: 12px; color: var(--it-muted); }

.it-subnav {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 8px 26px 0;
  border-bottom: 1px solid var(--it-border);
  background: var(--it-bg);
}
.it-subnav-item {
  padding: 7px 13px; font-size: 13px; color: var(--it-muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.it-subnav-item:hover { color: var(--it-text); text-decoration: none; }
.it-subnav-item.is-active { color: var(--it-accent-ink); border-bottom-color: var(--it-accent); font-weight: 600; }

/* ---------- first-run wizard ---------- */
.it-setup {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--it-accent) 9%, transparent), var(--it-bg) 58%);
  padding: 32px 18px;
}
.it-setup-shell { width: 100%; max-width: 620px; }
.it-setup-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 22px; }
.it-setup-head .dot {
  width: 14px; height: 14px; border-radius: 50%; background: var(--it-accent); margin-top: 6px;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--it-accent) 16%, transparent);
}
.it-setup-head h1 { font-size: 24px; margin-bottom: 4px; }
.it-setup-form {
  background: var(--it-surface); border: 1px solid var(--it-border);
  border-radius: var(--it-radius); padding: 22px;
}
.it-setup-foot {
  margin-top: 18px; display: flex; gap: 16px; justify-content: center;
  font-size: 12px; color: var(--it-muted);
}
.it-steps { display: flex; gap: 20px; list-style: none; margin: 0 0 18px; padding: 0; }
.it-step { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--it-muted); }
.it-step-number {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center;
  border: 1px solid var(--it-border); font-size: 11px; font-weight: 600;
}
.it-step.is-current { color: var(--it-text); }
.it-step.is-current .it-step-number {
  border-color: var(--it-accent); color: var(--it-accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--it-accent) 14%, transparent);
}
.it-step.is-done .it-step-number { border-color: var(--it-healthy); color: var(--it-healthy); }

.it-field { margin-bottom: 4px; }
.it-field-help { font-size: 11.5px; color: var(--it-muted); margin: 4px 0 0; }
.it-field-error { font-size: 12px; color: var(--it-critical-ink); margin: 4px 0 0; }

/* ---------- post-setup breathing reveal ---------- */
.it-welcome {
  position: fixed; inset: 0; z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 45%, color-mix(in srgb, var(--it-accent) 18%, transparent), var(--it-bg) 62%);
  animation: it-welcome-out 900ms ease 1500ms forwards;
}
.it-welcome-card { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.it-welcome-card .ring {
  width: 88px; height: 88px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--it-accent) 55%, transparent);
  background: color-mix(in srgb, var(--it-accent) 12%, transparent);
}
@keyframes it-welcome-out {
  to { opacity: 0; visibility: hidden; }
}

@media (max-width: 860px) {
  .it-layout { flex-direction: column; }
  .it-sidebar { width: auto; flex: none; height: auto; position: static; }
  .it-sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .it-sidebar-subs { flex-direction: row; flex-wrap: wrap; margin-left: 0; }
  .it-content .it-main { padding: 18px 16px 40px; }
}
