/* ════════════════════════════════════════════════════════
   Xëtu Dashboard — style.css
   Theme : Dark · Dakar · Temps réel
   ════════════════════════════════════════════════════════ */

:root {
  --bg:        #0A0F1E;
  --surface:   #111827;
  --surface2:  #1a2235;
  --border:    rgba(255,255,255,0.07);
  --orange:    #FF6B35;
  --green:     #00D67F;
  --yellow:    #FFD166;
  --red:       #FF4757;
  --text:      #F0F4FF;
  --muted:     #6B7A99;
  --font-head: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --radius:    16px;
  --shadow:    0 8px 32px rgba(0,0,0,0.4);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── HEADER ── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--orange);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 16px rgba(255,107,53,0.4);
}

.logo-text {
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 300;
  margin-top: -2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,214,127,0.1);
  border: 1px solid rgba(0,214,127,0.25);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-green 1.5s ease-in-out infinite;
}

@keyframes pulse-green {
  0%,100% { opacity:1; transform:scale(1); }
  50%      { opacity:0.4; transform:scale(0.7); }
}

.refresh-timer {
  font-size: 12px;
  color: var(--muted);
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── STATS BAR ── */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.stat-item {
  background: var(--surface);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.stat-icon { font-size: 20px; flex-shrink: 0; }

.stat-val {
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  transition: all 0.3s;
}

.stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* ── MAIN LAYOUT ── */
.main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── MAP ── */
#map {
  flex: 1;
  height: 100%;
  z-index: 1;
}

.leaflet-container {
  background: #0d1829 !important;
  font-family: var(--font-body) !important;
}

/* ── SIDEBAR ── */
.sidebar {
  width: 300px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  padding: 12px 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.tab-btn.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

.tab-btn:hover:not(.active) {
  color: var(--text);
}

/* ── TAB CONTENT ── */
.tab-content {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  gap: 8px;
  flex-direction: column;
}

.tab-content.active { display: flex; }

.tab-content::-webkit-scrollbar { width: 4px; }
.tab-content::-webkit-scrollbar-track { background: transparent; }
.tab-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── BUS CARD ── */
.bus-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  animation: slideIn 0.3s ease;
  flex-shrink: 0;
}

.bus-card:hover {
  border-color: rgba(255,107,53,0.3);
  transform: translateX(-2px);
}

.bus-card.selected {
  border-color: var(--orange);
  background: rgba(255,107,53,0.08);
}

@keyframes slideIn {
  from { opacity:0; transform:translateX(20px); }
  to   { opacity:1; transform:translateX(0); }
}

.bus-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.bus-badge {
  background: var(--orange);
  color: white;
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}

.bus-name {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bus-age {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  flex-shrink: 0;
}

.age-fresh  { background: rgba(0,214,127,0.15);  color: var(--green); }
.age-ok     { background: rgba(255,209,102,0.15); color: var(--yellow); }
.age-old    { background: rgba(255,71,87,0.15);   color: var(--red); }

.bus-position {
  font-size: 12px;
  color: var(--text);
  margin-bottom: 4px;
}

.bus-reporter {
  font-size: 11px;
  color: var(--muted);
}

/* ── LEADERBOARD ── */
.lb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  animation: slideIn 0.3s ease;
  flex-shrink: 0;
}

.lb-rank {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 800;
  width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.lb-rank.gold   { color: #FFD700; }
.lb-rank.silver { color: #C0C0C0; }
.lb-rank.bronze { color: #CD7F32; }
.lb-rank.other  { color: var(--muted); }

.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.lb-info { flex: 1; min-width: 0; }

.lb-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-zone {
  font-size: 11px;
  color: var(--muted);
  margin-top: 1px;
}

.lb-score { text-align: right; flex-shrink: 0; }

.lb-count {
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  color: var(--orange);
  line-height: 1;
}

.lb-unit { font-size: 10px; color: var(--muted); }

/* ── BADGES ── */
.badge-row {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.badge {
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 4px;
  font-weight: 500;
}

.badge-orange { background: rgba(255,107,53,0.15); color: var(--orange); }
.badge-green  { background: rgba(0,214,127,0.15);  color: var(--green); }
.badge-yellow { background: rgba(255,209,102,0.15); color: var(--yellow); }

/* ── BOTTOM CTA ── */
.bottom-cta {
  padding: 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.whatsapp-btn {
  width: 100%;
  padding: 13px;
  background: #25D366;
  border: none;
  border-radius: 12px;
  color: white;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(37,211,102,0.3);
}

.whatsapp-btn:hover {
  background: #20bd5a;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(37,211,102,0.4);
}

.whatsapp-btn:active {
  transform: translateY(0);
}

/* ── POPUP LEAFLET ── */
.leaflet-popup-content-wrapper {
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow) !important;
  color: var(--text) !important;
  font-family: var(--font-body) !important;
}

.leaflet-popup-tip { background: var(--surface2) !important; }
.leaflet-popup-close-button { color: var(--muted) !important; }

.popup-content { padding: 4px; }

.popup-ligne {
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 800;
  color: var(--orange);
  margin-bottom: 4px;
}

.popup-pos {
  font-size: 13px;
  color: var(--text);
  margin-bottom: 4px;
}

.popup-meta { font-size: 11px; color: var(--muted); }

.popup-wa {
  margin-top: 8px;
  padding: 7px 12px;
  background: #25D366;
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  font-family: var(--font-body);
  transition: background 0.2s;
}

.popup-wa:hover { background: #20bd5a; }

/* ── EMPTY STATE ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  color: var(--muted);
  text-align: center;
  gap: 8px;
}

.empty-icon { font-size: 32px; }
.empty-text { font-size: 13px; line-height: 1.5; }

/* ── MOBILE ── */
.mobile-panel { display: none; }

@media (max-width: 768px) {
  .sidebar { display: none; }

  .mobile-panel {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 20px 20px 0 0;
    padding: 16px;
    z-index: 500;
  }

  .stats-bar .stat-label { display: none; }
  .stat-val { font-size: 18px; }
  .stat-item { padding: 8px 12px; }
}
