/* ODE Admin Dashboard — Desktop-first Design System */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --card: #ffffff;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #3b82f6;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; z-index: 100;
  transition: transform 0.3s;
}
.sidebar-header {
  padding: 20px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-logo { font-size: 28px; }
.sidebar-title { font-size: 18px; font-weight: 700; color: white; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  color: var(--sidebar-text); text-decoration: none; font-size: 14px;
  cursor: pointer; transition: all 0.2s; border-left: 3px solid transparent;
}
.nav-link:hover { background: rgba(255,255,255,0.05); color: white; }
.nav-link.active { background: rgba(59,130,246,0.15); color: white; border-left-color: var(--sidebar-active); }
.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { display: flex; align-items: center; gap: 10px; }
.user-avatar { font-size: 24px; }
.user-name { display: block; font-size: 13px; font-weight: 600; color: white; }
.user-role { display: block; font-size: 11px; color: var(--sidebar-text); }

/* Main Content */
.main-content { margin-left: 260px; flex: 1; min-height: 100vh; }

/* Topbar */
.topbar {
  display: flex; align-items: center; gap: 16px; padding: 16px 24px;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar h1 { flex: 1; font-size: 20px; }
.menu-toggle { display: none; background: none; border: none; font-size: 24px; cursor: pointer; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.data-freshness { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot.live { background: var(--success); animation: pulse 2s infinite; }
.status-dot.green { background: var(--success); }
.status-dot.red { background: var(--danger); }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; }

/* Views */
.view { display: none; padding: 24px; }
.view.active { display: block; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); border-radius: var(--radius); padding: 20px;
  display: flex; align-items: center; gap: 16px; box-shadow: var(--shadow);
}
.stat-icon { font-size: 28px; width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.yellow { background: #fef3c7; }
.stat-icon.red { background: #fee2e2; }
.stat-value { display: block; font-size: 24px; font-weight: 700; }
.stat-label { display: block; font-size: 13px; color: var(--text-muted); }
.stat-change { font-size: 11px; font-weight: 500; margin-left: auto; }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }
.stat-change.neutral { color: var(--text-muted); }

/* Content Grid */
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card.full-width { margin-bottom: 24px; }
.card-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h3 { font-size: 16px; }
.card-actions { display: flex; gap: 8px; align-items: center; }

/* Map Placeholder */
.map-placeholder, .map-large {
  height: 250px; background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
  position: relative; display: flex; align-items: flex-end; justify-content: center; padding: 16px;
}
.map-large { height: 400px; }
.map-placeholder p { color: var(--text-muted); font-size: 13px; }
.map-dots { position: absolute; inset: 0; }
.map-dot {
  position: absolute; font-size: 16px; background: white; border-radius: 50%;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.map-dot.alert { background: #fee2e2; }
.map-legend { display: flex; gap: 16px; font-size: 12px; color: var(--text-muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }
.legend-dot.green { background: var(--success); }
.legend-dot.yellow { background: var(--warning); }
.legend-dot.red { background: var(--danger); }

/* Chart Bars */
.chart-bars { padding: 16px 20px; }
.chart-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.chart-label { width: 120px; font-size: 13px; color: var(--text-muted); text-align: right; }
.chart-bar-container { flex: 1; height: 28px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.chart-bar { height: 100%; border-radius: 6px; display: flex; align-items: center; padding-left: 10px; font-size: 12px; font-weight: 600; color: white; min-width: 30px; }
.chart-bar.green { background: var(--success); }
.chart-bar.blue { background: var(--primary); }
.chart-bar.yellow { background: var(--warning); }
.chart-bar.gray { background: #94a3b8; }
.chart-bar.red { background: var(--danger); }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.data-table td { padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border); }
.data-table tr:hover { background: #f8fafc; }

/* Badges */
.badge { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-live { background: #dcfce7; color: #065f46; animation: pulse-bg 2s infinite; }

/* Buttons */
.btn-sm { padding: 6px 12px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: white; cursor: pointer; }
.btn-sm.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary { padding: 10px 20px; background: var(--primary); color: white; border: none; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }

/* Filters */
.filter-select, .search-input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: white;
}
.search-input { width: 200px; }

/* Timeline */
.timeline { padding: 20px; }
.timeline-item { display: flex; gap: 16px; padding: 16px 0; position: relative; }
.timeline-item:not(:last-child)::after {
  content: ''; position: absolute; left: 15px; top: 48px; bottom: -16px;
  width: 2px; background: var(--border);
}
.timeline-item.done:not(:last-child)::after { background: var(--success); }
.timeline-dot {
  width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.timeline-item.done .timeline-dot { background: var(--success); color: white; }
.timeline-item.current .timeline-dot { background: var(--primary); color: white; animation: pulse 2s infinite; }
.timeline-item.locked .timeline-dot { background: #e2e8f0; color: #94a3b8; }
.timeline-content { flex: 1; }
.timeline-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.timeline-time { font-size: 12px; color: var(--text-muted); }
.timeline-evidence { display: flex; gap: 6px; margin-top: 8px; }
.thumb { width: 40px; height: 40px; background: #f1f5f9; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.timeline-tracking, .timeline-geofence { font-size: 12px; color: var(--text-muted); margin-top: 6px; padding: 6px 10px; background: #f8fafc; border-radius: 6px; }

/* Evidence Grid */
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; padding: 20px; }
.evidence-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.evidence-image { height: 140px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; font-size: 32px; }
.evidence-meta { padding: 12px; display: flex; flex-direction: column; gap: 4px; }
.evidence-checkpoint { font-size: 13px; font-weight: 500; }
.evidence-time, .evidence-gps { font-size: 11px; color: var(--text-muted); }

/* Communication Trace */
.commtrace-notice { padding: 16px 20px; background: #fef3c7; border-bottom: 1px solid #fde68a; font-size: 13px; color: #92400e; }
.commtrace-form { padding: 20px; display: flex; flex-direction: column; gap: 12px; max-width: 400px; }
.form-row { display: flex; flex-direction: column; gap: 4px; }
.form-row label { font-size: 13px; font-weight: 500; }
.commtrace-summary { padding: 20px; }
.commtrace-summary h4 { margin-bottom: 12px; font-size: 14px; }
.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.summary-item { background: #f8fafc; padding: 12px; border-radius: 8px; }
.summary-label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.summary-value { font-size: 14px; font-weight: 500; }

/* Animations */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes pulse-bg {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr; }
}
