/* ═══════════════════════════════════════════════════════════════════════════
   style.css — D&D Sword Coast Interactive Map — Dark Fantasy Theme
   ═══════════════════════════════════════════════════════════════════════════ */

/* ─── Reset & Base ──────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: #0d0a06;
  font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  color: #e0c870;
}

/* ─── Layout ────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #1a1208;
  border-bottom: 2px solid #6b4e1a;
  padding: 8px 16px;
  z-index: 1000;
}

#header h1 {
  font-size: 1.3rem;
  font-weight: bold;
  color: #e8b84b;
  letter-spacing: 0.05em;
  text-shadow: 0 0 10px rgba(232, 184, 75, 0.4);
  white-space: nowrap;
}

#header h1 .subtitle {
  font-size: 0.7rem;
  font-weight: normal;
  color: #a0824a;
  display: block;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ─── Search Bar (in header) ────────────────────────────────────────────── */
.search-wrapper {
  position: relative;
  flex: 1 1 260px;
  max-width: 380px;
}

#city-search-input {
  width: 100%;
  background: #0d0a06;
  border: 1.5px solid #6b4e1a;
  border-radius: 4px;
  color: #e0c870;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 6px 36px 6px 10px;
  outline: none;
  transition: border-color 0.2s;
}

#city-search-input::placeholder {
  color: #7a6030;
}

#city-search-input:focus {
  border-color: #e8b84b;
  box-shadow: 0 0 0 2px rgba(232, 184, 75, 0.15);
}

.search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #7a6030;
  pointer-events: none;
  font-size: 1rem;
}

#city-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: #1a1208;
  border: 1.5px solid #6b4e1a;
  border-radius: 4px;
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  z-index: 2000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.7);
}

#city-suggestions li {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid #2c1f0a;
  color: #e0c870;
  transition: background 0.15s, color 0.15s;
}

#city-suggestions li:last-child {
  border-bottom: none;
}

#city-suggestions li:hover {
  background: #2c1f0a;
  color: #e8b84b;
}

/* ─── Sidebar Toggle Button ─────────────────────────────────────────────── */
#sidebar-toggle {
  display: none;
  background: none;
  border: 1.5px solid #6b4e1a;
  border-radius: 4px;
  color: #e8b84b;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  transition: background 0.2s;
}

#sidebar-toggle:hover {
  background: #2c1f0a;
}

/* ─── Main Content Area ─────────────────────────────────────────────────── */
#main {
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
  position: relative;
}

/* ─── Map Container ─────────────────────────────────────────────────────── */
#map {
  flex: 1 1 auto;
  background: #0d0a06;
  cursor: crosshair;
}

/* Override Leaflet background */
.leaflet-container {
  background: #0d0a06 !important;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
#sidebar {
  flex: 0 0 270px;
  background: #12100a;
  border-left: 2px solid #6b4e1a;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  z-index: 500;
}

.sidebar-section {
  border-bottom: 1px solid #2c1f0a;
  padding: 16px;
}

.sidebar-section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #e8b84b;
  margin-bottom: 12px;
  border-bottom: 1px solid #3a2a0a;
  padding-bottom: 6px;
}

/* ─── Route Panel ────────────────────────────────────────────────────────── */
.route-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.route-row label {
  font-size: 0.78rem;
  color: #a0824a;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.route-row select {
  background: #0d0a06;
  border: 1.5px solid #6b4e1a;
  border-radius: 4px;
  color: #e0c870;
  font-family: inherit;
  font-size: 0.88rem;
  padding: 6px 8px;
  outline: none;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.2s;
}

.route-row select:focus {
  border-color: #e8b84b;
}

.route-buttons {
  display: flex;
  gap: 8px;
  margin-top: 2px;
}

.btn {
  flex: 1;
  padding: 7px 10px;
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-weight: bold;
  letter-spacing: 0.04em;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: #8b6914;
  color: #ffe4a0;
  border: 1px solid #c89a30;
}

.btn-primary:hover {
  background: #a07c1a;
}

.btn-secondary {
  background: #1e160a;
  color: #a0824a;
  border: 1px solid #4a3010;
}

.btn-secondary:hover {
  background: #2c1f0a;
  color: #e0c870;
}

#route-result {
  margin-top: 10px;
  font-size: 0.82rem;
  line-height: 1.45;
  min-height: 1.5em;
  word-break: break-word;
}

#route-result.success {
  color: #f0c040;
}

#route-result.error {
  color: #c04040;
}

/* ─── City List ──────────────────────────────────────────────────────────── */
#city-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#city-list li {
  padding: 6px 8px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 0.88rem;
  color: #c8a060;
  transition: background 0.15s, color 0.15s;
  border: 1px solid transparent;
}

#city-list li:hover {
  background: #2c1f0a;
  color: #e8b84b;
  border-color: #4a3010;
}

/* ─── Coordinate Display ─────────────────────────────────────────────────── */
#coord-display {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 800;
  background: rgba(13, 10, 6, 0.82);
  border: 1px solid #6b4e1a;
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-family: 'Courier New', Courier, monospace;
  color: #e8b84b;
  letter-spacing: 0.05em;
  pointer-events: none;
  backdrop-filter: blur(2px);
}

/* ─── Leaflet Popup Custom Style ─────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
  background: #1a1208 !important;
  border: 1.5px solid #8b6914 !important;
  border-radius: 6px !important;
  color: #e0c870 !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8) !important;
}

.leaflet-popup-tip-container .leaflet-popup-tip {
  background: #8b6914 !important;
}

.popup-content h3 {
  font-size: 1rem;
  color: #e8b84b;
  margin-bottom: 6px;
  border-bottom: 1px solid #4a3010;
  padding-bottom: 5px;
}

.popup-content p {
  font-size: 0.82rem;
  line-height: 1.5;
  color: #c8a060;
  max-width: 220px;
}

.leaflet-popup-close-button {
  color: #a0824a !important;
  font-size: 16px !important;
}

.leaflet-popup-close-button:hover {
  color: #e8b84b !important;
}

/* ─── Leaflet Zoom Controls ──────────────────────────────────────────────── */
.leaflet-control-zoom {
  border: 1.5px solid #6b4e1a !important;
  border-radius: 4px !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: #1a1208 !important;
  color: #e8b84b !important;
  border-bottom: 1px solid #6b4e1a !important;
  font-size: 16px !important;
  font-weight: bold;
  line-height: 26px !important;
  width: 28px !important;
  height: 28px !important;
}

.leaflet-control-zoom a:hover {
  background: #2c1f0a !important;
}

/* ─── Scrollbar Styling ──────────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #0d0a06;
}

::-webkit-scrollbar-thumb {
  background: #4a3010;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #8b6914;
}

/* ─── Edit Status Bar ────────────────────────────────────────────────────── */
#edit-status {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1500;
  background: rgba(26, 18, 8, 0.93);
  border: 1px solid #8b6914;
  border-radius: 4px;
  padding: 6px 18px;
  font-size: 0.82rem;
  color: #f0c040;
  white-space: nowrap;
  max-width: calc(100% - 40px);
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
  display: none;
}

/* ─── Edit Tools Section ────────────────────────────────────────────────── */
.edit-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.edit-buttons .btn {
  flex: 1;
  font-size: 0.8rem;
  padding: 6px 4px;
}

.btn-full {
  width: 100%;
  font-size: 0.8rem;
  padding: 6px 10px;
}

/* Active/toggled state for mode buttons */
.btn.active {
  background: #6b4c0f !important;
  color: #ffe4a0 !important;
  border-color: #e8b84b !important;
  box-shadow: 0 0 8px rgba(232, 184, 75, 0.35);
}

/* ─── Edit Panels (Add City / Add Road) ─────────────────────────────────── */
.edit-panel .form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.edit-panel .form-group label {
  font-size: 0.78rem;
  color: #a0824a;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.required {
  color: #c04040;
}

.edit-panel input[type="text"],
.edit-panel textarea,
.edit-panel select {
  background: #0d0a06;
  border: 1.5px solid #6b4e1a;
  border-radius: 4px;
  color: #e0c870;
  font-family: inherit;
  font-size: 0.88rem;
  padding: 6px 8px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.edit-panel textarea {
  resize: vertical;
  min-height: 56px;
}

.edit-panel input[type="text"]:focus,
.edit-panel textarea:focus,
.edit-panel select:focus {
  border-color: #e8b84b;
  box-shadow: 0 0 0 2px rgba(232, 184, 75, 0.15);
}

.edit-panel input.input-error {
  border-color: #c04040;
}

.edit-panel select option {
  background: #1a1208;
  color: #e0c870;
}

.coords-hint {
  font-size: 0.82rem;
  color: #7a6030;
  font-style: italic;
}

.coords-hint.has-coords {
  color: #f0c040;
  font-style: normal;
  font-family: 'Courier New', Courier, monospace;
}

.waypoint-info {
  font-size: 0.8rem;
  color: #a0824a;
  margin-bottom: 10px;
  text-align: center;
  padding: 4px;
  border: 1px solid #2c1f0a;
  border-radius: 3px;
  background: #0d0a06;
}

.form-buttons {
  display: flex;
  gap: 6px;
}

.form-buttons .btn {
  flex: 1;
  font-size: 0.82rem;
  padding: 7px 6px;
}

.road-form-buttons .btn:first-child {
  flex: 0 0 auto;
  padding: 7px 10px;
}

/* ─── Waypoint Dot Marker ───────────────────────────────────────────────── */
.waypoint-dot {
  background: #f0c040;
  border: 2px solid #2a1a00;
  border-radius: 50%;
}

/* ─── Export Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-box {
  background: #1a1208;
  border: 2px solid #8b6914;
  border-radius: 8px;
  padding: 24px;
  width: 100%;
  max-width: 620px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.9);
}

.modal-box h3 {
  font-size: 1rem;
  color: #e8b84b;
  border-bottom: 1px solid #4a3010;
  padding-bottom: 8px;
}

.modal-desc {
  font-size: 0.82rem;
  color: #a0824a;
  line-height: 1.5;
}

.modal-desc code {
  background: #0d0a06;
  border: 1px solid #4a3010;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.85em;
  color: #e0c870;
}

#export-textarea {
  flex: 1 1 auto;
  min-height: 280px;
  background: #0d0a06;
  border: 1.5px solid #6b4e1a;
  border-radius: 4px;
  color: #c8c880;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  padding: 10px;
  resize: vertical;
  outline: none;
  line-height: 1.5;
}

.modal-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-buttons .btn {
  flex: 1;
  min-width: 120px;
}

/* ─── Detail Image Editor Modal ─────────────────────────────────────────── */
.detail-editor-box {
  max-width: 680px;
  overflow-y: auto;
}

.detail-hint {
  font-size: 0.82rem;
  color: #7a6030;
  font-style: italic;
  text-align: center;
  padding: 10px 0;
}

#detail-images-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 2px;
  margin-bottom: 10px;
}

.detail-entry {
  background: #0d0a06;
  border: 1px solid #4a3010;
  border-radius: 5px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.detail-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.detail-entry-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #e8b84b;
  font-weight: bold;
}

.detail-remove-btn {
  flex: 0 0 auto;
  font-size: 0.75rem;
  padding: 3px 8px;
}

.detail-zoom-row {
  display: flex;
  gap: 8px;
}

.detail-zoom-row .form-group {
  flex: 1;
  margin-bottom: 0 !important;
}

.detail-bounds-display {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  color: #a0824a;
  font-style: normal;
  font-weight: normal;
  display: block;
  margin-top: 2px;
  word-break: break-all;
}

.detail-entry .form-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 0;
}

.detail-entry .form-group label {
  font-size: 0.75rem;
  color: #a0824a;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-entry input[type="text"],
.detail-entry input[type="number"] {
  background: #12100a;
  border: 1.5px solid #6b4e1a;
  border-radius: 4px;
  color: #e0c870;
  font-family: inherit;
  font-size: 0.85rem;
  padding: 5px 7px;
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}

.detail-entry input[type="text"]:focus,
.detail-entry input[type="number"]:focus {
  border-color: #e8b84b;
  box-shadow: 0 0 0 2px rgba(232, 184, 75, 0.15);
}

.detail-pick-bounds-btn {
  font-size: 0.78rem;
  padding: 4px 10px;
  margin-top: 2px;
}

#detail-add-row {
  margin-bottom: 4px;
}

#detail-city-select {
  background: #0d0a06;
  border: 1.5px solid #6b4e1a;
  border-radius: 4px;
  color: #e0c870;
  font-family: inherit;
  font-size: 0.88rem;
  padding: 6px 8px;
  outline: none;
  width: 100%;
  cursor: pointer;
  transition: border-color 0.2s;
}

#detail-city-select:focus {
  border-color: #e8b84b;
}

#detail-city-select option {
  background: #1a1208;
  color: #e0c870;
}

/* ─── Responsive / Mobile ────────────────────────────────────────────────── */
@media (max-width: 700px) {
  #sidebar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 270px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    border-left: 2px solid #6b4e1a;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  #sidebar-toggle {
    display: block;
  }

  #header h1 .subtitle {
    display: none;
  }
}

@media (max-width: 420px) {
  .search-wrapper {
    max-width: none;
  }

  #header h1 {
    font-size: 1rem;
  }
}
