/* FFXI Map Viewer — Dark FFXI-themed UI */

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
#header {
  display: flex;
  flex-direction: column;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

#header-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(5px + env(safe-area-inset-top)) 10px 2px;
}

#header-row2 {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 10px 5px;
}

#header h1 {
  font-size: 16px;
  color: #e94560;
  white-space: nowrap;
}

.nav-icon { height: 20px; vertical-align: middle; margin-right: 4px; image-rendering: pixelated; }

#nav { display: flex; gap: 4px; }
#nav a { color: #aaa; text-decoration: none; font-size: 12px; padding: 2px 6px; border-radius: 3px; }
#nav a:hover { color: #fff; }
#nav a.nav-active { color: #e94560; font-weight: bold; }

#zone-search-wrap {
  position: relative;
  flex: 1;
  max-width: 280px;
  min-width: 100px;
}

#zone-search {
  width: 100%;
  padding: 4px 8px;
  border: 1px solid #0f3460;
  border-radius: 4px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 16px;
  outline: none;
}

#zone-search:focus {
  border-color: #e94560;
}

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #16213e;
  border: 1px solid #0f3460;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 1000;
}

.dropdown.hidden { display: none; }

.dropdown-item {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dropdown-item:hover, .dropdown-item.active {
  background: #0f3460;
}

.dropdown-item .badges {
  display: flex;
  gap: 4px;
}

.badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: bold;
}

.badge-bst { background: #e94560; color: #fff; }
.badge-nm { background: #4da6ff; color: #1a1a2e; }
.badge-maps { background: #0f3460; color: #aaa; }

/* Camp finder inline in header */
#camp-finder-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

#camp-finder-inline label {
  font-size: 12px;
  color: #aaa;
  white-space: nowrap;
}

#camp-finder-inline input[type="number"] {
  width: 42px;
  padding: 3px 2px;
  border: 1px solid #0f3460;
  border-radius: 3px;
  background: #1a1a2e;
  color: #e0e0e0;
  font-size: 16px;
  text-align: center;
}

#camp-finder-inline button {
  padding: 4px 8px;
  border: 1px solid #e94560;
  border-radius: 3px;
  background: #e94560;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

#camp-finder-inline button:hover { background: #c73e54; }

/* Toolbar toggle button */
#toolbar-toggle {
  padding: 4px 10px;
  border: 1px solid #0f3460;
  border-radius: 3px;
  background: #1a1a2e;
  color: #aaa;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

#toolbar-toggle:hover { border-color: #e94560; color: #fff; }
#toolbar-toggle.active { background: #0f3460; color: #fff; border-color: #e94560; }
#toolbar-toggle.hidden { display: none; }

/* Toolbar (layers + floor buttons) */
#toolbar {
  display: flex;
  flex-direction: column;
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  flex-shrink: 0;
}

#toolbar.hidden { display: none; }

#toolbar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 12px;
  flex-wrap: wrap;
}

#toolbar-layers {
  display: flex;
  align-items: center;
  gap: 10px;
}

#toolbar-layers label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

#toolbar-layers label input[type="checkbox"] {
  accent-color: #e94560;
}

#toolbar-layers label.hidden { display: none; }

/* Floor buttons */
#floor-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

#floor-buttons:empty { display: none; }

.floor-btn {
  padding: 3px 8px;
  border: 1px solid #0f3460;
  border-radius: 3px;
  background: #1a1a2e;
  color: #aaa;
  cursor: pointer;
  font-size: 11px;
}

.floor-btn:hover { border-color: #e94560; color: #fff; }
.floor-btn.active {
  background: #e94560;
  border-color: #e94560;
  color: #fff;
}

/* Toolbar separator */
.toolbar-sep {
  width: 1px;
  height: 16px;
  background: #0f3460;
  margin: 0 2px;
}

/* Mob filter toggle */
#mob-filter-toggle {
  padding: 2px 8px;
  border: 1px solid #0f3460;
  border-radius: 3px;
  background: #1a1a2e;
  color: #aaa;
  cursor: pointer;
  font-size: 11px;
}
#mob-filter-toggle:hover { border-color: #e94560; color: #fff; }
#mob-filter-toggle.active { background: #0f3460; color: #fff; border-color: #e94560; }
#mob-filter-toggle.hidden { display: none; }

/* Mob filter panel */
#mob-filter-panel {
  border-top: 1px solid #0f3460;
  padding: 4px 12px 6px;
}
#mob-filter-panel.hidden { display: none; }

#mob-filter-header {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}
#mob-filter-header button {
  padding: 1px 8px;
  border: 1px solid #0f3460;
  border-radius: 3px;
  background: #1a1a2e;
  color: #aaa;
  cursor: pointer;
  font-size: 10px;
}
#mob-filter-header button:hover { border-color: #e94560; color: #fff; }

#mob-filter-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1px 12px;
  max-height: 150px;
  overflow-y: auto;
}

#mob-filter-list label {
  display: flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 1px 0;
}

#mob-filter-list label input[type="checkbox"] {
  accent-color: #6688aa;
  flex-shrink: 0;
}

#mob-filter-list label .mob-count {
  color: #666;
  font-size: 10px;
  margin-left: 2px;
}

/* Camp results panel (drops down from header) */
#camp-results-panel {
  background: #16213e;
  border-bottom: 1px solid #0f3460;
  max-height: 50vh;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 8px 12px;
}

#camp-results-panel.hidden { display: none; }

#camp-results {
  font-size: 12px;
}

.camp-zone {
  margin-bottom: 6px;
}

.camp-zone-name {
  color: #4da6ff;
  cursor: pointer;
  font-weight: bold;
  font-size: 13px;
}

.camp-zone-name:hover { text-decoration: underline; }

.camp-entry {
  padding: 1px 0 1px 12px;
  color: #ccc;
}

.camp-entry .pet-name { color: #e94560; }
.camp-entry .pet-level { color: #f5a623; }
.camp-entry .spawn-count { color: #888; }

/* Main layout — map takes all remaining space */
#main {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#map-container {
  width: 100%;
  height: 100%;
  position: relative;
}

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

#map-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  z-index: 400;
}

#map-placeholder p {
  color: #555;
  font-size: 18px;
}

#map-placeholder p.sub {
  font-size: 14px;
  margin-top: 8px;
}

#map-placeholder.hidden { display: none; }

/* Leaflet overrides for dark theme */
.leaflet-control-zoom a {
  background: #16213e !important;
  color: #e0e0e0 !important;
  border-color: #0f3460 !important;
}

.leaflet-control-zoom a:hover {
  background: #0f3460 !important;
}

.leaflet-popup-content-wrapper {
  background: #16213e;
  color: #e0e0e0;
  border-radius: 4px;
}

.leaflet-popup-tip { background: #16213e; }

.leaflet-popup-content {
  font-size: 12px;
  line-height: 1.5;
}

.leaflet-popup-content .popup-name { font-weight: bold; font-size: 13px; }
.leaflet-popup-content .popup-bst { color: #e94560; }
.leaflet-popup-content .popup-nm { color: #4da6ff; }
.leaflet-popup-content .popup-nm-cond { color: #c0a0e0; font-size: 11px; }
.leaflet-popup-content .popup-ph { color: #a0d0ff; }
.leaflet-popup-content .popup-spawn-cond { color: #c0a0e0; font-size: 11px; font-style: italic; }
.leaflet-popup-content .popup-chest-key { color: #f0c040; }
.leaflet-popup-content .popup-coffer-key { color: #40c080; }
.leaflet-popup-content .popup-id { color: #888; font-family: monospace; }
.leaflet-popup-content .popup-drops { margin-top: 4px; border-top: 1px solid #0f3460; padding-top: 4px; }
.leaflet-popup-content .popup-drop-item { padding-left: 8px; }
.leaflet-popup-content .drop-rate { color: #f5a623; font-size: 11px; margin-left: 4px; }
.leaflet-popup-content .item-link { color: #f0c040; text-decoration: none; }
.leaflet-popup-content .item-link:hover { text-decoration: underline; }

/* Fetch Price button */
.fetch-price-btn {
  background: transparent;
  border: 1px solid #f0c040;
  color: #f0c040;
  font-size: 10px;
  padding: 0 4px;
  border-radius: 2px;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
  line-height: 1.4;
}
.fetch-price-btn:hover { background: rgba(240, 192, 64, 0.15); }
.fetch-price-btn:disabled { opacity: 0.5; cursor: default; }

/* Inline AH price result */
.ah-inline-price { font-size: 10px; margin-left: 4px; }
.ah-inline-avg { color: #f0c040; font-weight: bold; }
.ah-inline-stock { color: #888; margin-left: 3px; }
.ah-inline-none { color: #666; font-style: italic; }
.ah-inline-stack { color: #aaa; }

/* Treasure markers — diamond shape to distinguish from mob circles */
.treasure-marker {
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  border: 2px solid #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}
.treasure-chest { background: #f5d020; }
.treasure-coffer { background: #20e070; }

/* Map legend */
.map-legend {
  background: rgba(22, 33, 62, 0.9);
  border: 1px solid #0f3460;
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 11px;
  color: #ccc;
  line-height: 1.6;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.legend-circle {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
}

.legend-diamond {
  display: inline-block;
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
  border: 1.5px solid #fff;
  flex-shrink: 0;
}

.legend-info {
  color: #aaa;
  font-size: 10px;
  font-style: italic;
  padding-left: 16px;
}

/* Item tooltip — FFXI in-game examine style */
#item-tooltip {
  position: fixed;
  z-index: 10000;
  pointer-events: none;
  display: none;
  background: #3a3a2e;
  border: 1px solid #7a7768;
  border-radius: 0;
  max-width: 320px;
  padding: 4px 6px;
  font-family: Tahoma, 'Segoe UI', Geneva, Verdana, sans-serif;
  font-size: 11px;
  line-height: 1.3;
  color: #e8e8e0;
  box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
  -webkit-font-smoothing: none;
  -moz-osx-font-smoothing: unset;
  text-rendering: optimizeSpeed;
  letter-spacing: 0.2px;
}

#item-tooltip .itt-name { margin-bottom: 0; }
#item-tooltip .itt-flags { margin-bottom: 0; }
#item-tooltip .itt-slot { margin-bottom: 0; }
#item-tooltip .itt-weapon { margin-bottom: 0; }
#item-tooltip .itt-stats { white-space: pre-line; margin-bottom: 0; }
#item-tooltip .itt-desc { margin-bottom: 0; }
#item-tooltip .itt-level { margin-top: 0; padding-top: 0; border-top: none; }
#item-tooltip .itt-vendor { color: #88cc88; font-size: 11px; margin-top: 3px; }

/* NM spawn heatmap canvas */
.spawn-heatmap { pointer-events: none; }

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: #1a1a2e; }
::-webkit-scrollbar-thumb { background: #0f3460; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #e94560; }

/* Mobile responsive */
@media (max-width: 768px) {
  #header-row1 { padding: calc(3px + env(safe-area-inset-top)) 6px 1px; gap: 4px; }
  #header-row2 { padding: 1px 6px 3px; gap: 4px; }
  #header h1 { font-size: 13px; }

  #zone-search-wrap { max-width: 200px; }
  #zone-search { font-size: 16px; padding: 3px 6px; }

  #camp-finder-inline input[type="number"] { width: 38px; padding: 2px 2px; font-size: 16px; }
  #camp-finder-inline button { padding: 3px 6px; font-size: 11px; }
  #camp-finder-inline label { font-size: 11px; }

  #toolbar-row { padding: 3px 8px; gap: 8px; }
  #toolbar-layers { gap: 6px; }
  #toolbar-layers label { font-size: 11px; }
  #mob-filter-panel { padding: 3px 8px 4px; }
  #mob-filter-list { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); max-height: 120px; }

  .floor-btn { padding: 2px 6px; font-size: 10px; }

  #camp-results-panel { max-height: 40vh; padding: 6px 8px; }
}

@media (max-width: 480px) {
  #header h1 { display: none; }
}
