/* ==============================================
   Gosmooth Phone Field — 全站唯一共用组件 CSS
   适用于：contact / joinus / inquiry popup
   版本：2026-07-04 v5
   ============================================== */

/* --- Root wrapper --- */
.gs-phone-field {
  display: block;
  position: relative;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* --- Control row (grid: country + input, 永远同一行) --- */
.gs-phone-control {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  align-items: stretch;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* --- Country toggle button --- */
.gs-phone-country-toggle {
  width: 140px;
  min-width: 140px;
  max-width: 140px;

  height: 52px;
  min-height: 52px;

  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;

  padding: 0 14px;
  margin: 0;

  border: 1px solid #d8d8d8;
  border-right: none;
  border-radius: 8px 0 0 8px;

  background: #fff;

  font-family: "Noto Sans TC", sans-serif;
  font-size: 14px;
  line-height: 1;
  color: #1a1a1a;

  box-sizing: border-box;
  overflow: hidden;
  white-space: nowrap;

  appearance: none;
  -webkit-appearance: none;

  cursor: pointer;
  transition: border-color 0.18s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.gs-phone-country-toggle:hover {
  background: #fafafa;
}

.gs-phone-country-toggle:focus-visible {
  outline: 2px solid #EEB21B;
  outline-offset: 1px;
}

/* --- Flags (确保旗帜清晰可见) --- */
.gs-phone-country-toggle .phone-country-flag,
.gs-phone-country-toggle .gs-phone-flag,
.gs-phone-country-toggle .iti-flag,
.gs-phone-country-toggle img,
.gs-phone-country-toggle svg,
.gs-phone-country-list button .phone-country-flag {
  display: inline-block;
  width: 22px;
  min-width: 22px;
  max-width: 22px;
  height: 16px;
  min-height: 16px;
  max-height: 16px;
  flex: 0 0 22px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  visibility: visible !important;
  opacity: 1 !important;
}

/* --- Toggle text --- */
.gs-phone-country-toggle .gs-phone-code,
.gs-phone-iso {
  display: inline-block;
  flex: 0 0 auto;
  font-weight: 600;
  font-size: 13px;
  color: #333;
  white-space: nowrap;
}

.gs-phone-country-toggle .gs-phone-dial,
.gs-phone-country-toggle strong {
  display: inline-block;
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 13px;
  color: #555;
  white-space: nowrap;
}

.gs-phone-country-toggle .gs-phone-arrow,
.gs-phone-caret {
  font-size: 10px;
  color: #888;
  transition: transform 0.2s;
  margin-left: auto;
  flex: 0 0 auto;
}

.gs-phone-field.is-open .gs-phone-arrow {
  transform: rotate(180deg);
}

/* --- Focus-within border sync --- */
.gs-phone-field:focus-within .gs-phone-country-toggle {
  border-color: #EEB21B;
}

/* --- Phone input --- */
.gs-phone-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;

  height: 52px;
  min-height: 52px;

  padding: 0 16px;
  margin: 0;

  border: 1px solid #d8d8d8;
  border-radius: 0 8px 8px 0;

  background: #fff;

  font-family: "Noto Sans TC", sans-serif;
  font-size: 16px;
  line-height: 1;
  color: #1a1a1a;

  box-sizing: border-box;

  appearance: none;
  -webkit-appearance: none;

  transition: border-color 0.18s;
}

.gs-phone-input:focus {
  outline: none;
  border-color: #EEB21B;
}

.gs-phone-input::placeholder {
  color: #aaa;
}

/* --- Error state --- */
.gs-phone-field.has-error .gs-phone-country-toggle,
.gs-phone-field.has-error .gs-phone-input {
  border-color: rgba(180, 35, 24, 0.38);
}

/* --- Country dropdown list --- */
.gs-phone-field .gs-phone-country-list {
  position: absolute;
  top: calc(56px + 8px);
  left: 0;
  width: min(420px, 100%);
  max-width: 100%;
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.10);
  border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.14);
  z-index: 200;
  display: none;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
}

.gs-phone-field.is-open .gs-phone-country-list {
  display: block;
}

/* --- Dropdown options --- */
.gs-phone-field .gs-phone-country-list button {
  display: grid;
  grid-template-columns: 28px 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  padding: 11px 14px;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
  font-family: "Noto Sans TC", sans-serif;
  font-size: 14px;
  color: #333;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

.gs-phone-field .gs-phone-country-list button:last-child {
  border-bottom: none;
}

.gs-phone-field .gs-phone-country-list button:hover {
  background: #f6f1df;
}

.gs-phone-field .gs-phone-country-list button:focus-visible {
  background: #f6f1df;
  outline: 2px solid #EEB21B;
  outline-offset: -2px;
}

.gs-phone-field .gs-phone-country-list button.is-active {
  background: #FFF8E7;
  color: #DB7F21;
  font-weight: 600;
}

/* --- Dropdown option flag images (SVG) --- */
.gs-phone-country-list button .gs-phone-flag-img {
  display: inline-block;
  width: 22px;
  min-width: 22px;
  max-width: 22px;
  height: 15px;
  min-height: 15px;
  max-height: 15px;
  object-fit: cover;
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.10);
  visibility: visible !important;
  opacity: 1 !important;
}

/* --- Option text --- */
.gs-phone-option-code,
.phone-country-option-code {
  font-weight: 600;
  min-width: 28px;
}

.gs-phone-option-name,
.phone-country-option-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: #666;
}

.gs-phone-option-dial,
.phone-country-option-dial {
  font-weight: 600;
  color: #555;
  justify-self: end;
  white-space: nowrap;
  padding-left: 10px;
}

/* ==============================================
   Error Message (由 JS 动态注入)
   ============================================== */
.gs-phone-message,
.phone-field__message {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: "Noto Sans TC", sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #b42318;
  background: rgba(180, 35, 24, 0.06);
  border: 1px solid rgba(180, 35, 24, 0.12);
  box-sizing: border-box;
}

.gs-phone-message:empty,
.phone-field__message:empty {
  display: none;
}

.gs-phone-message.is-visible,
.phone-field__message.is-visible {
  display: block;
}

/* ==============================================
   Responsive — Mobile
   ============================================== */
@media (max-width: 767px) {
  .gs-phone-control {
    grid-template-columns: 128px minmax(0, 1fr);
  }

  .gs-phone-country-toggle {
    width: 128px;
    min-width: 128px;
    max-width: 128px;

    height: 54px;
    min-height: 54px;

    padding: 0 10px;
    gap: 6px;
  }

  .gs-phone-input {
    height: 54px;
    min-height: 54px;
    padding: 0 12px;
    font-size: 15px;
  }

  .gs-phone-field .gs-phone-country-list {
    top: calc(54px + 6px);
    left: 0;
    width: 100%;
    max-width: 100%;
    max-height: 260px;
    border-radius: 8px;
  }

  .gs-phone-field .gs-phone-country-list button {
    grid-template-columns: 24px auto minmax(0, 1fr) auto;
    gap: 8px;
    padding: 11px 12px;
    font-size: 14px;
  }

  .gs-phone-message,
  .phone-field__message {
    font-size: 12px;
    margin-top: 6px;
    padding: 5px 8px;
  }
}

/* ==============================================
   prefers-reduced-motion
   ============================================== */
@media (prefers-reduced-motion: reduce) {
  .gs-phone-country-toggle .gs-phone-arrow,
  .gs-phone-message,
  .phone-field__message {
    transition: none;
  }
}