/* ===== БАЗА ===== */

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}



body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  background: #ffffff;
  position: relative;
}

/* ===== КАРТА ===== */

#map {
  position: absolute;
  left: 0;
  right: 0;
  top: 44px;      /* место под верхнюю панель (поиск + кнопки) */
  bottom: 0;
  z-index: 1;
}

/* ===== ВЕРХНЯЯ ПАНЕЛЬ: ПОИСК + КНОПКИ ===== */

/* поле поиска */
#search-input {
  position: absolute;
  top: 6px;
  left: 10px;
  right: 330px;   /* чуть больше места справа */
  height: 30px;
  box-sizing: border-box;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid #c7c7c7;
  font-size: 13px;
  z-index: 1000;
  background: #ffffff;
}

#search-btn,
#objects-btn {
  position: absolute;
  top: 6px;
  height: 30px;
  padding: 4px 12px;
  box-sizing: border-box;
  border-radius: 999px;
  border: 1px solid #c7c7c7;
  background: #f5f5f5;
  cursor: pointer;
  font-size: 13px;
  z-index: 1000;
}


/* Кнопки */
#search-btn { right: 260px; }
#profile-btn { right: 6px; top: 6px; position: absolute; } /* КРУЖОК */
#objects-btn { right: 50px; }

#nspd-proxy-toggle {
  position: absolute;
  top: 9px;
  right: 10px;
  z-index: 1000;
  font-size: 12px;
  background: rgba(255,255,255,0.9);
  padding: 2px 6px;
  border-radius: 999px;
}


/* кнопку layers-btn и theme-btn убираем, если где-то есть */
#layers-btn,
#theme-btn {
  display: none !important;
}

/* статус внизу слева */
#status-box {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.9);
  border: 1px solid #ccc;
  font-size: 12px;
  z-index: 1000;
}

/* ===== ПАНЕЛЬ ОБЪЕКТОВ ===== */

#objects-btn {
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
}

/* боковая панель */
#objects-panel {
  position: absolute;
  top: 52px;          /* ниже строки поиска */
  right: 12px;
  bottom: 12px;
  width: 340px;
  max-width: 90vw;
  background: rgba(255,255,255,0.97);
  color: #222;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  z-index: 900;
  display: flex;
  flex-direction: column;
}
#objects-panel.hidden {
  display: none;
}

#objects-panel .panel-header {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
#objects-panel .panel-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
#objects-close {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
}

#objects-panel .panel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
  gap: 8px;
  overflow: hidden;
}

/* зона действий: импорт + поиск */
.objects-actions {
  display: flex;
  flex-direction: column;   /* колонкой, чтобы ничего не вылезало */
  gap: 6px;
  align-items: stretch;
  margin-bottom: 4px;
}

.objects-actions .import-label {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f2f2f2;
  border: 1px solid #dddddd;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  box-sizing: border-box;
}

#objects-search-input {
  width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.15);
  background: #ffffff;
  color: inherit;
  font-size: 12px;
  box-sizing: border-box;
}

#objects-import-crs,
.objects-import-crs-select {
  width: 100%;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.15);
  background: #ffffff;
  color: inherit;
  font-size: 12px;
  box-sizing: border-box;
}

/* список объектов */
#objects-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 2px;
  margin-bottom: 6px;
}
.objects-item {
  border-radius: 10px;
  padding: 7px 9px;
  margin-bottom: 4px;
  background: #f7f7f7;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.1s;
}
.objects-item:hover {
  background: #ececec;
  transform: translateY(-1px);
}
.objects-item.selected {
  background: #ffe5e5;              /* мягкий красный фон */
  border-color: #ff4d4f;            /* красная рамка */
  box-shadow: 0 0 0 1px rgba(255,77,79,0.7);
}
.objects-item.selected .obj-title {
  color: #c53030;                    /* более контрастный цвет названия */
}

.objects-item .obj-title {
  font-size: 13px;
  font-weight: 500;
}
.objects-item .obj-subtitle {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 2px;
}

/* блок метаданных и документов */
.objects-meta {
  border-top: 1px solid rgba(0,0,0,0.06);
  padding-top: 6px;
  margin-top: 4px;
  font-size: 12px;
}
.meta-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 6px;
}
.meta-row label {
  font-size: 11px;
  opacity: 0.8;
}
.meta-row input[type="text"] {
  padding: 6px 9px;
  border-radius: 8px;
  border: 1px solid rgba(0,0,0,0.15);
  background: #ffffff;
  color: inherit;
  font-size: 12px;
  box-sizing: border-box;
}

.meta-docs-header {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}
.meta-docs-header span {
  font-size: 12px;
  opacity: 0.9;
}

/* кнопки */
.btn-primary,
.btn-danger {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(120deg, #3f82ff, #4fa6ff);
  color: white;
}
.btn-primary:hover {
  filter: brightness(1.08);
}
.btn-danger {
  background: linear-gradient(120deg, #ff5b5b, #ff7951);
  color: white;
}
.btn-danger:hover {
  filter: brightness(1.05);
}

/* экспорт: селекты растягиваются, кнопка справа */
.objects-export-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
#objects-export-format,
#objects-export-crs {
  flex: 1;
  border-radius: 999px;
  padding: 4px 8px;
  border: 1px solid rgba(0,0,0,0.15);
  background: #ffffff;
  color: inherit;
  font-size: 11px;
  box-sizing: border-box;
}

/* список документов */
.objects-docs-list {
  list-style: none;
  margin: 4px 0 2px;
  padding: 0;
  max-height: 120px;
  overflow-y: auto;
}
.objects-doc-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.objects-doc-item a {
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 2.6em;
  padding: 4px 8px;
  border-radius: 8px;
  background: #f2f2f2;
  font-size: 11px;
  text-decoration: none;
  color: inherit;
}
.objects-doc-item a:hover {
  background: #eaf2ff;
}
.doc-del-btn {
  border: none;
  border-radius: 999px;
  padding: 2px 6px;
  background: rgba(0,0,0,0.08);
  color: inherit;
  cursor: pointer;
  font-size: 11px;
  flex-shrink: 0;
}
.doc-del-btn:hover {
  background: rgba(0,0,0,0.15);
}

.leaflet-attribution-flag {
    display: none !important;
}


/* старая отдельная панель слоёв, если вдруг есть — прячем */
#layers-panel {
  display: none !important;
}


/* === AUTH OVERLAY === */

#auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;

  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);

  /* блокируем клики по карте под низом */
  pointer-events: auto;
}

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

.auth-modal {
  max-width: 420px;
  width: 90%;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 16px;
  padding: 24px 20px 20px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
  text-align: center;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
}

.auth-modal h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

.auth-modal p {
  margin: 4px 0;
  font-size: 14px;
}

.auth-modal-btn {
  margin: 16px 0 8px;
}

.auth-modal-note {
  font-size: 12px;
  color: #666;
}

/* === PROFILE BUTTON === */

#profile-btn {
  width: 30px;
  height: 30px;
  background: #f5f5f5;
  border-radius: 50%;
  border: 1px solid #ccc;
  margin-left: 6px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#profile-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Когда нет аватарки: показываем иконку */
#profile-btn.no-avatar {
  background: #eee;
}

#profile-btn.no-avatar img {
  filter: invert(30%);
}

/* === PROFILE MENU === */

#profile-menu {
  position: absolute;
  top: 50px;
  right: 10px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 12px;
  padding: 12px 14px;
  width: 160px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  z-index: 99999;
}

#profile-menu.hidden {
  display: none;
}

#profile-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  text-align: center;
}

#profile-menu button {
  padding: 8px;
  border-radius: 6px;
  border: none;
  background: #f44336;
  color: #fff;
  cursor: pointer;
}

#profile-menu button:hover {
  background: #d7372d;
}
