/* 국가 필터 스타일 */
.country-filter-container {
  position: relative;
  display: inline-block;
  margin: 10px 0;
  min-width: 200px;
  z-index: 1000;
  overflow: visible !important;
}

.country-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 15px;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 14px;
  font-weight: 500;
  min-height: 44px;
  box-sizing: border-box;
}

.country-selected:hover {
  border-color: #ff6b6b;
  background: #fff5f5;
}

.country-selected.open {
  border-color: #ff6b6b;
  background: #fff5f5;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.country-flag {
  font-size: 20px;
  line-height: 1;
}

.country-name {
  flex: 1;
  color: #333;
}

.dropdown-arrow {
  color: #999;
  font-size: 12px;
  transition: transform 0.3s ease;
}

.country-selected:hover .dropdown-arrow {
  color: #ff6b6b;
}

.country-dropdown {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 999999 !important;
  max-height: 400px;
  overflow: hidden;
  display: none; /* 기본적으로 숨김 */
  flex-direction: column;
  min-width: 250px;
  max-width: calc(100vw - 2rem);
}

.country-dropdown[style*="display: block"] {
  display: flex !important;
}

.country-search {
  padding: 10px;
  border-bottom: 1px solid #e0e0e0;
}

.country-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.3s ease;
}

.country-search input:focus {
  border-color: #ff6b6b;
}

.country-list {
  flex: 1;
  overflow-y: auto;
  max-height: 320px;
}

.country-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 14px;
}

.country-item:hover {
  background: #f8f8f8;
}

.country-item.selected {
  background: #fff5f5;
  color: #ff6b6b;
  font-weight: 500;
}

.country-item .country-name {
  flex: 1;
}

.check-mark {
  color: #ff6b6b;
  font-weight: bold;
  margin-left: auto;
}

/* 라운지 페이지 국가 필터 위치 */
.filter-section {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin: 20px 0;
  flex-wrap: wrap;
  overflow: visible !important;
  position: relative;
  z-index: 100;
}

.filter-section .country-filter-container {
  margin: 0;
}

/* 도전 카드에 국가 표시 */
.card .country-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: #f0f0f0;
  border-radius: 15px;
  font-size: 12px;
  margin-bottom: 8px;
  color: #666;
}

.card .country-badge .country-flag {
  font-size: 14px;
}

/* 도전 생성 페이지 국가 선택 */
.form-group select#countrySelect {
  width: 100%;
  padding: 10px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  background: white;
  cursor: pointer;
  transition: border-color 0.3s ease;
  position: relative;
  z-index: 1;
  max-height: 200px;
  overflow-y: auto;
}

.form-group select#countrySelect:focus {
  border-color: #ff6b6b;
  outline: none;
  z-index: 9999;
}

/* 모바일 반응형 */
@media (max-width: 768px) {
  .country-filter-container {
    width: 100%;
    min-width: unset;
  }

  .filter-section {
    flex-direction: column;
    align-items: stretch;
    overflow: visible !important;
  }

  .country-dropdown {
    position: fixed;
    left: 1rem;
    right: 1rem;
    top: auto;
    max-height: 60vh;
    width: calc(100vw - 2rem);
    max-width: unset;
    min-width: unset;
    transform: translateY(5px);
  }
  
  /* 화면 하단에 공간이 부족할 경우 위쪽으로 표시 */
  .country-filter-container.show-above .country-dropdown {
    bottom: 100%;
    top: auto;
    transform: translateY(-5px);
  }

  .country-list {
    max-height: calc(70vh - 80px);
  }

  .country-selected {
    padding: 12px 15px;
    font-size: 16px;
  }

  .country-item {
    padding: 14px 15px;
    font-size: 16px;
  }

  .country-search input {
    font-size: 16px;
    padding: 10px 12px;
  }
}