/* ==================== MAP-2D.CSS ==================== */
/* 2D map specific styles including map sections, search panel, layer panel, basemap, measurement, feature panel, legend, and popup styles */

/* Map Sections */
.map-section {
  height: calc(100vh - 80px);
  position: relative;
  background: var(--navy-darker);
}

.map-container {
  height: 100%;
  width: 100%;
}

.map-toolbar {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 100;
  background: var(--white);
  border-radius: 12px;
  padding: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.map-toolbar button {
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--navy);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.map-toolbar button:hover {
  background: linear-gradient(135deg, var(--cyan), var(--teal));
  color: var(--white);
  transform: scale(1.05);
}

.map-toolbar .divider {
  height: 1px;
  background: var(--gray-100);
  margin: 4px 0;
}

/* Active button state */
.map-toolbar button.active {
  background: var(--cyan);
  color: var(--white);
}

.measure-btn.active {
  background: var(--cyan) !important;
  color: var(--white) !important;
}

/* Map Legend */
.map-legend {
  position: absolute;
  bottom: 30px;
  left: 20px;
  z-index: 100;
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
  min-width: 220px;
}

.map-legend h4 {
  font-family: 'Cairo', sans-serif;
  color: var(--navy);
  margin-bottom: 16px;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-legend h4 i {
  color: var(--cyan);
}

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.legend-header h4 {
  margin-bottom: 0;
}

.legend-header button {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--off-white);
  border-radius: 8px;
  cursor: pointer;
  color: var(--navy);
  transition: all 0.2s ease;
}

.legend-header button:hover {
  background: var(--cyan);
  color: var(--white);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-color {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
}

/* Enhanced Legend Symbols */
.legend-symbol {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-symbol.well-production {
  background: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.3);
}

.legend-symbol.well-injection {
  background: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 180, 216, 0.3);
  border-radius: 2px;
  transform: rotate(45deg);
}

.legend-symbol.well-maintenance {
  background: var(--orange);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

.legend-symbol.facility {
  background: var(--red);
  border-radius: 3px;
  width: 14px;
  height: 14px;
}

.legend-line {
  width: 30px;
  height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-line.pipeline {
  background: var(--green);
}

.legend-line.pipeline-gas {
  background: var(--orange);
}

.legend-area {
  width: 20px;
  height: 14px;
  border: 2px dashed var(--purple);
  background: rgba(124, 58, 237, 0.1);
  border-radius: 3px;
  flex-shrink: 0;
}

.legend-area.concession {
  border-color: var(--purple);
}

/* Search Panel */
.search-panel {
  position: absolute;
  top: 20px;
  left: 80px;
  z-index: 150;
  background: var(--white);
  border-radius: 12px;
  padding: 0;
  box-shadow: var(--shadow-lg);
  width: 320px;
  display: none;
  overflow: hidden;
}

.search-panel.active {
  display: block;
  animation: slideIn 0.3s ease;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  gap: 10px;
  cursor: grab;
}

.search-input-wrapper:active {
  cursor: grabbing;
}

.search-input-wrapper i.fa-search {
  color: var(--text-secondary);
}

.search-input-wrapper input {
  flex: 1;
  border: none;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
}

.search-input-wrapper button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}

.search-input-wrapper button:hover {
  color: var(--red);
}

.search-results {
  max-height: 300px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s ease;
  border-bottom: 1px solid var(--gray-100);
}

.search-result-item:hover {
  background: var(--off-white);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item i {
  color: var(--gold);
  font-size: 1.1rem;
}

.search-result-item div {
  flex: 1;
}

.search-result-item strong {
  display: block;
  color: var(--navy);
  font-size: 0.9rem;
}

.search-result-item span {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Layer Panel */
.layer-panel, .layer-panel-3d {
  position: absolute;
  top: 80px;
  right: 20px;
  z-index: 150;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 280px;
  display: none;
  overflow: hidden;
}

.layer-panel.active, .layer-panel-3d.active {
  display: block;
  animation: slideIn 0.3s ease;
}

.layer-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  background: linear-gradient(180deg, var(--white), var(--off-white));
}

.layer-panel-header h4 {
  font-family: 'Cairo', sans-serif;
  color: var(--navy);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.layer-panel-header h4 i {
  color: var(--cyan);
}

.layer-panel-header button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 4px;
}

.layer-panel-header button:hover {
  color: var(--red);
}

.layer-list {
  padding: 16px 20px;
}

.layer-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}

.layer-item:last-child {
  border-bottom: none;
}

.layer-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 0.9rem;
}

.layer-checkbox input {
  display: none;
}

.layer-checkbox .checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--gray-200);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.layer-checkbox input:checked + .checkmark {
  background: var(--cyan);
  border-color: var(--cyan);
}

.layer-checkbox input:checked + .checkmark::after {
  content: '✓';
  color: var(--white);
  font-size: 0.7rem;
  font-weight: bold;
}

.layer-name {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--navy);
}

.layer-count {
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: var(--off-white);
  padding: 2px 8px;
  border-radius: 10px;
}

/* Basemap Section */
.basemap-section {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-100);
}

.basemap-section h5 {
  font-size: 0.85rem;
  color: var(--navy);
  margin-bottom: 12px;
  font-weight: 600;
}

.basemap-options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.basemap-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border: 2px solid transparent;
  border-radius: 8px;
  background: var(--off-white);
  cursor: pointer;
  transition: all 0.2s ease;
}

.basemap-btn img {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
}

.basemap-btn span {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

.basemap-btn:hover {
  border-color: var(--cyan-light);
}

.basemap-btn.active {
  border-color: var(--cyan);
  background: rgba(0, 180, 216, 0.1);
}

/* Measurement Panel */
.measurement-panel {
  position: absolute;
  bottom: 30px;
  left: 260px;
  z-index: 100;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 260px;
  display: none;
}

.measurement-panel.active {
  display: block;
}

.measurement-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
}

.measurement-header h4 {
  font-size: 0.9rem;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 8px;
}

.measurement-header h4 i {
  color: var(--cyan);
}

.measurement-header button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
}

.measurement-result {
  padding: 16px;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.measurement-result strong {
  color: var(--navy);
}

/* Feature Panel */
.feature-panel {
  position: absolute;
  bottom: 30px;
  right: 20px;
  z-index: 100;
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 300px;
  display: none;
}

.feature-panel.active {
  display: block;
}

.feature-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  background: linear-gradient(180deg, var(--navy), var(--navy-light));
  color: var(--white);
  border-radius: 12px 12px 0 0;
}

.feature-panel-header h4 {
  font-family: 'Cairo', sans-serif;
  font-size: 1rem;
}

.feature-panel-header button {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.7);
}

.feature-panel-header button:hover {
  color: var(--white);
}

.feature-panel-content {
  padding: 20px;
}

/* Popup Styles */
.popup-content {
  font-family: 'Cairo', sans-serif;
}

.popup-content p {
  margin: 8px 0;
  font-size: 0.9rem;
}

.popup-content strong {
  color: #00B4D8;
  font-family: 'Cairo', sans-serif;
  font-weight: 600;
}

.map-info-panel {
  position: absolute;
  top: 15px;
  right: 15px;
  z-index: 100;
  background: var(--white);
  border-radius: 10px;
  padding: 10px 12px;
  padding-top: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Drag handle for map-info-panel */
.map-info-panel.draggable-panel::before {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  cursor: grab;
}

.map-info-panel.draggable-panel:active::before {
  cursor: grabbing;
}

.map-info-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 10px;
  border-right: 1px solid var(--gray-100);
}

.map-info-item:last-child {
  border-right: none;
  padding-right: 0;
}

.map-info-item:first-child {
  padding-left: 0;
}

.map-info-item span {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.map-info-item strong {
  font-family: 'Cairo', sans-serif;
  font-size: 0.95rem;
  color: var(--navy);
}

/* ArcGIS Widget Overrides */
.esri-ui-corner .esri-component {
  box-shadow: var(--shadow-md) !important;
  border-radius: 8px !important;
}

.esri-widget--button {
  background: var(--white) !important;
  color: var(--navy) !important;
}

.esri-widget--button:hover {
  background: var(--navy) !important;
  color: var(--gold-light) !important;
}

/* Esri Popup and Feature Widget z-index fix */
.esri-popup,
.esri-popup__main-container,
.esri-features,
.esri-widget--panel {
  z-index: 9999 !important;
}

.esri-popup--is-docked {
  z-index: 9999 !important;
}

/* Hide dock button in popups */
calcite-action[title="Dock"],
calcite-action[aria-label="Dock"],
button[aria-label="Dock"],
calcite-action[data-action-uid*="object"][slot="header-actions-end"] {
  display: none !important;
}

/* Force popup to appear above objects */
.esri-popup--aligned-top-center,
.esri-popup--aligned-bottom-center,
.esri-popup--aligned-bottom-left,
.esri-popup--aligned-bottom-right {
  transform: translateY(-20px) !important;
}
