/* ==========================================================================
   CityHunt — desktop admin panel
   Sidebar + topbar shell, KPI cards, charts, live map. RTL, dark, responsive.
   ========================================================================== */

.admin-app {
  --sidebar: 248px;
  --topbar: 66px;
  --panel: #121214;
  --panel-2: #17171a;
  --panel-line: #212127;
  display: block;
  min-height: 100vh;
  background: #0a0a0b;
  color: var(--text);
}

/* app shell overrides the phone-sized container */
#app.wide { max-width: none; }

/* ---------- sidebar ---------- */

.admin-sidebar {
  position: fixed;
  inset-block: 0;
  left: 0;
  width: var(--sidebar);
  background: #0d0d0f;
  border-right: 1px solid var(--panel-line);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: transform 0.22s ease;
}
.admin-sidebar .brand {
  display: flex; flex-direction: row-reverse; align-items: center; gap: 10px;
  justify-content: flex-end; text-align: start;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--panel-line);
}
.admin-sidebar .brand img { width: 40px; height: 52px; object-fit: contain; flex: none; }
.admin-sidebar .brand b { font-size: 15px; letter-spacing: 1px; display: block; }
.admin-sidebar .brand span { font-size: 9.5px; color: var(--muted); letter-spacing: 2px; }

.admin-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 3px; }
.admin-nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: var(--text-2); font-size: 13px;
  transition: background 0.14s ease, color 0.14s ease;
}
.admin-nav a svg { width: 18px; height: 18px; opacity: .9; }
.admin-nav a:hover { background: var(--panel-2); color: var(--text); }
.admin-nav a.active { background: var(--red); color: #fff; font-weight: 700; }
.admin-nav a.active svg { opacity: 1; }
.admin-nav a .soon {
  margin-inline-start: auto; font-size: 9px; color: var(--muted-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 1px 6px;
}

.sidebar-foot { padding: 12px; border-top: 1px solid var(--panel-line); }
.theme-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: 12px 14px; width: 100%;
  color: var(--text-2); font-size: 12.5px;
}
.theme-toggle .bar { height: 3px; background: var(--line); border-radius: 3px; margin-top: 8px; position: relative; }
.theme-toggle .bar i { position: absolute; inset-inline-start: 32%; width: 22px; height: 3px; background: var(--red); border-radius: 3px; }

/* ---------- main column ---------- */

.admin-main { margin-left: var(--sidebar); min-height: 100vh; }

.admin-topbar {
  height: var(--topbar);
  display: flex; align-items: center; gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--panel-line);
  background: rgba(10, 10, 11, 0.92);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 40;
}
.admin-topbar .spacer { flex: 1; }
.topbar-icon {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center; color: var(--text-2);
  border: 1px solid var(--panel-line); background: var(--panel);
  position: relative;
}
.topbar-icon:hover { background: var(--panel-2); }
.topbar-icon .dot {
  position: absolute; top: -5px; inset-inline-end: -5px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid #0a0a0b;
}
.topbar-user { display: flex; align-items: center; gap: 10px; padding-inline-start: 6px; }
.topbar-user img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; border: 1px solid var(--panel-line); }
.topbar-user b { font-size: 13px; display: block; }
.topbar-user span { font-size: 11px; color: var(--muted); }

.admin-content { padding: 20px 22px 40px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0 0 4px; font-size: 20px; }
.page-head p { margin: 0; color: var(--muted); font-size: 12.5px; }
.page-head .tools { display: flex; align-items: center; gap: 10px; }

.pill-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-radius: 11px; font-size: 12.5px;
  background: var(--panel); border: 1px solid var(--panel-line); color: var(--text-2);
}
.pill-btn:hover { background: var(--panel-2); }
.pill-btn.primary { background: var(--red); border-color: var(--red); color: #fff; font-weight: 700; }
.pill-btn.primary:hover { filter: brightness(1.06); }

/* ---------- KPI cards ---------- */

.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--panel); border: 1px solid var(--panel-line); border-radius: 16px;
  padding: 16px; display: flex; align-items: center; gap: 14px;
}
.kpi .ic { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; flex: none; }
.kpi .ic svg { width: 24px; height: 24px; }
.kpi .ic.red { background: rgba(226,27,44,.14); color: #ff5666; }
.kpi .ic.green { background: rgba(53,194,107,.14); color: #4fd486; }
.kpi .ic.amber { background: rgba(224,169,46,.14); color: #f0bd52; }
.kpi .ic.purple { background: rgba(139,86,201,.16); color: #b183e8; }
.kpi .ic.cyan { background: rgba(56,182,213,.15); color: #55c9e6; }
.kpi .body { min-width: 0; flex: 1; text-align: end; }
.kpi .label { color: var(--muted); font-size: 12px; margin-bottom: 2px; }
.kpi .value { font-size: 25px; font-weight: 700; line-height: 1.25; direction: ltr; }
.kpi .delta { font-size: 10.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; justify-content: flex-end; margin-top: 2px; }
.kpi .delta.up { color: #4fd486; }
.kpi .delta.down { color: #ff5666; }

/* ---------- grid + panels ---------- */

.grid { display: grid; gap: 14px; margin-bottom: 16px; }
.grid.c3 { grid-template-columns: 1.15fr 0.95fr 1.1fr; }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
.grid.c2 { grid-template-columns: 1fr 1fr; }
.grid.c2-wide { grid-template-columns: 1.6fr 1fr; }

.panel {
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 16px; padding: 16px; display: flex; flex-direction: column;
}
.panel > .head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 14px;
}
.panel > .head h3 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.panel > .head .link { color: var(--red); font-size: 11.5px; }
.panel .foot-btn {
  margin-top: auto; padding-top: 12px;
}
.panel .foot-btn .pill-btn { width: 100%; justify-content: center; }

/* ---------- chart ---------- */

.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid line { stroke: #1d1d22; stroke-width: 1; }
.chart-axis text { fill: #6a6a74; font-size: 10px; }
.chart-area { fill: url(#chartGradient); }
.chart-line { fill: none; stroke: #e21b2c; stroke-width: 2.2; stroke-linejoin: round; }
.chart-dot { fill: #e21b2c; stroke: #0a0a0b; stroke-width: 2; }
.chart-tip {
  position: absolute; transform: translate(50%, -120%);
  background: var(--panel-2); border: 1px solid var(--panel-line);
  border-radius: 10px; padding: 6px 10px; font-size: 11px; text-align: center;
  pointer-events: none; white-space: nowrap;
}
.chart-tip b { display: block; font-size: 13px; }

/* ---------- lists inside panels ---------- */

.row-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--panel-line);
}
.row-item:last-child { border-bottom: none; }
.row-item img.thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: none; background: var(--panel-2); }
.row-item .info { flex: 1; min-width: 0; }
.row-item .info b { font-size: 13px; display: block; margin-bottom: 3px; }
.row-item .info span { font-size: 11px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }
.row-item .side { text-align: start; flex: none; }

.state-chip {
  font-size: 10.5px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.state-chip.on { background: rgba(53,194,107,.12); border-color: rgba(53,194,107,.4); color: #4fd486; }
.state-chip.warn { background: rgba(224,169,46,.12); border-color: rgba(224,169,46,.4); color: #f0bd52; }
.state-chip.red { background: rgba(226,27,44,.12); border-color: rgba(226,27,44,.45); color: #ff5666; }

.count-badge {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
  background: rgba(226,27,44,.12); color: #ff5666; border: 1px solid rgba(226,27,44,.3);
  line-height: 1;
}
.count-badge small { display: block; font-size: 8px; font-weight: 400; color: var(--muted); }

/* ---------- admin map ---------- */

.admin-map { height: 300px; border-radius: 12px; overflow: hidden; background: #0d0d10; position: relative; }
.admin-map .map-fallback { height: 100%; min-height: 0; border-radius: 12px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.map-legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-inline-end: 5px; }
.cluster-marker {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 12px; color: #fff;
  border: 2px solid rgba(255,255,255,.35); box-shadow: 0 4px 14px rgba(0,0,0,.55);
}

/* ---------- tables ---------- */

.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  text-align: start; color: var(--muted); font-weight: 500; font-size: 11.5px;
  padding: 10px 12px; border-bottom: 1px solid var(--panel-line); white-space: nowrap;
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--panel-line); }
.data-table tbody tr:hover { background: var(--panel-2); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .who { display: flex; align-items: center; gap: 10px; }
.data-table .who img { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }
.data-table .who small { display: block; color: var(--muted); font-size: 10.5px; direction: ltr; }
.table-scroll { overflow-x: auto; }

.online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); display: inline-block; }
.online-dot.on { background: #4fd486; box-shadow: 0 0 0 3px rgba(53,194,107,.18); }

/* ---------- search + filters ---------- */

.search-box {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--panel-line);
  border-radius: 12px; padding: 0 14px; min-width: 240px;
}
.search-box input { flex: 1; background: none; border: none; outline: none; padding: 11px 0; font-size: 12.5px; }
.search-box svg { color: var(--muted); }

.seg-tabs { display: inline-flex; gap: 6px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px; padding: 4px; }
.seg-tabs button { padding: 8px 14px; border-radius: 9px; font-size: 12px; color: var(--muted); }
.seg-tabs button.active { background: var(--red); color: #fff; font-weight: 700; }

/* ---------- forms in the panel ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.admin-app .field label { font-size: 12px; }
.admin-app .input, .admin-app .textarea, .admin-app .select {
  background: var(--panel-2); border-color: var(--panel-line); border-radius: 11px; padding: 11px 13px;
}

/* wizard */
.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.step .n {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--line); font-size: 12px;
}
.step.active { color: var(--text); }
.step.active .n { border-color: var(--red); background: rgba(226,27,44,.15); color: #ff5666; font-weight: 700; }
.step.done .n { border-color: var(--red); color: var(--red); }
.step-sep { width: 26px; height: 1px; background: var(--line); }

/* ---------- responsive ---------- */

.sidebar-backdrop { display: none; }

@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .grid.c3 { grid-template-columns: 1fr 1fr; }
  .grid.c4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 860px) {
  .admin-sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .admin-app.nav-open .admin-sidebar { transform: none; }
  .admin-app.nav-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 55;
  }
  .admin-main { margin-left: 0; }
  .admin-content { padding: 16px 14px 32px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .grid.c3, .grid.c4, .grid.c2, .grid.c2-wide { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .topbar-user b, .topbar-user span { display: none; }
}

@media (max-width: 520px) {
  .kpi-row { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .tools { flex-wrap: wrap; }
}
