/* ========================================
   DASHBOARD STYLES - c2lynx
   Estilos para el panel de control
======================================== */

/*********************************************************************************/

.map-container {
    display: flex;
    height: calc(100vh - 75px);
    background: var(--bg-secondary);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

/* ========== SIDEBAR ========== */
.drone-sidebar {
  width: 375px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-primary);
}

.sidebar-header h3 {
  margin: 0 0 var(--spacing-md) 0;
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.drone-stats {
  display: flex;
  gap: var(--spacing-lg);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

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

.status-dot.operational {
  background: var(--color-primary);
}

/* ========== DRONE LIST ========== */
.drone-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-sm);
}

.drone-item {
  display: flex;
  align-items: center;
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-sm);
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition-fast);
}

.drone-item:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.drone-item.active {
  border-color: var(--color-primary);
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-sm);
}

.drone-icon {
  width: 32px;
  height: 32px;
  margin-right: var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius);
  padding: var(--spacing-xs);
  position: relative; /* Añadido */
}

.drone-icon::before {
  content: '';
  position: absolute;
  top: var(--spacing-xs); /* Respeta el padding */
  left: var(--spacing-xs);
  right: var(--spacing-xs);
  bottom: var(--spacing-xs);
  background-color: var(--text-primary);
  -webkit-mask: url('/imgs/ico-drone.png') no-repeat center;
  mask: url('/imgs/ico-drone.png') no-repeat center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.drone-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0; /* Oculta la imagen original */
}

.drone-info {
  flex: 1;
}

.drone-info h4 {
  margin: 0 0 2px 0;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
}

.location {
  margin: 0 0 var(--spacing-xs) 0;
  font-size: var(--font-size-xs);
  color: var(--text-location);
}

.status {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  padding: 2px var(--spacing-sm);
  border-radius: 4px;
  display: inline-block;
}

.status.operational {
  background: var(--color-primary-light);
  color: var(--text-muted);
}

/* ========== MAP ========== */
.map-wrapper {
  flex: 1;
  position: relative;
  background: var(--bg-tertiary);
}

#drone-map {
  width: 100%;
  height: 100%;
  border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
}

/* ========== MAP CONTROLS ========== */
.map-controls {
  position: absolute;
  top: var(--spacing-lg);
  right: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  z-index: 999;
}

.btn-control {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-fast);
  color: var(--text-secondary);
}

.btn-control:hover {
  background: var(--color-secondary);
  color: var(--text-primary);
  border-color: var(--text-primary);
  box-shadow: var(--shadow);
}

/* ========== CUSTOM MARKERS ========== */
.custom-drone-marker {
  position: relative;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.custom-drone-marker img {
  width: 40px;
  height: 40px;
  z-index: 2;
  position: relative;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 55px;
  height: 55px;
  border: 2px solid var(--color-primary);
  border-radius: 50%;
  animation: pulse 1s infinite;
}

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

/* ========== POPUP STYLES ========== */
.drone-popup h4 {
  margin: 0 0 var(--spacing-sm) 0;
  color: var(--color-primary-hover);
  font-weight: var(--font-weight-semibold);
}

.drone-popup p {
  margin: 2px 0;
  font-size: var(--font-size-sm);
  color: var(--text-primary);
}

.popup-status.operational {
  color: var(--color-primary);
  font-weight: var(--font-weight-medium);
}

.leaflet-popup 

.popup-actions {
  text-align: center;
  margin-top: 20px;
}

.live-view-btn {
  background: var(--color-primary-hover);
  color: black;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}


.live-view-btn i {
  font-size: 11px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .map-container {
      flex-direction: column;
      height: auto;
  }
  
  .drone-sidebar {
      width: 100%;
      max-height: 300px;
  }
  
  .map-wrapper {
      height: 400px;
  }
  
  #drone-map {
      border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
  }
}

/* ========== LEAFLET OVERRIDES ========== */
.leaflet-popup-content-wrapper {
  width: 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-md);
}


.leaflet-popup-content p
{
  margin: 12px 0 !important;
}

.leaflet-popup-tip {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
}

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

.leaflet-control-zoom a:hover {
  background: var(--color-primary-light);
}

.leaflet-control-layers, .leaflet-control-zoom , .leaflet-control-zoom-out, .leaflet-control-zoom-in
{
  background: var(--bg-secondary) !important;
  color: var(--text-primary) !important;
}


/* Estilos para el nuevo sidebar de operaciones */
.operations-list {
  flex: 1;
  overflow-y: auto;
}

.operation-group {
  margin-bottom: 8px;
}

.operation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.operation-header:hover {
  background: var(--hover-background);
  border-color: var(--color-primary);
}

.operation-header.expanded {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  border-bottom: none;
}

.operation-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.operation-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.operation-details h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.operation-location {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 2px 0 0 0;
}

.operation-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-badge.status-active {
  background: #292929;
  color: white;
}

.status-badge.status-active.live {
  background: #10b981;
  animation: pulse 2s infinite;
}

.status-badge.status-active.offline {
  background: #6b7280;
}

.drone-count {
  background: var(--color-primary);
  color: black;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.expand-icon svg {
  transition: transform 0.2s ease;
}

/* Lista de drones desplegable */
.drones-list {
  border: 1px solid var(--border-color);
  border-top: none;
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
  background: var(--card-background);
  overflow: hidden;
  transition: all 0.3s ease;
}

.drones-list.collapsed {
  max-height: 0;
  border: none;
}

.drones-list.expanded {
  max-height: 500px;
  padding-bottom: 8px;
}

.drone-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
  border-bottom: 1px solid var(--border-color-light);
  transition: background-color 0.2s ease;
}

.drone-item:hover {
  background: var(--hover-background);
}

.drone-item:last-child {
  border-bottom: none;
}

.drone-item.active {
  background: var(--bg-primary);
  border-left: 3px solid var(--color-primary);
}

.drone-icon {
  position: relative;
  width: 24px;
  height: 24px;
}

.drone-icon img {
  width: 100%;
  height: 100%;
}

.connection-indicator {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4d4d4d;
  border: 1px solid white;
}

.connection-indicator.connected {
  background: #00ffaa;
  animation: pulse 2s infinite;
}

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

.drone-info h5 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.2;
}

.drone-serial {
  font-size: 10px;
  color: var(--text-secondary);
  margin: 1px 0 0 0;
}

.drone-status {
  margin-top: 2px;
}

.mqtt-status {
  font-size: 9px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.mqtt-status.live {
  background: #10b981;
  color: white;
}

.mqtt-status.offline {
  background: #6b7280;
  color: white;
}

.drone-actions {
  display: flex;
  gap: 4px;
}

.btn-track, .btn-live, .btn-no-live {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-track {
  color: var(--color-primary);
}

.btn-track:hover {
  background: var(--color-primary);
  color: black;
}

.btn-no-live {
  background: #6b7280;
  color: white;
  cursor: not-allowed;
}

.btn-no-live:hover {
  background: #6b7280;
  opacity: 0.8;
}

.btn-live {
  background: #dc2626;
  color: white;
}

.btn-live:hover {
  background: #b91c1c;
}

.no-drones, .no-operations {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-secondary);
}

.no-operations svg {
  color: var(--text-disabled);
  margin-bottom: 16px;
}

.operation-stats {
  display: flex;
  gap: 16px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Estados de carga */
.mqtt-connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.mqtt-connection-status.connecting {
  background: #f59e0b;
  color: white;
}

.mqtt-connection-status.connected {
  background: #12eba2;
  color: white;
}

.mqtt-connection-status.error {
  background: #ef4444;
  color: white;
}

.loading-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top: 2px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.status-badge.loading {
  background: #f59e0b;
  color: white;
}

.mqtt-status.loading {
  background: #f59e0b;
  color: white;
}

.connection-indicator.loading {
  background: #f59e0b;
  animation: pulse 1s infinite;
}

.drone-name-label {
  position: absolute;
  top: -25px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}