.ewm-shortcode {
  width: 100%;
}

.ewm-shortcode.elections-columns {
  display: grid;
  grid-template-columns: minmax(0, calc(65% - 10px)) minmax(0, calc(35% - 10px));
  gap: 20px;
  align-items: start;
}

.ewm-shortcode .ewm-map-column,
.ewm-shortcode .ewm-elections-list {
  min-width: 0;
}

.ewm-shortcode .continent-card,
.ewm-shortcode .ewm-map-panel {
  display: none;
}

.ewm-shortcode .continent-card.active,
.ewm-shortcode .ewm-map-panel.active {
  display: block;
}


/* Kontynenty i rodzaje wyborów zawsze wielkimi literami także na froncie. */
.ewm-shortcode .ewm-main-button,
.ewm-shortcode .ewm-election-button {
  text-transform: uppercase !important;
}

.ewm-shortcode .ewm-main-filters,
.ewm-shortcode .ewm-election-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ewm-shortcode .ewm-map-wrapper {
  position: relative;
  width: 100%;
}

/* Kontener mapy i responsywne skalowanie SVG. */
.ewm-shortcode #map-wrapper {
  position: relative;
  width: 100%;
  overflow: hidden;
  margin-bottom: 10px;
}

.ewm-shortcode #map-desktop svg {
  display: block;
  width: 100%;
  height: auto;
}

/*
 * Selektor kraju ma stać przy PRAWEJ krawędzi mapy.
 * !important kasuje stare reguły motywu/snippetów, które ustawiały
 * pozycję dla .country-select / .country-selected-election-page.
 */
.ewm-shortcode .ewm-selector-wrap {
  position: absolute !important;
  z-index: 200 !important;
  top: 20px !important;
  right: 20px !important;
  bottom: auto !important;
  left: auto !important;
  width: calc(100% - 30px) !important;
  max-width: 220px !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
}

.ewm-shortcode .ewm-country-select {
  position: relative !important;
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  transform: none !important;
  line-height: 1.25;
  box-sizing: border-box;
}

.ewm-shortcode .ewm-country-selected {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  max-width: none !important;
  min-height: 42px;
  margin: 0 !important;
  padding: 9px 14px !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  transform: none !important;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #222;
  cursor: pointer;
  user-select: none;
  box-sizing: border-box !important;
}

.ewm-shortcode .ewm-country-selected .country-label {
  display: block;
  min-width: 0;
  margin: 0;
  padding: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ewm-shortcode .ewm-country-selected:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Własna strzałka - bez zależności od starego .country-arrow z motywu. */
.ewm-shortcode .ewm-country-arrow {
  display: block !important;
  flex: 0 0 auto !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 1px 0 14px !important;
  padding: 0 !important;
  border: 0 !important;
  border-left: 7px solid transparent !important;
  border-right: 7px solid transparent !important;
  border-top: 9px solid #222 !important;
  border-bottom: 0 !important;
  background: transparent !important;
  transform: rotate(0deg) !important;
  transform-origin: 50% 45% !important;
  transition: transform .15s ease;
  box-sizing: content-box !important;
}

.ewm-shortcode .ewm-country-arrow::before,
.ewm-shortcode .ewm-country-arrow::after {
  content: none !important;
  display: none !important;
}

.ewm-shortcode .ewm-country-select.is-open .ewm-country-arrow {
  transform: rotate(180deg) !important;
}

.ewm-shortcode .ewm-country-options {
  display: none;
  position: absolute !important;
  z-index: 500 !important;
  left: 0 !important;
  right: 0 !important;
  top: calc(100% + 4px) !important;
  bottom: auto !important;
  width: 100% !important;
  min-width: 100% !important;
  max-width: 100% !important;
  max-height: 273px;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  overflow-x: hidden;
  overflow-y: auto;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  box-sizing: border-box !important;
}

.ewm-shortcode .ewm-country-option,
.ewm-shortcode .ewm-country-group {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  margin: 0;
  padding: 7px 11px;
  color: #999;
  cursor: default;
  box-sizing: border-box;
}

.ewm-shortcode .ewm-country-option.is-active {
  color: #222;
  cursor: pointer;
}

.ewm-shortcode .ewm-country-option.is-active:hover,
.ewm-shortcode .ewm-country-option.is-active:focus {
  background: #f2f2f2;
}

.ewm-shortcode .ewm-country-group {
  background: #f1f1f1;
  color: #555;
  font-weight: 700;
}

.ewm-shortcode .ewm-country-group + .ewm-country-option,
.ewm-shortcode .ewm-country-option + .ewm-country-group {
  margin-top: 0;
}

.ewm-shortcode img.flagselect {
  width: 22px;
  height: 22px;
  object-fit: cover;
  flex-direction: 0 0 auto;
  margin-top: -2px;
  border-radius: 3px;
  box-shadow: 1px 1px #ccc;
}

.ewm-shortcode .country.is-active {
  cursor: pointer !important;
}

.ewm-shortcode .country.is-archived {
  opacity: 1 !important;
  cursor: default !important;
}

.ewm-shortcode .country.country--occupied-territory {
  opacity: 1 !important;
}
/* Dla nieaktywnego kraju nadrzędnego front.js nadpisuje tę wartość inline
   na 0.8!important, aby terytorium okupowane miało identyczną jasność. */

/*
 * Wypełnienie terytoriów spornych ustawia front.js zależnie od stanu:
 * nieaktywne = szaro-czerwone kreskowanie,
 * hover nieaktywnego = ciemniejsze szaro-czerwone kreskowanie,
 * aktywne = szaro-czerwone wypełnienie,
 * hover aktywnego = ciemniejsze szaro-czerwone wypełnienie.
 */

@media (min-width: 1021px) {
  .ewm-shortcode .ewm-elections-list {
    margin-top: 94px;
  }
}

@media (max-width: 1020px) {
  .ewm-shortcode.elections-columns {
    grid-template-columns: 1fr;
  }

  .ewm-shortcode .ewm-elections-list {
    margin-top: 0;
  }
}

/*
 * Pozycja selektora ma dwa i tylko dwa tryby:
 * - od 721 px: desktop — na mapie, prawa górna krawędź,
 * - do 720 px: mobile — lewa górna krawędź.
 *
 * Używamy także ID #map-wrapper i #wybory-lista, ponieważ CSS motywu
 * ma własne reguły tabletowe (m.in. do 900 px) o większej specyficzności.
 * Dzięki temu zakres 721–900 px nie może już wyrzucić selektora nad mapę.
 */
@media (min-width: 721px) {
  /*
   * W starszym CSS strony zakres tabletowy (do 900 px) modyfikuje także
   * #map-wrapper / #map-desktop. Samo wymuszenie pozycji selektora nie
   * wystarczało, bo jego containing block przestawał zachowywać się jak
   * w desktopie. Resetujemy więc także kontener mapy, aby 721–900 px było
   * dokładnie tym samym układem co 901+.
   */
  .ewm-shortcode #map-wrapper.ewm-map-wrapper {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 0 50px !important;
    padding: 0 !important;
    inset: auto !important;
    transform: none !important;
  }

  .ewm-shortcode #map-desktop.ewm-map-desktop {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    transform: none !important;
  }

  .ewm-shortcode #map-wrapper.ewm-map-wrapper > #wybory-lista.ewm-selector-wrap {
    position: absolute !important;
    z-index: 200 !important;
    top: 0 !important;
    right: 1px !important;
    bottom: auto !important;
    left: auto !important;
    width: calc(100% - 30px) !important;
    max-width: 220px !important;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }
}

@media (max-width: 720px) {
  /*
   * Mobilny układ odpowiada dawnemu CSS strony: selektor od lewej,
   * minimum 230 px szerokości i mapa odsunięta o 100 px w dół.
   * Reguły są wtyczkowe, więc nie trzeba już trzymać ich w CSS motywu.
   */
  .ewm-shortcode #map-wrapper.ewm-map-wrapper > #wybory-lista.ewm-selector-wrap {
    position: absolute !important;
    z-index: 200 !important;
    width: 50% !important;
    min-width: 230px !important;
    max-width: calc(100% - 2px) !important;
    top: 0 !important;
    bottom: auto !important;
    left: 0 !important;
    right: auto !important;
    margin: 1px !important;
    padding: 0 !important;
    transform: none !important;
  }

  .ewm-shortcode .ewm-country-select,
  .ewm-shortcode .ewm-country-selected {
    width: 100% !important;
    min-width: 230px !important;
    max-width: 100% !important;
  }


  .ewm-shortcode .ewm-country-options {
    right: 1px !important;
    top: calc(100% + 4px) !important;
    width: 100% !important;
    min-width: 220px !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .ewm-shortcode #map-desktop.ewm-map-desktop {
    margin-top: 100px !important;
  }

  .ewm-shortcode .ewm-main-filters,
  .ewm-shortcode .ewm-election-filters {
    gap: 3px;
  }
}


/* Ciągłe granice międzynarodowe terytoriów spornych (np. Naddniestrze–Ukraina). */
.ewm-shortcode .occupied-territory-international-border {
  fill: none !important;
  stroke: #fff !important;
  stroke-width: 1 !important;
  stroke-dasharray: none !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  vector-effect: non-scaling-stroke;
  pointer-events: none !important;
}

/* ============================================================
 * Selektor kraju — nad mapą, wyrównany do prawej na każdej szerokości
 * ============================================================ */
.ewm-shortcode #map-wrapper.ewm-map-wrapper > #wybory-lista.ewm-selector-wrap {
  position: relative !important;
  z-index: 200 !important;
  top: auto !important;
  right: auto !important;
  bottom: auto !important;
  left: auto !important;
  width: 220px !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 0 8px auto !important;
  padding: 0 !important;
  transform: none !important;
}

.ewm-shortcode .ewm-country-select,
.ewm-shortcode .ewm-country-selected {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  font-size: 0.9rem !important;
}

.ewm-shortcode .ewm-country-selected {
  border: 0 !important;
  border-bottom: 1px solid #333 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.ewm-shortcode .ewm-country-options {
  font-size: 0.9rem !important;
}

.ewm-shortcode .ewm-country-option,
.ewm-shortcode .ewm-country-group {
  padding: 5px 8px !important;
}

.ewm-shortcode img.flagselect {
  width: 16px !important;
  height: 16px !important;
}

/* Po ustawieniu selektora nad mapą nie jest już potrzebny mobilny offset mapy. */
.ewm-shortcode #map-desktop.ewm-map-desktop {
  margin-top: 0 !important;
}

/* ============================================================
 * Selektor kraju — wygląd jak .ewybory-year-select
 * ============================================================ */
.ewm-shortcode .ewm-country-selected {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  height: 30px !important;
  min-height: 30px !important;
  padding: 0 20px 0 7px !important;
  border: 1px solid #d2d2d2 !important;
  border-radius: 4px !important;
  background-color: #fff !important;
  background-repeat: no-repeat !important;
  background-position: right 6px center !important;
  background-size: 10px 6px !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23545b66' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  box-shadow: none !important;
  font-family: inherit !important;
  line-height: 28px !important;
  text-align: left !important;
  cursor: pointer !important;
}

.ewm-shortcode .ewm-country-selected .country-label {
  line-height: 28px !important;
}

/* Strzałka jest teraz taka sama jak w select roku — jako background-image. */
.ewm-shortcode .ewm-country-arrow {
  display: none !important;
}
