/* HFSS Live Tracking Page Styles */

/* ============================================
   Base Layout & Full Viewport Setup
   ============================================ */

/* Ensure content body takes full viewport */
body {
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* Hide navbar for this page */
.navbar {
  display: none !important;
}

.content-body {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 !important;
  margin: 0 !important;
}

/* Ensure no container padding */
.container,
.container-fluid {
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
}

/* Override any base template styles for this page */
main, .main-content, .content-wrapper {
  padding: 0 !important;
  margin: 0 !important;
}

/* ============================================
   Map Container
   ============================================ */

/* Map container - Full viewport */
#mapid {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  margin: 0;
  border-radius: 0;
}

/* Adjust Leaflet controls to avoid header */
.leaflet-top {
  top: 70px !important;
}

.leaflet-top.leaflet-left {
  top: 70px !important;
}

.leaflet-top.leaflet-right {
  top: 70px !important;
}

/* ============================================
   Dashboard Header
   ============================================ */

.dashboard-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  z-index: 1001;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  border-bottom: none;
  height: 56px;
}

.nav-buttons {
  display: flex;
  gap: 5px;
}

.header-actions {
  display: flex;
  gap: 5px;
  align-items: center;
}

.btn-text {
  margin-left: 4px;
}

.header-title h1 {
  font-size: 1.1rem;
  margin: 0;
  line-height: 1.3;
  font-weight: 500;
  color: #2c3e50;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-selection {
  display: flex;
  align-items: center;
  gap: 5px;
}

.header-task-select {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #ddd;
  min-width: 120px;
  max-width: 180px;
  font-size: 0.9rem;
}

/* ============================================
   Collapsible Components
   ============================================ */

.collapsible {
  transition: all 0.3s ease-in-out;
  overflow: hidden;
}

.map-collapsed {
  height: 120px !important;
}

.map-toggle-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  background: white;
  border: none;
  border-radius: 4px;
  padding: 5px 8px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
}

.map-toggle-btn i {
  margin-right: 4px;
}

/* ============================================
   Pilot Control Panel
   ============================================ */

.leaflet-control-pilots {
  background: white;
  padding: 8px 0;
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
  max-height: calc(100vh - 120px);
  width: 280px;
  overflow-y: auto;
}

/* Collapsed state for the pilots control */
.leaflet-control-pilots.collapsed {
  width: 40px;
  height: 40px;
  overflow: hidden;
  padding: 0;
  border-radius: 4px;
  cursor: pointer;
}

.leaflet-control-pilots.collapsed .pilots-list,
.leaflet-control-pilots.collapsed .pilot-control-header,
.leaflet-control-pilots.collapsed .pilots-control-container {
  display: none;
}

.leaflet-control-pilots.collapsed::before {
  content: '👥';
  display: flex;
  width: 100%;
  height: 100%;
  justify-content: center;
  align-items: center;
  font-size: 18px;
}

.leaflet-control-pilots.collapsed .control-toggle-btn {
  display: none;
}

.pilot-control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px 8px;
  border-bottom: 1px solid #eee;
  margin-bottom: 8px;
}

.pilot-control-header h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #2c3e50;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.collapse-control-btn {
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  cursor: pointer;
  color: #666;
  font-size: 12px;
}

.collapse-control-btn:hover {
  color: #000;
}

.toggle-all {
  font-size: 12px;
}

.toggle-all label {
  display: flex;
  align-items: center;
}

.toggle-all label span {
  margin-left: 6px;
}

/* ============================================
   Pilot Items & Status
   ============================================ */

.pilot-item {
  margin: 0;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}

.pilot-item:hover {
  background-color: #f8f9fa;
}

.pilot-item.highlighted {
  background-color: rgba(0, 123, 255, 0.05);
  border-left-width: 5px;
}

.pilot-info {
  flex-grow: 1;
  font-size: 13px;
}

.pilot-name {
  font-weight: 600;
  display: flex;
  align-items: center;
}

.pilot-toggle {
  margin-left: 10px;
}

.pilot-toggle input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Pilot Status Tags */
.pilot-status {
  font-size: 11px;
  font-weight: 500;
  margin-left: 5px;
  padding: 1px 6px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
}

.pilot-status i {
  font-size: 10px;
  margin-right: 4px;
}

.flying {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.landed {
  background-color: #ffebee;
  color: #c62828;
}

.walking {
  background-color: #fff8e1;
  color: #ff8f00;
}

.stationary {
  background-color: #e3f2fd;
  color: #1565c0;
}

.launch {
  background-color: #e0f7fa;
  color: #00838f;
}

.landing {
  background-color: #f3e5f5;
  color: #6a1b9a;
}

.unknown {
  background-color: #f5f5f5;
  color: #757575;
}

/* Pilot Details */
.pilot-details {
  display: flex;
  align-items: center;
  font-size: 11px;
  color: #666;
  margin-top: 3px;
  flex-wrap: wrap;
}

.detail-item {
  display: flex;
  align-items: center;
  margin-right: 8px;
  margin-bottom: 3px;
}

.detail-item i {
  margin-right: 3px;
  font-size: 12px;
}

.detail-row {
  display: flex;
  width: 100%;
  margin-top: 2px;
}

.detail-item.bearing {
  display: flex;
  align-items: center;
}

.bearing-arrow {
  display: inline-block;
  transform-origin: center;
  margin-right: 4px;
  font-size: 14px;
}

/* ============================================
   Pilot Markers on Map
   ============================================ */

.pilot-marker {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 3px 8px 3px 3px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.1);
  font-size: 12px;
}

.pilot-marker-first {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 2px 8px 2px 3px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  font-weight: 600;
  font-size: 11px;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

.pilot-marker-first::before {
  content: '🏁';
  font-size: 14px;
  margin-right: 4px;
}

.pilot-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 5px;
  color: white;
  position: relative;
}

.pilot-icon i {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  margin-right: 0 !important;
}

/* Flight state colors */
.flight-state-flying {
  background-color: #4caf50;
}

.flight-state-walking {
  background-color: #ff9800;
}

.flight-state-stationary {
  background-color: #2196f3;
}

.flight-state-launch {
  background-color: #00bcd4;
}

.flight-state-landing {
  background-color: #9c27b0;
}

.flight-state-inactive {
  background-color: #757575;
}

.flight-state-uploaded {
  background-color: #3f51b5;
}

.flight-state-unknown {
  background-color: #9e9e9e;
}

/* ============================================
   Connection Status & Viewers
   ============================================ */

.connection-status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.8em;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
}

.status-icon {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.status-connected {
  background-color: rgba(255, 255, 255, 0.95);
  color: #28a745;
}

.status-connected .status-icon {
  background-color: #28a745;
}

.status-disconnected {
  background-color: rgba(255, 255, 255, 0.95);
  color: #dc3545;
}

.status-disconnected .status-icon {
  background-color: #dc3545;
}

.status-connecting {
  background-color: rgba(255, 255, 255, 0.95);
  color: #ffc107;
}

.status-connecting .status-icon {
  background-color: #ffc107;
}

.active-viewers {
  position: relative;
  padding: 8px 15px;
  background-color: rgba(255, 255, 255, 0.9);
  font-size: 0.85em;
  font-weight: 600;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  width: 100%;
}

.active-viewers::before {
  content: '👁️';
  margin-right: 8px;
  font-size: 14px;
}

.reconnect-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 1000;
  background: #dc3545;
  border: none;
  color: white;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 20px;
  font-size: 0.8em;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: background 0.2s ease;
  display: none;
}

.reconnect-btn:hover {
  background: #c82333;
}

/* ============================================
   Notifications
   ============================================ */

.notification-area {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  width: 80%;
  max-width: 600px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.notification {
  padding: 15px 20px;
  margin-bottom: 10px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.3s, fadeOut 0.5s 14.5s forwards;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: auto;
  width: 100%;
  text-align: center;
}

.notification.info {
  background-color: rgba(0, 123, 255, 0.95);
  color: white;
}

.notification.warning {
  background-color: rgba(255, 152, 0, 0.95);
  color: white;
}

.notification.alert {
  background-color: rgba(220, 53, 69, 0.95);
  color: white;
}

.notification.emergency {
  background-color: rgba(183, 28, 28, 0.95);
  color: white;
}

.notification-close {
  cursor: pointer;
  font-weight: bold;
  margin-left: 10px;
}

/* ============================================
   Director & Tracker Panels
   ============================================ */

.director-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1401;
  background: white;
  padding: 15px;
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  display: none;
  width: 80%;
  max-width: 500px;
}

.tracker-panel {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1401;
  background: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: none;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  border-top: 4px solid #ff7700;
}

.director-panel .panel-header,
.tracker-panel .panel-header {
  font-weight: bold;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.director-panel .panel-header .close-btn,
.tracker-panel .panel-header .close-btn {
  cursor: pointer;
  font-size: 16px;
}

/* Director Toggle Button */
.director-toggle-btn {
  background: #343a40;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 600;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: background-color 0.2s;
}

.director-toggle-btn:hover {
  background: #495057;
}

.director-toggle-btn.active {
  background: #007bff;
}

.director-toggle-btn.active:hover {
  background: #0069d9;
}

/* ============================================
   Form Controls
   ============================================ */

.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.priority-select,
.category-select,
.title-input,
.message-input {
  width: 100%;
  padding: 10px;
  border: 2px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}

.priority-select:focus,
.category-select:focus,
.title-input:focus,
.message-input:focus {
  outline: none;
  border-color: #ff7700;
  box-shadow: 0 0 0 3px rgba(255, 119, 0, 0.1);
}

.title-input {
  font-weight: 600;
}

.message-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.4;
}

.send-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #ff7700, #ff9500);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(255, 119, 0, 0.2);
}

.send-btn:hover {
  background: linear-gradient(135deg, #e66a00, #ff8c00);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(255, 119, 0, 0.3);
}

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

/* ============================================
   Actions Section
   ============================================ */

.actions-section {
  margin: 20px 0;
  padding: 15px;
  border: 1px solid #eee;
  border-radius: 6px;
  background: #fafafa;
}

.actions-header {
  margin-bottom: 10px;
}

.actions-header label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: 500;
}

.actions-header label span {
  margin-left: 8px;
}

.action-item {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
  padding: 10px;
  background: white;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.action-type-select,
.action-label-input,
.action-value-input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
}

.action-label-input {
  max-width: 120px;
}

.remove-action-btn {
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.add-action-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.add-action-btn:hover {
  background: #218838;
}

/* ============================================
   Preview Section
   ============================================ */

.preview-section {
  margin-top: 20px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  border-left: 4px solid #007bff;
}

.preview-section h5 {
  margin: 0 0 10px 0;
  color: #495057;
}

.preview-content {
  font-family: monospace;
  font-size: 12px;
  background: white;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #dee2e6;
  white-space: pre-wrap;
}

/* ============================================
   Utility Classes
   ============================================ */

.custom-checkbox {
  width: 16px;
  height: 16px;
  -webkit-appearance: none;
  appearance: none;
  background-color: #fff;
  border: 1.5px solid #ddd;
  border-radius: 3px;
  cursor: pointer;
  display: inline-block;
  position: relative;
  vertical-align: middle;
  transition: all 0.2s ease;
}

.custom-checkbox:checked {
  background-color: #007bff;
  border-color: #007bff;
}

.custom-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 5px;
  height: 9px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Track styling */
.pilot-track {
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pilot-takeoff-line {
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Task Selection */
.task-select-container:not(.task-selection) {
  display: none !important;
}

.content-body > .task-select-container {
  display: none !important;
}

#taskSelect {
  padding: 5px 10px;
  border-radius: 4px;
  border: 1px solid #ddd;
  background-color: white;
  font-size: 14px;
  max-width: 200px;
}

/* Altitude tooltip */
.altitude-tooltip {
  background-color: rgba(255, 255, 255, 0.95);
  border: none;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  font-weight: 500;
}

/* ============================================
   Animations
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.pulse {
  animation: pulse 1s infinite;
}

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

.arrow-rotating {
  animation: arrow-rotate 0.5s ease-out;
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 768px) {
  .dashboard-header {
    padding: 4px 8px;
    gap: 4px;
    height: 48px;
  }
  
  .nav-buttons {
    gap: 3px;
  }
  
  .header-actions {
    gap: 3px;
  }
  
  /* Adjust controls for mobile with header */
  .leaflet-top {
    top: 60px !important;
  }
  
  .leaflet-top.leaflet-left {
    top: 60px !important;
  }
  
  .leaflet-top.leaflet-right {
    top: 60px !important;
  }

  .header-title {
    flex: 1;
    min-width: 0;
    text-align: center;
  }
  
  .header-title h1 {
    font-size: 0.85rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .header-title .subtitle {
    display: none;
  }
  
  /* Compact button on mobile */
  .btn-text {
    display: none;
  }
  
  .btn {
    padding: 4px 8px;
    font-size: 0.85rem;
  }
  
  .btn-sm {
    padding: 3px 6px;
  }
  
  .header-task-select {
    font-size: 0.85rem;
    padding: 4px 8px;
    min-width: 100px;
    flex-grow: 1;
    min-width: 0;
  }

  .task-selection {
    display: none;
  }

  .map-toggle-btn,
  .map-collapsed {
    height: 60px !important;
  }

  #mapid {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile browsers */
  }

  .leaflet-control-pilots {
    max-width: 250px;
    width: 250px;
    max-height: calc(100vh - 120px);
    font-size: 0.85rem;
  }
  
  .leaflet-control-pilots .pilot-item {
    padding: 6px;
    font-size: 0.8rem;
  }
  
  .leaflet-control-pilots .pilot-name {
    font-size: 0.85rem;
  }

  .director-panel {
    width: 95%;
    padding: 10px;
    bottom: 10px;
  }

  .tracker-panel {
    width: 95%;
    padding: 12px;
    bottom: 10px;
  }

  .director-toggle-btn {
    padding: 6px 10px;
    font-size: 0.8em;
  }

  .active-viewers {
    padding: 6px 10px;
    font-size: 0.8em;
  }

  .notification-area {
    width: 95%;
    bottom: 15px;
  }

  .priority-select,
  .title-input,
  .message-input {
    padding: 8px;
    font-size: 13px;
  }

  .message-input {
    min-height: 60px;
  }

  .send-btn {
    padding: 8px;
  }

  .action-item {
    flex-direction: column;
    align-items: stretch;
  }

  .action-item > * {
    margin-bottom: 8px;
  }

  .action-item > *:last-child {
    margin-bottom: 0;
  }
}