/* ==========================================================================
   Uva Provincial Complaint Portal - app shell
   Paces-inspired: soft shadows, rounded, indigo accent, light + dark.
   ========================================================================== */

:root {
  --brand:        #4f46e5;
  --brand-2:      #0d6efd;
  --brand-grad:   linear-gradient(135deg, #0d6efd, #4f46e5);
  --accent:       #06b6d4;
  --ok:           #16a34a;
  --warn:         #d97706;
  --danger:       #dc2626;

  --bg:           #f4f6fb;
  --surface:      #ffffff;
  --surface-2:    #f8fafc;
  --border:       #e6e8f0;
  --text:         #1f2937;
  --text-soft:    #64748b;
  --sidebar-bg:   #0f172a;
  --sidebar-fg:   #cbd5e1;
  --sidebar-active:#1e293b;

  --radius:       14px;
  --radius-sm:    10px;
  --shadow-sm:    0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow:       0 10px 30px -12px rgba(15,23,42,.18);
  --sidebar-w:    264px;
  --sidebar-w-collapsed: 76px;
  --topbar-h:     62px;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

[data-bs-theme="dark"] {
  --bg:        #0b1120;
  --surface:   #111827;
  --surface-2: #0f172a;
  --border:    #1f2937;
  --text:      #e5e7eb;
  --text-soft: #94a3b8;
  --sidebar-bg:#0a0f1c;
  --sidebar-active:#16213a;
  --shadow:    0 10px 30px -12px rgba(0,0,0,.6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------------ shell */
.app-shell { display: flex; min-height: 100vh; }
.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  transition: margin-left .22s ease;
}
.app-shell.collapsed .app-main { margin-left: var(--sidebar-w-collapsed); }

/* ---------------------------------------------------------------- sidebar */
.app-sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex; flex-direction: column;
  z-index: 1040;
  transition: width .22s ease, transform .22s ease;
}
.app-shell.collapsed .app-sidebar { width: var(--sidebar-w-collapsed); }

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h);
  padding: 0 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  color: #fff;
}
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 11px;
  background: var(--brand-grad);
  display: grid; place-items: center;
  font-size: 19px; color: #fff;
}

/* Council crest (site logo) */
.brand-crest { flex: none; display: inline-flex; align-items: center; height: 36px; }
.brand-crest img { height: 100%; width: auto; display: block; }
.brand-swap .crest-on-dark { display: none; }
[data-bs-theme="dark"] .brand-swap .crest-on-light { display: none; }
[data-bs-theme="dark"] .brand-swap .crest-on-dark { display: block; }
.sidebar-brand .brand-crest { height: 34px; }
.app-shell.collapsed .sidebar-brand .brand-crest { height: 28px; }
.auth-brand .brand-crest { height: 42px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; font-size: 15px; }
.brand-text small { color: var(--sidebar-fg); font-size: 11px; opacity: .7; }
.app-shell.collapsed .brand-text,
.app-shell.collapsed .nav-section,
.app-shell.collapsed .nav-link span,
.app-shell.collapsed .sidebar-foot { display: none; }
.sidebar-collapse {
  margin-left: auto; color: var(--sidebar-fg);
  background: rgba(255,255,255,.06); border: 0; border-radius: 8px;
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-section {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: #64748b; margin: 16px 10px 6px;
}
.sidebar-nav .nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: 10px;
  color: var(--sidebar-fg); font-size: 14px; font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
.sidebar-nav .nav-link i { font-size: 17px; width: 20px; text-align: center; flex: 0 0 20px; }
.sidebar-nav .nav-link span { display: flex; align-items: center; gap: 8px; flex: 1; }
.sidebar-nav .nav-link:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--brand-grad); color: #fff; box-shadow: var(--shadow-sm); }
.sidebar-nav .nav-link.disabled { opacity: .45; pointer-events: none; }

.sidebar-foot { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.06); }
.role-chip {
  font-size: 12px; color: #cbd5e1;
  background: rgba(255,255,255,.06);
  border-radius: 999px; padding: 6px 12px; display: inline-flex; gap: 6px; align-items: center;
}
.sidebar-scrim {
  position: fixed; inset: 0; background: rgba(2,6,23,.5);
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 1035;
}
body.sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }

/* ---------------------------------------------------------------- topbar */
.app-topbar {
  position: sticky; top: 0; z-index: 1020;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); font-size: 17px;
  display: inline-grid; place-items: center; cursor: pointer;
  transition: .15s;
}
.icon-btn:hover { color: var(--brand); border-color: var(--brand); }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 5px 12px 5px 5px; cursor: pointer;
  color: var(--text); font-size: 14px; font-weight: 600;
}
.avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.avatar-initials { display: grid; place-items: center; background: var(--brand-grad); color: #fff; font-size: 13px; }

/* --------------------------------------------------------------- content */
.app-content { flex: 1; }
.app-footer {
  display: flex; justify-content: space-between;
  padding: 16px 24px; font-size: 12.5px; color: var(--text-soft);
  border-top: 1px solid var(--border);
}

.page-head { margin-bottom: 22px; }
.page-head h2 { font-weight: 800; font-size: 22px; margin: 0; letter-spacing: -.01em; }
.page-head p { color: var(--text-soft); margin: 4px 0 0; font-size: 14px; }

/* cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-hover { transition: transform .15s, box-shadow .15s; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* stat cards */
.stat-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.stat-card .stat-ico {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 20px; color: #fff;
  margin-bottom: 12px;
}
.stat-card .stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.stat-card .stat-label { color: var(--text-soft); font-size: 13px; font-weight: 500; }
.stat-card .stat-trend { font-size: 12px; margin-top: 6px; }
.bg-grad-brand { background: var(--brand-grad); }
.bg-grad-ok    { background: linear-gradient(135deg, #16a34a, #4ade80); }
.bg-grad-warn  { background: linear-gradient(135deg, #d97706, #fbbf24); }
.bg-grad-info  { background: linear-gradient(135deg, #0ea5e9, #22d3ee); }
.bg-grad-rose  { background: linear-gradient(135deg, #e11d48, #fb7185); }

.chart-card { padding: 20px; }
.chart-card h3 { font-size: 15px; font-weight: 700; margin: 0 0 14px; }
.chart-holder { position: relative; height: 280px; }

/* generic bits */
.text-soft { color: var(--text-soft); }
.hr-soft { border-color: var(--border); }
.badge-soft { background: color-mix(in srgb, var(--brand) 12%, transparent); color: var(--brand); font-weight: 600; }

/* ------------------------------------------------------------ auth pages */
.auth-body {
  margin: 0; min-height: 100vh;
  /* Top-align, don't vertically centre: a tall card (both channels + CAPTCHA +
     errors) must never have its top or bottom clipped off-screen. */
  display: flex; align-items: flex-start; justify-content: center;
  padding: clamp(24px, 6vh, 64px) 16px 48px;
  background:
    radial-gradient(1100px 620px at 6% -22%, color-mix(in srgb, var(--brand) 24%, transparent), transparent 60%),
    radial-gradient(920px 620px at 116% -4%, color-mix(in srgb, var(--brand-2) 20%, transparent), transparent 55%),
    var(--bg);
}
.auth-wrap { width: 100%; max-width: 430px; }
.auth-wrap:has(.auth-split) { max-width: 936px; }

.auth-split {
  display: grid; grid-template-columns: minmax(0, 1.02fr) minmax(0, .98fr);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 24px; overflow: hidden; box-shadow: var(--shadow);
  animation: authIn .5s ease both;
}
@keyframes authIn { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { .auth-split { animation: none; } }

/* left: brand panel */
.auth-hero {
  position: relative; color: #eef1ff; padding: 40px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: center;
  background: linear-gradient(150deg, #0d2a6b 0%, #3f3ac9 55%, #5b53e6 100%);
}
.auth-hero::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(440px 280px at 88% 6%, rgba(255,255,255,.16), transparent 60%),
    radial-gradient(380px 320px at -6% 104%, rgba(6,182,212,.30), transparent 60%);
}
.auth-hero-in { position: relative; }
.auth-hero .brand-crest { height: 54px; margin-bottom: 18px; }
.auth-hero .ah-kicker { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: #c3c9ff; margin-bottom: 8px; }
.auth-hero .ah-title { font-size: 22px; font-weight: 700; line-height: 1.22; margin: 0 0 10px; letter-spacing: -.01em; max-width: 15ch; }
.auth-hero .ah-lede { font-size: 13.5px; color: #ccd1f7; margin: 0 0 22px; max-width: 34ch; }
.auth-hero .ah-points { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.auth-hero .ah-points li { font-size: 12.5px; color: #e4e7ff; display: flex; gap: 9px; align-items: flex-start; }
.auth-hero .ah-points i { color: #aab0ff; font-size: 14px; margin-top: 1px; }

/* right: form panel */
.auth-panel { padding: 34px 36px; background: var(--surface); }
.auth-split .auth-brand { display: none; }

/* error pages keep the plain centred card */
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; box-shadow: var(--shadow); padding: 34px 32px;
  max-width: 420px; margin: 0 auto;
}

.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.auth-brand .brand-crest { height: 40px; }
.auth-brand strong { font-size: 16px; }
.auth-brand small { display: block; color: var(--text-soft); font-size: 12px; }

.auth-card h1, .auth-panel h1 { font-size: 23px; font-weight: 700; letter-spacing: -.02em; margin: 0 0 6px; }
.auth-card .sub, .auth-panel .sub { color: var(--text-soft); font-size: 14px; margin-bottom: 22px; }
.auth-card .form-label, .auth-panel .form-label { font-size: 12.5px; font-weight: 600; letter-spacing: .01em; }
.auth-card .form-control, .auth-panel .form-control { padding: 11px 13px; border-radius: 11px; }
.auth-card .form-control:focus, .auth-panel .form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 16%, transparent);
}

.btn-brand {
  background: var(--brand-grad); border: 0; color: #fff; font-weight: 650;
  padding: 12px 16px; border-radius: 11px; letter-spacing: .01em;
}
.btn-brand:hover { filter: brightness(1.06); color: #fff; box-shadow: 0 12px 24px -12px color-mix(in srgb, var(--brand) 65%, transparent); }
.btn-brand:active { transform: translateY(1px); }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 11px 16px; border-radius: 11px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; text-decoration: none; transition: border-color .15s, box-shadow .15s;
}
.btn-google i { color: #ea4335; }
.btn-google:hover { border-color: color-mix(in srgb, var(--brand) 45%, var(--border)); color: var(--text); box-shadow: var(--shadow-sm); }
.auth-sep { display: flex; align-items: center; gap: 12px; color: var(--text-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .12em; margin: 18px 0; }
.auth-sep::before, .auth-sep::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.auth-foot { text-align: center; font-size: 13px; color: var(--text-soft); margin-top: 22px; line-height: 1.9; }
.auth-foot a { text-decoration: none; }
.auth-foot a:hover { text-decoration: underline; }

.channel-switch {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 16px;
}
.chan-btn {
  flex: 1; border: 0; background: transparent; cursor: pointer;
  padding: 9px 10px; border-radius: 9px;
  font: inherit; font-size: 13px; font-weight: 600; color: var(--text-soft);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: color .15s, background .15s;
}
.chan-btn.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }

@media (max-width: 819.98px) {
  .auth-wrap:has(.auth-split) { max-width: 440px; }
  .auth-split { grid-template-columns: 1fr; border-radius: 20px; }
  .auth-hero { display: none; }
  .auth-panel { padding: 32px 26px; }
  .auth-split .auth-brand { display: flex; }
}

/* ---- compact for short laptop screens (14" ~ 1366x768 / 1080p @ 150%) ---- */
@media (min-width: 820px) and (max-height: 820px) {
  .auth-body { padding: 18px 16px 32px; }
  .auth-wrap:has(.auth-split) { max-width: 860px; }
  .auth-split { border-radius: 18px; }

  .auth-hero { padding: 26px 30px; }
  .auth-hero .brand-crest { height: 44px; margin-bottom: 14px; }
  .auth-hero .ah-kicker { margin-bottom: 6px; }
  .auth-hero .ah-title { font-size: 18.5px; margin-bottom: 8px; }
  .auth-hero .ah-lede { font-size: 12px; margin-bottom: 14px; }
  .auth-hero .ah-points { gap: 8px; }
  .auth-hero .ah-points li { font-size: 11.5px; }

  .auth-panel { padding: 24px 30px; }
  .auth-panel h1 { font-size: 20px; }
  .auth-panel .sub { font-size: 13px; margin-bottom: 14px; }
  .auth-panel .auth-brand { margin-bottom: 14px; }

  .btn-google { padding: 9px 16px; }
  .auth-sep { margin: 12px 0; }
  .channel-switch { margin-bottom: 10px; }
  .chan-btn { padding: 7px 10px; }
  .auth-panel form .mb-3 { margin-bottom: .65rem !important; }
  .auth-panel .form-text { font-size: 11.5px; margin-top: 2px; }
  .captcha-img, .captcha-box > .btn { height: 46px; }
  .btn-brand { padding: 10px 16px; }
  .auth-foot { margin-top: 14px; line-height: 1.7; }
}

/* very short (720p effective): also drop the hero's supporting copy */
@media (min-width: 820px) and (max-height: 680px) {
  .auth-hero .ah-lede, .auth-hero .ah-points { display: none; }
  .auth-hero { justify-content: center; }
  .auth-panel { padding: 20px 30px; }
}

.captcha-box { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.captcha-img {
  height: 56px; border-radius: 10px; border: 1px solid var(--border); background: #fff;
  image-rendering: -webkit-optimize-contrast;
}
.captcha-box > .btn { height: 56px; border-radius: 10px; flex: 0 0 auto; }
.captcha-box .form-control { flex: 1 1 100%; }
.g-recaptcha { transform-origin: 0 0; }
.otp-input {
  letter-spacing: 14px; text-align: center; font-size: 24px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* timeline (used from Phase 2, styled now) */
.timeline { position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 9px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item::before {
  content: ""; position: absolute; left: -23px; top: 3px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--brand);
}

/* ---------------------------------------------------------- responsive */
@media (max-width: 991.98px) {
  .app-main { margin-left: 0; }
  .app-sidebar { transform: translateX(-100%); }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-shell.collapsed .app-main { margin-left: 0; }
}

:fullscreen .app-content, :-webkit-full-screen .app-content { background: var(--bg); }

/* ---------------------------------------------------------- office tree */
.office-tree { font-size: 14px; }
.ot-list { list-style: none; margin: 0; padding: 0; }
.ot-children > .ot-list {
  margin-left: 13px; padding-left: 24px;
  border-left: 1px dashed var(--border);
}
.ot-root { min-height: 10px; }

.ot-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; margin: 4px 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); cursor: grab;
}
.ot-row:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--border)); }
.ot-row:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.ot-grip { color: var(--text-soft); display: inline-flex; }
.ot-name { font-weight: 600; color: var(--text); text-decoration: none; }
.ot-name:hover { text-decoration: underline; }
.ot-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ot-tag {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-soft); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
}
.ot-tag.ot-off { color: #fff; background: var(--text-soft); border-color: transparent; }
.ot-code { font-size: 12px; color: var(--text-soft); }
.ot-dim { font-size: 12px; color: var(--text-soft); display: inline-flex; align-items: center; gap: 3px; }

.ot-actions { margin-left: auto; display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.ot-row:hover .ot-actions, .ot-row:focus-within .ot-actions { opacity: 1; }
@media (hover: none) { .ot-actions { opacity: 1; } }
.ot-btn {
  border: 0; background: transparent; color: var(--text-soft); cursor: pointer;
  width: 28px; height: 28px; border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.ot-btn:hover { background: var(--surface-2); color: var(--text); }
.ot-btn-danger:hover { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.ot-dragging > .ot-row { opacity: .45; }
.ot-node.ot-over-before > .ot-row { box-shadow: 0 -3px 0 0 var(--brand); }
.ot-node.ot-over-after  > .ot-row { box-shadow: 0 3px 0 0 var(--brand); }
.ot-node.ot-over-into   > .ot-row {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, var(--surface));
}
.ot-list.ot-over-into { outline: 2px dashed var(--brand); outline-offset: 2px; border-radius: 8px; }

.ot-addform {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 2px 0 8px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.ot-addform.ot-addform-root { margin-bottom: 12px; }
.ot-addform .js-ot-name { max-width: 260px; }
.ot-addform .js-ot-level { max-width: 190px; }
.ot-addform .ot-adderr { flex-basis: 100%; }

.ot-toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 1080;
  padding: 10px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 600; color: #fff; box-shadow: var(--shadow);
}
.ot-toast-ok  { background: var(--ok); }
.ot-toast-err { background: var(--danger); }
