* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0a0e1a;
  color: #e0e0e0;
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */

#sidebar {
  width: 280px;
  min-width: 280px;
  height: 100vh;
  background: #0d1117;
  border-right: 1px solid rgba(255,255,255,0.06);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-header {
  padding: 14px 18px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  height: 28px;
  width: auto;
}

.sidebar-header .subtitle {
  font-size: 11px;
  color: #EBCA9C;
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* Search */
#search-container {
  position: relative;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

#search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

#search-input:focus { border-color: rgba(127, 168, 201, 0.5); }
#search-input::placeholder { color: rgba(176, 184, 196, 0.4); }

#search-results {
  position: absolute;
  top: 100%;
  left: 14px;
  right: 14px;
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  margin-top: 2px;
  max-height: 220px;
  overflow-y: auto;
  display: none;
  z-index: 30;
}

#search-results.visible { display: block; }

.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.search-recent-header {
  padding: 6px 12px 4px;
  font-size: 9px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.search-result-item:hover { background: rgba(127, 168, 201, 0.1); }
.search-result-item .place-name { color: #ddd; }
.search-result-item .place-context { color: #8893A0; font-size: 11px; margin-top: 1px; }

/* Sidebar sections */
.sidebar-section {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-section h3 {
  font-size: 10px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

/* Collapsible sections */
h3.collapsible {
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

h3.collapsible::before {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #EBCA9C;
  transition: transform 0.2s;
}

h3.collapsible.collapsed::before {
  transform: rotate(-90deg);
}

.collapsible-content {
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.collapsible-content.collapsed {
  max-height: 0 !important;
  overflow: hidden;
}

/* Checkbox filters */
.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  font-size: 12px;
  color: #aab;
  transition: color 0.1s;
}

.filter-item:hover { color: #fff; }

.filter-item input[type="checkbox"] {
  accent-color: #7FA8C9;
  flex-shrink: 0;
}

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

.filter-toggle-all {
  font-size: 11px;
  color: #7FA8C9;
  cursor: pointer;
  margin-bottom: 6px;
  display: inline-block;
}

.filter-toggle-all:hover { color: #A4C4DE; }

/* Overlay toggles */
.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  cursor: pointer;
  color: #aab;
  font-size: 12px;
}

.sidebar-toggle:hover { color: #fff; }
.sidebar-toggle input[type="checkbox"] { accent-color: #7FA8C9; }

.zoom-hint {
  color: rgba(176, 184, 196, 0.4);
  font-size: 10px;
}

/* Stats */
.sidebar-stats {
  font-size: 12px;
  color: #8893A0;
  margin-top: auto;
}

.sidebar-stats strong { color: #B0B8C4; }

.stat-detail {
  margin-top: 4px;
  font-size: 11px;
  color: #606A78;
  line-height: 1.5;
}

/* --- Map --- */

#map {
  flex: 1;
  height: 100vh;
}

/* --- Popups --- */

.mapboxgl-popup-content {
  background: rgba(13, 17, 23, 0.96) !important;
  color: #e0e0e0 !important;
  border-radius: 8px !important;
  padding: 14px 16px !important;
  border: 1px solid rgba(201, 158, 80, 0.2) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
  max-width: 320px !important;
  font-size: 13px !important;
}

.mapboxgl-popup-close-button {
  color: #8893A0 !important;
  font-size: 18px !important;
  right: 6px !important;
  top: 4px !important;
}

.mapboxgl-popup-close-button:hover { color: #fff !important; }

.mapboxgl-popup-tip {
  border-top-color: rgba(13, 17, 23, 0.96) !important;
}

.popup-title {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
  margin-bottom: 2px;
  padding-right: 16px;
}

.popup-subtitle {
  font-size: 12px;
  color: #B0B8C4;
  margin-bottom: 8px;
}

.popup-field {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.popup-label {
  color: #EBCA9C;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  min-width: 65px;
  flex-shrink: 0;
}

.popup-value { color: #ccd; }

.popup-link {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 10px;
  background: rgba(127, 168, 201, 0.12);
  color: #7FA8C9;
  border-radius: 4px;
  text-decoration: none;
  font-size: 11px;
  transition: background 0.15s;
}

.popup-link:hover { background: rgba(127, 168, 201, 0.25); }

/* --- Mobile top bar --- */

#mobile-bar {
  display: none;
}

#sidebar-overlay {
  display: none;
}

.sidebar-close-btn {
  display: none;
}

.mobile-btn {
  background: none;
  border: none;
  color: #B0B8C4;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-btn.sidebar-close-btn {
  display: none;
}

.mobile-btn:hover { background: rgba(127, 168, 201, 0.1); }

/* --- Mobile search panel --- */

#mobile-search-panel {
  display: none;
}

#mobile-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: rgba(255,255,255,0.04);
  color: #fff;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

#mobile-search-input:focus { border-color: rgba(127, 168, 201, 0.5); }
#mobile-search-input::placeholder { color: rgba(176, 184, 196, 0.4); }

#mobile-search-results {
  background: #161b22;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  margin-top: 4px;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}

#mobile-search-results.visible { display: block; }

/* --- Responsive: screens under 768px --- */

@media (max-width: 768px) {
  body {
    flex-direction: column;
  }

  #mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #0d1117;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    z-index: 20;
    height: 48px;
    flex-shrink: 0;
  }

  .mobile-logo {
    height: 24px;
    width: auto;
  }

  .mobile-actions {
    display: flex;
    align-items: center;
    gap: 4px;
  }

  #mobile-search-panel {
    position: absolute;
    top: 48px;
    left: 0;
    right: 0;
    z-index: 25;
    background: #0d1117;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
  }

  #mobile-search-panel.visible {
    display: block;
  }

  #mobile-search-panel #search-results {
    left: 12px;
    right: 12px;
  }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 300px;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 40;
    overflow-y: auto;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  /* Hide the search inside sidebar on mobile — it's in the top bar */
  #sidebar #search-container {
    display: none;
  }

  .sidebar-close-btn {
    display: flex;
    margin-left: auto;
  }

  #sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 35;
  }

  #sidebar-overlay.visible {
    display: block;
  }

  #map {
    height: calc(100vh - 48px);
  }

  .modal-content {
    width: 95vw !important;
    max-width: 95vw !important;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
  }

  .form-field.span-2 {
    grid-column: 1 !important;
  }

  .pill-dropdown {
    max-height: 150px;
  }
}

/* --- Intake Form Modal --- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  justify-content: center;
  align-items: flex-start;
  padding: 40px 20px;
  overflow-y: auto;
}

.modal-overlay.visible {
  display: flex;
}

.modal-content {
  background: #0d1117;
  border: 1px solid rgba(201, 158, 80, 0.2);
  border-radius: 10px;
  width: 680px;
  max-width: 100%;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
  margin-bottom: 40px;
  flex-shrink: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.modal-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #8893A0;
  font-size: 22px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.modal-close-btn:hover { color: #fff; background: rgba(255,255,255,0.06); }

.modal-body {
  padding: 8px 20px 16px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.form-section {
  margin-bottom: 16px;
}

.form-section h4 {
  font-size: 10px;
  font-weight: 600;
  color: #EBCA9C;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(235, 202, 156, 0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

.form-field.span-2 {
  grid-column: 1 / -1;
}

.form-field label {
  display: block;
  font-size: 11px;
  color: #B0B8C4;
  margin-bottom: 4px;
}

.field-hint {
  color: #606A78;
  font-size: 10px;
  font-weight: 400;
}

.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: rgba(127, 168, 201, 0.5);
}

.form-field select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.form-field textarea {
  resize: vertical;
  min-height: 60px;
}

/* Flatpickr overrides */
.flatpickr-calendar {
  background: #161b22 !important;
  border-color: rgba(201, 158, 80, 0.2) !important;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5) !important;
}

.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months {
  background: #161b22 !important;
  color: #e0e0e0 !important;
}

.flatpickr-current-month input.cur-year { color: #e0e0e0 !important; }
.flatpickr-months .flatpickr-prev-month, .flatpickr-months .flatpickr-next-month { fill: #B0B8C4 !important; }
.flatpickr-months .flatpickr-prev-month:hover, .flatpickr-months .flatpickr-next-month:hover { fill: #EBCA9C !important; }
span.flatpickr-weekday { color: #EBCA9C !important; font-size: 10px !important; }
.flatpickr-day { color: #ccc !important; border-radius: 4px !important; }
.flatpickr-day:hover { background: rgba(127, 168, 201, 0.15) !important; border-color: transparent !important; }
.flatpickr-day.selected { background: rgba(201, 158, 80, 0.8) !important; border-color: transparent !important; color: #0d1117 !important; }
.flatpickr-day.today { border-color: rgba(127, 168, 201, 0.4) !important; }

.form-field input.flatpickr-input[readonly] {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.04);
}

/* Job type pill multi-select */
.pill-select {
  position: relative;
}

.pill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 34px;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.04);
  cursor: text;
  transition: border-color 0.2s;
}

.pill-tags.focused { border-color: rgba(127, 168, 201, 0.5); }
.pill-tags.empty::before {
  content: 'Select job types...';
  color: rgba(176, 184, 196, 0.4);
  font-size: 13px;
  line-height: 24px;
}

.pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(127, 168, 201, 0.15);
  border: 1px solid rgba(127, 168, 201, 0.25);
  border-radius: 12px;
  font-size: 11px;
  color: #B0B8C4;
  white-space: nowrap;
}

.pill-tag .pill-x {
  cursor: pointer;
  color: #8893A0;
  font-size: 13px;
  line-height: 1;
  margin-left: 2px;
}

.pill-tag .pill-x:hover { color: #e74c6f; }

.pill-search {
  border: none;
  background: none;
  color: #fff;
  font-size: 12px;
  outline: none;
  flex: 1;
  min-width: 80px;
  padding: 2px 0;
}

.pill-search::placeholder { color: rgba(176, 184, 196, 0.3); }

.pill-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 2px;
  background: #161b22;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  max-height: 180px;
  overflow-y: auto;
  z-index: 110;
}

.pill-dropdown.open { display: block; }

.pill-option {
  padding: 6px 10px;
  font-size: 12px;
  color: #aab;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.pill-option:hover { background: rgba(127, 168, 201, 0.1); color: #fff; }
.pill-option.selected { color: #606A78; }
.pill-option.hidden { display: none; }

/* Buttons */
.btn-cancel {
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  background: transparent;
  color: #B0B8C4;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-cancel:hover { border-color: rgba(255,255,255,0.2); color: #fff; }

.btn-submit {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  background: rgba(201, 158, 80, 0.9);
  color: #0d1117;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-submit:hover { background: rgba(201, 158, 80, 1); }
.btn-submit:disabled { opacity: 0.5; cursor: not-allowed; }

/* Error / Success states */
.intake-error {
  margin: 0 20px;
  padding: 8px 12px;
  background: rgba(231, 76, 111, 0.15);
  border: 1px solid rgba(231, 76, 111, 0.3);
  border-radius: 6px;
  color: #e74c6f;
  font-size: 12px;
}

.intake-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}

.intake-success svg { margin-bottom: 16px; }
.intake-success h3 { font-size: 18px; color: #fff; margin-bottom: 6px; }
.intake-success p { font-size: 13px; color: #B0B8C4; }

/* Quote button in parcel popup */
.intake-btn {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 10px;
  padding: 6px 12px;
  background: rgba(201, 158, 80, 0.15);
  color: #C99E50;
  border: 1px solid rgba(201, 158, 80, 0.3);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
}

.intake-btn:hover {
  background: rgba(201, 158, 80, 0.3);
  color: #EBCA9C;
}
