/* CityCanvas admin & vendor portal
   Design tokens first — change colours, radius and spacing here. */

:root {
  /* Brand */
  --brand-dark: #0f1426;
  --brand-dark-2: #1a2140;
  --accent: #4c6fff;
  --accent-hover: #3a5bea;
  --accent-soft: #e8edff;

  /* Surfaces & text */
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8f9fc;
  --border: #e2e6ef;
  --text: #161a2b;
  --text-muted: #6a7187;
  --on-dark: #ffffff;
  --on-dark-muted: #aab1cc;

  /* States */
  --success: #13804b;
  --success-soft: #e3f6ec;
  --warning: #9a6200;
  --warning-soft: #fff3dc;
  --danger: #c62d3a;
  --danger-soft: #fde8ea;

  /* Shape */
  --radius: 10px;
  --radius-small: 6px;
  --shadow: 0 1px 2px rgba(15, 20, 38, 0.06), 0 2px 8px rgba(15, 20, 38, 0.05);
  --shadow-dialog: 0 20px 60px rgba(15, 20, 38, 0.3);
  --gap: 16px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f1d;
    --surface: #141a2e;
    --surface-2: #1a2139;
    --border: #283050;
    --text: #e8ebf5;
    --text-muted: #949bb5;
    --accent-soft: #1f2a55;
    --success-soft: #0f3324;
    --warning-soft: #3a2a08;
    --danger-soft: #3d1419;
    --success: #4ccf8d;
    --warning: #f0b44a;
    --danger: #ff6b78;
  }
}

/* ---------------------------------------------------------------
   Base
   --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0 0 0.75em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.9em; }
.muted { color: var(--text-muted); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------
   Boot & auth screens
   --------------------------------------------------------------- */
.boot, .auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 30% 20%, var(--brand-dark-2), var(--brand-dark) 70%);
}
.boot img { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.boot-error {
  max-width: 520px;
  margin: 15vh auto;
  padding: 24px;
  color: var(--text);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
}
.auth-logo {
  display: block;
  width: 72px;
  height: 72px;
  margin: -68px auto 16px;
  padding: 10px;
  border-radius: 18px;
  background: var(--brand-dark);
  box-shadow: var(--shadow);
}
.auth-card h1 { text-align: center; margin-bottom: 24px; font-size: 1.35rem; }

/* ---------------------------------------------------------------
   Top bar
   --------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 60px;
  background: var(--brand-dark);
  color: var(--on-dark);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--on-dark);
  font-weight: 700;
  font-size: 1.05rem;
}
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }

.mainnav { display: flex; gap: 4px; flex: 1; }
.mainnav a {
  padding: 8px 12px;
  border-radius: var(--radius-small);
  color: var(--on-dark-muted);
  font-weight: 500;
}
.mainnav a:hover { color: var(--on-dark); background: var(--brand-dark-2); text-decoration: none; }
.mainnav a.active { color: var(--on-dark); background: var(--brand-dark-2); }

.user-menu { display: flex; align-items: center; gap: 12px; }
.user-name { display: flex; flex-direction: column; text-align: right; font-size: 0.875rem; line-height: 1.2; }
.user-name small { color: var(--on-dark-muted); }

/* ---------------------------------------------------------------
   Layout
   --------------------------------------------------------------- */
.view {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 64px;
}

.page-header { margin-bottom: 24px; }
.page-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title-row p { margin: 4px 0 0; }
.page-actions, .card-actions, .list-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; font-size: 0.875rem; }
.crumb-sep { color: var(--text-muted); }

.card {
  margin-bottom: 20px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
ul.card { padding: 4px 20px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--gap); }
.tile {
  display: block;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}
.tile:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.tile-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.tile p { margin: 0; font-size: 0.875rem; }

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card .facts { margin-bottom: 0; }
.fact {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  min-width: 0;
}
.fact-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.fact-value { overflow-wrap: anywhere; white-space: pre-line; }
.description { white-space: pre-wrap; margin-bottom: 20px; }

/* ---------------------------------------------------------------
   Lists
   --------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child { border-bottom: 0; }
.list-main { flex: 1; min-width: 0; color: var(--text); }
a.list-main:hover { text-decoration: none; }
a.list-main:hover .list-title { color: var(--accent); }
.list-title { font-weight: 500; overflow-wrap: anywhere; }
.list-meta { font-size: 0.85rem; color: var(--text-muted); overflow-wrap: anywhere; }

.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-muted);
}
.empty .btn { margin-top: 8px; }

.loading { display: flex; align-items: center; gap: 10px; padding: 32px 0; color: var(--text-muted); }
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------
   Badges
   --------------------------------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  vertical-align: middle;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* ---------------------------------------------------------------
   Buttons
   --------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-small { padding: 5px 10px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, 0.25); color: var(--on-dark); }
.btn-ghost:hover { border-color: var(--on-dark); }

.icon-btn {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-small);
  background: transparent;
  color: var(--text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.link-btn {
  display: block;
  margin: 12px auto 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

/* ---------------------------------------------------------------
   Forms
   --------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.field legend, .field-label { font-size: 0.875rem; font-weight: 500; padding: 0; margin-bottom: 6px; }
.field-label { margin-bottom: 0; }
.hint { color: var(--text-muted); font-size: 0.8rem; }

input, textarea, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}
input:disabled, textarea:disabled, select:disabled { background: var(--surface-2); color: var(--text-muted); }
input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
textarea { resize: vertical; }

.field-checkbox { flex-direction: row; align-items: center; gap: 10px; }
.field-checkbox .hint { margin-left: auto; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.check-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  cursor: pointer;
}
.check-option input { margin-top: 2px; }
.check-option span { display: flex; flex-direction: column; font-size: 0.9rem; }

.location-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.location-row input { flex: 1 1 130px; }

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-small);
  background: var(--danger-soft);
  color: var(--danger);
}
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.inline-form { display: flex; gap: 8px; margin-bottom: 12px; }
.inline-form input { max-width: 320px; }

progress { width: 100%; height: 8px; accent-color: var(--accent); }

/* ---------------------------------------------------------------
   Dialogs
   --------------------------------------------------------------- */
.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-dialog);
}
.dialog-wide { width: min(860px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(10, 14, 28, 0.55); }
.dialog-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.dialog-body { padding: 20px; }
.dialog-body > p:last-child { margin-bottom: 0; }
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ---------------------------------------------------------------
   Location picker
   --------------------------------------------------------------- */
.picker { display: flex; flex-direction: column; gap: 12px; }
.picker-toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1 1 260px; }
.search-results {
  position: absolute;
  z-index: 1000;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  margin: 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface);
  box-shadow: var(--shadow-dialog);
}
.search-results button {
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.search-results button:hover { background: var(--accent-soft); }
.map {
  height: min(52vh, 460px);
  border: 1px solid var(--border);
  border-radius: var(--radius-small);
  background: var(--surface-2);
}
.picker-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }
.notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius-small);
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 0.875rem;
}

/* ---------------------------------------------------------------
   Toasts
   --------------------------------------------------------------- */
.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(380px, calc(100vw - 32px));
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius-small);
  background: var(--brand-dark);
  color: var(--on-dark);
  box-shadow: var(--shadow-dialog);
  animation: toast-in 0.2s ease-out;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

/* ---------------------------------------------------------------
   Small screens
   --------------------------------------------------------------- */
@media (max-width: 760px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px; }
  .mainnav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .user-menu { margin-left: auto; }
  .user-name { display: none; }
  .view { padding: 20px 16px 48px; }
  .list-row { flex-wrap: wrap; }
  .list-actions { width: 100%; }
  .card { padding: 16px; }
  ul.card { padding: 4px 16px; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input { max-width: none; }
}
