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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #222;
  background: #f4f4f4;
}

/* ── Layout ── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
}

#map {
  flex: 1;
  height: 100%;
}

/* ── Sidebar header ── */
#sidebar-header {
  padding: 16px;
  border-bottom: 1px solid #eee;
}

#sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  color: #111;
  line-height: 1.2;
}

#sidebar-header p {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

/* ── Filter controls ── */
#filter-controls {
  padding: 12px 16px 8px;
  border-bottom: 1px solid #eee;
}

#filter-controls label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-bottom: 8px;
}

#filter-buttons {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

#filter-buttons button {
  flex: 1;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fafafa;
  cursor: pointer;
  transition: background 0.15s;
}

#filter-buttons button:hover {
  background: #eee;
}

/* ── Category list ── */
#category-list {
  list-style: none;
  padding: 0;
}

#category-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  cursor: pointer;
  border-radius: 0;
  transition: background 0.1s;
  user-select: none;
}

#category-list li:hover {
  background: #f5f5f5;
}

#category-list li.inactive {
  opacity: 0.4;
}

.cat-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0,0,0,0.15);
}

.cat-name {
  flex: 1;
  font-size: 13px;
}

.cat-count {
  font-size: 11px;
  color: #aaa;
  background: #f0f0f0;
  border-radius: 10px;
  padding: 1px 7px;
}

/* ── Sidebar scroll area ── */
#category-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* ── Admin badge ── */
#admin-badge {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  background: #e53e3e;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

#admin-badge.visible {
  display: block;
}

/* ── Map cursor in edit mode ── */
#map.edit-mode {
  cursor: crosshair !important;
}

/* ── Modal overlay ── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

#modal-overlay.visible {
  display: flex;
}

#modal {
  background: #fff;
  border-radius: 10px;
  width: 480px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 28px;
}

#modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #111;
}

/* ── Form ── */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
}

.form-group input:not([type="checkbox"]),
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  background: #fafafa;
}

.form-group input:not([type="checkbox"]):focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: #4a90e2;
  background: #fff;
}

.form-group textarea {
  resize: vertical;
  min-height: 72px;
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row .form-group {
  flex: 1;
}

/* ── Modal actions ── */
#modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

#modal-actions button {
  padding: 9px 20px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
}

#btn-cancel {
  background: #f0f0f0;
  color: #444;
}

#btn-cancel:hover {
  background: #e0e0e0;
}

#btn-save {
  background: #2563eb;
  color: #fff;
}

#btn-save:hover {
  background: #1d4ed8;
}

#btn-save:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

#save-status {
  font-size: 12px;
  color: #888;
  margin-top: 8px;
  text-align: right;
  min-height: 18px;
}

#save-status.error {
  color: #e53e3e;
}

#save-status.success {
  color: #16a34a;
}

/* ── Popup styles ── */
.resource-popup {
  min-width: 200px;
  max-width: 280px;
}

.resource-popup h3 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #111;
}

.resource-popup .popup-category {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding: 2px 7px;
  border-radius: 10px;
  display: inline-block;
  color: #fff;
}

.resource-popup .popup-field {
  font-size: 12px;
  color: #444;
  margin-bottom: 4px;
  line-height: 1.4;
}

.resource-popup .popup-field a {
  color: #2563eb;
  text-decoration: none;
}

.resource-popup .popup-field a:hover {
  text-decoration: underline;
}

.resource-popup .popup-tags {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.resource-popup .popup-tag {
  font-size: 10px;
  background: #f0f0f0;
  color: #666;
  padding: 2px 6px;
  border-radius: 8px;
}

/* ── Tag checkboxes in modal ── */
#tag-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 0 2px;
}

.tag-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  background: #f0f0f0;
  border-radius: 8px;
  padding: 3px 8px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.tag-checkbox input {
  margin: 0;
  cursor: pointer;
}

/* ── Edit button in popup ── */
.popup-edit-btn {
  margin-top: 10px;
  display: block;
  width: 100%;
  padding: 5px 0;
  font-size: 12px;
  font-weight: 600;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 5px;
  cursor: pointer;
}

.popup-edit-btn:hover {
  background: #1d4ed8;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  #sidebar {
    width: 220px;
  }
}
