/* GRAOULIB — Intelligence Réseau — Main styles */

:root {
  --bg: #0a0c0f;
  --bg2: #0f1318;
  --bg3: #151b22;
  --border: rgba(255,255,255,0.07);
  --border-strong: rgba(255,255,255,0.14);
  --text: #e8eaed;
  --text2: #8b9099;
  --text3: #4a5260;
  --accent: #00ff87;
  --accent2: #0ff;
  --warn: #ff6b35;
  --danger: #ff3b5c;
  --purple: #a78bfa;
  --gold: #fbbf24;
  --mono: 'Space Mono', monospace;
  --sans: 'DM Sans', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.logo {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

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

.status-pill {
  font-family: var(--mono);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  color: var(--text2);
}

.status-pill.live {
  border-color: var(--accent);
  color: var(--accent);
}

#last-refresh {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
}

/* Bearer token (Fifteen API) */
.header-token-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-token-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--text3);
  text-transform: uppercase;
}

.header-token-input {
  width: 120px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  outline: none;
  transition: border-color 0.2s;
}

.header-token-input::placeholder {
  color: var(--text3);
}

.header-token-input:focus {
  border-color: var(--border-strong);
}

.header-token-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  min-width: 1ch;
}

.header-token-wrap.token-set .header-token-status {
  color: var(--accent);
}

.btn-refresh {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text2);
  font-family: var(--mono);
  font-size: 11px;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.05em;
}

.btn-refresh:hover { border-color: var(--accent); color: var(--accent); }
.btn-refresh.loading { opacity: 0.5; pointer-events: none; }

/* ── LAYOUT ── */
.main {
  display: grid;
  grid-template-columns: 340px 1fr 300px;
  flex: 1;
  overflow: hidden;
}

/* ── PANNEAU GAUCHE ── */
.panel-left {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg2);
}

.panel-section {
  border-bottom: 1px solid var(--border);
}

.panel-section-title {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--text3);
  text-transform: uppercase;
  padding: 10px 16px 6px;
}

/* ── KPI GRID ── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--border);
  margin: 0;
}

.kpi {
  background: var(--bg2);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi-val {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.kpi-val.green { color: var(--accent); }
.kpi-val.orange { color: var(--warn); }
.kpi-val.red { color: var(--danger); }
.kpi-val.purple { color: var(--purple); }

.kpi-label {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 3px;
}

/* ── USER SECTION ── */
.user-section {
  margin: 0 0 8px 0;
}

.user-section-card {
  margin: 0 10px 0 10px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.user-section-title {
  font-weight: 600;
  font-size: 11px;
  color: var(--text);
  margin-bottom: 8px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.user-section-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  padding: 2px 0;
  gap: 8px;
}

.user-section-key {
  color: var(--text3);
  font-family: var(--mono);
  font-size: 10px;
  flex-shrink: 0;
}

.user-section-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
  text-align: right;
  word-break: break-word;
}

/* ── STATION LIST ── */
.station-list {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg3) transparent;
}

.station-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.station-item:hover { background: var(--bg3); }
.station-item.selected { background: rgba(0,255,135,0.06); border-left: 2px solid var(--accent); }

.station-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.station-name {
  font-weight: 500;
  font-size: 12px;
  color: var(--text);
}

.station-bikes {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--accent);
}

.station-meta {
  display: flex;
  gap: 8px;
  font-size: 10px;
  color: var(--text3);
}

.badge {
  font-family: var(--mono);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}

.badge-ok { background: rgba(0,255,135,0.1); color: var(--accent); border: 1px solid rgba(0,255,135,0.2); }
.badge-warn { background: rgba(255,107,53,0.1); color: var(--warn); border: 1px solid rgba(255,107,53,0.2); }
.badge-danger { background: rgba(255,59,92,0.12); color: var(--danger); border: 1px solid rgba(255,59,92,0.2); }
.badge-purple { background: rgba(167,139,250,0.1); color: var(--purple); border: 1px solid rgba(167,139,250,0.2); }
.badge-cyan { background: rgba(0,255,255,0.08); color: var(--accent2); border: 1px solid rgba(0,255,255,0.2); }

/* ── CARTE ── */
#map {
  width: 100%;
  height: 100%;
  background: var(--bg);
}

/* ── PANNEAU DROIT ── */
.panel-right {
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg2);
}

.panel-right-inner {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--bg3) transparent;
}

/* ── STATION SUMMARY (full Graoulib data) ── */
.station-summary-card {
  margin: 8px 10px;
  padding: 10px 12px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.station-summary-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 8px;
  font-family: var(--mono);
}

.station-summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
}

.station-summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.station-summary-key {
  color: var(--text3);
  font-family: var(--mono);
  font-size: 10px;
}

.station-summary-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text);
}

/* ── VEHICLE CARD ── */
.vehicle-card {
  margin: 8px 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.vehicle-card:hover { border-color: var(--border-strong); }

.vehicle-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

.vehicle-id {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--accent2);
}

.vehicle-body {
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.vehicle-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
}

.vehicle-row-key {
  color: var(--text3);
  font-family: var(--mono);
  font-size: 10px;
}

.vehicle-row-val {
  color: var(--text);
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Battery bar */
.battery-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.battery-bar {
  width: 60px;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
}

.battery-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s;
}

/* ── THEFT ALERT ── */
.theft-row {
  background: rgba(255,59,92,0.06);
  border: 1px solid rgba(255,59,92,0.15);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 10px;
  color: var(--danger);
  font-family: var(--mono);
  margin-top: 2px;
}

/* ── GEOFENCING ── */
.geo-item {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.geo-type-0 { border-left: 3px solid var(--accent); }
.geo-type-1 { border-left: 3px solid var(--warn); }
.geo-type-2 { border-left: 3px solid var(--danger); }

/* ── PRICING ── */
.pricing-table {
  padding: 8px 16px;
}

.pricing-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
}

.pricing-row:last-child { border-bottom: none; }

.price-key { color: var(--text2); }
.price-val { font-family: var(--mono); color: var(--gold); }

/* ── TABS ── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 10px;
  gap: 2px;
}

.tab {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  text-transform: uppercase;
}

.tab:hover { color: var(--text2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── EMPTY STATE ── */
.empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text3);
  font-size: 11px;
  font-family: var(--mono);
}

/* ── LOADER ── */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 20px;
  transition: opacity 0.4s;
}

.loader-overlay.hidden { opacity: 0; pointer-events: none; }

.loader-logo {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.15em;
}

.loader-bar {
  width: 200px;
  height: 2px;
  background: var(--bg3);
  border-radius: 1px;
  overflow: hidden;
}

.loader-progress {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  width: 0%;
  transition: width 0.3s;
  box-shadow: 0 0 8px var(--accent);
}

.loader-status {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text3);
  letter-spacing: 0.05em;
}

/* ── LEAFLET OVERRIDES ── */
.leaflet-container { background: #0a0c0f; }
.leaflet-popup-content-wrapper {
  background: var(--bg3);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  color: var(--text);
  box-shadow: 0 4px 24px rgba(0,0,0,0.6);
}
.leaflet-popup-tip { background: var(--bg3); }
.leaflet-popup-content { font-family: var(--sans); font-size: 12px; margin: 10px 14px; }
.leaflet-control-zoom a {
  background: var(--bg3) !important;
  border-color: var(--border-strong) !important;
  color: var(--text2) !important;
}

.error-msg {
  padding: 8px 16px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--danger);
  background: rgba(255,59,92,0.05);
  border: 1px solid rgba(255,59,92,0.15);
  margin: 8px;
  border-radius: 4px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 4px;
}

.search-box {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 6px 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  outline: none;
  margin: 6px 10px;
  width: calc(100% - 20px);
  transition: border-color 0.2s;
}
.search-box::placeholder { color: var(--text3); }
.search-box:focus { border-color: var(--border-strong); }
