/**
 * @file
 * Styles for the Patria Offices Map.
 */

.offices-map {
  width: 1152px;
  max-width: calc(100% - 2rem);
  margin: 0 auto;
}

/* Header with title and select */
.offices-map__header {
  display: flex;
  align-items: center;
  justify-content: start;
  margin: 0 0 2rem;
  gap: 2rem;
  flex-wrap: wrap;
}

.offices-map__title {
  font-size: 30px;
  font-weight: 600;
  margin: 0;
  color: #000;
}

.current-country-label {
  cursor: pointer;
  display: inline;
}

.offices-map__title .current-country {
  font-weight: 600;
}

.offices-map__select-wrapper {
  flex-shrink: 0;
  min-width: 250px;
}

.offices-map__select {
  appearance: none;
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23003370' d='M1.41 0L6 4 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 8px;
  border: 1px solid #003370;
  cursor: pointer;
  color: #003370;
  font-size: 14px;
  font-weight: 700;
  padding: 12px 40px 12px 16px;
  width: 100%;
}

.offices-map__select:hover,
.offices-map__select:focus {
  border-color: #00A3E0;
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 163, 224, 0.2);
}

.offices-map__container {
  position: relative;
  margin-bottom: 2rem;
}

.offices-map__svg-wrapper {
  width: 100%;
  background-color: transparent;
  border-radius: 8px;
  padding: 2rem;
}

#offices-map-svg {
  background-image: url('../images/map.png');
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  width: 100%;
  height: auto;
}

#offices-map-svg svg {
  width: 100%;
  height: auto;
  display: block;
}

/* Clickable countries */
#offices-map-svg .country-clickable {
  cursor: pointer;
  transition: fill 0.3s ease, opacity 0.3s ease, stroke 0.3s ease;
  fill: #003370;
}

#offices-map-svg .country-clickable:hover,
#offices-map-svg .country-clickable.hover {
  fill: #205390;
  stroke: #6093F0;
}

#offices-map-svg .country-clickable:focus {
  outline: 2px solid #205390;
  outline-offset: 2px;
}

#offices-map-svg .country-clickable.active {
  fill: #4073B0;
  stroke: #6093F0;
  stroke-width: 1px;
}

/* Country groups (from processed SVG) */
/* Only apply styles to groups that contain a path with data-country-id */
#offices-map-svg .country-group:has(path[data-country-id]) {
  cursor: pointer;
}

#offices-map-svg .country-group:has(path[data-country-id]):hover path.country-path {
  transition: fill 0.3s ease;
  fill: #205390;
}

/* Country text labels */
#offices-map-svg #markers-labels-group .country-label {
  cursor: pointer;
  fill: #00A3E0 !important;
  font-size: 16px;
  font-family: "Titillium web";
  font-weight: 700;
  transition: outline 0.3s ease, fill 0.3s ease;
}

#offices-map-svg #markers-labels-group .country-label:hover,
#offices-map-svg #markers-labels-group .country-label.hover {
  fill: #EFAF00 !important;
}

/* Clickable text elements */
#offices-map-svg .country-clickable-text {
  fill: #00A3E0 !important;
  transition: outline 0.3s ease, fill 0.3s ease;
}

#offices-map-svg .country-clickable-text:hover,
#offices-map-svg .country-clickable-text.hover {
  fill: #EFAF00 !important;
}

#offices-map-svg .country-marker line {
  position: relative;
  stroke-width: 2px;
  z-index: 10;
}

#offices-map-svg #map-legend text {
    fill: #000;
}
/* Hide all the unnecessary elements (wrong language) */
html[lang="en"] #offices-map-svg #markers-labels-group .country-label.country-label-fi,
html[lang="fi"] #offices-map-svg #markers-labels-group .country-label.country-label-en {
  display: none !important;
}

/* Map markers */
.map-marker {
  cursor: pointer;
  transition: transform 0.2s ease;
}

.map-marker:hover {
  transform: scale(1.2);
}

/* Legend */
.offices-map__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin-top: 1.5rem;
  padding: 1rem;
  background-color: #fff;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.legend-icon--hq {
  color: #ffa500;
}

.legend-icon--office {
  color: #003370;
}

.legend-icon--representation {
  color: #ffa500;
}

.legend-icon--ilias {
  color: #ffa500;
}

.legend-label {
  font-size: 0.9rem;
  color: #333;
}

/* Country content area */
.offices-map__content {
  min-height: 200px;
  background-color: #fff;
  border-radius: 8px;
}

.country-content__placeholder {
  text-align: center;
  color: #666;
  padding: 3rem 1rem;
}

.country-content__empty {
  text-align: center;
  color: #999;
  font-style: italic;
  padding: 2rem 1rem;
}

/* Loading state */
.offices-map__content.htmx-request {
  opacity: 0.6;
  position: relative;
}

.offices-map__content.htmx-request::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #003370;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Footer with country list */
.offices-map__footer {
  border-top: 1px solid #003370;
  margin: 0rem 0rem 2rem;
  padding-top: 3rem;
}

.offices-map__countries-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 1.5rem 0;
  color: #000;
}

.offices-map__countries-list {
  list-style: none;
  padding: 0;
  margin: 0;
  .country-item {
    display: inline-block;
    margin-right: 40px;
    a {
      font-size: 18px;
      font-weight: 700;
    }
  }
  @media (max-width: 768px) {
    display: flex;
    flex-wrap: wrap;
    gap: 33px 2rem !important;
    .country-item {
      flex-basis: 45%;
      margin-right: 0px;
    }
  }
}

.country-item {
  margin: 0;
}

.country-link {
  font-size: 1rem;
  color: #00A3E0;
  text-decoration: none;
  transition: color 0.2s ease;
  cursor: pointer;
}

.country-link:hover {
  color: #003370;
  text-decoration: underline;
}

.country-link.active {
  color: #000;
  font-weight: 600;
  text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
  .offices-map__header {
    align-items: flex-start;
    flex-direction: column;
    margin: 0 0em 0rem;
  }

  .offices-map__title {
  }

  .offices-map__select-wrapper {
    width: 100%;
  }

  .offices-map__svg-wrapper {
    padding: 1rem;
  }

  .offices-map__legend {
    flex-direction: column;
    gap: 0.75rem;
  }

  .offices-map__content {
    padding: 0 0rem 1rem;
  }

  .offices-map__countries-list {
    gap: 0.75rem 1rem;
  }

  .country-link {
    font-size: 0.9rem;
  }
}
