.sls-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

html.sls-modal-open,
body.sls-modal-open {
  overflow: hidden;
}

body.sls-modal-open {
  touch-action: none;
  overscroll-behavior: contain;
}

.sls-modal__content {
  background: var(--wp--preset--color--base, #fff);
  border-radius: 12px;
  max-width: 560px;
  width: 100%;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  text-align: center;
  color: var(--wp--preset--color--contrast, #000);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.sls-modal__title {
  margin: 0 0 12px;
  font-size: 1.5rem;
  line-height: 1.3;
  color: var(--wp--preset--color--contrast, #000);
}

.sls-modal__description {
  margin: 0 0 24px;
  color: var(--wp--preset--color--contrast-2, #666);
  font-size: 1rem;
}

.sls-modal__languages {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

/* 3 languages: 3 columns */
.sls-modal__languages[data-language-count="3"] {
  grid-template-columns: repeat(3, 1fr);
}

/* 4 languages: 3 columns with 4th item positioned to create 3+1 layout */
.sls-modal__languages[data-language-count="4"] {
  grid-template-columns: repeat(3, 1fr);
}

.sls-modal__languages[data-language-count="4"]
  .sls-modal__language:nth-child(4) {
  grid-column: 1 / span 1;
}

/* 5+ languages: 3 columns */
.sls-modal__languages[data-language-count="5"],
.sls-modal__languages[data-language-count="6"],
.sls-modal__languages[data-language-count="7"],
.sls-modal__languages[data-language-count="8"],
.sls-modal__languages[data-language-count="9"],
.sls-modal__languages[data-language-count="10"] {
  grid-template-columns: repeat(3, 1fr);
}

/* Mobile adjustments for smaller screens */
@media (max-width: 479px) {
  /* On mobile, keep 2 columns for 4+ languages */
  .sls-modal__languages[data-language-count="4"],
  .sls-modal__languages[data-language-count="5"],
  .sls-modal__languages[data-language-count="6"],
  .sls-modal__languages[data-language-count="7"],
  .sls-modal__languages[data-language-count="8"],
  .sls-modal__languages[data-language-count="9"],
  .sls-modal__languages[data-language-count="10"] {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Reset the 4th item positioning on mobile */
  .sls-modal__languages[data-language-count="4"]
    .sls-modal__language:nth-child(4) {
    grid-column: auto;
  }
}

.sls-modal__language {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--wp--preset--color--contrast-3, #ddd);
  border-radius: 8px;
  background: var(--wp--preset--color--base, #fff);
  color: var(--wp--preset--color--contrast, #000);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.sls-modal__language:hover {
  border-color: #7600ca;
  background: var(--wp--preset--color--base-2, #f8f9fa);
  color: #7600ca;
}

.sls-modal__language--suggested {
  border-color: #7600ca;
  background: rgba(118, 0, 202, 0.1);
  border-width: 2px;
}

.sls-modal__language--suggested:hover {
  background: rgba(118, 0, 202, 0.2);
}

.sls-modal__flag {
  width: 24px;
  height: 18px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}

.sls-modal__name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sls-modal__close {
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 0.9rem;
  cursor: pointer;
  background: var(--wp--preset--color--secondary, #f6f7f7);
  color: var(--wp--preset--color--secondary-contrast, #666);
  transition: all 0.2s ease;
}

.sls-modal__close:hover {
  background: var(--wp--preset--color--secondary-hover, #edeff0);
}

/* Loading spinner overlay */
.sls-modal__loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 12px;
}

.sls-modal__loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #7600ca;
  border-radius: 50%;
  animation: sls-spin 1s linear infinite;
}

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

/* Blur effect when loading - only affects content behind the overlay */
.sls-modal--loading .sls-modal__content {
  filter: blur(2px);
  position: relative;
  z-index: 5;
}
