:root {
  --color-primary-text: #051413;
  --color-primary-dark: #218377;
  --color-primary-light: #c6f1ec;
  --color-background: #ebfaf8;
  --desktop-header-height: 56px;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  color: var(--color-primary-text);
  background: var(--color-background);
}

/* Header styling */
#mainHeader {
  display: flex;
  width: 100%;
  padding: 8px 0;
  min-height: var(--desktop-header-height);
  align-items: center;
  background: var(--color-primary-light);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
}

/* Match EXACT layout of container (2:1 ratio) */
.header-left {
  width: 66.6666%;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  font-size: 20px;
  color: var(--color-primary-dark);
  font-weight: bold;
  min-height: 36px;
}

.header-left-text {
  display: flex;
  align-items: center;
  min-width: 0;
}

.header-title {
  padding-left: 24px;
}

.header-sub-title {
  padding-left: 24px;
  font-size: 16px;
}

.header-right {
  width: 33.3333%;
  padding-right: 15px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  flex-direction: column;
  box-sizing: border-box;
  gap: 6px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  margin-right: 24px;
  flex-shrink: 0;
}

.header-share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--color-primary-dark);
  border-radius: 4px;
  background: #fff;
  color: var(--color-primary-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1.2;
}

.header-share-btn:hover {
  background: #a1e8df;
}

.header-share-icon {
  flex-shrink: 0;
}

.header-left .locale-switch {
  margin-left: 0;
  margin-right: 0;
}

.locale-switch {
  display: flex;
  gap: 0;
  border: 1px solid var(--color-primary-dark);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.locale-btn {
  border: none;
  background: #fff;
  color: var(--color-primary-dark);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 10px;
  cursor: pointer;
  line-height: 1.2;
}

.locale-btn:hover {
  background: #a1e8df;
}

.locale-btn-active {
  background: var(--color-primary-dark);
  color: #fff;
}

.locale-btn-active:hover {
  background: var(--color-primary-dark);
  color: #fff;
}

/* Container & panels */
.app-container {
  display: flex;
  height: calc(100vh - var(--desktop-header-height));
  width: 100%;
  position: relative;
}

#mapContainer {
  display: flex;
  position: relative;
  flex: 2;
  transition: all 0.3s;
}

#mapContainer.map-collapsed {
  flex: 0 0 24px;
}

#mapWrapper {
  width: 100%;
  height: 100%;
  transition: height 0.3s ease;
  overflow: hidden;
  display: block;
}

#mapContainer.map-collapsed #mapWrapper {
  display: none;
}

#map {
  width: 100%;
  height: 100%;
}

#locationPanel {
  flex: 1;
  height: 100%;
  overflow-y: auto;
  padding: 15px;
  box-sizing: border-box;
  background: #fff;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  transition: flex 0.3s, width 0.3s;
}

#locationPanel.map-collapsed {
  flex: 1 1 100%;
}

/* Current City Display */
#currentCityDisplay {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 2px solid var(--color-primary-dark);
  border-radius: 6px;
  background: #fff;
  padding: 0;
  height: 36px;
  box-sizing: border-box;
  width: 100%;
}

.city-label {
  color: var(--color-primary-dark);
  font-weight: bold;
  width: 84px;
  min-width: 84px;
  margin: 0;
  padding: 0 6px;
  box-sizing: border-box;
  text-align: center;
  white-space: nowrap;
  flex: none;
}

#currentCity {
  flex: 1;
  background: var(--color-primary-dark);
  color: #fff;
  font-weight: bold;
  border-radius: none;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  margin: 0;
  line-height: normal;
}

#changeCityBtn {
  flex: none;
  box-sizing: border-box;
  width: 32px;
  min-width: 32px;
  cursor: pointer;
  color: var(--color-primary-dark);
  font-size: 18px;
  line-height: 1;
  padding: 0;
  border-radius: 0px 4px 4px 0px;
  transition: background 0.2s, color 0.2s;
  display: flex;
  justify-content: center;
  height: 100%;
  border-left: 2px solid #fff;
}

#changeCityBtn:not(.is-open) {
  align-items: center;
}

#changeCityBtn.is-open {
  font-size: 26px;
  font-weight: 700;
  align-items: flex-start;
  color: #cc0000;
}

#changeCityBtn:hover {
  background: var(--color-primary-dark);
  color: #fff;
}

#changeCityBtn.is-open:hover {
  color: #cc0000;
}

/* City selector */
.city-selector {
  display: block;
  margin-top: 6px;
  position: relative;
  width: 100%;
  z-index: 1001;
}

#citySearch {
  width: 100%;
  padding: 8px 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-sizing: border-box;
}

#citySearch:focus {
  outline: none;
  border-color: var(--color-primary-dark);
  box-shadow: 0 0 5px rgba(33, 131, 119, 0.3);
}

.city-dropdown {
  position: absolute;
  width: 100%;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid #ddd;
  background: white;
  border-radius: 6px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.city-dropdown-item {
  padding: 8px 10px;
  cursor: pointer;
}

.city-dropdown-item:hover {
  background: #c6f1ec;
}

/* List container DataTable */
#locationList {
  margin-top: 10px;
  width: 100%;
}

/* Ensure table container is responsive */
#locationList .dataTables_wrapper {
  width: 100% !important;
}

/* Custom styles for DataTable rows (active highlight) */
#locationsTable tbody tr.active {
  border: 2px solid #2aa799 !important;
  background-color: #ebfaf8 !important;
}

/* Custom CSS for wrapping */
.dt-wrap {
  white-space: normal !important;
  word-wrap: break-word;
}

.dt-nowrap {
  white-space: nowrap !important;
}

li[data-dt-column="3"] .dtr-title {
  display: none !important;
}

li[data-dt-column="4"]:has(.dtr-data:empty) {
  display: none !important;
}

li[data-dt-column="5"]:has(.dtr-data:empty) {
  display: none !important;
}

li[data-dt-column="6"]:has(.dtr-data:empty) {
  display: none !important;
}

li[data-dt-column="6"] .dtr-title {
  display: none !important;
}

/* Direction button */
.direction-btn {
  background: #fff;
  color: var(--color-primary-dark);
  border: 2px solid var(--color-primary-dark);
  border-radius: 5px;
  padding: 5px 10px;
  cursor: pointer;
  font-weight: normal;
  font-size: 13px;
  flex: 1 1 100%;
  max-width: 150px;
  margin-top: 6px;
  justify-self: start;
}

.direction-btn:hover {
  color: #fff;
  background-color: var(--color-primary-dark) !important;
}

.pics-btn {
  background: #fff;
  color: var(--color-primary-dark);
  border: 2px solid var(--color-primary-dark);
  border-radius: 5px;
  padding: 5px 10px;
  cursor: pointer;
  font-weight: normal;
  font-size: 13px;
  flex: 1 1 100%;
  max-width: 150px;
  margin-top: 6px;
  justify-self: start;
}

.pics-btn .btn-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin-right: 4px;
  background-color: currentColor;
  -webkit-mask: url("./../images/camera-icon.svg") no-repeat center / contain;
  mask: url("./../images/camera-icon.svg") no-repeat center / contain;
}

.pics-btn:hover {
  color: #fff;
  background-color: var(--color-primary-dark) !important;
}

/* Toggle map button */
#mapToggleBtn {
  position: absolute;
  display: flex;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 46px;
  background: var(--color-primary-dark);
  color: #fff;
  border: 2px solid var(--color-primary-dark);
  border-radius: 4px 0 0 4px;
  font-size: 18px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s;
  right: 0;
  left: auto;
}

#mapToggleBtn:hover {
  background: #fff;
  color: var(--color-primary-dark);
}

#mapToggleBtnMobile {
  position: absolute;
  display: none;
  left: 50%;
  transform: translateX(-50%);
  width: 46px;
  height: 16px;
  background: var(--color-primary-dark);
  color: #fff;
  border: 2px solid var(--color-primary-dark);
  border-radius: 4px 4px 0 0;
  font-size: 18px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s;
  bottom: 0;
}

#mapToggleBtnMobile:hover {
  background: #fff;
  color: var(--color-primary-dark);
}

#locationsTable tbody tr.dt-hasChild.dtr-expanded td.dt-custom-0 {
  background-color: var(--color-primary-light) !important;
  color: var(--color-primary-dark);
  font-weight: bold;
}

/* Modal overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-content {
  background: #fff;
  border-radius: 8px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
  position: relative;
  padding: 20px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  color: #c00;
  line-height: 1;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: all 0.2s;
}

.modal-close:hover {
  color: #fff;
  background-color: #c00;
  text-decoration: none;
}

.modal-body {
  margin-top: 20px;
  text-align: center;
}

/* Images: max-width to avoid horizontal scroll, max-height to fit one screen */
.modal-body img {
  max-width: 100%;
  max-height: 80vh;
  /* each image at most 80% of viewport height */
  width: auto;
  height: auto;
  margin-bottom: 15px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: block;
  margin-left: auto;
  margin-right: auto;
}

/* Share modal */
.share-modal-content {
  max-width: 420px;
  width: 90vw;
  padding: 24px 20px 20px;
}

.share-modal-title {
  margin: 0 0 16px;
  font-size: 1.25rem;
  color: var(--color-primary-dark);
  text-align: center;
}

.share-section {
  margin-bottom: 20px;
}

.share-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary-dark);
  margin-bottom: 6px;
}

.share-link-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.share-url-input {
  flex: 1 1 160px;
  min-width: 0;
  padding: 8px 10px;
  font-size: 13px;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-sizing: border-box;
  background: #f8f8f8;
}

.share-action-btn {
  flex: none;
  border: 1px solid var(--color-primary-dark);
  border-radius: 6px;
  background: var(--color-primary-dark);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}

.share-action-btn:hover {
  background: #1a6b61;
}

.share-native-btn {
  display: none;
  margin-top: 10px;
  width: 100%;
  justify-content: center;
  background: #fff;
  color: var(--color-primary-dark);
}

.share-native-btn:hover {
  background: #a1e8df;
}

.share-qr-section {
  text-align: center;
  margin-bottom: 0;
}

.share-qr-hint {
  margin: 0 0 12px;
  font-size: 14px;
  color: #333;
}

.share-qr-img {
  max-width: 200px;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.share-download-link {
  display: inline-block;
  margin-top: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary-dark);
}

.share-download-link:hover {
  text-decoration: underline;
}

/* Responsive */
@media(max-width:900px) {
  #mainHeader {
    flex-direction: column;
    align-items: stretch;
    padding: 8px 16px;
    min-height: 0;
  }

  .header-left,
  .header-right {
    width: 100%;
    padding: 4px 0;
    justify-content: center;
  }

  .header-right {
    gap: 6px;
  }

  .header-left {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    min-height: 0;
  }

  .header-left-text {
    flex-direction: column;
    align-items: center;
  }

  .header-actions {
    margin-left: auto;
    margin-right: 0;
    justify-content: center;
  }

  .header-share-label {
    display: none;
  }

  .app-container {
    flex-direction: column;
  }

  #mapContainer {
    flex: 0 0 auto;
    width: 100%;
    height: 40vh;
  }

  #mapContainer.map-collapsed {
    flex: 0 0 24px;
  }

  #mapContainer.map-collapsed #mapWrapper {
    display: block;
    height: 0;
    overflow: hidden;
  }

  #mapWrapper {
    flex: none;
    height: calc(40vh - 24px);
  }

  #locationPanel {
    flex: 1;
    max-width: 100%;
    height: auto;
    box-shadow: none;
    transition: height 0.3s ease;
  }

  #mapToggleBtn {
    display: none;
  }

  #mapToggleBtnMobile {
    display: flex;
  }

  /* DataTables responsive handles mobile stacking via child rows */
  #locationList {
    overflow-x: auto;
  }

}

@media (max-width: 600px) {

  .direction-btn,
  .pics-btn {
    width: 100% !important;
    margin-top: 6px;
  }
}