/* Страница /polygons — редактор полигонов пользователя */
:root {
  --bg: #f3f5fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body.polygons-page {
  margin: 0;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.polygons-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.polygons-page__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.polygons-page__back {
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.polygons-page__main {
  padding: 16px;
  max-width: 1400px;
  margin: 0 auto;
}

.polygons-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.polygons-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.muted { color: var(--muted); }

.polygons-gate {
  padding: 24px 16px;
  text-align: center;
}

.polygons-gate[hidden],
.polygons-editor[hidden] {
  display: none !important;
}

button, .btn-primary {
  margin-top: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.btn-del-city {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

input, select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.cities-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.cities-table th,
.cities-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f5f9;
  text-align: left;
}

.cities-table th {
  background: #f8fafc;
  font-size: 12px;
  color: var(--muted);
  position: sticky;
  top: 0;
}

.poly-editor-split {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  min-height: min(72vh, 820px);
}

.poly-editor-side {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(72vh, 820px);
}

.poly-editor-map-col {
  min-width: 0;
  min-height: 420px;
  height: min(72vh, 820px);
}

.poly-editor-map-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #eef1f5;
}

#polyEditorMap { width: 100%; height: 100%; }

.poly-list-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  border: 1px solid #eee;
  border-radius: 10px;
  background: #fff;
}

.poly-list-wrap .cities-table { border-radius: 0; }
.poly-row { cursor: pointer; }
.poly-row.is-selected td { background: #e0f2fe; }

.poly-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.poly-toolbar input {
  margin-top: 0;
  flex: 1;
  min-width: 140px;
}

#polyDeleteVertexBtn.is-active {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.poly-add-box {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.poly-add-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.poly-add-row label { margin: 0; font-size: 13px; display: block; }
.poly-add-row input,
.poly-add-row select { margin-top: 4px; width: 100%; }

.poly-add-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  align-items: center;
}

.poly-add-actions button { margin-top: 0; }

#polyDrawBtn.is-active {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}

.poly-my-box {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
}

.poly-my-box h4 {
  margin: 0;
  font-size: 13px;
}

.poly-my-head {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.poly-my-head button {
  margin-top: 0;
  padding: 5px 10px;
  font-size: 12px;
}

.poly-my-proposals {
  margin: 0;
  padding-left: 0;
  list-style: none;
  font-size: 12px;
  color: var(--muted);
}

.poly-my-proposals li {
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 5px 0;
  border-bottom: 1px solid #eef2f7;
}

.poly-my-proposals li:last-child {
  border-bottom: 0;
}

.poly-status {
  font-weight: 700;
  font-size: 11px;
  text-transform: lowercase;
}

.poly-status.is-pending { color: #b45309; }
.poly-status.is-approved { color: #047857; }
.poly-status.is-rejected { color: #b91c1c; }

@media (max-width: 900px) {
  .poly-add-row { grid-template-columns: 1fr; }
  .poly-editor-split {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .poly-editor-side { max-height: none; }
  .poly-editor-map-col {
    height: 55vh;
    min-height: 320px;
  }
}
