/* ═══════════════════════════════════════════════════════════════
   SafaiMitra — Main Stylesheet
   Green theme matching the dashboard screenshots
═══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:        #1b8a4c;
  --green-dark:   #146b3a;
  --green-light:  #e8f5ee;
  --green-bg:     #f0faf4;
  --sidebar-w:    220px;
  --header-h:     64px;
  --white:        #ffffff;
  --gray-50:      #f8fafc;
  --gray-100:     #f1f5f9;
  --gray-200:     #e2e8f0;
  --gray-400:     #94a3b8;
  --gray-600:     #475569;
  --gray-800:     #1e293b;
  --red:          #c62828;
  --orange:       #e65100;
  --amber:        #f57f17;
  --blue:         #1565c0;
  --purple:       #6a1b9a;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.08);
  --shadow:       0 2px 8px rgba(0,0,0,.10);
  --radius:       10px;
  --radius-sm:    6px;
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
             font-size: 14px; color: var(--gray-800); background: var(--gray-50); }

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ── Layout Shell ─────────────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  z-index: 200;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--gray-200);
}
.sidebar-logo img { width: 40px; height: 40px; object-fit: contain; }
.sidebar-logo .logo-text { line-height: 1.2; }
.sidebar-logo .logo-text strong { font-size: 16px; font-weight: 700; color: var(--green); display: block; }
.sidebar-logo .logo-text small { font-size: 11px; color: var(--gray-600); }

/* user card in sidebar */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--green-bg);
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-user .u-name { font-weight: 600; font-size: 13px; }
.sidebar-user .u-role { font-size: 11px; color: var(--gray-600); }

/* nav */
.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px;
  font-size: 13.5px;
  color: var(--gray-600);
  border-left: 3px solid transparent;
  transition: all .15s;
  cursor: pointer;
}
.nav-item:hover { background: var(--green-light); color: var(--green); }
.nav-item.active { background: var(--green-light); color: var(--green);
                   border-left-color: var(--green); font-weight: 600; }
.nav-item .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-group-label { font-size: 10px; font-weight: 700; letter-spacing: .08em;
                   text-transform: uppercase; color: var(--gray-400);
                   padding: 12px 16px 4px; }
.nav-sub { padding-left: 40px; }
.nav-sub .nav-item { padding: 7px 16px; font-size: 13px; }

/* expand arrow */
.nav-arrow { margin-left: auto; font-size: 11px; transition: transform .2s; }
.nav-item.open .nav-arrow { transform: rotate(90deg); }

/* sidebar footer */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--gray-200);
  background: linear-gradient(135deg, #e8f5ee 0%, #d0ead9 100%);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--green-dark);
}
.sidebar-footer img { width: 80px; margin-bottom: 6px; }

/* ── Top Header ───────────────────────────────────────────── */
.main-header {
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.header-hamburger { font-size: 20px; color: var(--gray-600); cursor: pointer;
                    background: none; border: none; padding: 4px; }
.header-city {
  display: flex; align-items: center; gap: 10px;
}
.header-city img { width: 40px; height: 40px; object-fit: contain; }
.header-city .city-name { font-size: 12px; color: var(--gray-600); }
.header-city .city-full { font-size: 14px; font-weight: 700; }

.header-center { flex: 1; display: flex; justify-content: center; }
.header-center img { height: 40px; }

.header-right { display: flex; align-items: center; gap: 20px; margin-left: auto; }

.header-helpline { display: flex; align-items: center; gap: 8px; }
.header-helpline .icon { color: var(--green); font-size: 18px; }
.header-helpline .label { font-size: 11px; color: var(--gray-600); }
.header-helpline .number { font-size: 18px; font-weight: 800; color: var(--green); line-height: 1; }

.header-bell { position: relative; font-size: 20px; color: var(--gray-600); cursor: pointer; }
.header-bell .badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--red); color: #fff;
  border-radius: 50%; width: 16px; height: 16px;
  font-size: 10px; display: flex; align-items: center; justify-content: center;
  font-weight: 700;
}

.header-user { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.header-user .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.header-user .u-info { line-height: 1.2; }
.header-user .u-name { font-weight: 600; font-size: 13px; }
.header-user .u-role { font-size: 11px; color: var(--gray-600); }

/* ── Page Content ─────────────────────────────────────────── */
.main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.page-content { flex: 1; overflow-y: auto; padding: 20px; }

/* breadcrumb */
.breadcrumb { font-size: 12px; color: var(--gray-400); margin-bottom: 6px; }
.breadcrumb a { color: var(--gray-400); }
.breadcrumb span { color: var(--gray-600); font-weight: 500; }

/* page title */
.page-title { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
.page-subtitle { font-size: 13px; color: var(--gray-600); margin-bottom: 16px; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(180px,1fr)); margin-bottom: 20px; }

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--gray-200);
  transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow); }

.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.green  { background: #e8f5ee; color: var(--green); }
.stat-icon.blue   { background: #e3f2fd; color: var(--blue); }
.stat-icon.orange { background: #fff3e0; color: var(--orange); }
.stat-icon.red    { background: #fce4ec; color: var(--red); }
.stat-icon.purple { background: #f3e5f5; color: var(--purple); }
.stat-icon.amber  { background: #fffde7; color: var(--amber); }
.stat-icon.gray   { background: #f5f5f5; color: #757575; }

.stat-info .stat-label { font-size: 12px; color: var(--gray-600); }
.stat-info .stat-value { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-info .stat-sub   { font-size: 11px; color: var(--gray-400); }

/* coloured stat cards (fleet tracking style) */
.stat-card.bg-blue   { background: #2196f3; color: #fff; border-color: transparent; }
.stat-card.bg-red    { background: #f44336; color: #fff; border-color: transparent; }
.stat-card.bg-green  { background: #4caf50; color: #fff; border-color: transparent; }
.stat-card.bg-orange { background: #ff9800; color: #fff; border-color: transparent; }
.stat-card.bg-dark   { background: #607d8b; color: #fff; border-color: transparent; }
.stat-card.bg-purple { background: #9c27b0; color: #fff; border-color: transparent; }
.stat-card[class*=bg-] .stat-label,
.stat-card[class*=bg-] .stat-sub { color: rgba(255,255,255,.8); }
.stat-card[class*=bg-] .stat-icon { background: rgba(255,255,255,.2); color: #fff; }

/* ── Cards & Panels ───────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
}
.card-header .card-icon { font-size: 16px; color: var(--green); }
.card-header .card-title { flex: 1; }
.card-body { padding: 16px 18px; }

/* ── Tabs ─────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  font-size: 13px;
  color: var(--gray-600);
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  display: flex; align-items: center; gap: 6px;
}
.tab-btn:hover { background: #fff; color: var(--gray-800); }
.tab-btn.active { background: var(--green); color: #fff; box-shadow: var(--shadow-sm); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Filters / Toolbar ─────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: #fff;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  margin-bottom: 16px;
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label { font-size: 11px; font-weight: 600; color: var(--gray-600); text-transform: uppercase; letter-spacing: .04em; }

/* ── Form Controls ────────────────────────────────────────── */
.form-control {
  height: 36px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  font-size: 13px;
  color: var(--gray-800);
  background: #fff;
  outline: none;
  transition: border-color .15s;
}
.form-control:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(27,138,76,.12); }
select.form-control { padding-right: 28px; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2394a3b8'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
textarea.form-control { height: auto; padding: 8px 10px; resize: vertical; }

.form-row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; margin-bottom: 14px; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--gray-600); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--green);   color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger    { background: var(--red); color: #fff; }
.btn-outline   { background: none; border: 1.5px solid var(--green); color: var(--green); }
.btn-outline:hover { background: var(--green-light); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th {
  background: var(--gray-50);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--gray-600);
  border-bottom: 1.5px solid var(--gray-200);
  white-space: nowrap;
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--green-bg); }
.data-table .num { font-weight: 700; }

/* ── Status Badges ─────────────────────────────────────────── */
.status-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── Table Footer / Pagination ────────────────────────────── */
.table-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--gray-200);
  font-size: 12px;
  color: var(--gray-600);
  flex-wrap: wrap;
  gap: 8px;
}
.show-entries { display: flex; align-items: center; gap: 6px; }
.pagination { display: flex; gap: 4px; }
.pagination a {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200); font-size: 12px;
  color: var(--gray-600); background: #fff; transition: all .15s;
}
.pagination a:hover, .pagination a.active {
  background: var(--green); color: #fff; border-color: var(--green);
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff; border-radius: var(--radius);
  width: 96%; max-width: 640px; max-height: 90vh;
  display: flex; flex-direction: column;
  transform: translateY(20px); transition: transform .2s;
  box-shadow: 0 10px 40px rgba(0,0,0,.2);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 15px;
}
.modal-close { background: none; border: none; font-size: 20px; color: var(--gray-400); cursor: pointer; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-200); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Map ──────────────────────────────────────────────────── */
.map-container { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--gray-200); }
#mainMap, #trackingMap, #routeMap { width: 100%; height: 440px; }

/* ── Coverage progress ────────────────────────────────────── */
.progress-bar { background: var(--gray-200); border-radius: 4px; height: 6px; overflow: hidden; }
.progress-bar .fill { height: 100%; border-radius: 4px; background: var(--green); transition: width .4s; }

/* ── Toast ────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fff; border-radius: var(--radius-sm); padding: 12px 20px;
  box-shadow: 0 4px 16px rgba(0,0,0,.15); font-size: 13px; border-left: 4px solid var(--green);
  min-width: 240px; animation: slideIn .2s ease;
}
.toast.error   { border-color: var(--red); }
.toast.warning { border-color: var(--amber); }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Alert ────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px;
  margin-bottom: 14px; border-left: 4px solid;
}
.alert-success { background: #e8f5e9; color: #2e7d32; border-color: #2e7d32; }
.alert-error   { background: #fce4ec; color: #c62828; border-color: #c62828; }
.alert-info    { background: #e3f2fd; color: #1565c0; border-color: #1565c0; }
.alert-warning { background: #fff8e1; color: #f57f17; border-color: #f57f17; }

/* ── Donut (simple CSS ring) ──────────────────────────────── */
.donut-wrap { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.donut-value { position: absolute; font-size: 18px; font-weight: 800; }
.donut-label { position: absolute; top: calc(50% + 16px); font-size: 11px; color: var(--gray-600); }

/* ── KML upload zone ──────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  font-size: 13px;
  color: var(--gray-600);
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.upload-zone .up-icon { font-size: 36px; margin-bottom: 8px; }

/* ── Login page ───────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1b8a4c 0%, #0d5c30 100%);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 36px;
  width: 96%; max-width: 420px; box-shadow: 0 12px 48px rgba(0,0,0,.2);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo img { height: 60px; margin-bottom: 10px; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--green); }
.login-logo p  { font-size: 12px; color: var(--gray-600); }
.login-form .form-group { margin-bottom: 16px; }
.login-form label { font-size: 12px; font-weight: 600; color: var(--gray-600); display: block; margin-bottom: 5px; }
.login-form input { width: 100%; height: 42px; }
.login-form .btn-primary { width: 100%; height: 44px; font-size: 15px; margin-top: 8px; justify-content: center; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -240px; top: 0; height: 100%; transition: left .25s; z-index: 300; }
  .sidebar.open { left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .stat-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .page-content { padding: 12px; }
}

/* ── Utility ──────────────────────────────────────────────── */
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-orange { color: var(--orange); }
.text-blue   { color: var(--blue); }
.text-muted  { color: var(--gray-400); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.fw-bold     { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.w-100 { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 768px) { .grid-2,.grid-3 { grid-template-columns: 1fr; } }
