/**
 * Area Selection Module Styles
 */

/* ===========================================
   AREA SELECTION TRIGGER BUTTON
   =========================================== */

.area-selection-btn {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--c-depth);
  border: 1px solid var(--c-border);
  border-radius: 2rem;
  color: var(--c-text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

.area-selection-btn:hover {
  background: var(--c-surface-glow);
  border-color: var(--c-accent);
  box-shadow: var(--shadow-lg);
}

.area-selection-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  color: var(--c-accent);
}

.area-selection-btn span {
  white-space: nowrap;
}

/* Hide button when selection mode is active */
body.selection-mode-active .area-selection-btn {
  display: none;
}

/* Body state when selection mode is active */
body.selection-mode-active .instructions-panel {
  display: none;
}

body.selection-mode-active .create-panel {
  display: none;
}

/* ===========================================
   SELECTION TOOLBAR
   =========================================== */

.area-selection-toolbar {
  position: absolute;
  top: 5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-depth);
  border: 1px solid var(--c-border);
  border-radius: 0.75rem;
  padding: 0;
  z-index: 1200;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  min-width: 320px;
  max-width: 90vw;
  animation: toolbarSlideIn 0.3s ease;
}

@keyframes toolbarSlideIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.toolbar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--c-border);
}

.toolbar-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-text);
}

.toolbar-close {
  background: none;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.25rem;
  line-height: 1;
  transition: color 0.2s;
}

.toolbar-close:hover {
  color: var(--c-text);
}

/* Mode Buttons */
.toolbar-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  justify-content: center;
}

.toolbar-mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: var(--c-abyss);
  border: 1px solid var(--c-border);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 60px;
}

.toolbar-mode-btn:hover {
  background: var(--c-surface-glow);
  border-color: var(--c-border);
}

.toolbar-mode-btn.active {
  background: var(--c-accent-glow);
  border-color: var(--c-accent);
  color: var(--c-accent);
}

.mode-icon {
  font-size: 1.25rem;
}

.mode-label {
  font-size: 0.65rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.toolbar-mode-btn.active .mode-label {
  color: var(--c-accent);
}

/* Toolbar Actions */
.toolbar-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--c-border);
  justify-content: flex-end;
}

/* Toolbar Hint */
.toolbar-hint {
  padding: 0.5rem 1rem;
  background: var(--c-abyss);
  border-radius: 0 0 0.75rem 0.75rem;
  text-align: center;
}

#selection-hint {
  font-size: 0.75rem;
  color: var(--c-text-muted);
}

/* Loading state */
.area-selection-toolbar.loading {
  pointer-events: none;
  opacity: 0.7;
}

.area-selection-toolbar.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--c-overlay);
  border-radius: 0.75rem;
}

/* ===========================================
   SELECTION PANEL
   =========================================== */

.area-selection-panel {
  position: absolute;
  top: 5rem;
  right: 1rem;
  width: 320px;
  max-width: calc(100vw - 2rem);
  background: var(--c-depth);
  border: 1px solid var(--c-border);
  border-radius: 0.75rem;
  z-index: 1200;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 8rem);
  animation: panelSlideIn 0.3s ease;
}

@keyframes panelSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--c-border);
}

.panel-header h3 {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-text);
}

.panel-close {
  background: none;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.25rem;
  line-height: 1;
}

.panel-close:hover {
  color: var(--c-text);
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.panel-footer {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--c-border);
  justify-content: flex-end;
}

/* Selection Summary */
.selection-summary {
  margin-bottom: 1rem;
}

.no-selection {
  color: var(--c-text-muted);
  font-style: italic;
  text-align: center;
  padding: 1rem;
}

.selection-type {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--c-accent);
  margin-bottom: 0.5rem;
}

.selection-detail {
  font-size: 0.8rem;
  color: var(--c-text-soft);
  padding: 0.25rem 0;
}

/* Composite Selections */
.selection-composite {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--c-border);
}

.selection-composite h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: 0.5rem;
}

.composite-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.composite-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.375rem 0.5rem;
  background: var(--c-abyss);
  border-radius: 0.375rem;
  font-size: 0.8rem;
}

.remove-composite {
  background: none;
  border: none;
  color: var(--c-text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.25rem;
}

.remove-composite:hover {
  color: var(--c-danger);
}

/* Impact Preview */
.impact-preview {
  margin-bottom: 1rem;
}

.impact-preview h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: 0.5rem;
}

.impact-levels {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.impact-level {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0;
}

.impact-color {
  width: 1rem;
  height: 1rem;
  border-radius: 0.25rem;
  flex-shrink: 0;
}

.impact-label {
  font-size: 0.75rem;
  color: var(--c-text-soft);
  flex: 1;
}

.impact-stats {
  font-size: 0.7rem;
  color: var(--c-text-muted);
  font-family: var(--font-mono);
}

.impact-toggles {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--c-border);
}

.impact-toggles label:first-child {
  font-size: 0.7rem;
  color: var(--c-text-muted);
}

.impact-toggle {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  cursor: pointer;
}

.impact-toggle input {
  width: 0.875rem;
  height: 0.875rem;
}

.impact-toggle span {
  font-size: 0.7rem;
  color: var(--c-text-muted);
}

/* Selection Context */
.selection-context h4 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--c-text-muted);
  margin-bottom: 0.5rem;
}

.context-data {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.context-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

.context-label {
  color: var(--c-text-soft);
}

.context-value {
  color: var(--c-text);
  font-weight: 500;
}

.context-data .loading,
.context-data .error {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  font-style: italic;
  text-align: center;
  padding: 0.5rem;
}

/* ===========================================
   MAP ELEMENTS
   =========================================== */

/* Selection marker */
.selection-marker {
  background: transparent;
}

.marker-pulse {
  width: 20px;
  height: 20px;
  background: var(--c-accent);
  border-radius: 50%;
  position: relative;
}

.marker-pulse::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  background: var(--c-accent);
  border-radius: 50%;
  animation: pulse 1.5s ease-out infinite;
}

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

/* Impact level circles */
.impact-level-1 { z-index: 405; }
.impact-level-2 { z-index: 404; }
.impact-level-3 { z-index: 403; }
.impact-level-4 { z-index: 402; }
.impact-level-5 { z-index: 401; }

/* Impact popup */
.impact-popup {
  font-size: 0.8rem;
  line-height: 1.4;
}

.impact-popup strong {
  color: var(--c-accent);
}

/* ===========================================
   LEAFLET DRAW OVERRIDES
   =========================================== */

.leaflet-draw-toolbar a {
  background-color: var(--c-depth) !important;
  border-color: var(--c-border) !important;
}

.leaflet-draw-toolbar a:hover {
  background-color: var(--c-surface-glow) !important;
}

.leaflet-draw-actions {
  background: var(--c-depth) !important;
  border-color: var(--c-border) !important;
}

.leaflet-draw-actions a {
  background-color: var(--c-depth) !important;
  color: var(--c-text) !important;
}

.leaflet-draw-actions a:hover {
  background-color: var(--c-surface-glow) !important;
}

/* ===========================================
   RESPONSIVE
   =========================================== */

@media (max-width: 768px) {
  .area-selection-btn {
    bottom: 1rem;
    padding: 0.625rem 1rem;
    font-size: 0.8125rem;
  }

  .area-selection-btn svg {
    width: 1rem;
    height: 1rem;
  }

  .area-selection-toolbar {
    top: auto;
    bottom: 1rem;
    left: 0.5rem;
    right: 0.5rem;
    transform: none;
    max-width: none;
  }

  .toolbar-modes {
    justify-content: space-between;
  }

  .toolbar-mode-btn {
    flex: 1;
    min-width: auto;
    max-width: 60px;
  }

  .area-selection-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: none;
    border-radius: 1rem 1rem 0 0;
    max-height: 50vh;
  }
}
