/* Search uses shared styles from styles.css */
.search-filter-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 40px;
}

/* Filter Controls Row */
.filter-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
}

.controls-right,
.controls-left {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.control-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.control-label-sm {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.custom-select-wrapper {
  min-width: 180px;
}

.country-filter-area .category-scroll {
  padding: 6px;
}

.header-actions .category-scroll {
  max-width: 360px;
}

.count-display {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
  color: var(--muted);
  background: var(--surface-2);
  padding: 8px 16px;
  border-radius: 99px;
  border: 1px solid var(--border);
  min-height: 40px;
}

.count-display .separator {
  opacity: 0.2;
}

.count-display strong {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.1rem;
}

/* Country Filter Area */
.country-filter-area {
  transition: opacity 0.3s ease, transform 0.3s ease;
  transform-origin: left center;
  animation: slideInLeft 0.3s ease forwards;
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.country-filter-area.is-hidden {
  display: none;
}
/* Removed old filter-header and chip-grid styles as they are replaced by select */

/* Flag Grid */
.flag-list-section {
  display: flex;
  flex-direction: column;
}

.flag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
}

.flag-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 25px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  position: relative;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm); /* Add subtle shadow */
}

.flag-image-wrapper {
  aspect-ratio: 3/2;
  background-color: var(--surface-2);
  /* Checkerboard pattern for transparency */
  background-image:
    linear-gradient(45deg, var(--border) 25%, transparent 25%),
    linear-gradient(-45deg, var(--border) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--border) 75%),
    linear-gradient(-45deg, transparent 75%, var(--border) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-blend-mode: overlay;
  opacity: 1; /* Fixed from 0.8 for clarity */
  
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border-bottom: 1px solid var(--border);
  position: relative;
  /* ✨ Safari flexbox fix */
  -webkit-box-align: center;
  -webkit-box-pack: center;
}

[data-theme="dark"] .flag-image-wrapper {
  background-image: none; /* Simplify for dark mode or use subtly */
  background: var(--surface-2);
}

.flag-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
  transition: transform 0.3s ease;
}

.flag-card:hover .flag-img {
  transform: scale(1.1);
}

.flag-info {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.flag-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin: 0;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.flag-meta {
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}


.badge-outline {
  font-size: 0.7rem;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--muted);
  text-transform: uppercase;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.flag-card {
  animation: fadeIn 0.4s ease backwards;
}

@media (max-width: 768px) {
  .search-filter-container {
    gap: 16px;
  }
  
  .filter-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  
  .control-group {
    justify-content: space-between;
  }
  
  .flag-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
}

/* Match Country Select to Segmented Button Design */
.country-filter-area .select-wrapper--sm .custom-select {
  border-radius: 999px;
  background-color: var(--surface-2);
  border: 1px solid var(--border);
  height: 48px;
  line-height: 46px; /* -2px for borders */
  padding: 0 40px 0 24px;
  min-width: 180px;
}

.country-filter-area .select-wrapper--sm .select-icon {
  right: 20px;
}


/* Horizontal scroll for dynamic segmented controls */
.scroll-x {
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: thin;
  padding-bottom: 4px; /* Space for scrollbar */
  flex-wrap: nowrap;
}

.scroll-x::-webkit-scrollbar {
  height: 4px;
}
.scroll-x::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* Ensure buttons don't shrink */
.scroll-x .segmented__btn {
  flex: 0 0 auto;
}

