/* ==================== CONTROL TOWER STYLES ==================== */

/* ==================== LAYOUT ==================== */
.control-container {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  max-width: 100%;
  margin: 0 auto;
  align-items: start;
}

/* ==================== DEVICES PANEL ==================== */
.devices-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  transition: all var(--transition-base);
  position: sticky;
  top: 20px;
}

.devices-panel:hover {
  box-shadow: var(--shadow-xl);
}

.devices-panel h2 {
  margin: 0 0 1.25rem 0;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.625rem;
}

.devices-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
}

/* ==================== DEVICE CARDS ==================== */
.device-card {
  background: var(--color-white);
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  padding: 1rem;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.device-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(99, 102, 241, 0.1),
    transparent
  );
  transition: left 0.5s ease;
}

.device-card:hover::before {
  left: 100%;
}

.device-card:hover {
  border-color: var(--color-primary);
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

.device-card.selected {
  border-color: var(--color-primary);
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.1) 0%,
    rgba(139, 92, 246, 0.1) 100%
  );
  box-shadow: var(--shadow-md);
  transform: translateX(5px);
}

.device-card.selected::after {
  content: "✓";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  background: var(--color-success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 12px;
  box-shadow: var(--shadow-md);
}

.device-name {
  font-weight: 600;
  color: var(--color-text);
  font-size: 1rem;
  margin-bottom: 0.375rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.device-id {
  color: var(--color-secondary);
  font-size: 0.8125rem;
  margin-bottom: 0.375rem;
  font-family: var(--font-mono);
}

.device-status {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--color-success);
  font-weight: 500;
}

.device-status::before {
  content: "●";
  font-size: 1rem;
  animation: pulse 2s ease-in-out infinite;
}

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

.device-timestamp {
  font-size: 0.75rem;
  color: var(--color-secondary-light);
  margin-top: 0.375rem;
}

/* Empty & Loading States */
.no-devices {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--color-secondary);
}

.no-devices-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.devices-list.loading {
  text-align: center;
  padding: 2rem;
  color: var(--color-secondary);
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.devices-list.loading .device-card {
  pointer-events: none;
  opacity: 0.5;
}

.loading::after {
  content: "...";
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0%,
  20% {
    content: ".";
  }
  40% {
    content: "..";
  }
  60%,
  100% {
    content: "...";
  }
}

/* ==================== PANEL DEL MAPA ==================== */

.map-container {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-2xl);
  padding: 1.5rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transition: all var(--transition-base);
}

.map-container:hover {
  box-shadow: var(--shadow-xl);
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.map-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

/* ==================== MAP INSTRUCTIONS ==================== */
.map-instruction {
  background: linear-gradient(
    135deg,
    rgba(99, 102, 241, 0.1) 0%,
    rgba(139, 92, 246, 0.1) 100%
  );
  border-left: 4px solid var(--color-primary);
  padding: 0.875rem 1rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1rem;
  font-size: 0.9375rem;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 0.625rem;
  transition: all var(--transition-base);
}

.map-instruction.ready {
  background: linear-gradient(
    135deg,
    rgba(16, 185, 129, 0.1) 0%,
    rgba(5, 150, 105, 0.1) 100%
  );
  border-left-color: var(--color-success);
}

.map-instruction.success {
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.1) 0%,
    rgba(37, 99, 235, 0.1) 100%
  );
  border-left-color: #3b82f6;
}

.map-instruction.waiting {
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.1) 0%,
    rgba(217, 119, 6, 0.1) 100%
  );
  border-left-color: var(--color-warning);
}

.map-instruction.warning {
  background: linear-gradient(
    135deg,
    rgba(239, 68, 68, 0.1) 0%,
    rgba(220, 38, 38, 0.1) 100%
  );
  border-left-color: var(--color-danger);
}

/* ==================== MAP ==================== */
#map {
  height: 450px;
  min-height: 300px;
  border-radius: var(--radius-xl);
}

#map.selection-mode {
  cursor: crosshair !important;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-xl), 0 0 0 3px rgba(14, 165, 233, 0.15);
}

/* ==================== DESTINATION INFO ==================== */
.destination-info {
  background: var(--color-white);
  border-radius: var(--radius-xl);
  padding: 1.25rem;
  margin-top: 1rem;
  display: none;
  border: 1px solid var(--color-border);
  transition: all var(--transition-base);
}

.destination-info.show {
  display: block;
  animation: slideUp 0.3s ease-out;
}

.destination-info h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.0625rem;
}

.destination-coords {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.coord-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.coord-field label {
  font-weight: 600;
  color: var(--color-secondary);
  font-size: 0.8125rem;
}

.coord-field input {
  background: var(--color-light);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--color-primary);
  cursor: default;
}

/* ==================== ACTION BUTTONS ==================== */
.action-buttons {
  display: flex;
  gap: 0.875rem;
}

.btn-send {
  flex: 1;
  background: linear-gradient(135deg, var(--color-success) 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: var(--radius-lg);
  padding: 0.875rem;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  box-shadow: var(--shadow-md), 0 4px 12px rgba(16, 185, 129, 0.25);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.btn-send::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  transition: left 0.5s ease;
}

.btn-send:hover:not(:disabled)::before {
  left: 100%;
}

.btn-send:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), 0 8px 20px rgba(16, 185, 129, 0.35);
}

.btn-send:disabled {
  background: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
  cursor: not-allowed;
  box-shadow: var(--shadow-sm);
  opacity: 0.7;
}

.btn-cancel {
  flex: 1;
  background: var(--color-white);
  color: var(--color-danger);
  border: 2px solid var(--color-danger);
  border-radius: var(--radius-lg);
  padding: 0.875rem;
  font-weight: 600;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: all var(--transition-base);
}

.btn-cancel:hover {
  background: var(--color-danger);
  color: white;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 480px;
  padding: 1rem 1.25rem;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  animation: toastSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
  border: 1px solid var(--glass-border);
}

.toast.removing {
  animation: toastSlideOut 0.3s ease-out forwards;
}

.toast-success {
  border-left: 4px solid var(--color-success);
}
.toast-error {
  border-left: 4px solid var(--color-danger);
}
.toast-warning {
  border-left: 4px solid var(--color-warning);
}
.toast-info {
  border-left: 4px solid var(--color-primary);
}

.toast-icon {
  font-size: 1.375rem;
  flex-shrink: 0;
}

.toast-success .toast-icon {
  color: var(--color-success);
}
.toast-error .toast-icon {
  color: var(--color-danger);
}
.toast-warning .toast-icon {
  color: var(--color-warning);
}
.toast-info .toast-icon {
  color: var(--color-primary);
}

.toast-message {
  flex: 1;
  font-size: 0.875rem;
  color: var(--color-text);
  font-weight: 500;
  line-height: 1.5;
}

.toast-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--color-secondary-light);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.toast-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--color-text);
}

@keyframes toastSlideIn {
  from {
    transform: translateX(120%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(120%);
    opacity: 0;
  }
}

/* ==================== CUSTOM SCROLLBAR ==================== */
.devices-panel::-webkit-scrollbar {
  width: 8px;
}

.devices-panel::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.03);
  border-radius: var(--radius-full);
}

.devices-panel::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    var(--color-primary),
    var(--color-accent)
  );
  border-radius: var(--radius-full);
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
  .control-container {
    grid-template-columns: 340px 1fr;
  }
}

@media (max-width: 1024px) {
  .control-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .devices-panel {
    max-height: 280px;
    position: static;
  }

  #map {
    height: 400px;
  }

  .toast-container {
    right: 12px;
    left: 12px;
    top: 12px;
  }

  .toast {
    min-width: 0;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .devices-panel,
  .map-container {
    padding: 1.25rem;
    border-radius: var(--radius-xl);
  }

  #map {
    height: 350px;
    border-radius: var(--radius-lg);
  }

  .destination-coords {
    grid-template-columns: 1fr;
  }

  .action-buttons {
    flex-direction: column;
  }

  .device-card {
    padding: 0.875rem;
  }
}

@media (max-width: 480px) {
  .devices-panel {
    padding: 1rem;
    max-height: 220px;
  }

  .map-container {
    padding: 1rem;
  }

  .devices-panel h2,
  .map-header h2 {
    font-size: 1.125rem;
  }

  #map {
    height: 280px;
  }

  .btn-send,
  .btn-cancel {
    padding: 0.75rem;
    font-size: 0.875rem;
  }
}
