/* ============================================================
   BASE
   ============================================================ */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: sans-serif;
  overflow: hidden;
}

/* ============================================================
   LAYOUT
   ============================================================ */
#app-container {
  display: flex;
  height: 100vh;
}

#map {
  flex: 1;
  height: 100%;
  background-color: #f9f7f2;
  position: relative;
  z-index: 0;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */
#loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #f9f7f2;
  gap: 24px;
}

#loading-overlay video {
  width: 200px;
  border-radius: 12px;
}

#loading-overlay p {
  color: #495057;
  font-size: 1rem;
  text-align: center;
  max-width: 420px;
  line-height: 1.4;
  padding: 0 24px;
  margin: 0;
}

#loading-overlay.hidden {
  display: none;
}

/* ============================================================
   TRAY
   ============================================================ */
#tray {
  width: 350px;
  background-color: #f8f9fa;
  border-left: 1px solid #dee2e6;
  overflow: hidden;
  transition: width 0.3s ease;
}

#tray-inner {
  width: 350px;
  height: 100%;
  padding: 15px;
  box-sizing: border-box;
  overflow-y: auto;
}

body.tray-closed #tray {
  width: 0;
  border-left: none;
}

.tray-section {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #dee2e6;
}

.tray-section:last-child {
  border-bottom: none;
}

.tray-section h3 {
  margin: 0 0 10px 0;
  font-size: 14px;
  font-weight: 600;
  color: #495057;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* COG Selector */
#cog-selector label {
  display: block;
  margin-bottom: 5px;
  font-size: 13px;
  font-weight: 500;
  color: #495057;
}

#cog-selector-dropdown {
  width: 100%;
  padding: 5px;
}

/* Map Info */
#map-info-content {
  word-wrap: break-word;
  font-size: 13px;
}

/* Messages */
#messages-content {
  padding: 10px;
  background-color: #fff;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.6;
}

#messages-content div {
  padding: 4px 0;
  border-bottom: 1px solid #f0f0f0;
  color: grey;
}

#messages-content div:first-child {
  border-bottom: none;
  color: black;
}

#messages-content div:last-child {
  border-bottom: none;
}

/* ============================================================
   TOOLS
   ============================================================ */
.tool-item {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 15px;
}

.tool-icon-button {
  width: 32px;
  height: 32px;
  padding: 0;
  background-color: transparent;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.tool-item:hover .tool-icon-button {
  background-color: rgba(0, 0, 0, 0.08);
}

.tool-icon-button.active {
  background-color: rgba(0, 0, 0, 0.15);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tool-label {
  font-size: 13px;
  color: #495057;
  cursor: pointer;
  user-select: none;
}

/* Coordinates tool */
.coordinates-marker-icon {
  background-image: url('https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon-2x.png');
  background-size: 14px auto;
  background-repeat: no-repeat;
  background-position: center;
}

.coordinates-tool-active,
.coordinates-tool-active *,
.measure-tool-active,
.measure-tool-active * {
  cursor: crosshair !important;
}

.coordinates-popup .leaflet-popup-tip-container {
  display: none;
}

/* Measure tool */
.measure-ruler-icon::before {
  content: '📏';
  font-size: 18px;
  line-height: 1;
}

.measure-popup .leaflet-popup-content {
  margin: 8px 10px;
  font-size: 12px;
  font-weight: 600;
}

/* ============================================================
   LEAFLET OVERRIDES
   ============================================================ */
.leaflet-popup-content-wrapper {
  background-color: #2c2c2c;
  color: #e0e0e0;
  border: 1px solid #00a8e8;
}

.leaflet-popup-tip {
  background-color: #2c2c2c;
}

.leaflet-control-scale-line {
  background-color: rgba(44, 44, 44, 0.8);
  border-color: #00a8e8;
  color: #e0e0e0;
}

/* ============================================================
   TRAY CONTAINER
   ============================================================ */
#tray-container {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: row;
  z-index: 100;
}

#tray-tabs {
  align-self: flex-start;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  /* sits between the map and the tray panel */
}
/* ============================================================
   TRAY TOGGLE BUTTON
   ============================================================ */
#tray-toggle-btn {
  width: 32px;
  height: 32px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-right: none;
  border-radius: 4px 0 0 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background-color 0.2s ease;
}

#tray-toggle-btn:hover {
  background-color: #e9ecef;
}

#tray-toggle-btn::before {
  content: '›';
  font-size: 16px;
  color: #6c757d;
  line-height: 1;
}

body.tray-closed #tray-toggle-btn {
  border-right: 1px solid #dee2e6;
}

body.tray-closed #tray-toggle-btn::before {
  content: '‹';
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 768px) {
  #tray {
    width: min(350px, 85vw);
  }

  #tray-inner {
    width: min(350px, 85vw);
  }
}