body { margin: 0; padding: 0; }
#map { position: absolute; top: 0; bottom: 0; width: 100%; }

#info-panel {
  position: absolute;
  top: 70px;
  right: 20px;
  width: 700px;
  height: 80vh;
  max-height: 900px;
  min-height: 500px;
  background: white;
  padding: 1em;
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(0,0,0,0.3);
  z-index: 1;
  display: none;
  cursor: move;
  overflow-y: auto;
}

#info-panel h2 {
  margin-top: 0;
}

#close-btn {
  position: sticky;
  position: -webkit-sticky;
  top: 5px;
  right: 8px;
  float: right;
  background: white;
  z-index: 10;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #eee;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

/* City selection modal styles */
#city-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}

#city-modal-content {
  background: white;
  padding: 30px;
  border-radius: 8px;
  max-width: 900px;
  width: 95%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: row;
  gap: 32px;
}

.city-modal-left {
  flex: 1 1 0;
  padding-right: 16px;
  border-right: 1px solid #eee;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.city-modal-right {
  flex: 1 1 0;
  padding-left: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#city-modal h2 {
  margin-top: 0;
  margin-bottom: 20px;
  text-align: center;
  color: #333;
}

.city-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.city-item {
  padding: 15px;
  margin: 10px 0;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.city-item:hover {
  background: #007bff;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,123,255,0.3);
}

.city-name {
  font-weight: bold;
  font-size: 16px;
}

.city-population {
  color: #6c757d;
  font-size: 14px;
}

.city-item:hover .city-population {
  color: rgba(255,255,255,0.8);
}

#skip-selection {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  color: white;
  font-size: 14px;
  cursor: pointer;
  text-decoration: underline;
}

#skip-selection:hover {
  color: #ccc;
}

/* Top menu styles */
#top-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  z-index: 100;
  padding: 10px 20px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#app-title {
  color: white;
  font-size: 20px;
  font-weight: bold;
  margin: 0;
}

#menu-button {
  background: #007bff;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease;
}

#menu-button:hover {
  background: #0056b3;
}

/* Adjust map to account for top menu */
#map {
  top: 50px;
  height: calc(100vh - 50px);
}

/* Navigation panel styles */
#nav-panel {
  position: absolute;
  top: 80px;
  left: 20px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid rgba(0,0,0,0.1);
}

.nav-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: bold;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 3px;
}

.zoom-controls {
  display: flex;
  flex-direction: column;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  overflow: hidden;
}

.zoom-btn {
  width: 32px;
  height: 32px;
  background: white;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  color: #495057;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.zoom-btn:hover {
  background: #f8f9fa;
  color: #007bff;
}

.zoom-btn:active {
  background: #e9ecef;
}

.zoom-btn + .zoom-btn {
  border-top: 1px solid #dee2e6;
}

.north-arrow {
  width: 40px;
  height: 40px;
  background: white;
  border: 2px solid #dee2e6;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #495057;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.north-arrow:hover {
  border-color: #007bff;
  color: #007bff;
  transform: scale(1.05);
}

.north-arrow::before {
  content: "N";
  font-weight: bold;
  font-size: 12px;
  position: absolute;
  top: 6px;
}

.north-arrow::after {
  content: "▲";
  font-size: 14px;
  margin-top: 6px;
}

.zoom-level {
  font-size: 11px;
  color: #6c757d;
  text-align: center;
  padding: 4px;
  background: #f8f9fa;
  border-radius: 3px;
  border: 1px solid #dee2e6;
  min-width: 50px;
}

.map-scale {
  font-size: 10px;
  color: #495057;
  text-align: center;
  padding: 4px;
  background: #f8f9fa;
  border-radius: 3px;
  border: 1px solid #dee2e6;
  min-width: 50px;
  font-weight: bold;
}

/* Data visualization styles */
.data-section {
  margin: 15px 0;
}

.filter-controls {
  margin-bottom: 15px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #e9ecef;
}

.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.filter-group {
  flex: 1;
}

.filter-group label {
  display: block;
  font-size: 12px;
  font-weight: bold;
  color: #495057;
  margin-bottom: 3px;
}

.filter-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ced4da;
  border-radius: 3px;
  font-size: 13px;
  background: white;
}

.filter-select:focus {
  border-color: #007bff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0,123,255,0.25);
}

.clear-filters {
  background: #6c757d;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
  margin-top: 18px;
}

.clear-filters:hover {
  background: #5a6268;
}

.data-category {
  margin-bottom: 15px;
}

.files-list {
  margin-top: 10px;
}

/* Dashboard grid styles */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  margin: 15px 0;
  height: 320px;
}

.dashboard-tile {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  overflow: hidden;
  background: white;
  display: flex;
  flex-direction: column;
  cursor: default;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.dashboard-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.dashboard-tile.dragging {
  opacity: 0.5;
  transform: rotate(5deg);
  z-index: 1000;
}

.dashboard-tile.drop-target {
  border: 2px dashed #007bff;
  background-color: #f8f9ff;
}

.tile-header {
  padding: 8px 25px 8px 10px;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  font-size: 11px;
  font-weight: bold;
  color: #495057;
  text-align: center;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
  position: relative;
}

.tile-header:active {
  cursor: grabbing;
}

.tile-header::after {
  content: "⋮⋮";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: #6c757d;
  font-size: 12px;
  line-height: 1;
  pointer-events: none;
}

.tile-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 8px;
  background: #fff;
  cursor: pointer;
  min-height: 0;
  overflow: hidden;
}

.tile-gif {
  max-width: 100%;
  max-height: 100px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 3px;
  display: block;
}

.tile-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 100px;
  width: 100%;
  overflow: hidden;
}

.tile-placeholder {
  color: #6c757d;
  font-size: 12px;
  text-align: center;
  padding: 20px;
}

.tile-info {
  font-size: 10px;
  color: #6c757d;
  margin-top: 5px;
  text-align: center;
  flex-shrink: 0;
}

/* Pagination styles */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 15px 0;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 4px;
}

.pagination-btn {
  background: #007bff;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 12px;
}

.pagination-btn:hover {
  background: #0056b3;
}

.pagination-btn:disabled {
  background: #6c757d;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 12px;
  color: #495057;
  font-weight: bold;
}

.view-mode-toggle {
  margin: 10px 0;
  display: flex;
  gap: 5px;
}

.mode-btn {
  background: #6c757d;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

.mode-btn.active {
  background: #007bff;
}

.mode-btn:hover {
  background: #5a6268;
}

.mode-btn.active:hover {
  background: #0056b3;
}

.category-header {
  background: #f8f9fa;
  padding: 8px 12px;
  border-radius: 4px;
  font-weight: bold;
  color: #495057;
  cursor: pointer;
  border: 1px solid #e9ecef;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-header:hover {
  background: #e9ecef;
}

.category-content {
  display: none;
  padding: 10px 0;
}

.category-content.expanded {
  display: block;
}

.data-file {
  padding: 8px 12px;
  margin: 5px 0;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.data-file:hover {
  background: #f8f9fa;
  border-color: #007bff;
}

.data-file.hidden {
  display: none;
}

.file-name {
  font-size: 12px;
  color: #6c757d;
  margin-top: 3px;
}

.file-type {
  display: inline-block;
  background: #007bff;
  color: white;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  margin-right: 8px;
}

.file-type.gif { background: #28a745; }
.file-type.png { background: #17a2b8; }
.file-type.csv { background: #ffc107; color: #212529; }
.file-type.xlsx { background: #6f42c1; }

.expand-icon {
  transition: transform 0.2s ease;
}

.expand-icon.rotated {
  transform: rotate(180deg);
}

.no-results {
  padding: 20px;
  text-align: center;
  color: #6c757d;
  font-style: italic;
}

/* Modal for viewing files */
#file-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

#file-modal-content {
  background: white;
  border-radius: 8px;
  max-width: 98%;
  max-height: 98%;
  width: 1600px;
  height: 900px;
  position: relative;
  display: flex;
  overflow: hidden;
}

#file-modal-close {
  position: absolute;
  top: 15px;
  right: 20px;
  font-size: 28px;
  cursor: pointer;
  z-index: 2001;
  color: #666;
  background: white;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#file-modal-close:hover {
  background: #f0f0f0;
  color: #333;
}

.modal-main-content {
  flex: 2;
  padding: 20px;
  display: flex;
  flex-direction: column;
  background: #f8f9fa;
  border-right: 1px solid #dee2e6;
  min-height: 0;
  overflow: hidden;
}

.modal-main-content.image-mode {
  justify-content: center;
  align-items: center;
  padding: 0;
}

.modal-sidebar {
  flex: 1;
  padding: 20px;
  background: white;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-image {
  max-width: calc(100% - 20px);
  max-height: calc(100% - 20px);
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  cursor: crosshair;
  transition: transform 0.5s ease;
  user-select: none;
  transform-origin: center center;
}

.modal-image.zoomed {
  cursor: grab;
  /* Use containment to prevent overflow beyond bounds */
  contain: layout style;
}

.modal-image.zoomed:active {
  cursor: grabbing;
}

.modal-image-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  padding: 60px 60px 90px 60px; /* More padding to ensure buttons stay visible */
}

/* Simpler approach - constrain the image directly */
.modal-image {
  max-width: calc(100% - 20px);
  max-height: calc(100% - 20px);
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  cursor: crosshair;
  transition: transform 0.5s ease;
  user-select: none;
  transform-origin: center center;
  position: relative;
  z-index: 1;
}

.zoom-selection-box {
  position: absolute;
  border: 2px dashed #007bff;
  background: rgba(0, 123, 255, 0.1);
  pointer-events: none;
  display: none;
  z-index: 10;
}

.image-zoom-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 4px;
  padding: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.zoom-control-btn {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ccc;
  border-radius: 3px;
  padding: 5px 6px;
  cursor: pointer;
  font-size: 8px;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-control-btn:hover {
  background: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.zoom-control-btn:active {
  transform: translateY(0);
}

#gif-refresh {
  background: linear-gradient(135deg, #28a745, #20c997);
  color: white;
  border: 1px solid #1e7e34;
}

#gif-refresh:hover {
  background: linear-gradient(135deg, #218838, #1dd2aa);
  transform: translateY(-1px) scale(1.05);
}

.zoom-control-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.zoom-info {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 10px 15px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  text-align: center;
}

.zoom-info.visible {
  opacity: 1;
}

.modal-table-container {
  width: 100%;
  height: 100%;
  overflow: auto;
  background: white;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  padding: 15px;
  box-sizing: border-box;
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.modal-table-container::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

.modal-table-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 6px;
}

.modal-table-container::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 6px;
}

.modal-table-container::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

.modal-table-container::-webkit-scrollbar-corner {
  background: #f1f1f1;
}

.modal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 800px;
  margin: 0;
}

.modal-table th,
.modal-table td {
  border: 1px solid #dee2e6;
  padding: 8px;
  text-align: left;
}

.modal-table th {
  background: #f8f9fa;
  font-weight: bold;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  border-bottom: 2px solid #dee2e6;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.modal-table td {
  white-space: nowrap;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.modal-table td:hover {
  overflow: visible;
  white-space: normal;
  word-wrap: break-word;
  position: relative;
  background: #f8f9fa;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.modal-file-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #6c757d;
  font-size: 18px;
}

.modal-file-icon {
  font-size: 64px;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #333;
  border-bottom: 2px solid #007bff;
  padding-bottom: 10px;
}

.modal-subtitle {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 15px;
  color: #495057;
  padding-bottom: 8px;
}

.modal-metadata {
  margin-bottom: 20px;
}

.modal-metadata-item {
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
}

.modal-metadata-label {
  font-weight: bold;
  color: #495057;
  min-width: 80px;
  margin-right: 10px;
}

.modal-metadata-value {
  color: #6c757d;
  flex: 1;
}

.modal-description {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.modal-description-label {
  font-weight: bold;
  color: #495057;
  margin-bottom: 10px;
  font-size: 16px;
}

.modal-description-content {
  flex: 1;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 15px;
  font-size: 14px;
  line-height: 1.6;
  color: #495057;
  overflow-y: auto;
  white-space: pre-line; /* Preserve line breaks and allow wrapping */
}

.modal-description-content br {
  margin-bottom: 0.5em;
}

/* Style for bullet points and lists in descriptions */
.modal-description-content {
  text-align: left;
}

/* Style for bullet point divs created by JavaScript */
.modal-description-content div[style*="margin-left"] {
  display: block !important;
  margin-left: 20px !important;
  text-indent: -15px !important;
  margin-bottom: 8px !important;
  line-height: 1.4 !important;
  white-space: normal !important;
}

/* Style for indented list items (legacy) */
.modal-description-content span[style*="margin-left"] {
  padding-left: 15px;
  text-indent: -15px;
}

/* Style for section headers in descriptions */
.modal-description-content strong {
  color: #333;
  display: block;
  margin: 10px 0 5px 0;
  font-weight: 600;
}

.modal-description-empty {
  color: #adb5bd;
  font-style: italic;
}

.download-btn {
  background: #28a745;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 10px;
  text-decoration: none;
  display: inline-block;
}

.download-btn:hover {
  background: #218838;
  color: white;
  text-decoration: none;
}
