/**
 * MAPPERS — Backoffice Admin Styles
 * Premium tabbed admin console with dark cards & KPI dashboard
 */

/* ─── Header ─── */
.bo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border-subtle, #e5e7eb);
  margin-bottom: 0;
}
.bo-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, #009639, #00c853);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.bo-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted, #6b7280);
  display: block;
  margin-top: 2px;
}
.bo-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.bo-live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
  animation: bo-pulse 2s infinite;
  display: inline-block;
}
@keyframes bo-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}
.bo-live-label {
  font-size: 0.75rem;
  color: var(--text-muted, #6b7280);
}
.bo-btn-refresh {
  width: 34px; height: 34px;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 8px;
  background: var(--bg-surface, #fff);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.bo-btn-refresh:hover { background: var(--bg-hover, #f3f4f6); border-color: var(--primary, #009639); }

/* ─── Tab Navigation ─── */
.bo-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 0 0;
  border-bottom: 2px solid var(--border-subtle, #e5e7eb);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.bo-tab {
  padding: 10px 18px;
  border: none;
  background: none;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bo-tab:hover { color: var(--text-primary, #111827); background: var(--bg-hover, #f3f4f6); border-radius: 8px 8px 0 0; }
.bo-tab.active {
  color: var(--primary, #009639);
  border-bottom-color: var(--primary, #009639);
}
.bo-tab-icon { font-size: 1rem; }

/* ─── Panels ─── */
.bo-panel { display: none; padding-top: 24px; }
.bo-panel.active { display: block; animation: bo-fadein 0.25s ease; }
@keyframes bo-fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ─── KPI Cards ─── */
.bo-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.bo-kpi {
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.bo-kpi:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.bo-kpi::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 4px;
  border-radius: 14px 14px 0 0;
}
.bo-kpi-purple::before { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.bo-kpi-blue::before { background: linear-gradient(90deg, #2563eb, #60a5fa); }
.bo-kpi-green::before { background: linear-gradient(90deg, #059669, #34d399); }
.bo-kpi-amber::before { background: linear-gradient(90deg, #d97706, #fbbf24); }
.bo-kpi-red::before { background: linear-gradient(90deg, #dc2626, #f87171); }

.bo-kpi-icon { font-size: 1.6rem; margin-bottom: 6px; }
.bo-kpi-value { font-size: 1.65rem; font-weight: 800; color: var(--text-primary, #111827); }
.bo-kpi-label { font-size: 0.75rem; color: var(--text-muted, #6b7280); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

/* ─── Grid layouts ─── */
.bo-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 768px) { .bo-grid-2 { grid-template-columns: 1fr; } }

/* ─── Cards ─── */
.bo-card {
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 20px;
}
.bo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle, #e5e7eb);
  background: var(--bg-hover, #f9fafb);
}
.bo-card-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary, #111827);
}
.bo-card-actions { display: flex; gap: 8px; align-items: center; }
.bo-card-body { padding: 16px 20px; }

/* ─── Forms in card headers ─── */
.bo-select {
  padding: 6px 12px;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 8px;
  font-size: 0.82rem;
  background: var(--bg-surface, #fff);
  color: var(--text-primary, #111827);
  cursor: pointer;
}
.bo-input {
  padding: 6px 12px;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 8px;
  font-size: 0.82rem;
  background: var(--bg-surface, #fff);
  color: var(--text-primary, #111827);
  width: 160px;
}
.bo-input:focus, .bo-select:focus { outline: none; border-color: var(--primary, #009639); box-shadow: 0 0 0 3px rgba(0,150,57,0.1); }

/* ─── Buttons ─── */
.bo-btn {
  padding: 7px 14px;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.bo-btn-primary {
  background: var(--primary, #009639);
  color: #fff;
  border-color: var(--primary, #009639);
}
.bo-btn-primary:hover { background: #007a2e; }
.bo-btn-danger { background: #fff; color: #dc2626; border-color: #fca5a5; }
.bo-btn-danger:hover { background: #fef2f2; }
.bo-btn-sm { padding: 4px 10px; font-size: 0.75rem; }

/* ─── Tables ─── */
.bo-table-wrap { overflow-x: auto; }
.bo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}
.bo-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border-subtle, #e5e7eb);
  white-space: nowrap;
}
.bo-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle, #f0f0f0);
  color: var(--text-primary, #111827);
  vertical-align: middle;
}
.bo-table tbody tr:hover { background: var(--bg-hover, #f9fafb); }
.bo-table tbody tr:last-child td { border-bottom: none; }

/* ─── Badges ─── */
.bo-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
}
.bo-badge-green { background: #05966922; color: #059669; }
.bo-badge-red { background: #ef444422; color: #ef4444; }
.bo-badge-amber { background: #d9770622; color: #d97706; }
.bo-badge-blue { background: #2563eb22; color: #2563eb; }
.bo-badge-gray { background: #6b728022; color: #6b7280; }
.bo-badge-purple { background: #7c3aed22; color: #7c3aed; }

/* ─── Utility ─── */
.bo-dim { color: var(--text-muted, #9ca3af); font-style: italic; font-size: 0.85rem; }
.bo-font-mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.82rem; }

/* ─── Relation bars (dashboard) ─── */
.bo-bar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.bo-bar-label {
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 120px;
  white-space: nowrap;
  color: var(--text-primary, #111827);
}
.bo-bar-track {
  flex: 1;
  background: var(--bg-hover, #f3f4f6);
  border-radius: 6px;
  height: 24px;
  overflow: hidden;
  position: relative;
}
.bo-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
}
.bo-bar-fill.purple { background: linear-gradient(90deg, #7c3aed, #a78bfa); }
.bo-bar-fill.blue { background: linear-gradient(90deg, #2563eb, #60a5fa); }
.bo-bar-fill.green { background: linear-gradient(90deg, #059669, #34d399); }
.bo-bar-fill.amber { background: linear-gradient(90deg, #d97706, #fbbf24); }
.bo-bar-fill.red { background: linear-gradient(90deg, #dc2626, #f87171); }

.bo-bar-count {
  font-size: 0.82rem;
  font-weight: 700;
  min-width: 80px;
  text-align: right;
  color: var(--text-primary, #111827);
}

/* ─── Coverage gauge ─── */
.bo-coverage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.bo-coverage-item {
  padding: 16px;
  background: var(--bg-hover, #f9fafb);
  border-radius: 10px;
}
.bo-coverage-label { font-size: 0.82rem; font-weight: 600; margin-bottom: 8px; }
.bo-coverage-bar { height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; margin-bottom: 4px; }
.bo-coverage-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.bo-coverage-pct { font-size: 0.75rem; color: var(--text-muted, #6b7280); }

/* ─── Config grid ─── */
.config-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.config-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-hover, #f9fafb);
  border-radius: 10px;
  gap: 12px;
}
.config-row-left {
  flex: 1;
}
.config-key { font-weight: 700; font-size: 0.88rem; font-family: 'SF Mono', monospace; }
.config-desc { font-size: 0.78rem; color: var(--text-muted, #6b7280); margin-top: 2px; }
.config-value-input {
  padding: 6px 12px;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 8px;
  font-size: 0.85rem;
  min-width: 180px;
  background: var(--bg-surface, #fff);
}
.config-save-btn {
  padding: 6px 14px;
  background: var(--primary, #009639);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
}
.config-save-btn:hover { background: #007a2e; }

/* ─── City list ─── */
.bo-city-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle, #f0f0f0);
}
.bo-city-item:last-child { border-bottom: none; }
.bo-city-name { font-weight: 600; font-size: 0.88rem; }
.bo-city-count { font-size: 0.82rem; color: var(--text-muted, #6b7280); font-weight: 700; }

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .bo-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .bo-tabs { gap: 2px; }
  .bo-tab { padding: 8px 10px; font-size: 0.78rem; }
  .bo-tab-icon { display: none; }
  .bo-card-header { flex-direction: column; gap: 8px; align-items: flex-start; }
  .bo-card-actions { flex-wrap: wrap; width: 100%; }
  .bo-header { flex-direction: column; gap: 10px; }
}

/* ─── Modal ─── */
.bo-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: bo-fadein 0.2s ease;
}
.bo-modal {
  background: var(--bg-surface, #fff);
  border-radius: 16px;
  width: 90vw;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 24px 48px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
}
.bo-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle, #e5e7eb);
  background: var(--bg-hover, #f9fafb);
}
.bo-modal-header h3 { margin: 0; font-size: 1.05rem; font-weight: 700; }
.bo-btn-icon {
  width: 32px; height: 32px;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 8px;
  background: var(--bg-surface, #fff);
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.bo-btn-icon:hover { background: #fef2f2; border-color: #fca5a5; color: #dc2626; }
.bo-modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* ─── Form fields in modal ─── */
.bo-form-section {
  margin-bottom: 20px;
}
.bo-form-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #6b7280);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border-subtle, #e5e7eb);
}
.bo-form-section-title.green  { border-bottom-color: #059669; color: #059669; }
.bo-form-section-title.blue   { border-bottom-color: #2563eb; color: #2563eb; }
.bo-form-section-title.purple { border-bottom-color: #7c3aed; color: #7c3aed; }
.bo-form-section-title.amber  { border-bottom-color: #d97706; color: #d97706; }
.bo-form-section-title.red    { border-bottom-color: #dc2626; color: #dc2626; }

.bo-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 600px) { .bo-form-grid { grid-template-columns: 1fr; } }

.bo-form-group {
  display: flex;
  flex-direction: column;
}
.bo-form-group.full { grid-column: 1 / -1; }
.bo-form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.bo-form-control {
  padding: 8px 12px;
  border: 1px solid var(--border-subtle, #e5e7eb);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--bg-surface, #fff);
  color: var(--text-primary, #111827);
  transition: border-color .15s, box-shadow .15s;
}
.bo-form-control:focus {
  outline: none;
  border-color: var(--primary, #009639);
  box-shadow: 0 0 0 3px rgba(0,150,57,0.1);
}
.bo-form-control:read-only {
  background: var(--bg-hover, #f3f4f6);
  color: var(--text-muted, #6b7280);
  cursor: not-allowed;
}
.bo-form-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle, #e5e7eb);
  margin-top: 8px;
}
.bo-btn-lg {
  padding: 10px 28px;
  font-size: 0.92rem;
  border-radius: 10px;
}

/* ─── Scoring Config ─── */
.scoring-section { margin-bottom: 24px; }

.scoring-weight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-hover, #f9fafb);
  margin-bottom: 8px;
  transition: background .15s;
}
.scoring-weight-row:hover { background: #f0fdf4; }
.scoring-weight-label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.scoring-weight-icon { font-size: 1.4rem; }
.scoring-weight-label strong { display: block; font-size: 0.88rem; }
.scoring-weight-label small { display: block; font-size: 0.75rem; line-height: 1.3; }
.scoring-weight-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.scoring-slider {
  width: 120px;
  accent-color: var(--primary, #009639);
  cursor: pointer;
}
.scoring-weight-value {
  font-weight: 700;
  font-size: 0.92rem;
  width: 40px;
  text-align: right;
  color: var(--primary, #009639);
}

.scoring-total-ok { color: #059669; font-weight: 700; }
.scoring-total-bad { color: #dc2626; font-weight: 700; }

.scoring-grades-grid { display: flex; flex-direction: column; gap: 8px; }
.scoring-grade-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--bg-hover, #f9fafb);
}
.scoring-grade-badge {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1rem;
  flex-shrink: 0;
}
.scoring-grade-label { flex: 1; min-width: 100px; }
.scoring-grade-min { width: 70px; text-align: center; }
.scoring-grade-color {
  width: 36px; height: 36px;
  border: none; border-radius: 8px;
  cursor: pointer; padding: 0;
  background: none;
}

.scoring-param-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-hover, #f9fafb);
  margin-bottom: 8px;
  gap: 16px;
}
.scoring-param-row strong { font-size: 0.85rem; }
.scoring-param-row .bo-form-control { width: 80px; text-align: center; }
