/* ============================================================
   СОПС — стили карты
   ============================================================ */

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

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

/* ---- Шапка с фильтром ---- */
#map-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--color-surface);
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
#map-header .logo-link {
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-primary);
  white-space: nowrap;
  text-decoration: none;
}
#station-filter-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
}
#station-input {
  width: 100%;
  padding: 7px 30px 7px 10px;
  border: 1.5px solid var(--color-border);
  border-radius: 20px;
  font-size: .9rem;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color .15s;
}
#station-input:focus { border-color: var(--color-primary); }
#station-clear {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; font-size: 1rem;
  color: var(--color-text-sec);
  display: none;
  padding: 2px;
}
#station-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
  z-index: 300;
  display: none;
}
.suggestion-item {
  padding: 9px 12px;
  cursor: pointer;
  font-size: .9rem;
  border-bottom: 1px solid var(--color-border);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--color-surface2); }

#map-header .spacer { flex: 1; }
#header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
  white-space: nowrap;
}
#header-user a { color: var(--color-primary); text-decoration: none; }

/* ---- Загрузочный оверлей ---- */
#loading-overlay {
  position: fixed; inset: 0;
  background: var(--color-surface);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  transition: opacity .4s;
}
#loading-overlay.fade-out { opacity: 0; pointer-events: none; }

.loading-logo {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
}
.loading-step {
  width: 280px;
}
.loading-label {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  color: var(--color-text-sec);
  margin-bottom: 6px;
}
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--color-surface2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--color-primary);
  width: 0%;
  transition: width .2s;
}
#loco-step { opacity: .4; transition: opacity .3s; }
#loco-step.active { opacity: 1; }

/* ---- Иконки поездов ---- */
.train-icon {
  position: relative;
  cursor: pointer;
  transform: translate(-50%, -100%);
}
.train-icon-inner {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border: 2px solid #4a4a4a;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  font-family: system-ui, Arial, sans-serif;
  overflow: hidden;
  min-width: 44px;
  position: relative;
}
.train-icon-inner::after {
  content: '';
  position: absolute;
  bottom: -7px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 7px solid #4a4a4a;
}
.train-icon-photo {
  width: 56px; height: 32px;
  object-fit: cover; display: block;
}
.train-icon-text {
  display: flex;
  align-items: baseline;
  gap: 3px;
  padding: 3px 6px;
  white-space: nowrap;
}
.train-icon-name { font-size: 12px; font-weight: bold; color: #222; }
.train-icon-loco { font-size: 9px; color: #777; font-weight: normal; }
.train-icon-inner.no-photo .train-icon-text { padding: 3px 7px; }

[data-theme="dark"] .train-icon-inner { background: #2a2a2a; border-color: #888; }
[data-theme="dark"] .train-icon-name  { color: #eee; }

/* ---- Баллун ---- */
.train-balloon {
  font-family: system-ui, Arial, sans-serif;
  line-height: 1.5;
  min-width: 240px;
  max-width: 320px;
  max-height: min(520px, 70vh);
  overflow-y: auto;
  font-size: .9rem;
}
.balloon-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: #1a73e8;
}
.balloon-route {
  font-size: .85rem;
  color: #666;
  margin-bottom: 10px;
}
.balloon-status {
  background: #f1f3f4;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: .875rem;
}
.balloon-rzd-link {
  margin-bottom: 10px;
  font-size: .82rem;
}
.balloon-rzd-link a {
  color: var(--color-primary, #1a73e8);
  text-decoration: none;
}
.balloon-rzd-link a:hover { text-decoration: underline; }
.balloon-loco {
  margin-bottom: 10px;
}
.balloon-loco-label {
  font-size: .8rem;
  color: #666;
  margin-bottom: 3px;
}
.balloon-loco-value {
  font-weight: 600;
  font-size: .95rem;
}
.balloon-loco-photo {
  max-width: 100%;
  border-radius: 4px;
  margin-top: 5px;
  display: block;
}
.balloon-votes {
  display: flex;
  gap: 12px;
  font-size: .85rem;
  color: #555;
  margin-top: 4px;
}
.balloon-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.balloon-actions .btn { font-size: .8rem; padding: 5px 12px; }
.balloon-loading {
  color: #999;
  font-size: .85rem;
  font-style: italic;
}

/* ---- Кластер ---- */
.cluster-list {
  font-family: system-ui, Arial, sans-serif;
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
  min-width: 200px;
  font-size: .9rem;
}
.cluster-list a {
  color: #1a73e8;
  text-decoration: none;
  cursor: pointer;
  display: block;
  padding: 2px 0;
}
.cluster-list a:hover { text-decoration: underline; }

/* ---- Модальное "нужна авторизация" ---- */
#auth-prompt .modal { text-align: center; }
#auth-prompt .modal p { color: var(--color-text-sec); font-size: .9rem; margin-bottom: 16px; }

/* ---- Комментарии в баллуне ---- */
.balloon-comments { margin-top: 12px; }
.balloon-comments-label {
  font-size: .8rem;
  color: #666;
  font-weight: 600;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.balloon-comments-list {
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 8px;
}
.balloon-comment {
  padding: 5px 0;
  border-bottom: 1px solid var(--color-border, #eee);
  font-size: .82rem;
}
.balloon-comment:last-child { border-bottom: none; }
.balloon-comment-author {
  font-weight: 600;
  color: var(--color-text, #222);
  margin-right: 4px;
}
.balloon-comment-author.admin { color: #d62;  }
.balloon-comment-time {
  font-size: .75rem;
  color: #999;
}
.balloon-comment-text {
  color: var(--color-text, #333);
  margin-top: 2px;
  white-space: pre-wrap;
  word-break: break-word;
}
.balloon-comment-form {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.balloon-comment-input {
  width: 100%;
  padding: 6px 8px;
  border: 1.5px solid var(--color-border, #ddd);
  border-radius: 6px;
  font-size: .85rem;
  resize: vertical;
  font-family: inherit;
  box-sizing: border-box;
}
.balloon-comment-input:focus { border-color: var(--color-primary, #1a73e8); outline: none; }
.balloon-votes { margin-top: 4px; gap: 8px; }
.btn-xs { font-size: .72rem !important; padding: 2px 8px !important; }

/* ---- Адаптив ---- */
@media (max-width: 600px) {
  #map-header { flex-wrap: wrap; padding: 6px 10px; gap: 6px; }
  #station-filter-wrap {
    order: 3;
    flex: 0 0 100%;
    max-width: none;
  }
  #map-header .spacer { display: none; }
  .loading-step { width: 260px; }
}
