/* ============================================
   MOBILE MISSION VIEW STYLES
   ============================================ */

.mobile-mission-view {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 56px - 64px); /* Header and bottom nav */
  background: #111827;
  overflow-y: auto;
  position: relative;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

/* ============================================
   MAP SECTION - matches teleop video size
   ============================================ */

.mission-map-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  flex-shrink: 0;
}

.mission-map-container .leaflet-container {
  width: 100%;
  height: 100%;
  background: #1a1a2e;
}

/* Map overlay - top left badges */
.map-overlay-top {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  gap: 8px;
  z-index: 1000;
}

.map-badge {
  padding: 5px 10px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.map-badge.mode-standby {
  color: #fcd34d;
  border-left: 3px solid #f59e0b;
}

.map-badge.mode-auto {
  color: #6ee7b7;
  border-left: 3px solid #10b981;
}

.map-badge.mode-teleop {
  color: #93c5fd;
  border-left: 3px solid #3b82f6;
}

.map-badge.mode-disabled {
  color: #fca5a5;
  border-left: 3px solid #ef4444;
}

.map-badge.connected {
  color: #6ee7b7;
}

.map-badge.disconnected {
  color: #fca5a5;
}

/* Map overlay - mission status (center) */
.map-overlay-status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
}

.mission-status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  border-radius: 20px;
  border: 2px solid;
  font-size: 12px;
  font-weight: 600;
  color: white;
}

.mission-status-badge .status-icon {
  font-size: 10px;
}

.mission-status-badge .wp-count {
  margin-left: 6px;
  padding-left: 6px;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 11px;
  opacity: 0.8;
}

/* Map overlay - GPS (bottom right) */
.map-overlay-gps {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 1000;
}

.gps-badge {
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.75);
  border-radius: 4px;
  font-size: 11px;
  color: white;
}

.gps-badge.good { color: #6ee7b7; }
.gps-badge.ok { color: #fcd34d; }
.gps-badge.poor { color: #fca5a5; }

/* ============================================
   TELEMETRY STRIP
   ============================================ */

.mission-telemetry-strip {
  display: flex;
  justify-content: space-around;
  align-items: center;
  background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.mission-telemetry-strip .telem-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 45px;
}

.mission-telemetry-strip .telem-value {
  font-size: 15px;
  font-weight: 700;
  color: white;
  font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
  line-height: 1;
}

.mission-telemetry-strip .telem-value.good {
  color: #6ee7b7;
}

.mission-telemetry-strip .telem-value.warn {
  color: #fcd34d;
}

.mission-telemetry-strip .telem-label {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ============================================
   CONTROLS SECTION (flows below map)
   ============================================ */

.mission-controls-scroll {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ============================================
   CONTROL CARDS
   ============================================ */

.control-card {
  background: #1f2937;
  border-radius: 12px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.control-card.compact {
  padding: 12px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.mode-indicator {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.mode-indicator.mode-standby {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.mode-indicator.mode-auto {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.mode-indicator.mode-teleop {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.mode-indicator.mode-disabled {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

/* ============================================
   MODE BUTTONS
   ============================================ */

.mode-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.mode-buttons .mode-btn {
  flex: 1;
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-buttons .mode-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mode-buttons .mode-btn.active {
  color: white;
  font-weight: 600;
}

.mode-buttons .mode-btn.active.standby {
  background: rgba(245, 158, 11, 0.25);
  border-color: #f59e0b;
}

.mode-buttons .mode-btn.active.teleop {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
}

.mode-buttons .mode-btn.active.auto {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
}

/* Mode status message */
.mode-status-msg {
  font-size: 11px;
  text-align: center;
  padding: 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
}

.mode-status-msg .status-disabled { color: #fca5a5; }
.mode-status-msg .status-standby { color: #fcd34d; }
.mode-status-msg .status-auto { color: #6ee7b7; }
.mode-status-msg .status-active { color: #93c5fd; }

/* ============================================
   ACTION BUTTONS
   ============================================ */

.action-btn {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.action-btn:active {
  transform: scale(0.98);
}

.action-btn.primary {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white;
}

.action-btn.start {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.action-btn.pause {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
}

.action-btn.resume {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
}

.action-btn.abort {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.action-btn.disabled {
  background: #374151;
  color: #6b7280;
  cursor: not-allowed;
}

.action-btn.full-width {
  margin-bottom: 12px;
}

.mission-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ============================================
   MISSION LOADED INFO
   ============================================ */

.mission-loaded-info {
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
}

.loaded-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.loaded-icon {
  color: #a78bfa;
  font-size: 14px;
}

.loaded-label {
  font-size: 12px;
  font-weight: 600;
  color: #a78bfa;
}

.loaded-name {
  font-size: 15px;
  font-weight: 600;
  color: white;
  margin-bottom: 6px;
}

.loaded-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.loaded-details span {
  background: rgba(0, 0, 0, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
}

.clear-btn {
  margin-top: 10px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  cursor: pointer;
}

/* No mission state */
.no-mission-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
}

.no-mission-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.no-mission-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  margin-top: 4px;
}

/* Route info */
.route-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 8px 10px;
  background: rgba(16, 185, 129, 0.1);
  border-radius: 6px;
  font-size: 12px;
  color: #6ee7b7;
}

.route-info.loading {
  background: rgba(59, 130, 246, 0.1);
  color: #93c5fd;
}

.route-icon {
  font-size: 14px;
}

/* ============================================
   MISSION PROGRESS
   ============================================ */

.mission-progress-section {
  background: rgba(59, 130, 246, 0.1);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

.progress-percent {
  font-size: 16px;
  font-weight: 700;
  color: #93c5fd;
  font-family: 'SF Mono', monospace;
}

.progress-bar-container {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

/* Rover mission info */
.rover-mission-info {
  background: rgba(55, 65, 81, 0.5);
  border-radius: 8px;
  padding: 10px;
  margin-top: 12px;
}

.rover-mission-header {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.rover-mission-name {
  font-size: 13px;
  font-weight: 600;
  color: white;
  margin-bottom: 4px;
}

.rover-mission-details {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

/* Progress log */
.progress-log {
  margin-top: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 8px;
  overflow: hidden;
}

.log-header {
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.2);
}

.log-content {
  padding: 8px 10px;
  max-height: 80px;
  overflow-y: auto;
}

.log-line {
  font-size: 10px;
  font-family: 'SF Mono', monospace;
  color: rgba(255, 255, 255, 0.6);
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* ============================================
   NAVIGATION GRID
   ============================================ */

.nav-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.nav-item {
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 8px;
  text-align: center;
}

.nav-label {
  display: block;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 4px;
}

.nav-value {
  font-size: 15px;
  font-weight: 600;
  color: white;
  font-family: 'SF Mono', monospace;
}

.nav-value.warn {
  color: #fcd34d;
}

/* ============================================
   EMERGENCY STOP
   ============================================ */

.emergency-stop-btn {
  display: block;
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #991b1b, #7f1d1d);
  border: 2px solid #ef4444;
  border-radius: 12px;
  color: white;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
  transition: all 0.2s;
}

.emergency-stop-btn:active {
  transform: scale(0.98);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
}

/* ============================================
   SLIDE-OUT PANEL
   ============================================ */

.panel-toggle {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 56px;
  background: rgba(59, 130, 246, 0.9);
  border: none;
  border-radius: 8px 0 0 8px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1100;
  transition: right 0.3s ease;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
}

.panel-toggle.open {
  right: 260px;
}

.controls-panel {
  position: fixed;
  top: 0;
  right: -260px;
  width: 260px;
  height: 100%;
  background: #1a1a2e;
  z-index: 1050;
  transition: right 0.3s ease;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  padding-bottom: 100px;
}

.controls-panel.open {
  right: 0;
}

.panel-content {
  padding: 16px;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
  color: white;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-section {
  margin-bottom: 18px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.8);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.status-dot.on {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-dot.off {
  background: #4b5563;
}

.status-text {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
}

.value-display {
  font-size: 12px;
  color: #93c5fd;
  font-family: 'SF Mono', monospace;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-btn {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: white;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.panel-btn:active {
  transform: scale(0.97);
}

.panel-btn.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
}

.panel-btn.start {
  background: rgba(16, 185, 129, 0.2);
  border-color: #10b981;
  color: #6ee7b7;
}

.panel-btn.stop {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #fca5a5;
}

.panel-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.panel-btn.full {
  width: 100%;
  margin-bottom: 8px;
}

.panel-btn.danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #fca5a5;
}

/* Throttle slider */
.throttle-slider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  margin-bottom: 10px;
  -webkit-appearance: none;
}

.throttle-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #3b82f6;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.preset-row {
  display: flex;
  gap: 6px;
}

.preset-btn {
  flex: 1;
  padding: 6px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.preset-btn:active {
  background: rgba(59, 130, 246, 0.3);
}

/* Speed controls */
.speed-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 10px;
}

.speed-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid #3b82f6;
  background: transparent;
  color: #3b82f6;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.speed-btn:active {
  background: rgba(59, 130, 246, 0.3);
}

.speed-value {
  font-size: 22px;
  font-weight: 700;
  color: white;
  font-family: 'SF Mono', monospace;
  min-width: 50px;
  text-align: center;
}

/* ============================================
   MISSION MODAL
   ============================================ */

.mission-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.mission-modal {
  width: 100%;
  max-width: 340px;
  max-height: 75vh;
  background: #1f2937;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: white;
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  font-size: 16px;
  cursor: pointer;
}

.modal-loading,
.modal-empty {
  padding: 40px 20px;
  text-align: center;
  color: rgba(255, 255, 255, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.loading-spinner {
  font-size: 24px;
  animation: spin 1s linear infinite;
}

.empty-icon {
  font-size: 32px;
  opacity: 0.5;
}

.empty-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
}

.mission-list {
  max-height: 55vh;
  overflow-y: auto;
}

.mission-list-item {
  width: 100%;
  padding: 14px 16px;
  border: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s;
}

.mission-list-item:active {
  background: rgba(124, 58, 237, 0.2);
}

.mission-item-name {
  font-size: 14px;
  font-weight: 600;
  color: white;
  margin-bottom: 4px;
}

.mission-item-details {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
}

/* ============================================
   DRAGGABLE CAMERAS
   ============================================ */

.draggable-camera {
  position: fixed;
  width: 220px;
  height: 165px;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  z-index: 1200;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
  cursor: move;
  touch-action: none;
}

.draggable-camera.front-camera {
  border: 2px solid #3b82f6;
}

.draggable-camera.feed-view {
  border: 2px solid #f59e0b;
}

.camera-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
  background: rgba(59, 130, 246, 0.75);
  z-index: 10;
  pointer-events: none;
  height: 18px;
}

.camera-header.feed {
  background: rgba(245, 158, 11, 0.75);
}

.camera-header span {
  font-size: 8px;
  font-weight: 600;
  color: white;
  letter-spacing: 0.5px;
}

.camera-header button {
  width: 18px;
  height: 18px;
  border-radius: 0;
  border: none;
  background: transparent;
  color: white;
  font-size: 12px;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}

.camera-header button:active {
  opacity: 1;
}

.draggable-camera remote-teleop-device,
.draggable-camera webrtc-video-device {
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ============================================
   SAFE AREA SUPPORT
   ============================================ */

@supports (padding: env(safe-area-inset-right)) {
  .controls-panel {
    padding-right: calc(16px + env(safe-area-inset-right));
  }
  
  .panel-toggle {
    right: env(safe-area-inset-right);
  }
  
  .panel-toggle.open {
    right: calc(260px + env(safe-area-inset-right));
  }
}