/* Kynra admin console.
   Hand-rolled rather than a framework: this is the only server-rendered UI in
   the project and adding a CSS build step for it would not pay for itself.

   Colors come from css/colors.css, which the templates load first. Nothing
   here should introduce a new hex value — reach for a token instead. */

:root {
  /* Link color. The semantic --accent token is the teal *tint* meant for
     subtle fills, so text-weight teal is pulled from the scale directly. */
  --link: var(--teal-700);
  --link-hover: var(--teal-800);
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 62px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }

/* ---------- shell ---------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  color: var(--navy-100);
  display: flex;
  flex-direction: column;
  padding: 14px 10px;
  gap: 6px;
  transition: width .18s ease, flex-basis .18s ease;
}
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.brand { display: flex; align-items: center; gap: 10px; color: var(--sidebar-foreground); overflow: hidden; }
.brand:hover { text-decoration: none; }
/* The logo sits on a light chip so its navy wordmark stays legible against the
   navy sidebar. Collapsed, the wrap clips to the leading lion mark. */
.brand-logo-wrap {
  display: flex; align-items: center; overflow: hidden;
  background: var(--ivory-50); border-radius: 8px; padding: 5px 8px;
  transition: width .18s ease;
}
.brand-logo { height: 24px; width: auto; max-width: none; display: block; }

.icon-btn {
  background: transparent; border: 0; color: var(--navy-300); cursor: pointer;
  width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); }
.chev { width: 9px; height: 9px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); }
html.sidebar-collapsed .chev { transform: rotate(-135deg); }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--navy-100); font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden;
  background: transparent; border: 0; width: 100%; text-align: left;
  font-family: inherit; cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-accent); color: var(--sidebar-accent-foreground); text-decoration: none; }
.nav-item.active { background: var(--sidebar-primary); color: var(--sidebar-primary-foreground); }
.nav-item .ico { flex: 0 0 20px; text-align: center; font-size: 15px; }
.nav-item.danger { color: var(--danger-500); }
.nav-item.danger:hover {
  background: color-mix(in srgb, var(--danger-500) 18%, transparent);
  color: var(--danger-100);
}

/* Grouped with the nav rather than pinned to the bottom of the viewport: on a
   tall window `margin-top:auto` strands it far below everything else, where it
   reads as absent. */
.signout { margin-top: 8px; border-top: 1px solid var(--sidebar-border); padding-top: 8px; }

/* Collapsed: icons only. Labels are hidden rather than removed so the toggle
   does not reflow the nav or lose the title tooltips. */
html.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed); }
html.sidebar-collapsed .label { display: none; }
html.sidebar-collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }
html.sidebar-collapsed .sidebar-top { flex-direction: column; gap: 10px; }
html.sidebar-collapsed .brand-logo-wrap { width: 38px; padding: 5px 7px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 28px; border-bottom: 1px solid var(--border); background: var(--background);
}
.topbar-title { font-weight: 600; }
.whoami { color: var(--muted-foreground); font-size: 14px; }

.content { padding: 26px 28px 40px; min-width: 0; }

/* ---------- dashboard ---------- */

.page-head { margin-bottom: 20px; }
.page-head h1 { margin: 0 0 4px; font-size: 27px; letter-spacing: -.3px; }
.page-head p { margin: 0; color: var(--muted-foreground); }

.stat-grid {
  display: grid; gap: 14px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; display: block; color: var(--card-foreground);
}
.stat:hover { text-decoration: none; border-color: var(--navy-200); }
.stat .stat-label { color: var(--muted-foreground); font-size: 13.5px; }
.stat .stat-value { font-size: 30px; font-weight: 700; margin-top: 10px; line-height: 1; }

.panel-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.panel {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.panel-head h2 { margin: 0; font-size: 15.5px; font-weight: 600; }
.panel-body { padding: 6px 0; }

.row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 9px 16px; }
.row + .row { border-top: 1px solid var(--border); }
.row .row-main { min-width: 0; }
.row .row-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .row-sub { color: var(--muted-foreground); font-size: 13px; }
.row time { color: var(--muted-foreground); font-size: 12.5px; white-space: nowrap; }

.empty { padding: 30px 16px; text-align: center; color: var(--muted-foreground); font-size: 14px; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--accent); color: var(--accent-foreground); font-size: 12px; font-weight: 600;
}

.totals { display: flex; gap: 22px; flex-wrap: wrap; color: var(--muted-foreground); font-size: 13.5px; margin-top: 20px; }
.totals b { color: var(--foreground); }

/* ---------- auth pages ---------- */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card {
  width: 100%; max-width: 410px; background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 26px 26px 22px;
}
.auth-card.wide { max-width: 520px; }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-brand .brand-logo { height: 30px; }
.auth-card h1 { margin: 0 0 4px; font-size: 21px; }
.auth-card .sub { margin: 0 0 18px; color: var(--muted-foreground); font-size: 14px; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13.5px; font-weight: 550; margin-bottom: 5px; }
.field input {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--foreground);
  /* --input is a hairline meant for filled controls; these sit on white, so
     they need the next step up the scale to read as an editable edge. */
  border: 1px solid var(--navy-200); border-radius: var(--radius-md); background: var(--card);
}
.field input:focus {
  outline: 2px solid color-mix(in srgb, var(--ring) 45%, transparent);
  outline-offset: 1px; border-color: var(--ring);
}
.field .help { color: var(--muted-foreground); font-size: 12.5px; margin-top: 4px; }
.field .err { color: var(--destructive); font-size: 12.5px; margin-top: 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-block; box-sizing: border-box; width: 100%; padding: 10px 14px;
  font: inherit; font-weight: 600; text-align: center; text-decoration: none;
  color: var(--primary-foreground); background: var(--primary);
  border: 0; border-radius: var(--radius-md); cursor: pointer;
}
.btn:hover { background: var(--navy-600); color: var(--primary-foreground); text-decoration: none; }

.alert { border-radius: var(--radius-md); padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }
.alert-error { background: var(--danger-50); border: 1px solid var(--danger-100); color: var(--danger-700); }
.alert-ok { background: var(--success-50); border: 1px solid var(--success-100); color: var(--success-700); }

.auth-foot { margin-top: 15px; text-align: center; font-size: 13.5px; color: var(--muted-foreground); }

/* allauth's own pages, rendered through templates/allauth/layouts/entrance.html.
   Sign-in and signup have hand-written templates carrying the classes above;
   the rest (password reset, email confirmation, "verification sent") arrive as
   allauth's bare <p><label><input> markup. These element rules give that markup
   the same treatment without templating every page allauth ships. */

.auth-card h1 { font-size: 21px; }
.auth-card > p,
.auth-card form > p { margin: 0 0 13px; }
.auth-card label { display: block; font-size: 13.5px; font-weight: 550; margin-bottom: 5px; }
.auth-card input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) {
  width: 100%; padding: 9px 11px; font: inherit; color: var(--foreground);
  border: 1px solid var(--navy-200); border-radius: var(--radius-md); background: var(--card);
}
.auth-card input:focus {
  outline: 2px solid color-mix(in srgb, var(--ring) 45%, transparent);
  outline-offset: 1px; border-color: var(--ring);
}
.auth-card button:not(.btn) {
  width: 100%; padding: 10px 14px; margin-top: 4px; font: inherit; font-weight: 600;
  color: var(--primary-foreground); background: var(--primary);
  border: 0; border-radius: var(--radius-md); cursor: pointer;
}
.auth-card button:not(.btn):hover { background: var(--navy-600); }
/* allauth reports field errors as a <ul> hung off the input. */
.auth-card .errorlist { list-style: none; margin: 4px 0 0; padding: 0; color: var(--destructive); font-size: 12.5px; }

@media (max-width: 720px) {
  .sidebar { width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed); }
  .sidebar .label { display: none; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .field-row { grid-template-columns: 1fr; }
}
