/* ============================================================
   AuthKit — Stylesheet
   Customise the :root variables to match your brand.
   ============================================================ */
:root {
  --primary: #0f2d52;      /* main brand colour — buttons, nav, headings */
  --primary-l: #1e4d8c;   /* lighter shade for hover states */
  --accent:  #c9973f;      /* accent / call-to-action colour */
  --accent-l: #f0c96b;
  --bg:      #f4f6fb;      /* page background */
  --card:    #ffffff;
  --text:    #1a1d2e;
  --muted:   #6b7280;
  --border:  #e2e8f0;
  --danger:  #dc2626;
  --success: #16a34a;
  --warn:    #d97706;
  --radius:  10px;
  --shadow:  0 2px 12px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Navbar ────────────────────────────────────────────────── */
.navbar {
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem 0 1rem;
  height: 56px;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.nav-left {
  display: flex;
  align-items: center;
  gap: .65rem;
}
.nav-brand {
  color: #fff;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
}
.sidebar-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,.85);
  cursor: pointer;
  padding: .4rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.15); }
.nav-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  font-size: .85rem;
  color: rgba(255,255,255,.9);
  white-space: nowrap;
}
.nav-user-name {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: .82rem;
  transition: color .2s;
}
.nav-user-name:hover, .nav-user-name.active { color: #fff; }
.btn-logout {
  background: var(--accent);
  color: var(--primary) !important;
  padding: .32rem .85rem;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: .82rem;
  transition: background .2s;
}
.btn-logout:hover { background: var(--accent-l); }

/* ── Role badges ───────────────────────────────────────────── */
.role-badge {
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.role-superadmin { background: #064e3b; color: #fff; }
.role-admin      { background: #7c3aed; color: #fff; }
.role-manager    { background: #0284c7; color: #fff; }
.role-user       { background: var(--accent); color: var(--primary); }

/* ── App layout ────────────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width .22s ease, min-width .22s ease;
  flex-shrink: 0;
}
.sidebar--collapsed {
  width: 52px;
  min-width: 52px;
}
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: .65rem .4rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.sidebar-group { margin-bottom: .35rem; }
.sidebar-group-label {
  font-size: .63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: .45rem .75rem .2rem;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .15s;
}
.sidebar--collapsed .sidebar-group-label { opacity: 0; }
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .52rem .75rem;
  border-radius: 7px;
  text-decoration: none;
  color: var(--text);
  font-size: .865rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  transition: background .15s, color .15s;
}
.sidebar-link:hover { background: var(--bg); color: var(--primary); }
.sidebar-link.active {
  background: rgba(15,45,82,.09);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-icon { flex-shrink: 0; opacity: .65; transition: opacity .15s; }
.sidebar-link:hover .sidebar-icon,
.sidebar-link.active .sidebar-icon { opacity: 1; }
.sidebar-label { transition: opacity .15s; }
.sidebar--collapsed .sidebar-label { opacity: 0; }
.sidebar--collapsed .sidebar-link { justify-content: center; padding: .52rem; }
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: .72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

/* ── Main content ──────────────────────────────────────────── */
.main-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
}

/* ── Alerts ────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.2rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: .9rem;
  font-weight: 500;
  border-left: 4px solid transparent;
}
.alert-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-error   { background: #fef2f2; border-color: var(--danger);  color: #991b1b; }
.alert-info    { background: #eff6ff; border-color: #3b82f6;        color: #1d4ed8; }
.alert-warning { background: #fffbeb; border-color: var(--warn);    color: #92400e; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: .85rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1.05rem; font-weight: 700; color: var(--primary); }

/* ── Stat grid ─────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.35rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #dcfce7; }
.stat-icon.gold   { background: #fef9c3; }
.stat-icon.purple { background: #f3e8ff; }
.stat-num   { font-size: 1.8rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: .2rem; }

/* ── Tables ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .87rem; }
thead th {
  background: var(--primary); color: #fff;
  padding: .7rem 1rem; text-align: left;
  font-weight: 600; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .04em;
}
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: 7px; border: none;
  font-family: inherit; font-size: .85rem; font-weight: 600;
  cursor: pointer; text-decoration: none;
  transition: filter .2s, opacity .2s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-warning { background: var(--warn);    color: #fff; }
.btn-ghost   { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-accent  { background: var(--accent); color: var(--primary); }
.btn-sm      { padding: .3rem .7rem; font-size: .78rem; }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group   { margin-bottom: 1.1rem; }
.form-label   { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .4rem; color: var(--primary); }
.form-control {
  width: 100%; padding: .6rem .85rem;
  border: 1.5px solid var(--border); border-radius: 7px;
  font-family: inherit; font-size: .9rem; color: var(--text);
  background: #fff; transition: border-color .2s, box-shadow .2s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,45,82,.1);
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control   { appearance: none; cursor: pointer; }
.form-hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Login page ────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-l) 100%);
}
.login-box {
  background: #fff; border-radius: 16px;
  padding: 2.5rem; width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 1.75rem; }
.login-logo h1 { font-size: 1.3rem; color: var(--primary); font-weight: 700; }
.login-logo p  { font-size: .83rem; color: var(--muted); margin-top: .3rem; }

/* ── Page header ───────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 1.75rem;
}
.page-header h1 { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.page-header p  { font-size: .85rem; color: var(--muted); margin-top: .2rem; }

/* ── Status badges ─────────────────────────────────────────── */
.badge {
  display: inline-block; padding: .2rem .6rem;
  border-radius: 20px; font-size: .72rem;
  font-weight: 700; text-transform: uppercase;
}
.badge-active    { background: #dcfce7; color: #15803d; }
.badge-suspended { background: #fef2f2; color: #b91c1c; }
.badge-pending   { background: #fef9c3; color: #a16207; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: none; align-items: center;
  justify-content: center; z-index: 200;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border-radius: 14px;
  padding: 2rem; width: min(550px, 95vw);
  box-shadow: 0 25px 60px rgba(0,0,0,.25);
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 1.5rem;
}
.modal-header h2 { font-size: 1.1rem; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--muted); }

/* ── Footer (removed — copyright now in sidebar) ───────────── */

/* ── Utilities ─────────────────────────────────────────────── */
.text-muted   { color: var(--muted); }
.text-center  { text-align: center; }
.w-full       { width: 100%; }
.flex         { display: flex; }
.gap-2        { gap: .5rem; }
.mt-1         { margin-top: .5rem; }
.mt-2         { margin-top: 1rem; }

/* ── Sidebar brand switcher ────────────────────────────────── */
.sidebar-brand-switcher {
  position: relative;
  padding: .6rem .5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-brand-btn {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  padding: .5rem .65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
  overflow: hidden;
}
.sidebar-brand-btn:hover { background: var(--border); }
.sidebar--collapsed .sidebar-brand-btn { justify-content: center; padding: .5rem; }
.sidebar-brand-menu {
  top: calc(100% - .4rem);
  left: .5rem;
  right: .5rem;
  width: auto;
}

/* ── Brand switcher (navbar — kept for compatibility) ──────── */
.brand-switcher { position: relative; }
.brand-switcher-btn {
  display: flex; align-items: center; gap: .45rem;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff; padding: .32rem .75rem; border-radius: 7px;
  font-family: inherit; font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: background .2s; white-space: nowrap;
}
.brand-switcher-btn:hover { background: rgba(255,255,255,.22); }
.brand-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid rgba(255,255,255,.35);
}
.brand-switcher-menu {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  background: #fff; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.18);
  min-width: 220px; z-index: 300; overflow: hidden;
  border: 1px solid var(--border);
}
.brand-switcher-menu.open { display: block; }
.switcher-group-label {
  padding: .55rem 1rem .2rem;
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted);
}
.switcher-brand-btn {
  display: flex; align-items: center; gap: .6rem;
  width: 100%; padding: .6rem 1rem;
  background: none; border: none;
  font-family: inherit; font-size: .85rem; color: var(--text);
  cursor: pointer; text-align: left; transition: background .15s;
}
.switcher-brand-btn:hover:not(:disabled) { background: var(--bg); }
.switcher-brand-btn.active { font-weight: 700; color: var(--primary); cursor: default; }
.brand-dot-menu { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.switcher-divider { border: none; border-top: 1px solid var(--border); margin: .3rem 0; }
.switcher-action {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem 1rem; font-size: .82rem; color: var(--primary);
  text-decoration: none; font-weight: 600; transition: background .15s;
}
.switcher-action:hover { background: var(--bg); }

/* ── Onboarding ─────────────────────────────────────────────── */
.onboard-wrap {
  min-height: 100vh; display: flex;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-l) 100%);
  padding: 2rem;
}
.onboard-box {
  background: #fff; border-radius: 16px;
  padding: 2.5rem; width: 520px; max-width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.onboard-logo { margin-bottom: 1.75rem; }
.onboard-logo h1 { font-size: 1.5rem; color: var(--primary); font-weight: 800; }
.onboard-logo p  { font-size: .875rem; color: var(--muted); margin-top: .4rem; line-height: 1.5; }
.onboard-step {
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--accent); margin-bottom: .75rem;
}

/* ── Colour presets ─────────────────────────────────────────── */
.onboard-colour-presets { display: flex; gap: .4rem; flex-wrap: wrap; }
.colour-preset {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,.1); cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  flex-shrink: 0;
}
.colour-preset:hover { transform: scale(1.2); box-shadow: 0 2px 6px rgba(0,0,0,.2); }

/* ── Brand card grid ────────────────────────────────────────── */
.brand-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
}
.brand-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
  border: 2px solid transparent; transition: border-color .2s;
}
.brand-card-active { border-color: var(--primary); }
.brand-card-colour { height: 8px; }
.brand-card-body { padding: 1.1rem 1.25rem; flex: 1; }
.brand-card-name { font-size: 1rem; font-weight: 700; color: var(--primary); }
.brand-card-company { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.brand-card-actions {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .5rem; background: var(--bg);
}

/* ── Filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: .75rem;
  align-items: center; margin-bottom: 1.5rem;
}

/* ── Detail list (view pages) ───────────────────────────────── */
dl.detail-list { display: grid; grid-template-columns: auto 1fr; gap: .4rem .85rem; font-size: .87rem; }
dl.detail-list dt { color: var(--muted); font-weight: 600; white-space: nowrap; }
dl.detail-list dd { color: var(--text); }
dl.detail-list a  { color: var(--primary); text-decoration: none; }
dl.detail-list a:hover { text-decoration: underline; }

/* ── Person row (in org view) ───────────────────────────────── */
.person-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem .75rem; background: var(--bg); border-radius: 8px;
  text-decoration: none; color: var(--text); transition: background .15s;
}
.person-row:hover { background: var(--border); }
.person-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
  .navbar    { padding: 0 .75rem; }
  .sidebar   { display: none; }
  .form-row  { grid-template-columns: 1fr; }
  .main-wrap { padding: 1rem; }
  .login-box { width: 95vw; padding: 1.75rem; }
}
