/* Styles for the map page (the whole UI): map, side panel, modal, flash. */

html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
#cluster-map { width: 100%; height: 100%; background: #1c1c1c; }
/* Dark tiles. Filter the tiles rather than the layer, since leaflet.css sets .leaflet-tile { filter: inherit }. */
.map-tiles-dark .leaflet-tile { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.6); }

/* Cluster icons */
.marker-cluster {
  background: rgba(16, 185, 129, 0.35);
  border-radius: 50%;
}
.marker-cluster div {
  background: rgba(16, 185, 129, 0.85);
  border-radius: 50%;
  color: #fff;
  font-family: "Lato", sans-serif;
  font-weight: 700;
  text-align: center;
}
.marker-cluster-small { width: 36px; height: 36px; }
.marker-cluster-small div { width: 28px; height: 28px; line-height: 28px; margin: 4px; font-size: 13px; }
.marker-cluster-medium { width: 44px; height: 44px; }
.marker-cluster-medium div { width: 34px; height: 34px; line-height: 34px; margin: 5px; font-size: 14px; }
.marker-cluster-large { width: 52px; height: 52px; }
.marker-cluster-large div { width: 42px; height: 42px; line-height: 42px; margin: 5px; font-size: 15px; }

/* Side panel */
.map-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 380px;
  height: 100%;
  z-index: 1000;
  background: rgba(23, 23, 23, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-left: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  font-family: "Lato", sans-serif;
  transition: transform 0.25s ease;
}
.map-panel.collapsed { transform: translateX(100%); }
.map-panel-toggle {
  position: absolute;
  top: 12px;
  right: 392px;
  z-index: 1001;
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: rgba(23, 23, 23, 0.85);
  border: 1px solid rgba(255,255,255,0.12);
  color: #10b981;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: right 0.25s ease, background 0.15s;
}
.map-panel-toggle.panel-closed { right: 12px; }
.map-panel-toggle:hover { background: rgba(23, 23, 23, 1); }
@media (max-width: 640px) {
  .map-panel {
    width: 100%;
    height: 55%;
    top: auto;
    bottom: 0;
    border-left: none;
    border-top: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px 16px 0 0;
  }
  .map-panel.collapsed { transform: translateY(100%); }
  .map-panel-toggle { top: 12px; right: 12px; }
  .map-panel-toggle.panel-closed { right: 12px; }
}

/* Panel views: browsing (search + list) or a source's details (Turbo Frame) */
.map-panel-browse { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.map-panel-detail { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 0 16px 16px; color: #d4d4d4; font-size: 14px; }
.map-panel.showing-detail .map-panel-browse { display: none; }
.map-panel.showing-detail .map-panel-detail { display: block; }
.panel-back { display: inline-block; margin-bottom: 10px; font-size: 13px; color: #10b981; text-decoration: none; }
.panel-title { margin: 0 0 4px; font-size: 20px; font-weight: 700; color: #6ee7b7; }
.panel-meta { margin-bottom: 12px; font-size: 12px; color: #888; }
.panel-description { margin: 0 0 12px; line-height: 1.5; }
.panel-coords { margin-bottom: 12px; font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; color: #aaa; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.panel-actions .button_to { display: inline; }
.panel-btn {
  display: inline-block; padding: 5px 12px; border-radius: 6px; border: 1px solid #404040;
  background: #262626; color: #d4d4d4; font: 600 12px "Lato", sans-serif; text-decoration: none; cursor: pointer;
}
.panel-btn:hover { border-color: #10b981; color: #6ee7b7; }
.panel-btn-primary { background: #10b981; border-color: #10b981; color: #fff; }
.panel-btn-primary:hover { background: #059669; color: #fff; }
.panel-btn-danger { color: #f87171; }
.panel-btn-danger:hover { border-color: #f87171; color: #fca5a5; }
.panel-section-title { margin: 16px 0 4px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 14px; font-weight: 700; color: #e5e5e5; }
.panel-comment { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.panel-comment-author { font-size: 13px; font-weight: 600; color: #e5e5e5; }
.panel-comment-date { margin-left: 6px; font-size: 11px; color: #777; }
.panel-comment p { margin: 4px 0 0; font-size: 13px; color: #bbb; white-space: pre-line; }
.panel-empty { margin: 8px 0; font-size: 13px; font-style: italic; color: #777; }
.panel-form { margin-top: 12px; }
.panel-form input[type="text"], .panel-form textarea {
  display: block; width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 7px 10px; border-radius: 6px;
  border: 1px solid #404040; background: #262626; color: #e5e5e5; font: 13px "Lato", sans-serif; outline: none;
}
.panel-form input[type="number"], .panel-form select {
  display: block; width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 7px 10px; border-radius: 6px;
  border: 1px solid #404040; background: #262626; color: #e5e5e5; font: 13px "Lato", sans-serif; outline: none;
}
.panel-row { display: flex; gap: 6px; }
.panel-row input { flex: 1; min-width: 0; }
.panel-hint { margin: 4px 0 6px; font-size: 12px; color: #888; }
.panel-locate { margin-bottom: 12px; }
#cluster-map.placing-pin, #cluster-map.placing-pin.leaflet-grab { cursor: crosshair; }
.panel-flash { margin: 0 0 10px; padding: 8px 10px; border-radius: 6px; background: rgba(16,185,129,0.15); color: #6ee7b7; font-size: 13px; }
.panel-flash-alert { background: rgba(248,113,113,0.15); color: #fca5a5; }

/* Info menu (FAQ / About) */
.map-info-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(23,23,23,0.85); color: #10b981; font: italic 700 17px Georgia, serif; cursor: pointer;
}
.map-info-btn:hover { background: rgba(23,23,23,1); }
.map-info-menu {
  margin-top: 6px; padding: 4px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(23,23,23,0.95); min-width: 120px;
}
.map-info-menu a { display: block; padding: 7px 12px; border-radius: 6px; color: #d4d4d4; font: 600 13px "Lato", sans-serif; text-decoration: none; }
.map-info-menu a:hover { background: rgba(16,185,129,0.12); color: #6ee7b7; }
.map-info-languages {
  display: flex; gap: 4px; margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,0.08);
}
.map-info-menu .map-info-language { flex: 1; padding: 6px 8px; text-align: center; font-size: 12px; }
.map-info-language.is-current { border-radius: 6px; background: rgba(16,185,129,0.15); color: #6ee7b7; font: 700 12px "Lato", sans-serif; }

/* FAQ / About modal */
.map-modal {
  width: min(640px, calc(100% - 32px)); max-height: calc(100% - 64px); padding: 0; margin: auto;
  border: 1px solid rgba(255,255,255,0.1); border-radius: 12px; background: #1c1c1c; color: #d4d4d4;
  font-family: "Lato", sans-serif; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}
.map-modal::backdrop { background: rgba(0,0,0,0.6); }
.map-modal-body { position: relative; max-height: calc(100vh - 64px); overflow-y: auto; padding: 20px 24px 24px; box-sizing: border-box; }
.map-modal-close {
  position: absolute; top: 10px; right: 12px; width: 32px; height: 32px; border: none; border-radius: 6px;
  background: transparent; color: #aaa; font-size: 24px; line-height: 1; cursor: pointer;
}
.map-modal-close:hover { background: rgba(255,255,255,0.08); color: #fff; }
.map-modal h1 { margin: 0 0 14px; padding-right: 36px; font-size: 22px; font-weight: 700; color: #6ee7b7; }
.map-modal h2 { margin: 18px 0 6px; font-size: 16px; font-weight: 700; color: #e5e5e5; }
.map-modal p { margin: 0 0 10px; line-height: 1.6; }
.map-modal strong { color: #fff; }
.map-modal details { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
.map-modal summary { font-weight: 600; color: #e5e5e5; cursor: pointer; }
.map-modal details p { margin: 8px 0 0; }
.map-modal-credits { margin-top: 20px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.08); font-size: 12px; color: #888; }
.map-modal-credits p { margin: 0 0 2px; line-height: 1.5; }

/* Flash message after a full page load (e.g. after saving a source) */
.map-flash {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 1100;
  padding: 8px 16px; border-radius: 6px; background: rgba(6,78,59,0.95); color: #d1fae5;
  font: 600 13px "Lato", sans-serif; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  animation: map-flash-hide 0.4s ease 5s forwards;
}
.map-flash-alert { background: rgba(127,29,29,0.95); color: #fee2e2; }
@keyframes map-flash-hide { to { opacity: 0; visibility: hidden; } }

/* Panel header */
.map-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0; padding: 14px 16px 0; margin-bottom: 10px;
}
.map-panel-brand { font-size: 16px; font-weight: 700; color: #10b981; text-decoration: none; }
.map-panel-new {
  padding: 4px 12px; border-radius: 6px; background: #10b981; color: #fff;
  font-size: 12px; font-weight: 600; text-decoration: none;
}

/* Panel browsing view: search, filters, count, list */
.map-panel-controls { flex-shrink: 0; padding: 0 16px; }
.map-search { position: relative; }
.map-search-row { display: flex; gap: 6px; margin-bottom: 8px; }
.map-search-row:last-child { margin-bottom: 10px; }
.map-input {
  box-sizing: border-box; padding: 7px 10px; border-radius: 6px; border: 1px solid #404040;
  background: #262626; color: #e5e5e5; font-size: 13px; outline: none;
}
.map-search-input { flex: 1; min-width: 0; width: 100%; }
.map-radius-input { width: 60px; padding: 7px 8px; }
.map-radius-unit { color: #888; font-size: 13px; line-height: 34px; }
.map-button {
  padding: 7px 12px; border-radius: 6px; border: 1px solid #404040;
  background: #262626; color: #aaa; font-size: 13px; cursor: pointer;
}
.map-button-primary { border: none; background: #10b981; color: #fff; font-weight: 600; }
.map-search-button { flex: 1; padding: 7px; }
.map-locate-button { padding: 0 10px; color: #10b981; font-size: 16px; }

.map-category-filters { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.map-category-filter {
  padding: 4px 12px; border-radius: 9999px; border: 1.5px solid #555;
  background: transparent; color: #888; font: 600 12px "Lato", sans-serif;
  cursor: pointer; transition: all 0.15s;
}
.map-category-filter.is-active { border-color: #10b981; background: #10b981; color: #fff; }

.map-source-count { margin-bottom: 8px; font-size: 12px; color: #888; }
.map-source-list { flex: 1; overflow-y: auto; padding: 0 16px 16px; }

/* Source list items */
.source-item { padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.06); cursor: pointer; transition: background 0.15s; }
.source-item:hover { background: rgba(16, 185, 129, 0.08); }
.source-item.highlighted { background: rgba(16, 185, 129, 0.15); }
.source-item-row { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
.source-item-main { min-width: 0; }
.source-item-name {
  display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
  font-size: 14px; font-weight: 600; color: #6ee7b7; text-decoration: none;
}
.source-item-meta { margin-top: 2px; font-size: 11px; color: #888; }
.source-item-navigate {
  flex-shrink: 0; padding: 3px 10px; border-radius: 4px; border: 1px solid #404040;
  color: #aaa; font-size: 11px; text-decoration: none; white-space: nowrap;
}

/* Marker popups */
.popup-title { font-weight: 600; }
.popup-meta { color: #999; }
.popup-link { font-size: 12px; }

/* "izvori.org" in the map's bottom-left corner (beats .leaflet-container a { color: inherit }) */
.leaflet-container .map-brand {
  display: inline-block; padding: 6px 14px; border-radius: 6px; border: 1px solid rgba(255,255,255,0.08);
  background: rgba(23,23,23,0.85); color: #10b981; font: bold 14px "Lato", sans-serif; text-decoration: none;
}
