/* General resets */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Arial', sans-serif;
}

body, html {
  height: 100%;
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar styles */
.sidebar {
  width: 300px;
  background-color: #faf5f1;
  border-right: 1px solid #e4d9d3;
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-title {
  font-size: 1.1rem;
  color: #b49181;
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* Back to Home link in sidebar */
.home-link {
  display: block;
  margin-bottom: 12px;
  color: #b49181;
  font-size: 0.95rem;
  text-decoration: none;
  font-weight: bold;
}

.home-link:hover {
  text-decoration: underline;
}

.category-list {
  list-style: none;
  flex-grow: 1;
}

.category-item {
  /* container for category header and sublist */
  margin-bottom: 8px;
}

/* Style for category header (clickable) */
.category-header {
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
  padding: 8px;
  border-radius: 4px;
  margin-bottom: 2px;
}

.category-header:hover, .category-item.active > .category-header {
  background-color: #f1e7e1;
}

.category-item .number {
  width: 24px;
  height: 24px;
  background-color: #e0c8ba;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 8px;
  font-size: 0.8rem;
  transform: rotate(45deg);
}

.category-item .number .num-text {
  transform: rotate(-45deg);
  display: block;
  width: 100%;
  text-align: center;
}

.category-item .label {
  color: #5d4a42;
  font-size: 0.9rem;
}

/* Sublist of travels under a category */
.travel-sublist {
  list-style: none;
  margin-left: 32px;
  margin-top: 4px;
  padding-left: 0;
  display: none;
}

.travel-sublist.open {
  display: block;
}

.travel-item {
  font-size: 0.85rem;
  color: #6f5a52;
  margin-bottom: 4px;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.travel-item:hover {
  background-color: #f5ece8;
}

.add-travel-btn {
  margin-top: 20px;
  padding: 10px;
  background-color: #d4a89c;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s ease;
}

.add-travel-btn:hover {
  background-color: #c49789;
}

/* Map container */
.map-container {
  flex-grow: 1;
  position: relative;
  height: 100vh; /* ensure the map container fills the viewport height */
  /* Use equirectangular world map for accurate lat/lon mapping */
  background-image: url('world_map_equirectangular.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Container for marker elements */
.markers-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* let clicks pass through to map for location selection */
}

/* Individual marker element */
.marker {
  position: absolute;
  /* tiny blue dot marker */
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #007bff;
  transform: translate(-50%, -50%); /* anchor center */
  pointer-events: auto;
  cursor: pointer;
  z-index: 5;
  animation: blink 1.4s infinite;
}

/* Blinking animation for dot markers */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  z-index: 10;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.4);
  pointer-events: none; /* allow clicks to pass through to map except modal content */
}

.modal-content {
  background-color: #fff;
  margin: 10% auto;
  padding: 20px;
  border: 1px solid #888;
  width: 90%;
  max-width: 500px;
  border-radius: 6px;
  position: relative;
  pointer-events: auto; /* enable interaction on modal content */
}

.close {
  color: #aaa;
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover, .close:focus {
  color: #000;
  text-decoration: none;
  cursor: pointer;
}

.modal-content h3 {
  margin-bottom: 20px;
  font-size: 1.2rem;
  color: #5d4a42;
}

form label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.9rem;
  color: #5d4a42;
}

form input[type="date"],
form input[type="file"],
form input[type="text"],
form textarea,
form select {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

.notice {
  font-size: 0.8rem;
  color: #8c7b74;
  margin-bottom: 5px;
}

.submit-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background-color: #d4a89c;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.submit-btn:hover {
  background-color: #c49789;
}

/* Side panel for adding travels */
/* Side panel for adding travels (as a flex child of #app) */
.form-panel {
  /* initially hidden: zero width */
  flex: 0 0 0;
  width: 0;
  height: 100vh;
  background-color: #fff;
  border-left: 1px solid #e4d9d3;
  box-shadow: -2px 0 6px rgba(0, 0, 0, 0.1);
  transition: width 0.3s ease;
  padding: 20px;
  overflow-y: auto;
}

.form-panel.open {
  /* when open, allocate space */
  flex: 0 0 320px;
  width: 320px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.panel-header h3 {
  margin: 0;
  font-size: 1.2rem;
  color: #5d4a42;
}

.panel-header .close {
  font-size: 24px;
  color: #aaa;
  cursor: pointer;
}

.panel-header .close:hover {
  color: #000;
}

.panel-form label {
  display: block;
  margin-top: 10px;
  margin-bottom: 5px;
  font-size: 0.9rem;
  color: #5d4a42;
}

.panel-form input[type="date"],
.panel-form input[type="file"],
.panel-form input[type="text"],
.panel-form input[type="password"],
.panel-form textarea,
.panel-form select {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Leaflet popup adjustments for images */
.leaflet-popup-content-wrapper {
  max-width: 300px;
}

/* Custom thumbnail marker container (for Leaflet div icons) */
.thumb-marker {
  cursor: pointer;
}

.popup-content {
  text-align: center;
}

.popup-content img {
  max-width: 100%;
  border-radius: 4px;
  margin-bottom: 8px;
}

.popup-content h4 {
  margin: 0;
  font-size: 1rem;
  color: #5d4a42;
}

.popup-content p {
  font-size: 0.85rem;
  color: #6f5a52;
}

/* Custom popup container for markers (we'll style via inline style, but ensure fonts) */
.custom-popup .popup-content {
  text-align: left;
}

.custom-popup .popup-content h4 {
  margin-top: 0;
  margin-bottom: 4px;
  font-size: 1rem;
  color: #5d4a42;
}

.custom-popup .popup-content p {
  margin: 2px 0;
  color: #6f5a52;
  font-size: 0.85rem;
}

/* Login overlay for admin page */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.login-box {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.login-box h2 {
  margin-bottom: 12px;
  color: #5d4a42;
}

.login-box input[type="password"] {
  width: 100%;
  padding: 8px;
  margin-bottom: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

.login-box button {
  padding: 8px 16px;
  background-color: #d4a89c;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

.login-box button:hover {
  background-color: #c49789;
}

.login-error {
  color: red;
  font-size: 0.85rem;
  margin-top: 8px;
  display: none;
}

/* Travel list for admin */
.admin-travel-list {
  padding: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  background-color: #faf5f1;
}

.travel-card {
  border: 1px solid #e4d9d3;
  border-radius: 6px;
  padding: 10px;
  width: 200px;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.travel-card img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 6px;
}

.travel-card h4 {
  margin: 0 0 4px 0;
  font-size: 1rem;
  color: #5d4a42;
}

.travel-card p {
  margin: 2px 0;
  font-size: 0.85rem;
  color: #6f5a52;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  #app {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid #e4d9d3;
  }
  .sidebar .category-list {
    display: flex;
    flex-wrap: nowrap;
  }
  .sidebar .category-item {
    margin-right: 12px;
    margin-bottom: 0;
    flex-shrink: 0;
  }
  .add-travel-btn {
    margin: 10px;
  }
  .map-container {
    height: 55vh;
  }
  .form-panel {
    /* take full width when open */
    width: 0;
    flex: 0 0 0;
    border-left: none;
    border-top: 1px solid #e4d9d3;
  }
  .form-panel.open {
    width: 100%;
    flex: 0 0 100%;
  }
  .marker {
    /* reduce marker size on small screens */
    width: 10px;
    height: 10px;
  }
}