/* Pogoda — плашки віджетів: погода (card | bar | mini), втрати ворога
 * (grid | list | bar), карта DeepState. Спільна база .pogoda + теми. */

.pogoda {
  --pogoda-accent: #f5a623;
  --pogoda-bg: rgba(128, 128, 128, 0.08);
  --pogoda-fg: inherit;
  --pogoda-muted: rgba(128, 128, 128, 0.95);
  --pogoda-border: rgba(128, 128, 128, 0.2);
  --pogoda-radius: 14px;
  --pogoda-inc: #2e9e4f;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.25;
  color: var(--pogoda-fg);
  background: var(--pogoda-bg);
  border: 1px solid var(--pogoda-border);
  border-radius: var(--pogoda-radius);
  padding: 14px 16px;
  max-width: 100%;
  min-width: 0;
}
.pogoda *, .pogoda *::before, .pogoda *::after { box-sizing: border-box; }

/* Захист від стилів теми (pogoda-theme-guard).
   Теми малюють роздільники списків через li::after; наші li — флекс-рядки,
   тож такий роздільник ставав смужкою праворуч від числа і з'їдав ширину
   підпису (текст ламався по літері). Прибираємо чужі псевдоелементи,
   маркери, рамки й відступи всередині віджета. */
.pogoda ul, .pogoda ol {
  padding: 0 !important;
  list-style: none !important;
}
.pogoda li {
  margin: 0 !important;
  border: 0 !important;
  background: none !important;
  box-shadow: none !important;
  text-indent: 0 !important;
  list-style: none !important;
  word-break: normal !important;
  overflow-wrap: break-word;
}
.pogoda li::before, .pogoda li::after {
  content: none !important;
  display: none !important;
}

.pogoda-theme-light {
  --pogoda-bg: #ffffff;
  --pogoda-fg: #1a1a1a;
  --pogoda-muted: #6b7280;
  --pogoda-border: #e5e7eb;
}
.pogoda-theme-dark {
  --pogoda-bg: #1f1f1f;
  --pogoda-fg: #f3f4f6;
  --pogoda-muted: #9ca3af;
  --pogoda-border: #333333;
  --pogoda-inc: #5fd37f;
}

/* ── Шапка: заголовок + місто (селект або текст) + кнопки ── */
.pogoda-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 10px;
}
.pogoda-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pogoda-muted);
  white-space: nowrap;
}
.pogoda-city-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  min-width: 0;
}
.pogoda-city-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--pogoda-fg);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
  padding: 2px 22px 2px 4px;
  margin: 0;
  cursor: pointer;
  max-width: 200px;
  text-overflow: ellipsis;
}
.pogoda-city-select:focus {
  outline: 2px solid var(--pogoda-accent);
  outline-offset: 2px;
  border-radius: 4px;
}
.pogoda-city-select option { color: #1a1a1a; background: #fff; }
.pogoda-chevron {
  position: absolute;
  right: 2px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  pointer-events: none;
  color: var(--pogoda-muted);
}
.pogoda-city-name {
  margin-left: auto;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pogoda-close, .pogoda-geo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  margin: 0 0 0 2px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--pogoda-muted);
  cursor: pointer;
  flex: 0 0 auto;
  box-shadow: none;
}
.pogoda-close:hover, .pogoda-geo:hover { background: rgba(128, 128, 128, 0.15); color: var(--pogoda-fg); }
.pogoda-close .pogoda-icon, .pogoda-geo .pogoda-icon { width: 16px; height: 16px; }
.pogoda-is-geo .pogoda-geo { color: var(--pogoda-accent); }
.pogoda-geo-busy .pogoda-geo { opacity: 0.5; cursor: progress; }

/* ── Тіло погоди: іконка + температура + метрики ── */
.pogoda-body {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.pogoda-main-icon-wrap { display: inline-flex; flex: 0 0 auto; }
.pogoda-main-icon { width: 48px; height: 48px; stroke-width: 1.5; }
.pogoda-i-accent { stroke: var(--pogoda-accent); }
.pogoda-icon-sun circle.pogoda-i-accent,
.pogoda-icon-cloud-sun circle.pogoda-i-accent { fill: var(--pogoda-accent); fill-opacity: 0.25; }
.pogoda-icon-moon .pogoda-i-accent,
.pogoda-icon-cloud-moon .pogoda-i-accent { fill: var(--pogoda-accent); fill-opacity: 0.2; }
.pogoda-temp {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
}
.pogoda .pogoda-meta {
  list-style: none;
  margin: 0 0 0 auto;
  padding: 0;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 14px;
  color: var(--pogoda-muted);
}
.pogoda-meta li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  margin: 0;
  padding: 0;
}
.pogoda-meta li::before { content: none; }
.pogoda-meta .pogoda-icon { width: 16px; height: 16px; flex: 0 0 auto; }
.pogoda-wind-dir { font-size: 12px; opacity: 0.8; }

/* ── Підвал ── */
.pogoda-foot {
  margin-top: 8px;
  font-size: 13px;
  color: var(--pogoda-muted);
  display: flex;
  gap: 4px 12px;
  flex-wrap: wrap;
  align-items: center;
}
.pogoda-feels-val { font-weight: 600; color: var(--pogoda-fg); }
.pogoda-feels[hidden] { display: none; }

/* ── Стани ── */
.pogoda-unavailable .pogoda-temp { opacity: 0.35; }
.pogoda-unavailable .pogoda-meta { visibility: hidden; }
.pogoda-loading { opacity: 0.85; }

/* ── Погода: макет «рядок» ── */
.pogoda-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 8px 16px;
  border-radius: 0;
  border-width: 0 0 1px 0;
}
.pogoda-bar .pogoda-head { margin: 0; gap: 12px; }
.pogoda-bar .pogoda-city-wrap, .pogoda-bar .pogoda-city-name { margin-left: 0; }
.pogoda-bar .pogoda-body { gap: 10px; flex-wrap: nowrap; }
.pogoda-bar .pogoda-main-icon { width: 28px; height: 28px; }
.pogoda-bar .pogoda-temp { font-size: 20px; }
.pogoda-bar .pogoda-meta { margin-left: 0; gap: 12px; font-size: 13px; }
.pogoda-bar .pogoda-foot { margin: 0; }

/* ── Погода: макет «міні» ── */
.pogoda-mini {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
}
.pogoda-mini .pogoda-head { margin: 0; order: 2; }
.pogoda-mini .pogoda-title { display: none; }
.pogoda-mini .pogoda-city-wrap, .pogoda-mini .pogoda-city-name { margin-left: 0; }
.pogoda-mini .pogoda-body { gap: 8px; flex-wrap: nowrap; order: 1; }
.pogoda-mini .pogoda-meta, .pogoda-mini .pogoda-foot { display: none; }
.pogoda-mini .pogoda-main-icon { width: 28px; height: 28px; }
.pogoda-mini .pogoda-temp { font-size: 22px; }
.pogoda-mini .pogoda-close { order: 3; }

/* ── Втрати ворога ── */
.pogoda-losses .pogoda-head { margin-bottom: 12px; }
.pogoda-losses-title { color: var(--pogoda-fg); font-size: 13px; letter-spacing: 0.06em; white-space: normal; }
.pogoda-losses-day { font-size: 12px; color: var(--pogoda-muted); white-space: nowrap; margin-left: auto; }
.pogoda .pogoda-losses-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 12px 18px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.pogoda-losses-list .pogoda-loss {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 0;
}
.pogoda-losses-list li::before { content: none; }
.pogoda-loss-icon { display: inline-flex; flex: 0 0 auto; color: var(--pogoda-accent); }
.pogoda-loss-icon .pogoda-icon { width: 26px; height: 26px; }
.pogoda-loss-body { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.pogoda-loss-num { font-size: 18px; font-weight: 700; line-height: 1.15; white-space: nowrap; }
.pogoda-loss-inc {
  font-style: normal;
  font-weight: 600;
  font-size: 13px;
  color: var(--pogoda-inc);
  margin-left: 4px;
  white-space: nowrap;
}
.pogoda-loss-inc[hidden] { display: none; }
.pogoda-loss-label { font-size: 12.5px; color: var(--pogoda-muted); line-height: 1.2; }
.pogoda-losses-empty { color: var(--pogoda-muted); font-size: 14px; }
.pogoda-losses-source { color: var(--pogoda-muted); font-size: 12px; text-decoration: none; }
.pogoda-losses-source:hover { text-decoration: underline; }

/* втрати: список (сайдбар) */
.pogoda-losses-layout-list .pogoda-losses-list { grid-template-columns: 1fr; gap: 8px; }
.pogoda-losses-layout-list .pogoda-loss { align-items: center; }
.pogoda-losses-layout-list .pogoda-loss-icon .pogoda-icon { width: 22px; height: 22px; }
.pogoda-losses-layout-list .pogoda-loss-body {
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  gap: 8px;
}
.pogoda-losses-layout-list .pogoda-loss-label { order: -1; font-size: 13.5px; color: var(--pogoda-fg); flex: 1 1 auto; }
.pogoda-losses-layout-list .pogoda-loss-num { font-size: 15px; flex: 0 0 auto; }

/* втрати: стрічка (над шапкою) */
.pogoda-losses-layout-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 16px;
  border-radius: 0;
  border-width: 0 0 1px 0;
}
.pogoda-losses-layout-bar .pogoda-head { margin: 0; flex: 0 0 auto; }
.pogoda-losses-layout-bar .pogoda-losses-list { display: flex; gap: 18px; flex-wrap: nowrap; }
.pogoda-losses-layout-bar .pogoda-loss { flex: 0 0 auto; align-items: center; }
.pogoda-losses-layout-bar .pogoda-loss-icon .pogoda-icon { width: 20px; height: 20px; }
.pogoda-losses-layout-bar .pogoda-loss-body { flex-direction: row; align-items: baseline; gap: 6px; }
.pogoda-losses-layout-bar .pogoda-loss-num { font-size: 15px; }
.pogoda-losses-layout-bar .pogoda-loss-label { font-size: 12px; white-space: nowrap; }
.pogoda-losses-layout-bar .pogoda-foot { display: none; }

/* ── Карта DeepState ── */
.pogoda-map { padding: 12px 14px; }
.pogoda-map .pogoda-head { margin-bottom: 10px; }
.pogoda-map-open {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--pogoda-muted);
  text-decoration: none;
  white-space: nowrap;
}
.pogoda-map-open:hover { color: var(--pogoda-fg); }
.pogoda-map-open .pogoda-icon { width: 14px; height: 14px; }
.pogoda-map-frame {
  position: relative;
  height: var(--pogoda-map-h, 480px);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(128, 128, 128, 0.12);
}
.pogoda-map-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pogoda-map-load {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: linear-gradient(135deg, rgba(128, 128, 128, 0.12), rgba(128, 128, 128, 0.28));
  color: var(--pogoda-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.pogoda-map-load:hover { background: linear-gradient(135deg, rgba(128, 128, 128, 0.18), rgba(128, 128, 128, 0.34)); }
.pogoda-map-load .pogoda-icon { width: 40px; height: 40px; color: var(--pogoda-accent); }
.pogoda-map-source { font-size: 12px; color: var(--pogoda-muted); }

/* ── Кадастрова карта (партнерський iframe) ── */
.pogoda-kadastr { padding: 12px 14px; }
.pogoda-kadastr .pogoda-head { margin-bottom: 10px; }
.pogoda-kadastr-open {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--pogoda-muted);
  text-decoration: none;
  white-space: nowrap;
}
.pogoda-kadastr-open:hover { color: var(--pogoda-fg); }
.pogoda-kadastr-open .pogoda-icon { width: 14px; height: 14px; }
.pogoda-kadastr-frame {
  position: relative;
  height: var(--pogoda-kadastr-h, 600px);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(128, 128, 128, 0.12);
}
.pogoda-kadastr-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.pogoda-kadastr-load {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: linear-gradient(135deg, rgba(128, 128, 128, 0.12), rgba(128, 128, 128, 0.28));
  color: var(--pogoda-fg);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.pogoda-kadastr-load:hover { background: linear-gradient(135deg, rgba(128, 128, 128, 0.18), rgba(128, 128, 128, 0.34)); }
.pogoda-kadastr-load .pogoda-icon { width: 40px; height: 40px; color: var(--pogoda-accent); }
.pogoda-kadastr-note { font-size: 12px; color: var(--pogoda-muted); }

/* ── Обгортки авто-вставки ── */
.pogoda-top-wrap { width: 100%; }
.pogoda-front-wrap { margin: 0 0 20px; display: flex; flex-direction: column; gap: 16px; }
.pogoda-floating-wrap {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 9999;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.pogoda-floating-wrap .pogoda {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  background: var(--pogoda-bg);
  max-width: 360px;
}
.pogoda-floating-wrap .pogoda-theme-auto {
  --pogoda-bg: #ffffff;
  --pogoda-fg: #1a1a1a;
  --pogoda-muted: #6b7280;
  --pogoda-border: #e5e7eb;
}
.pogoda-floating-wrap .pogoda-map { width: 340px; }
.pogoda-auto-widget .pogoda { width: 100%; }

/* ── Прев'ю адміністратора (?pogoda_preview=1): підсвітка місць ── */
.pogoda-debug { outline: 2px dashed #e0562b; outline-offset: 3px; position: relative; }
.pogoda-debug::after {
  content: attr(data-placement);
  position: absolute;
  top: -11px;
  left: 8px;
  background: #e0562b;
  color: #fff;
  font: 600 11px/1 -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 3px 6px;
  border-radius: 4px;
  z-index: 1;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.pogoda-debug-pulse { animation: pogoda-pulse 1.6s ease-out 1; }
@keyframes pogoda-pulse {
  0% { box-shadow: 0 0 0 0 rgba(224, 86, 43, 0.75); }
  100% { box-shadow: 0 0 0 22px rgba(224, 86, 43, 0); }
}

@media (max-width: 480px) {
  .pogoda { font-size: 14px; padding: 12px 14px; }
  .pogoda-temp { font-size: 28px; }
  .pogoda-meta { gap: 10px; font-size: 13px; }
  .pogoda-main-icon { width: 40px; height: 40px; }
  .pogoda-losses-list { grid-template-columns: repeat(2, 1fr); gap: 10px 12px; }
  .pogoda-loss-num { font-size: 16px; }
  .pogoda-floating-wrap { right: 8px; bottom: 8px; max-width: calc(100vw - 16px); }
  .pogoda-floating-wrap .pogoda-map { width: calc(100vw - 16px); }
}
