/* Mobile Modal Backdrop */
.elevation-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 999;
  animation: fadeIn 0.2s ease;
}

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

/* Elevation Display (Persistent at top) */
.elevation-display {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  background: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.9rem;
  white-space: nowrap;
  position: relative;
}

.elevation-label {
  font-weight: 600;
  color: var(--text-secondary);
}

.elevation-number {
  font-weight: 700;
  color: var(--primary-color);
  min-width: 50px;
}

.elevation-unit {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-right: 0.5rem;
}

/* Elevation Picker Button (Small icon button within display) */
.elevation-display .elevation-picker-btn {
  padding: 0.25rem 0.5rem;
  background: transparent;
  border: none;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: auto;
}

.elevation-display .elevation-picker-btn:hover {
  background: var(--surface-hover);
  border: 1px solid var(--primary-color);
  border-radius: 0.35rem;
}

.elevation-display .elevation-picker-btn:active {
  transform: scale(0.95);
}

.elevation-icon {
  font-size: 1rem;
}

.elevation-icon-img {
  width: 1rem;
  height: 1rem;
  object-fit: contain;
}

/* Elevation Picker Panel */
.elevation-picker-panel {
  position: absolute;
  top: 100%;
  right: 0;
  width: 380px;
  max-height: 600px;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  animation: slideIn 0.2s ease;
  margin-top: 0.5rem;
}

.elevation-picker-panel.hidden {
  display: none;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Panel Header */
.elevation-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.elevation-panel-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.elevation-panel-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.25rem;
  transition: background 0.2s;
}

.elevation-panel-close:hover {
  background: var(--surface-hover);
}

/* Panel Content */
.elevation-panel-content {
  display: flex;
  flex-direction: column;
  overflow: auto;
  flex: 1;
}

/* Search Input */
.elevation-search {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.elevation-search-input {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 0.4rem;
  font-size: 0.9rem;
  background: var(--background-color);
  color: var(--text-color);
  font-family: inherit;
}

.elevation-search-input::placeholder {
  color: var(--text-secondary);
}

.elevation-search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* City List */
.elevation-city-list {
  padding: 0.5rem;
  overflow-y: auto;
  max-height: 350px;
  flex: 1;
}

.elevation-city-item {
  padding: 0.75rem;
  margin: 0.25rem 0;
  background: var(--background-color);
  border: 1px solid transparent;
  border-radius: 0.4rem;
  cursor: pointer;
  transition: all 0.2s;
}

.elevation-city-item:hover {
  background: var(--surface-hover);
  border-color: var(--border-color);
}

.elevation-city-item:active {
  transform: scale(0.98);
}

.city-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-color);
}

.city-country {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.2rem;
}

/* Elevation Result */
.elevation-result {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--surface-color) 0%, var(--background-color) 100%);
}

.elevation-result.hidden {
  display: none;
}

.elevation-value {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.elevation-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.elevation-number {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}

.elevation-unit {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.elevation-details {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.elevation-cached,
.elevation-city-selected {
  margin: 0.3rem 0;
}

/* Responsive */
@media (max-width: 640px) {
  .elevation-display {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    gap: 0.15rem;
  }

  .elevation-display .elevation-picker-btn {
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
  }

  .elevation-number {
    min-width: 40px;
    font-size: 1.1rem;
  }

  .elevation-unit {
    font-size: 0.7rem;
    margin-right: 0.25rem;
  }

  .elevation-picker-panel {
    width: calc(100% - 40px);
    max-height: 70vh;
  }

  .elevation-picker-panel.elevation-mobile-modal {
    /* Full-screen modal for mobile */
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    bottom: auto;
    right: auto;
    width: min(100vw - 32px, 100%);
    max-height: 85vh;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    animation: slideUpModal 0.3s ease-out;
  }

  @keyframes slideUpModal {
    from {
      opacity: 0;
      transform: translate(-50%, calc(-50% + 30px));
    }
    to {
      opacity: 1;
      transform: translate(-50%, -50%);
    }
  }

  /* Single unified scroll for mobile modal */
  .elevation-mobile-modal .elevation-panel-content {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }

  /* City list in mobile modal - allow flex growth */
  .elevation-mobile-modal .elevation-city-list {
    max-height: none;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Increase touch targets on mobile */
  .elevation-city-item {
    padding: 0.875rem; /* Increased from 0.75rem */
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .elevation-panel-close {
    width: 44px;  /* Increased from 32px */
    height: 44px; /* Increased from 32px */
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .elevation-picker-btn {
    background: var(--surface-color);
    color: var(--text-color);
  }

  .elevation-picker-panel {
    background: var(--surface-color);
    border-color: var(--border-color);
  }
}
