/* Map page layout — full-screen shell with left filter panel */

/* Prevent body scroll; map fills the viewport */
.map-body {
  overflow: hidden;
  height: 100vh;
}

.map-shell {
  display: flex;
  height: 100vh;
  padding-top: 64px; /* nav height */
}

/* ── FILTER PANEL ─────────────────────────────────────────────────── */
.map-panel {
  width: 280px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.panel-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
}

.panel-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.label-mark {
  font-size: 0.55rem;
}

.panel-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1.1;
  margin-bottom: 0.6rem;
}

.panel-counter {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.panel-counter strong {
  color: var(--text);
}

/* ── FILTERS ──────────────────────────────────────────────────────── */
.panel-filters {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.filter-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.filter-select {
  width: 100%;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.45rem 0.7rem;
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.82rem;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a8075'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
  cursor: pointer;
  transition: border-color 0.15s;
}

.filter-select:focus {
  outline: none;
  border-color: var(--accent-dim);
}

.filter-apply {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 0.55rem 1rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.15s;
}

.filter-apply:hover { opacity: 0.85; }

.filter-reset {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s;
}

.filter-reset:hover { color: var(--text); }

/* ── LEGEND ───────────────────────────────────────────────────────── */
.panel-legend {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.legend-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── PANEL FOOTER ─────────────────────────────────────────────────── */
.panel-footer {
  padding: 1.25rem 1.5rem;
  margin-top: auto;
}

.panel-link {
  font-size: 0.8rem;
  color: var(--accent);
  text-decoration: none;
  transition: opacity 0.15s;
}

.panel-link:hover { opacity: 0.75; }

/* ── MAP CANVAS ───────────────────────────────────────────────────── */
.map-canvas {
  flex: 1;
  min-width: 0;
}

/* ── ASSET MARKERS ────────────────────────────────────────────────── */
.asset-marker {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--dot-color, #e8760a);
  border: 2px solid rgba(255,255,255,0.3);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 0 0 rgba(255,255,255,0.1);
}

.asset-marker:hover {
  transform: scale(1.5);
  box-shadow: 0 0 8px var(--dot-color, #e8760a);
  border-color: rgba(255,255,255,0.7);
  z-index: 10;
}

.asset-marker--inactive {
  opacity: 0.55;
  border-style: dashed;
}

/* ── POPUP STYLES ─────────────────────────────────────────────────── */
.maplibregl-popup-content {
  background: #12141a !important;
  border: 1px solid #22252c !important;
  border-radius: 4px !important;
  padding: 0 !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.6) !important;
  font-family: 'Instrument Sans', sans-serif !important;
}

.maplibregl-popup-close-button {
  color: #8a8075 !important;
  font-size: 1.1rem !important;
  padding: 0.2rem 0.5rem !important;
}

.maplibregl-popup-tip {
  border-top-color: #22252c !important;
}

.map-popup {
  padding: 0.9rem 1rem;
  min-width: 200px;
}

.popup-commodity {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.5rem;
  border-radius: 2px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ede4d6;
  margin-bottom: 0.6rem;
}

.popup-commodity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.popup-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: #ede4d6;
  margin-bottom: 0.35rem;
  line-height: 1.2;
}

.popup-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
}

.popup-type {
  font-size: 0.72rem;
  color: #8a8075;
  text-transform: capitalize;
}

.popup-status {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
}

.popup-status--producing { background: rgba(61,186,84,0.15); color: #3dba54; }
.popup-status--development { background: rgba(74,144,217,0.15); color: #4a90d9; }
.popup-status--exploration { background: rgba(245,210,75,0.15); color: #f5d24b; }
.popup-status--care_and_maintenance { background: rgba(232,118,10,0.15); color: #e8760a; }
.popup-status--closed { background: rgba(138,128,117,0.15); color: #8a8075; }

.popup-operator {
  font-size: 0.78rem;
  color: #8a8075;
  margin-bottom: 0.2rem;
}

.popup-company-link {
  color: #c97a2a;
  text-decoration: none;
}

.popup-company-link:hover { text-decoration: underline; }

.popup-location {
  font-size: 0.75rem;
  color: #4a4540;
  margin-bottom: 0.3rem;
}

.popup-source {
  margin-top: 0.4rem;
}

.popup-source-link {
  font-size: 0.72rem;
  color: #4a90d9;
  text-decoration: none;
}

.popup-source-link:hover { text-decoration: underline; }

/* ── RESPONSIVE — collapse panel on mobile ──────────────────────── */
@media (max-width: 680px) {
  .map-shell { flex-direction: column; }
  .map-panel {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .map-canvas { flex: 1; }
}

/* ── NEW: Map area (map + search bar wrapper) ────────────────────── */
.map-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ── Global search bar ────────────────────────────────────────────── */
.map-search-bar {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  max-width: 480px;
}

.search-input-wrap:focus-within {
  border-color: var(--accent-dim);
}

.search-icon { flex-shrink: 0; }

.global-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: 'Instrument Sans', sans-serif;
  font-size: 0.85rem;
  min-width: 0;
}

.global-search-input::placeholder { color: var(--text-muted); }

.search-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  flex-shrink: 0;
}

/* Global search dropdown */
.global-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 1rem;
  right: 1rem;
  max-width: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  overflow: hidden;
  z-index: 30;
}

.global-search-section { border-bottom: 1px solid var(--border); }
.global-search-section:last-child { border-bottom: none; }

.gs-section-label, .autocomplete-section-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem 0.25rem;
}

.gs-results, .autocomplete-results { padding-bottom: 0.25rem; }

.gs-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: background 0.12s;
}

.gs-item:hover { background: var(--surface2); }

.gs-ticker {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
  min-width: 40px;
  flex-shrink: 0;
}

.gs-name {
  font-size: 0.82rem;
  color: var(--text);
  flex: 1;
}

.gs-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.gs-empty {
  padding: 0.75rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── Autocomplete (company search) ────────────────────────────────── */
.autocomplete-wrapper {
  position: relative;
}

.autocomplete-input {
  width: 100%;
}

.autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  max-height: 220px;
  overflow-y: auto;
  z-index: 20;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.6rem;
  cursor: pointer;
  transition: background 0.12s;
}

.autocomplete-item:hover { background: var(--surface2); }

.autocomplete-ticker {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 36px;
  flex-shrink: 0;
}

.autocomplete-name { font-size: 0.8rem; color: var(--text); }

/* ── Checkbox filters ─────────────────────────────────────────────── */
.filter-group { display: flex; flex-direction: column; gap: 0.25rem; }

.filter-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.filter-selection {
  font-size: 0.72rem;
  color: var(--accent);
  font-weight: 600;
}

.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.scrollable-list {
  max-height: 140px;
  overflow-y: auto;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  cursor: pointer;
  font-size: 0.78rem;
  color: var(--text-muted);
  transition: color 0.12s;
}

.checkbox-item:hover { color: var(--text); }

.filter-cb { display: none; }

.cb-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cb-dot--neutral { background: var(--text-muted); }

.cb-dot--status {
  background: transparent;
  border: 1.5px solid;
}
.cb-dot--producing         { border-color: #3dba54; }
.cb-dot--development       { border-color: #4a90d9; }
.cb-dot--exploration       { border-color: #f5d24b; }
.cb-dot--care_and_maintenance { border-color: #e8760a; }
.cb-dot--closed            { border-color: #8a8075; }

/* When checked, change text color */
.filter-cb:checked + .cb-dot + span,
.filter-cb:checked ~ span { color: var(--text); }

/* Use adjacent sibling — but we need to style via JS or CSS nth — using JS instead */
.checkbox-item:has(.filter-cb:checked) span:last-child { color: var(--text); }

/* ── Clear all button ─────────────────────────────────────────────── */
.btn-clear-all {
  margin-top: 0.5rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.35rem 0.75rem;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  width: 100%;
}

.btn-clear-all:hover { color: var(--text); border-color: var(--text-muted); }

/* ── Cluster markers ───────────────────────────────────────────────── */
.cluster-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cluster-color, #e8760a);
  border: 2px solid rgba(255,255,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  color: #12141a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  transition: transform 0.15s;
  z-index: 5;
}

.cluster-marker:hover { transform: scale(1.2); }

.cluster-popup { padding: 0.75rem; }
.cluster-count {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #ede4d6;
  margin-bottom: 0.4rem;
}
.cluster-commodities { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.4rem; }
.cluster-commodity { font-size: 0.75rem; font-family: 'Barlow Condensed', sans-serif; }
.cluster-zoom-hint { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Panel filters padding fix ───────────────────────────────────── */
.panel-filters {
  padding: 1rem 1.25rem;
}
