/* Shared flag country picker — premium SaaS, dark-mode ready */

.gw-country {
  --gw-c-border: var(--border-color, rgba(15, 23, 42, 0.12));
  --gw-c-surface: var(--surface-elevated, #ffffff);
  --gw-c-muted: var(--text-muted, #64748b);
  --gw-c-text: var(--text-primary, #1b1b1b);
  --gw-c-heading: var(--color-text-heading, #13009a);
  position: relative;
  width: 100%;
}

html.dark .gw-country {
  --gw-c-border: var(--color-dm-border, rgba(255, 255, 255, 0.1));
  --gw-c-surface: var(--color-dm-elevated, #111827);
  --gw-c-muted: var(--color-dm-text-soft, #94a3b8);
  --gw-c-text: var(--color-dm-text, #f8fafc);
  --gw-c-heading: var(--color-dm-heading, #e8e9ff);
}

.gw-country__trigger {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 2.75rem;
  padding: 0.65rem 0.85rem;
  border: 1.5px solid var(--gw-c-border);
  border-radius: 11px;
  background: var(--gw-c-surface);
  color: var(--gw-c-text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.gw-country__trigger:hover {
  border-color: color-mix(in srgb, var(--gw-c-heading) 35%, var(--gw-c-border));
}

.gw-country.is-open .gw-country__trigger {
  border-color: color-mix(in srgb, var(--gw-c-heading) 55%, var(--gw-c-border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--gw-c-heading) 14%, transparent);
}

.gw-country__flag {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  min-height: 1.15rem;
  font-size: 1.15rem;
  line-height: 1;
  text-align: center;
}

.gw-country__fi,
.gw-country-badge__fi {
  display: block;
  width: 1.25rem;
  height: 0.94rem;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.12);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  flex: 0 0 auto;
  align-self: center;
  line-height: 0;
  font-size: 0;
  overflow: hidden;
}

/* flag-icons :before spacer pushes badges off baseline — size is fixed above */
.gw-country__fi:before,
.gw-country-badge__fi:before {
  content: none !important;
}

.gw-country-badge__fi {
  width: 1.15rem;
  height: 0.86rem;
}

/* Prefer SVG flag-icons; hide PNG duplicate if both present */
.gw-country-badge__img {
  display: none;
}

.gw-country__flag-img {
  display: none;
}

.gw-country__label,
.gw-country__name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gw-country__chevron {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.55;
  margin-top: -0.2rem;
}

.gw-country__menu {
  position: absolute;
  z-index: 40;
  left: 0;
  right: 0;
  top: calc(100% + 0.35rem);
  border: 1px solid var(--gw-c-border);
  border-radius: 12px;
  background: var(--gw-c-surface);
  box-shadow: 0 18px 40px rgb(15 23 42 / 0.16);
  overflow: hidden;
}

html.dark .gw-country__menu {
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.45);
}

.gw-country__menu[hidden] { display: none !important; }

.gw-country__search-wrap {
  padding: 0.5rem;
  border-bottom: 1px solid var(--gw-c-border);
}

.gw-country__search {
  width: 100%;
  min-height: 2.35rem;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--gw-c-border);
  border-radius: 9px;
  background: color-mix(in srgb, var(--gw-c-surface) 92%, #000);
  color: var(--gw-c-text);
  font: inherit;
  font-size: 0.875rem;
}

html.dark .gw-country__search {
  background: color-mix(in srgb, var(--gw-c-surface) 80%, #000);
}

.gw-country__search:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--gw-c-heading) 45%, var(--gw-c-border));
}

.gw-country__list {
  list-style: none;
  margin: 0;
  padding: 0.3rem;
  max-height: min(16rem, 45vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.gw-country__option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--gw-c-text);
  font-size: 0.875rem;
}

.gw-country__option:hover,
.gw-country__option.is-highlighted {
  background: color-mix(in srgb, var(--gw-c-heading) 10%, transparent);
}

.gw-country__option.is-selected {
  background: color-mix(in srgb, var(--gw-c-heading) 14%, transparent);
  font-weight: 650;
}

.gw-country__empty {
  margin: 0;
  padding: 0.85rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--gw-c-muted);
}

.gw-country__empty[hidden] { display: none !important; }

/* Auth / register skin compatibility */
.cp-auth-form .gw-country__trigger,
.cp-reg-form .gw-country__trigger {
  min-height: auto;
  padding: 0.72rem 0.85rem;
  border-radius: 11px;
}

html.dark body.cp-auth-page .gw-country__trigger,
html.dark body.cp-auth-page .gw-country__search,
html.dark body.cp-auth-page .gw-country__label,
html.dark body.cp-auth-page .gw-country__name {
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

html.dark body.cp-auth-page .gw-country__trigger,
html.dark body.cp-auth-page .gw-country__search {
  background-color: var(--color-chrome-4) !important;
  border-color: var(--color-chrome-2) !important;
}

@media (max-width: 640px) {
  .gw-country__list { max-height: min(14rem, 40vh); }
  .gw-country__flag { font-size: 1.2rem; }
}

/* Premium Flag + Country Name badge (read-only display) */
.gw-country-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 100%;
  padding: 0.3rem 0.7rem 0.3rem 0.5rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, #13009a 12%, transparent);
  background: #f8f9ff;
  color: #13009a;
  font-size: 0.875rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1;
  vertical-align: middle;
  box-shadow: 0 4px 14px color-mix(in srgb, #13009a 6%, transparent);
}

.gw-country-badge__flag {
  display: none; /* never show emoji letter-codes like BD/AF on Windows */
}

.gw-country-badge__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gw-country-badge--empty {
  color: #64748b;
  font-weight: 550;
  background: color-mix(in srgb, #64748b 8%, #ffffff);
  border-color: color-mix(in srgb, #64748b 18%, transparent);
  box-shadow: none;
}

html.dark .gw-country-badge {
  background: color-mix(in srgb, #13009a 28%, #0f172a);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e8e9ff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

html.dark .gw-country-badge--empty {
  background: rgba(255, 255, 255, 0.04);
  color: #94a3b8;
}
