/* =========================================================================
   Backoffice prototype — base styles
   Loosely based on The 50 Best design system, adapted for dense backoffice UI.
   ========================================================================= */

@import url("design-system/colors_and_type.css");

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--c-surface-0);
  color: var(--fg-1);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

a { color: inherit; }

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

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.app--collapsed { grid-template-columns: 72px 1fr; }

/* ---- Sidebar ------------------------------------------------------------ */

.sidebar {
  background: #0A0A0A;
  color: #FAFAF9;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.02em;
}
.sidebar__logo svg { color: #FAFAF9; }
.sidebar__logo span { transform: translateY(2px); }

.sidebar__collapse {
  width: 28px; height: 28px;
  border: none; background: transparent;
  color: #B0ACA3;
  border-radius: 4px;
  display: grid; place-items: center;
  transition: background 150ms;
}
.sidebar__collapse:hover { background: rgba(255,255,255,0.08); color: #FAFAF9; }

.sidebar__section {
  display: flex; flex-direction: column;
  gap: 4px;
}

.sidebar__section-title {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8C887F;
  padding: 0 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar__section-title button {
  border: none; background: none; color: inherit;
  display: grid; place-items: center;
  cursor: pointer;
}

.sidebar__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 6px;
  color: #D4D2CD;
  text-decoration: none;
  font-size: 14px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  position: relative;
  transition: background 150ms, color 150ms;
}
.sidebar__item:hover { background: rgba(255,255,255,0.06); color: #FAFAF9; }
.sidebar__item.is-active { background: rgba(255,255,255,0.10); color: #FAFAF9; }
.sidebar__item .dot {
  margin-left: auto;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #34D27F;
}

.sidebar__profile {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}
.sidebar__profile img {
  width: 32px; height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: #444;
}
.sidebar__profile .meta {
  font-size: 13px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sidebar__profile .status {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #34D27F;
  margin-left: auto;
  margin-right: 6px;
  box-shadow: 0 0 0 2px #0A0A0A;
}

/* sidebar collapsed */
.app--collapsed .sidebar__section-title,
.app--collapsed .sidebar__item span:not(.icon),
.app--collapsed .sidebar__profile .meta,
.app--collapsed .sidebar__logo span,
.app--collapsed .sidebar__item .dot {
  display: none;
}
.app--collapsed .sidebar { padding: 24px 12px; align-items: center; }
.app--collapsed .sidebar__item { justify-content: center; padding: 9px; }

/* ---- Main content area -------------------------------------------------- */

.main {
  background: var(--c-surface-0);
  min-width: 0;
}

.topbar {
  padding: 24px 40px 0 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--fg-3);
}
.crumbs .home { display: inline-grid; place-items: center; }
.crumbs span { color: var(--fg-1); }
.crumbs button {
  border: none; background: none; color: inherit;
  font-size: inherit; padding: 0;
}
.crumbs button:hover { color: var(--fg-1); }

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 32px;
  flex-wrap: wrap;
}
.page-head > .page-title { flex: 0 1 auto; min-width: 0; }
.wizard-tabs { flex: 1 1 auto; justify-content: center; flex-wrap: wrap; }

.page-title {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.page-title__icon {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  color: var(--fg-1);
  flex-shrink: 0;
  margin-top: 4px;
}
.page-title h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 36px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 520px;
}
.page-title p {
  margin: 6px 0 0 0;
  color: var(--fg-3);
  font-size: 14px;
}

/* ---- Tab pills (wizard) ------------------------------------------------- */

.wizard-tabs {
  display: flex;
  gap: 8px;
  align-items: center;
}
.wizard-tab {
  border: 1px solid var(--line-1);
  background: #FFF;
  padding: 10px 16px 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--fg-2);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 150ms;
  white-space: nowrap;
}
.wizard-tab .num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-3);
}
.wizard-tab:hover { border-color: var(--fg-3); }
.wizard-tab.is-active {
  background: #0A0A0A;
  color: #FAFAF9;
  border-color: #0A0A0A;
}
.wizard-tab.is-active .num { color: #B0ACA3; }
.wizard-tab.is-complete {
  background: #E8F5EC;
  border-color: #BFE2C9;
  color: #0F6E56;
}
.wizard-tab.is-complete .num { color: #0F6E56; }
.wizard-tab.is-incomplete {
  background: #FBE9E9;
  border-color: #F1C8C8;
  color: #890512;
}
.wizard-tab.is-incomplete .num { color: #890512; }

/* ---- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  padding: 11px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-weight: 500;
  white-space: nowrap;
  transition: all 150ms cubic-bezier(0.2, 0, 0, 1);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--primary {
  background: #0A0A0A;
  color: #FAFAF9;
  border-color: #0A0A0A;
}
.btn--primary:hover:not(:disabled) { background: #1A1918; border-color: #1A1918; }
.btn--primary:disabled { background: #C6C6C6; border-color: #C6C6C6; color: #FAFAF9; opacity: 1; }

.btn--secondary {
  background: #FFF;
  border-color: var(--line-1);
  color: var(--fg-1);
}
.btn--secondary:hover:not(:disabled) { border-color: var(--fg-1); }

.btn--ghost {
  background: transparent;
  color: var(--fg-2);
}
.btn--ghost:hover { background: var(--c-surface-1); color: var(--fg-1); }

.btn--danger {
  background: #FFF;
  border-color: var(--line-1);
  color: var(--c-danger);
}
.btn--danger:hover { background: var(--c-danger-bg); border-color: #F1C8C8; }

.btn--lg { padding: 13px 22px; font-size: 14px; }
.btn--sm { padding: 7px 12px; font-size: 13px; }

.btn-row { display: flex; gap: 12px; align-items: center; }

/* ---- Inputs ------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-1);
}
.field label .req { color: var(--c-danger); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--fg-3); }

.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line-1);
  background: #FFF;
  padding: 11px 14px;
  border-radius: 8px;
  font-size: 14px;
  color: var(--fg-1);
  transition: border-color 150ms;
  outline: none;
}
.input::placeholder, .textarea::placeholder { color: var(--fg-5); }
.input:focus, .textarea:focus, .select:focus { border-color: var(--fg-1); }
.textarea { resize: vertical; min-height: 110px; }
.input--with-icon { padding-left: 40px; }
.input-wrap { position: relative; }
.input-wrap .input-icon {
  position: absolute;
  left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--fg-4);
  pointer-events: none;
}

.select-wrap { position: relative; }
.select {
  appearance: none;
  padding-right: 36px;
  background: #FFF;
}
.select-wrap .chev {
  position: absolute;
  right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--fg-3);
  pointer-events: none;
}

/* Toggle switch */
.toggle {
  position: relative;
  width: 40px; height: 22px;
  background: #D4D2CD;
  border-radius: 999px;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: background 150ms;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: #FFF;
  border-radius: 50%;
  transition: transform 150ms;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle.is-on { background: #0A0A0A; }
.toggle.is-on::after { transform: translateX(18px); }

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.checkbox-row > div { flex: 1; }
.checkbox-row .label { font-size: 14px; font-weight: 500; color: var(--fg-1); }
.checkbox-row .description { font-size: 13px; color: var(--fg-3); margin-top: 2px; }

input[type="checkbox"].cb {
  appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid #C6C6C6;
  border-radius: 4px;
  background: #FFF;
  margin: 0;
  cursor: pointer;
  display: grid; place-items: center;
  flex-shrink: 0;
  position: relative;
  top: 2px;
}
input[type="checkbox"].cb:checked {
  background: #0A0A0A;
  border-color: #0A0A0A;
}
input[type="checkbox"].cb:checked::after {
  content: "";
  width: 10px; height: 6px;
  border-left: 2px solid #FFF;
  border-bottom: 2px solid #FFF;
  transform: rotate(-45deg) translate(1px, -1px);
}

/* Radio */
input[type="radio"].rd {
  appearance: none;
  width: 18px; height: 18px;
  border: 1.5px solid #C6C6C6;
  border-radius: 50%;
  background: #FFF;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
}
input[type="radio"].rd:checked {
  border-color: #0A0A0A;
  border-width: 5px;
}

/* ---- Cards / panels ----------------------------------------------------- */

.panel {
  background: #FFF;
  border: 1px solid var(--line-1);
  border-radius: 12px;
  padding: 28px;
}
.panel--inset {
  background: var(--c-surface-1);
}
.panel--ghost {
  background: transparent;
  border: 1px solid var(--line-1);
}

.panel h2 {
  margin: 0 0 4px 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 22px;
  letter-spacing: -0.01em;
}
.panel .panel__sub {
  color: var(--fg-3);
  font-size: 13px;
  margin-bottom: 20px;
}

/* ---- Page layout -------------------------------------------------------- */

.page {
  padding: 0 40px 40px 40px;
}

.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.content-grid--single { grid-template-columns: 1fr; }
.content-grid--2-1 { grid-template-columns: 2fr 1fr; }
.content-grid--1-2 { grid-template-columns: 1fr 2fr; }

/* ---- Badges / chips ----------------------------------------------------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.chip--success { background: #E8F5EC; color: #0F6E56; }
.chip--warning { background: #FBF1DD; color: #855E0B; }
.chip--danger  { background: #FBE9E9; color: #890512; }
.chip--info    { background: #E6F1FB; color: #185FA5; }
.chip--neutral { background: var(--c-surface-2); color: var(--fg-2); }
.chip--ink     { background: #0A0A0A; color: #FFF; }
.chip--outline { background: #FFF; border: 1px solid var(--line-1); color: var(--fg-1); }
.chip--dot::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip--lg { padding: 6px 14px; font-size: 13px; }

/* ---- Tables ------------------------------------------------------------- */

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tbl thead th {
  text-align: left;
  font-weight: 500;
  color: var(--fg-4);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line-1);
}
.tbl tbody td {
  padding: 18px 12px;
  border-bottom: 1px solid var(--line-1);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--c-surface-1); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl tbody td.primary { font-weight: 500; }
.tbl tbody td.actions { text-align: right; }

/* ---- Modal -------------------------------------------------------------- */

.scrim {
  position: fixed;
  inset: 0;
  background: rgba(10,10,10,0.45);
  display: grid;
  place-items: center;
  z-index: 100;
  animation: fade 150ms ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: #FFF;
  border-radius: 16px;
  width: min(560px, calc(100vw - 48px));
  max-height: calc(100vh - 96px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--elev-lg);
  animation: pop 200ms cubic-bezier(0.2, 0, 0, 1);
}
.modal--wide { width: min(720px, calc(100vw - 48px)); }
@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal__head {
  padding: 24px 28px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.modal__head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 24px;
  letter-spacing: -0.01em;
}
.modal__head .label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-4);
  margin-bottom: 6px;
}
.modal__close {
  border: none; background: transparent;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--fg-3);
}
.modal__close:hover { background: var(--c-surface-1); color: var(--fg-1); }
.modal__body { padding: 12px 28px 24px; overflow: auto; }
.modal__foot {
  padding: 18px 28px;
  border-top: 1px solid var(--line-1);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--c-surface-0);
}
.modal__foot--space-between { justify-content: space-between; }

/* ---- Misc utilities ----------------------------------------------------- */

.divider { height: 1px; background: var(--line-1); border: none; margin: 0; }

.muted { color: var(--fg-3); }
.subtle { color: var(--fg-4); font-size: 12px; }

.label-overline {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-4);
  font-weight: 500;
}

.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }
.row--center { justify-content: center; }
.grow { flex: 1; }

/* Drag handle */
.drag-handle {
  color: var(--fg-4);
  cursor: grab;
  display: inline-grid;
  place-items: center;
  padding: 4px;
}
.drag-handle:active { cursor: grabbing; }

/* Hover row used for sortable lists */
.draggable-row {
  display: grid;
  grid-template-columns: 28px 28px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line-1);
  background: #FFF;
  border-radius: 8px;
  transition: box-shadow 150ms, border-color 150ms;
}
.draggable-row:hover { border-color: var(--fg-3); box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.draggable-row .seq {
  font-family: var(--font-mono);
  font-size: 13px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--fg-2);
  display: grid; place-items: center;
}

/* World map placeholder */
.worldmap {
  height: 320px;
  background:
    radial-gradient(circle at 20% 40%, var(--c-surface-2) 0%, var(--c-surface-2) 2px, transparent 2px),
    radial-gradient(circle at 30% 35%, var(--c-surface-2) 0%, var(--c-surface-2) 2px, transparent 2px),
    radial-gradient(circle at 25% 50%, var(--c-surface-2) 0%, var(--c-surface-2) 2px, transparent 2px),
    var(--c-surface-1);
  background-size: 16px 16px;
  background-image:
    radial-gradient(circle, var(--c-surface-3) 1.5px, transparent 1.5px);
  background-position: 0 0;
  border-radius: 12px;
  display: grid;
  place-items: end center;
  padding: 16px;
  color: var(--fg-4);
  font-size: 12px;
}

/* progress dots for voter step tracker */
.steps {
  display: flex;
  align-items: center;
  gap: 4px;
}
.steps .step {
  width: 22px; height: 8px;
  border-radius: 999px;
  background: var(--c-surface-3);
}
.steps .step.is-done { background: #0F6E56; }
.steps .step.is-current { background: #855E0B; }
.steps .step.is-missing { background: #C4956A; }

/* shadows used sparingly */
.has-shadow-sm { box-shadow: var(--elev-sm); }

/* helper for fixed-width cells */
.w-160 { width: 160px; }
.w-200 { width: 200px; }
.w-220 { width: 220px; }
