/* ============================================================
   select.css  --  Map-based land selection page
   Full-page map layout with right sidebar
   ============================================================ */

/* ---- Page Layout ---- */

.select-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px); /* below navbar */
  overflow: hidden;
  background: var(--bg, #f5f7fa);
}

.select-page__search {
  position: relative;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: var(--card, #ffffff);
  border-bottom: 1px solid var(--border, #e2e8f0);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.select-page__search-input {
  flex: 1;
  height: 44px;
  padding: 0 1rem;
  font-size: 0.95rem;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 22px;
  background: var(--bg, #f5f7fa);
  color: var(--text, #1a202c);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.select-page__search-input::placeholder {
  color: var(--text-muted, #718096);
}

.select-page__search-input:focus {
  border-color: var(--accent, #3182ce);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.12);
}

.select-page__search-btn {
  flex-shrink: 0;
  height: 44px;
  padding: 0 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent, #3182ce);
  border: none;
  border-radius: 22px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

.select-page__search-btn:hover {
  background: #2b6cb0;
}

.select-page__search-btn:active {
  transform: scale(0.97);
}

.select-page__layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.select-page__map {
  flex: 1;
  position: relative;
  min-height: calc(100vh - 64px - 66px); /* minus navbar + search */
  background: var(--bg, #f5f7fa);
}

.select-page__map--loading::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 600;
  background: rgba(255, 255, 255, 0.65);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.select-page__sidebar {
  width: 380px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--card, #ffffff);
  border-left: 1px solid var(--border, #e2e8f0);
  overflow-y: auto;
  overflow-x: hidden;
}


/* ---- Search Results Dropdown ---- */

.select-search__results {
  position: absolute;
  top: 100%;
  left: 1rem;
  right: 1rem;
  z-index: 900;
  max-height: 320px;
  overflow-y: auto;
  background: var(--card, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  margin-top: 4px;
}

.select-search__item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border, #e2e8f0);
}

.select-search__item:last-child {
  border-bottom: none;
}

.select-search__item:hover {
  background: var(--bg, #f5f7fa);
}

.select-search__item-icon {
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
  font-size: 1rem;
  color: var(--accent, #3182ce);
}

.select-search__item-text {
  font-size: 0.9rem;
  color: var(--text, #1a202c);
  line-height: 1.4;
}

.select-search__no-result {
  padding: 1.25rem 1rem;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted, #718096);
}


/* ---- Sidebar Content ---- */

.select-sidebar__mode {
  display: flex;
  gap: 0;
  margin: 0.75rem 1rem;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
}

.select-sidebar__mode-btn {
  flex: 1;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  text-align: center;
  color: var(--text-muted, #718096);
  background: var(--card, #ffffff);
  border: none;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.select-sidebar__mode-btn:not(:last-child) {
  border-right: 1px solid var(--border, #e2e8f0);
}

.select-sidebar__mode-btn:hover {
  background: var(--bg, #f5f7fa);
}

.select-sidebar__mode-btn--active {
  color: #fff;
  background: var(--accent, #3182ce);
}

.select-sidebar__mode-btn--active:hover {
  background: #2b6cb0;
}

.select-sidebar__empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted, #718096);
  font-size: 0.9rem;
  line-height: 1.6;
}

.select-sidebar__warn-title {
  padding: 0.75rem 1rem 0.25rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted, #718096);
}


/* ---- Parcel Cards ---- */

.select-parcel {
  margin: 0.5rem 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--card, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.select-parcel:hover {
  border-color: var(--accent, #3182ce);
  box-shadow: 0 2px 8px rgba(49, 130, 206, 0.1);
}

.select-parcel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.select-parcel__lot {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text, #1a202c);
}

.select-parcel__remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-muted, #718096);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.select-parcel__remove:hover {
  background: #fed7d7;
  color: #c53030;
}

.select-parcel__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted, #718096);
  margin-bottom: 0.4rem;
}

.select-parcel__tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent, #3182ce);
  background: rgba(49, 130, 206, 0.1);
  border-radius: 999px;
}

.select-parcel__inclusion {
  font-size: 0.82rem;
  color: var(--text-muted, #718096);
}

.select-parcel__warning {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding: 0.5rem 0.65rem;
  font-size: 0.8rem;
  border-radius: 6px;
  border-left: 3px solid var(--border, #e2e8f0);
  background: var(--bg, #f5f7fa);
  color: var(--text, #1a202c);
}

.select-parcel__warning--high {
  border-left-color: #e53e3e;
  background: #fff5f5;
}

.select-parcel__warning--medium {
  border-left-color: #dd6b20;
  background: #fffaf0;
}

.select-parcel__warning--low {
  border-left-color: #3182ce;
  background: #ebf8ff;
}

.select-parcel__warning-icon {
  flex-shrink: 0;
  font-size: 0.9rem;
  line-height: 1;
}


/* ---- Standalone Warnings ---- */

.select-warning {
  margin: 0.5rem 0.75rem;
  padding: 0.65rem 0.85rem;
  font-size: 0.82rem;
  border-radius: 8px;
  border-left: 3px solid var(--border, #e2e8f0);
  background: var(--bg, #f5f7fa);
  color: var(--text, #1a202c);
}

.select-warning--high {
  border-left-color: #e53e3e;
  background: #fff5f5;
}

.select-warning--medium {
  border-left-color: #dd6b20;
  background: #fffaf0;
}

.select-warning--low {
  border-left-color: #3182ce;
  background: #ebf8ff;
}


/* ---- Summary & Actions ---- */

.select-sidebar__summary {
  position: sticky;
  bottom: 0;
  padding: 0.85rem 1rem;
  background: var(--card, #ffffff);
  border-top: 1px solid var(--border, #e2e8f0);
  font-size: 0.85rem;
  color: var(--text-muted, #718096);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
}

.select-sidebar__summary strong {
  color: var(--text, #1a202c);
  font-weight: 700;
}

#startAnalysisBtn {
  display: block;
  width: calc(100% - 1.5rem);
  margin: 0.75rem auto;
  padding: 0.85rem 1.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent, #3182ce);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(49, 130, 206, 0.25);
}

#startAnalysisBtn:hover {
  background: #2b6cb0;
  box-shadow: 0 4px 14px rgba(49, 130, 206, 0.35);
}

#startAnalysisBtn:active {
  transform: scale(0.98);
}

#startAnalysisBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}


/* ---- Draw Mode ---- */

.select-draw__info {
  margin: 0.5rem 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(49, 130, 206, 0.06);
  border: 1px dashed var(--accent, #3182ce);
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--text, #1a202c);
  line-height: 1.5;
}

.select-draw__area {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text, #1a202c);
  margin-top: 0.25rem;
}

.select-draw__count {
  font-size: 0.82rem;
  color: var(--text-muted, #718096);
  margin-top: 0.15rem;
}


/* ---- Business Type Modal ---- */

.select-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.select-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

.select-modal__content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--card, #ffffff);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: selectModalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes selectModalIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.select-modal__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.select-modal__option {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 1rem;
  background: var(--bg, #f5f7fa);
  border: 2px solid var(--border, #e2e8f0);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  font-size: 0.9rem;
  color: var(--text, #1a202c);
}

.select-modal__option:hover {
  border-color: var(--accent, #3182ce);
  background: rgba(49, 130, 206, 0.04);
}

.select-modal__option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border, #e2e8f0);
  border-radius: 4px;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.select-modal__option input[type="checkbox"]:checked {
  background: var(--accent, #3182ce);
  border-color: var(--accent, #3182ce);
}

.select-modal__option input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.select-modal__option:has(input:checked) {
  border-color: var(--accent, #3182ce);
  background: rgba(49, 130, 206, 0.06);
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}


/* ---- Leaflet Overrides ---- */

.leaflet-container {
  font-family: inherit;
}

.leaflet-control-zoom a {
  background: var(--card, #ffffff) !important;
  color: var(--text, #1a202c) !important;
  border-color: var(--border, #e2e8f0) !important;
  transition: background 0.15s;
}

.leaflet-control-zoom a:hover {
  background: var(--bg, #f5f7fa) !important;
}

.select-page__map--dark .leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.85);
}


/* ---- Responsive (Mobile) ---- */

@media (max-width: 768px) {
  .select-page {
    height: 100vh;
    height: 100dvh;
  }

  .select-page__layout {
    flex-direction: column;
    position: relative;
  }

  .select-page__sidebar {
    width: 100%;
    max-height: 40vh;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-left: none;
    border-top: 1px solid var(--border, #e2e8f0);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
  }

  .select-page__map {
    height: 60vh;
    min-height: auto;
  }

  .select-page__search-input {
    height: 40px;
    font-size: 0.88rem;
  }

  .select-page__search-btn {
    height: 40px;
    padding: 0 1rem;
    font-size: 0.85rem;
  }

  .select-modal__grid {
    grid-template-columns: 1fr;
  }

  .select-modal__content {
    padding: 1.25rem;
    max-height: 90vh;
  }
}


/* ---- Print ---- */

@media print {
  .select-page {
    display: none;
  }
}
