/* =====================================================================
   assets/css/admin.css
   Soft UI theme — Orange & White, per project spec.
   ===================================================================== */

:root {
  --color-primary: #FF7A00;
  --color-secondary: #FFA94D;
  --color-bg: #FFF8F2;
  --color-card: #FFFFFF;
  --color-sidebar: #FFFFFF;
  --color-icon: #FF7A00;
  --radius: 18px;
  --shadow-soft: 0 10px 30px rgba(255, 122, 0, 0.08), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-soft-hover: 0 14px 36px rgba(255, 122, 0, 0.14), 0 4px 10px rgba(0,0,0,0.06);
  --text-main: #2B2118;
  --text-muted: #8A7A6D;
  --border-soft: #FBE6D4;
}

[data-theme="dark"] {
  --color-bg: #1B1712;
  --color-card: #26201A;
  --color-sidebar: #221C16;
  --text-main: #F5EDE4;
  --text-muted: #B8A99A;
  --border-soft: #3A2E22;
  --shadow-soft: 0 10px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--text-main);
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: inherit; text-decoration: none; }

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: var(--color-sidebar);
  border-right: 1px solid var(--border-soft);
  padding: 24px 16px;
  flex-shrink: 0;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 32px;
  color: var(--color-primary);
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
  transition: all 0.2s ease;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff;
  box-shadow: var(--shadow-soft);
}

.main-content {
  flex: 1;
  padding: 28px 32px;
  animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 24px;
  margin: 0;
}

.card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 20px;
  margin-bottom: 20px;
  border: 1px solid var(--border-soft);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.card:hover { box-shadow: var(--shadow-soft-hover); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  border: none;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: #fff;
  box-shadow: 0 6px 16px rgba(255,122,0,0.3);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(255,122,0,0.38); }

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}

.btn-outline:hover { background: rgba(255,122,0,0.08); }

.btn-danger {
  background: #fff0ec;
  color: #D64545;
  border: 1.5px solid #F5B7AC;
}

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 9px; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.badge-tomtom { background: #FFF1E0; color: #B45B00; }
.badge-manual { background: #E9F6EC; color: #1E8E3E; }
.badge-active { background: #E9F6EC; color: #1E8E3E; }
.badge-inactive { background: #F1F1F1; color: #888; }

.badge-level-smooth   { background:#E9F6EC; color:#1E8E3E; }
.badge-level-moderate { background:#FFF6D9; color:#B08900; }
.badge-level-slow     { background:#FFE9D6; color:#B45B00; }
.badge-level-heavy    { background:#FFE1DC; color:#C2361B; }
.badge-level-blocked  { background:#3a2e2e; color:#fff; }
.badge-level-unknown  { background:#F1F1F1; color:#888; }

.badge-info     { background:#E7F1FF; color:#1E5FB4; }
.badge-warning  { background:#FFF6D9; color:#B08900; }
.badge-critical { background:#FFE1DC; color:#C2361B; }
.badge-high     { background:#FFE9D6; color:#B45B00; }
.badge-moderate { background:#FFF6D9; color:#B08900; }
.badge-low      { background:#F1F1F1; color:#666; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data-table th {
  text-align: left;
  padding: 12px 14px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid var(--border-soft);
}

table.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

table.data-table tr:hover td { background: rgba(255,122,0,0.035); }

.editable-cell {
  border: 1.5px dashed transparent;
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 140px;
  cursor: text;
  transition: border-color 0.15s ease;
}

.editable-cell:hover,
.editable-cell:focus {
  border-color: var(--color-secondary);
  outline: none;
  background: #FFF8F2;
}

.editable-cell.dirty {
  border-color: var(--color-primary);
  background: #FFF3E5;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.input, select.input {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--border-soft);
  background: var(--color-card);
  color: var(--text-main);
  font-size: 14px;
}

.input:focus, select.input:focus { outline: none; border-color: var(--color-primary); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.form-group { margin-bottom: 4px; }

.map-draw {
  height: 380px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-soft);
}

.pagination {
  display: flex;
  gap: 6px;
  margin-top: 16px;
  justify-content: flex-end;
}

.pagination a, .pagination span {
  padding: 8px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-soft);
  font-size: 13px;
}

.pagination .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-main);
  color: #fff;
  padding: 14px 20px;
  border-radius: 12px;
  box-shadow: var(--shadow-soft);
  font-size: 14px;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s ease;
  z-index: 999;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #C2361B; }

.skeleton {
  background: linear-gradient(90deg, #f2e9e0 25%, #fbf3ea 37%, #f2e9e0 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 8px;
}

@keyframes skeleton-loading {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---------------------------------------------------------------------
   Dashboard: stat cards, animated counters, chart cards
   --------------------------------------------------------------------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 20px;
  border: 1px solid var(--border-soft);
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-soft-hover); }

.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  background: linear-gradient(135deg, rgba(255,122,0,0.12), rgba(255,169,77,0.18));
  color: var(--color-icon);
  margin-bottom: 12px;
}

.stat-card .stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-card .stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.stat-card.warn { border-color: #FFD9A8; }
.stat-card.warn .stat-value { color: #B45B00; }
.stat-card.critical { border-color: #F5B7AC; }
.stat-card.critical .stat-value { color: #C2361B; }
.stat-card.good .stat-value { color: #1E8E3E; }

.chart-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

@media (max-width: 960px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-card h3 {
  margin: 0 0 14px 0;
  font-size: 15px;
  font-weight: 700;
}

.chart-canvas-wrap { position: relative; height: 260px; }

.theme-toggle {
  border: 1.5px solid var(--border-soft);
  border-radius: 999px;
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  background: var(--color-card);
  font-size: 18px;
}

/* ---------------------------------------------------------------------
   Smart Map
   --------------------------------------------------------------------- */
.map-page-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.map-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

#smartMap {
  height: 640px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-soft);
}

.map-legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-muted);
  align-items: center;
}

.map-legend .dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.leaflet-popup-content { font-size: 13px; min-width: 220px; }
.leaflet-popup-content h4 { margin: 0 0 6px 0; font-size: 15px; color: var(--color-primary); }
.popup-row { display: flex; justify-content: space-between; padding: 2px 0; border-bottom: 1px dashed #eee; }
.popup-row:last-child { border-bottom: none; }
