/* Command Center Setup & Configuration Modals */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.97);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: tactical-fade-in 0.5s ease-out;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: var(--tactical-bg);
  backdrop-filter: blur(20px);
  border-radius: 0;
  clip-path: polygon(20px 0%, 100% 0%, calc(100% - 20px) 100%, 0% 100%);
  padding: 2rem;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 
    var(--glow-lg) var(--emergency-red-glow),
    0 25px 80px rgba(0, 0, 0, 0.9);
  border: 2px solid var(--steel-medium);
  position: relative;
}

.modal-content::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, 
    var(--emergency-red) 0%, 
    var(--tactical-orange) 50%, 
    var(--electric-blue) 100%);
  animation: border-glow 4s ease-in-out infinite;
}

/* Command Center Setup Modal */
.setup-modal {
  max-width: 900px;
  width: 100%;
  padding: 3rem;
  position: relative;
}

.setup-modal::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(220, 38, 38, 0.05) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(14, 165, 233, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: -1;
}

.setup-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--steel-dark);
  position: relative;
}

.setup-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 2px;
  background: linear-gradient(90deg, var(--emergency-red), var(--tactical-orange));
  box-shadow: var(--glow-md) var(--emergency-red-glow);
}

.setup-logo {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  font-family: 'Roboto', sans-serif;
  position: relative;
  text-transform: none;
}

.setup-logo::before {
  content: '▶';
  position: absolute;
  left: -3rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--emergency-red);
  font-size: 2rem;
  animation: status-pulse 2s ease-in-out infinite;
}

.setup-logo::after {
  content: '◀';
  position: absolute;
  right: -3rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--emergency-red);
  font-size: 2rem;
  animation: status-pulse 2s ease-in-out infinite;
  animation-delay: 1s;
}

.setup-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Setup Steps */
.setup-step {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.setup-step.active {
  display: block;
}

.step-content h2 {
  color: var(--emergency-red);
  margin-bottom: 1rem;
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: var(--glow-sm) var(--emergency-red-glow);
  position: relative;
}

.step-content h2::before {
  content: '■■';
  color: var(--tactical-orange);
  font-size: 0.8rem;
  margin-right: 1rem;
  animation: status-pulse 3s ease-in-out infinite;
}

.step-content p {
  color: var(--text-secondary);
  margin-bottom: 2rem;
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.6;
}

/* Tactical Deployment Zone Selection */
.city-selection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.city-option {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  background: var(--steel-dark);
  backdrop-filter: blur(10px);
  border: 2px solid var(--steel-medium);
  clip-path: polygon(12px 0%, 100% 0%, calc(100% - 12px) 100%, 0% 100%);
  cursor: pointer;
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
  animation: slide-in-left 0.6s ease-out;
}

.city-option::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, 
    rgba(220, 38, 38, 0.1) 0%, 
    rgba(14, 165, 233, 0.1) 100%);
  opacity: 0;
  transition: all 0.4s ease;
}

.city-option::after {
  content: '▶';
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--steel-light);
  font-size: 1.5rem;
  transition: all 0.3s ease;
}

.city-option:hover::before {
  opacity: 1;
}

.city-option:hover {
  border-color: var(--electric-blue);
  transform: translateY(-3px) translateX(3px);
  box-shadow: 
    var(--glow-lg) var(--electric-blue-glow),
    0 10px 30px rgba(0, 0, 0, 0.4);
}

.city-option:hover::after {
  color: var(--electric-blue);
  transform: translateY(-50%) translateX(3px);
}

.city-option.selected {
  border-color: var(--emergency-red);
  background: rgba(220, 38, 38, 0.2);
  box-shadow: var(--glow-md) var(--emergency-red-glow);
}

.city-option.selected::before {
  opacity: 1;
  background: linear-gradient(135deg, 
    rgba(220, 38, 38, 0.2) 0%, 
    rgba(245, 158, 11, 0.1) 100%);
}

.city-option.selected::after {
  color: var(--emergency-red);
  animation: status-pulse 2s ease-in-out infinite;
}

.city-option.detected {
  border-color: var(--electric-blue);
  background: rgba(14, 165, 233, 0.1);
}

.city-option.detected::before {
  opacity: 0.5;
  background: linear-gradient(135deg,
    rgba(14, 165, 233, 0.15) 0%,
    rgba(59, 130, 246, 0.1) 100%);
}

.city-option.detected::after {
  color: var(--electric-blue);
}

.city-flag {
  font-size: 2.5rem;
  line-height: 1;
  text-shadow: var(--glow-sm) rgba(0, 0, 0, 0.5);
}

.city-info {
  flex: 1;
}

.city-name {
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: var(--glow-sm) rgba(248, 250, 252, 0.3);
}

.city-region {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.city-services {
  font-size: 0.8rem;
  color: var(--tactical-orange);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.5rem 0.75rem;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--tactical-orange);
  clip-path: polygon(4px 0%, 100% 0%, calc(100% - 4px) 100%, 0% 100%);
  display: inline-block;
  text-shadow: var(--glow-sm) var(--tactical-orange-glow);
}

/* Tactical Deployment Instructions */
.map-instruction {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  background: rgba(14, 165, 233, 0.1);
  backdrop-filter: blur(10px);
  border: 2px solid var(--electric-blue);
  clip-path: polygon(12px 0%, 100% 0%, calc(100% - 12px) 100%, 0% 100%);
  margin-bottom: 2rem;
  position: relative;
}

.map-instruction::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--electric-blue), var(--tactical-orange));
  box-shadow: var(--glow-sm) var(--electric-blue-glow);
}

.instruction-icon {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--electric-blue);
  text-shadow: var(--glow-sm) var(--electric-blue-glow);
  animation: status-pulse 3s ease-in-out infinite;
}

.instruction-text {
  flex: 1;
  color: var(--text-secondary);
  font-weight: 500;
}

.instruction-text strong {
  color: var(--electric-blue);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: var(--glow-sm) var(--electric-blue-glow);
}

.setup-map {
  width: 100%;
  height: 450px;
  border-radius: 0;
  clip-path: polygon(16px 0%, 100% 0%, calc(100% - 16px) 100%, 0% 100%);
  overflow: hidden;
  border: 3px solid var(--steel-medium);
  margin-bottom: 2rem;
  position: relative;
  box-shadow: 
    var(--glow-md) rgba(0, 0, 0, 0.5),
    inset 0 0 20px rgba(14, 165, 233, 0.1);
}

.location-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

/* Confirmation Step */
.setup-summary {
  text-align: center;
  padding: 2rem;
}

.summary-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  line-height: 1;
}

.summary-content h3 {
  color: #61dafb;
  font-size: 1.5rem;
  margin-bottom: 2rem;
}

.summary-details {
  background: #1a1a1a;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: left;
}

.summary-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid #333;
}

.summary-item:last-child {
  border-bottom: none;
}

.summary-label {
  font-weight: 600;
  color: #888;
}

.summary-item span:last-child {
  color: #c5c6c7;
}

/* Command Configuration Panel */
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid var(--steel-dark);
  position: relative;
}

.modal-header::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 30%;
  height: 2px;
  background: linear-gradient(90deg, var(--emergency-red), var(--tactical-orange));
  box-shadow: var(--glow-sm) var(--emergency-red-glow);
}

.modal-header h2 {
  color: var(--emergency-red);
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-shadow: var(--glow-sm) var(--emergency-red-glow);
}

.modal-header h2::before {
  content: '⚙';
  margin-right: 1rem;
  color: var(--tactical-orange);
  animation: radar-sweep 4s linear infinite;
}

.close-btn {
  background: var(--steel-dark);
  border: 2px solid var(--steel-medium);
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.75rem;
  clip-path: polygon(4px 0%, 100% 0%, calc(100% - 4px) 100%, 0% 100%);
  transition: all 0.3s ease;
  font-weight: 700;
}

.close-btn:hover {
  color: var(--emergency-red);
  border-color: var(--emergency-red);
  background: rgba(220, 38, 38, 0.1);
  box-shadow: var(--glow-sm) var(--emergency-red-glow);
}

.settings-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.settings-section h3 {
  color: var(--tactical-orange);
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-shadow: var(--glow-sm) var(--tactical-orange-glow);
  position: relative;
}

.settings-section h3::before {
  content: '▶';
  color: var(--emergency-red);
  font-size: 1rem;
  margin-right: 0.75rem;
  animation: status-pulse 2s ease-in-out infinite;
}

/* Radio button groups */
.radius-options,
.refresh-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Animation for modal entrance */
@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-content {
  animation: modalSlideIn 0.3s ease-out;
}

/* Map container specific styling */
#setup-map .gm-style {
  border-radius: 12px;
}

/* Enhanced responsive adjustments for better mobile UX */
@media (max-width: 768px) {
  .modal-overlay {
    /* Optimize scrolling on mobile */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .setup-modal {
    padding: 2rem 1.5rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .setup-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
  }
  
  .setup-logo {
    font-size: 2rem;
  }
  
  .setup-logo::before,
  .setup-logo::after {
    display: none; /* Hide decorative elements on mobile */
  }
  
  .setup-subtitle {
    font-size: 1rem;
  }
  
  .city-selection-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .city-option {
    padding: 1.5rem;
    gap: 1rem;
  }
  
  .city-flag {
    font-size: 2rem;
  }
  
  .city-name {
    font-size: 1.25rem;
  }
  
  .setup-map {
    height: 360px; /* Taller for better touch interaction and accuracy */
    touch-action: pan-x pan-y; /* Enable touch gestures */
  }
  
  .map-instruction {
    padding: 1.5rem;
    gap: 1rem;
    flex-direction: column;
    text-align: center;
  }
  
  .instruction-icon {
    font-size: 2rem;
  }
  
  .location-controls {
    flex-direction: column;
    gap: 1rem;
  }
  
  .location-controls .btn {
    width: 100%;
    min-height: 48px; /* Better touch target */
  }
  
  /* Enhanced settings modal for mobile */
  .modal-content {
    max-width: 95vw;
    max-height: 88vh;
    padding: 1.5rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .modal-header h2 {
    font-size: 1.5rem;
  }
  
  .settings-content {
    gap: 1.5rem;
  }
  
  .settings-section h3 {
    font-size: 1.125rem;
  }
}

@media (max-width: 480px) {
  .setup-modal {
    padding: 1.5rem 1rem;
    padding-bottom: calc(1.5rem + env(safe-area-inset-bottom));
    max-width: 98vw;
    max-height: 92vh;
    overflow-y: auto;
  }
  
  .setup-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
  }
  
  .setup-logo {
    font-size: 1.75rem;
  }
  
  .setup-subtitle {
    font-size: 0.9rem;
  }
  
  .step-content h2 {
    font-size: 1.5rem;
  }
  
  .step-content p {
    font-size: 1rem;
    margin-bottom: 1.5rem;
  }
  
  .city-option {
    padding: 1.25rem 1rem;
    gap: 1rem;
    min-height: 64px; /* Better touch target */
  }
  
  .city-flag {
    font-size: 1.75rem;
  }
  
  .city-name {
    font-size: 1.125rem;
  }
  
  .city-region {
    font-size: 0.85rem;
  }
  
  .city-services {
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
  }
  
  .setup-map {
    height: 320px; /* Better proportions and touch accuracy for small screens */
    touch-action: pan-x pan-y;
  }
  
  .map-instruction {
    padding: 1.25rem;
  }
  
  .instruction-text {
    font-size: 0.9rem;
  }
  
  .summary-content h3 {
    font-size: 1.25rem;
  }
  
  .summary-details {
    padding: 1.25rem;
  }
  
  /* Enhanced modal content for small screens */
  .modal-content {
    max-width: 98vw;
    max-height: 92vh;
    padding: 1.25rem;
    padding-bottom: calc(1.25rem + env(safe-area-inset-bottom));
    overflow-y: auto;
  }
  
  .modal-header h2 {
    font-size: 1.25rem;
  }
  
  .close-btn {
    padding: 0.6rem;
    font-size: 1.125rem;
    min-width: 44px;
    min-height: 44px;
  }
  
  .settings-section h3 {
    font-size: 1rem;
  }
  
  .radio-option {
    padding: 0.875rem;
    min-height: 48px; /* Better touch target */
  }
}

/* Notification Setup Step */
.notification-setup {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.notification-option-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  background: var(--steel-dark);
  border: 2px solid var(--steel-medium);
  border-radius: 8px;
  transition: all 0.3s ease;
}

.notification-option-card:hover {
  border-color: var(--electric-blue);
  box-shadow: var(--glow-md) var(--electric-blue-glow);
}

.option-icon {
  font-size: 3rem;
  line-height: 1;
}

.option-content {
  flex: 1;
}

.option-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.option-content p {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0;
}

/* Toggle Switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--steel-medium);
  transition: 0.4s;
  border-radius: 34px;
  border: 2px solid var(--steel-light);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 2px;
  bottom: 2px;
  background: white;
  transition: 0.4s;
  border-radius: 50%;
}

input:checked + .toggle-slider {
  background: var(--electric-blue);
  border-color: var(--electric-blue);
  box-shadow: var(--glow-sm) var(--electric-blue-glow);
}

input:checked + .toggle-slider:before {
  transform: translateX(26px);
}

/* Notification Preferences */
.notification-preferences {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.notification-preferences.hidden {
  display: none;
}

.notification-preferences h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.notification-topics {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Checkbox Option */
.checkbox-option {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid var(--steel-medium);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.checkbox-option:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--electric-blue);
}

.checkbox-option input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--electric-blue);
  flex-shrink: 0;
}

.checkbox-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.checkbox-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.checkbox-description {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Notification Settings in Modal */
.notification-status-display {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--steel-medium);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
}

.status-row:not(:last-child) {
  border-bottom: 1px solid var(--steel-dark);
}

.status-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
}

.status-value {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 600;
}

.notification-topics-list {
  margin-top: 1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--steel-medium);
  border-radius: 6px;
}

.notification-topics-list h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem 0;
}

.topics-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.topics-list li {
  padding: 0.5rem 0.75rem;
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid var(--electric-blue);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--electric-blue);
  font-family: 'Courier New', monospace;
}