@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Readi Signature Light Palette */
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-muted: #f1f5f9;
  --border: #e2e8f0;
  --border-active: #7c3aed;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --accent-purple: #7c3aed;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --glow-purple: rgba(124, 58, 237, 0.1);
  --glow-green: rgba(16, 185, 129, 0.1);
  /* Mapping for legacy logic */
  --accent-blue: #7c3aed;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* SCROLLBAR */
::-webkit-scrollbar {
  width: 5px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

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

.leaflet-container {
  background: #f1f5f9;
}

.leaflet-control-zoom a {
  background: var(--bg-elevated) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border) !important;
}

.leaflet-control-zoom a:hover {
  background: var(--bg-muted) !important;
}

/* === PREMIUM DRONE MARKERS === */
.drone-marker-wrap {
  position: relative;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  --drone-color: #58a6ff;
  /* Fallback */
}

.drone-marker-icon-premium {
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 12px;
  border: 2px solid var(--drone-color);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--drone-color), inset 0 0 10px rgba(0, 0, 0, 0.1);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: 2;
  overflow: hidden;
}

.drone-marker-icon-premium img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.drone-marker-icon-premium.flying {
  border-radius: 50%;
  animation: drone-float 2s infinite ease-in-out;
}

.drone-marker-icon-premium.docked {
  border-radius: 8px;
  filter: grayscale(0.2);
}

@keyframes drone-float {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-5px) scale(1.05);
  }
}

.drone-marker-pulse {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  background: var(--drone-color);
  border-radius: 50%;
  opacity: 0.3;
  animation: marker-pulse 2s infinite;
}

@keyframes marker-pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.4;
  }

  100% {
    transform: translate(-50%, -50%) scale(2.5);
    opacity: 0;
  }
}

.premium-tooltip {
  background: rgba(10, 15, 24, 0.95) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 1px !important;
  padding: 4px 10px !important;
  border-radius: 4px !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

.premium-tooltip:before {
  border-top-color: rgba(10, 15, 24, 0.95) !important;
}

/* Map Path Glow */
.leaflet-interactive {
  filter: drop-shadow(0 0 5px currentColor);
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* === GLASS PANELS === */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.panel-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-elevated);
}

.panel-header-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  padding: 16px 20px;
}

/* === STAT CARDS === */
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* === STATUS BADGE === */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-badge.online {
  background: var(--glow-green);
  color: var(--accent-green);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.status-badge.offline {
  background: rgba(248, 81, 73, 0.1);
  color: var(--accent-red);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.status-badge.charging {
  background: rgba(210, 153, 34, 0.1);
  color: var(--accent-orange);
  border: 1px solid rgba(210, 153, 34, 0.3);
}

.status-badge .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-badge.online .dot {
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

/* === NAV === */
#navbar {
  height: 58px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

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

.nav-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #1f6feb, #58a6ff);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(88, 166, 255, 0.3);
}

.nav-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.nav-title span {
  color: var(--accent-blue);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-left: 8px;
  opacity: 0.8;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
}

.nav-btn:hover {
  background: var(--bg-muted);
  color: var(--text-primary);
  border-color: var(--border-active);
}

.nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(135deg, #1f6feb, #58a6ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* === SIDEBAR === */
#sidebar {
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 4px;
}

/* === DRONE CARD === */
.drone-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 20px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.drone-card:hover {
  border-color: var(--accent-purple);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.08);
}

.drone-card.selected {
  border-color: var(--accent-purple);
  background: #fdfaff;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.12);
}

.drone-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.drone-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.drone-card-model {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.drone-card-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.drone-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.drone-stat-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.drone-stat-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

/* === MAP OVERLAY CARD === */
#map-overlay {
  position: absolute;
  bottom: 24px;
  right: 24px;
  z-index: 400;
  background: rgba(13, 17, 23, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  width: 260px;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  transform: translateY(12px);
}

#map-overlay.visible {
  opacity: 1;
  transform: translateY(0);
}

.overlay-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.overlay-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.overlay-item-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.overlay-item-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

/* === BATTERY BAR === */
.battery-bar-wrap {
  width: 100%;
  height: 3px;
  background: var(--bg-muted);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.battery-bar {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent-green), #56d364);
  transition: width 0.5s ease;
}

/* === TERMINAL === */
#terminal {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  line-height: 1.8;
}

.log-entry {
  display: flex;
  gap: 8px;
  animation: fadeIn 0.2s ease;
}

.log-time {
  color: var(--text-muted);
  flex-shrink: 0;
}

.log-msg {
  color: var(--text-secondary);
}

.log-msg.success {
  color: var(--accent-green);
}

.log-msg.error {
  color: var(--accent-red);
}

.log-msg.warn {
  color: var(--accent-orange);
}

.log-msg.info {
  color: var(--accent-blue);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === CONNECTION STATUS === */
#conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  transition: all 0.3s;
}

#conn-status.connected {
  color: var(--accent-green);
  border-color: rgba(63, 185, 80, 0.3);
  background: var(--glow-green);
}

#conn-status .conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-red);
  transition: background 0.3s;
}

#conn-status.connected .conn-dot {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: blink 1.5s infinite;
}

/* === MOCK TOGGLE BUTTON === */
#mock-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

#mock-btn:hover {
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

#mock-btn.active {
  background: rgba(210, 153, 34, 0.1);
  border-color: rgba(210, 153, 34, 0.4);
  color: var(--accent-orange);
}

/* === LAYOUT === */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

#content {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 16px 20px 16px;
  margin-top: 58px;
  overflow: hidden;
}

#map-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
  min-width: 0;
}

#map-wrap {
  flex: 1;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}

#log-panel {
  height: 160px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#log-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 20px;
}

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

.empty-state svg {
  opacity: 0.3;
}

.empty-state p {
  font-size: 12px;
}

/* === TOOLTIP OVERRIDE === */
.leaflet-tooltip {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
  padding: 4px 8px !important;
}

.leaflet-tooltip::before {
  border-top-color: var(--border) !important;
}