/* One dropdown language for the portal, public pages, login and wp-admin:
   warm white surface, soft line, burnt-orange accent, and always exactly as wide as its field. */
:root {
  --yd-pop-bg: #fff;
  --yd-pop-line: #ead8c9;
  --yd-pop-radius: 12px;
  --yd-pop-row-radius: 8px;
  --yd-pop-shadow: 0 16px 40px #4a2a1420, 0 2px 6px #4a2a140d;
  --yd-pop-hover: #fff4ea;
  --yd-pop-active: #ffead8;
  --yd-pop-ink: var(--orange-ink, #36251c);
  --yd-pop-muted: var(--orange-muted, #796454);
  --yd-pop-accent: var(--orange-primary, #bd4c0c);
  --yd-select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23796454' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
@keyframes yd-pop-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes yd-pop-up { from { opacity: 0; transform: translateY(4px); } }
@keyframes yd-spin { to { transform: rotate(360deg); } }

/* ---- Shared popup surface ---- */
.yd-combo-list,
.yd-order-more > div,
.yd-workspace-columns > div,
.yd-account-menu > div,
.yvt-typeahead-suggestions,
#yvt-customer-suggestions {
  background: var(--yd-pop-bg) !important;
  border: 1px solid var(--yd-pop-line) !important;
  border-radius: var(--yd-pop-radius) !important;
  box-shadow: var(--yd-pop-shadow) !important;
  color: var(--yd-pop-ink);
}
/* Button menus (更多 / 欄位 / 帳戶) hold their own controls, so they size to that content and line up with the button's right edge. */
.yd-order-more > div, .yd-workspace-columns > div, .yd-account-menu > div { top: calc(100% + 6px) !important; right: 0 !important; left: auto !important; animation: yd-pop-in .14s ease-out; }

/* ---- Type-ahead list (combobox.js): width is set to the field's width in script ---- */
.yd-combo-list {
  position: fixed; z-index: 2147483000; box-sizing: border-box; margin: 0; padding: 6px;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: thin;
  font: 14px/1.45 "Segoe UI Variable Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  text-align: left; animation: yd-pop-in .14s ease-out;
}
.yd-combo-list.is-above { animation-name: yd-pop-up; }
.yd-combo-list.is-loading { opacity: .72; }
.yd-combo-option {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; min-height: 38px; box-sizing: border-box;
  padding: 9px 10px; border-radius: var(--yd-pop-row-radius); cursor: pointer; user-select: none;
}
.yd-combo-option.is-active { background: var(--yd-pop-active); }
/* In a narrow field the phone / tag drop to a second line instead of widening the list. */
.yd-combo-main { flex: 0 1 auto; max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--yd-pop-ink); }
.yd-combo-meta { flex: 1 1 auto; max-width: 100%; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--yd-pop-muted); font-variant-numeric: tabular-nums; }
.yd-combo-tag { flex: none; margin-left: auto; font-size: 12px; color: var(--yd-pop-muted); font-variant-numeric: tabular-nums; }
.yd-combo-option mark { background: none; color: var(--yd-pop-accent); font-weight: 700; }
.yd-combo-action { margin-top: 4px; border-top: 1px solid #f1e4d9; border-radius: 0 0 var(--yd-pop-row-radius) var(--yd-pop-row-radius); }
.yd-combo-option:first-child.yd-combo-action { margin-top: 0; border-top: 0; border-radius: var(--yd-pop-row-radius); }
.yd-combo-action .yd-combo-main { color: var(--yd-pop-accent); white-space: normal; }
.yd-combo-action .yd-combo-main::before { content: "＋"; margin-right: 6px; font-weight: 400; }
.yd-combo-action.is-clear .yd-combo-main { color: var(--yd-pop-muted); font-weight: 500; }
.yd-combo-action.is-clear .yd-combo-main::before { content: none; }
.yd-combo-status { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-size: 13px; color: var(--yd-pop-muted); }
.yd-combo-spinner { flex: none; width: 13px; height: 13px; border: 2px solid #f0dccb; border-top-color: var(--yd-pop-accent); border-radius: 50%; animation: yd-spin .7s linear infinite; }

/* Selected-customer hint under a type-ahead field. */
.yd-combo-picked { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; margin: -4px 0 4px; font-size: 13px; color: var(--yd-pop-muted); }
.yd-combo-picked:empty { display: none; }
.yd-combo-picked strong { color: var(--yd-pop-ink); font-weight: 600; }
.yd-combo-picked .yd-combo-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px solid #f0d2bb; border-radius: 999px; background: #fff6ee; }
.yd-combo-picked button { border: 0; background: transparent; color: var(--yd-pop-muted); font: inherit; font-size: 12px; line-height: 1; padding: 4px 6px; border-radius: 999px; cursor: pointer; }
.yd-combo-picked button:hover { background: #ffe6d3; color: var(--yd-pop-accent); }

.yd-profile-recipient-history { margin-bottom: 16px; }
.yd-profile-recipient-picker { display: block; position: relative; }
.yd-profile-recipient-picker input { width: 100%; padding-right: 48px !important; box-sizing: border-box; }
.yd-profile-recipient-picker button { position: absolute; right: 4px; top: 4px; bottom: 4px; width: 40px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: var(--yd-pop-accent); font-size: 24px; cursor: pointer; }
.yd-profile-recipient-picker button:is(:hover, :focus-visible) { background: var(--yd-pop-hover); }
.yd-profile-recipient-status { margin: 8px 0 0; color: var(--yd-pop-muted); font-size: 14px; }
.yd-profile-recipient-options .yd-combo-option { display: block; min-height: 58px; }
.yd-profile-recipient-options :is(.yd-combo-main, .yd-combo-meta, .yd-combo-tag) { display: block; white-space: normal; overflow-wrap: anywhere; }
.yd-profile-recipient-options .yd-combo-meta { margin-top: 4px; }
.yd-profile-recipient-options .yd-combo-tag { margin: 4px 0 0; color: var(--yd-pop-accent); }

/* ---- Menu rows and inline suggestion lists ---- */
.yd-account-menu > div :is(button, a) {
  border-radius: var(--yd-pop-row-radius) !important; padding: 9px 10px !important; font-size: 14px !important; color: var(--yd-pop-ink) !important; background: transparent !important;
}
.yd-account-menu > div :is(button, a):is(:hover, :focus-visible) { background: var(--yd-pop-hover) !important; outline: none; }
.yd-workspace-columns label { border-radius: var(--yd-pop-row-radius); padding: 4px 6px; margin: 0 -6px; }
.yd-workspace-columns label:hover { background: var(--yd-pop-hover); }
.yd-address-suggestions { padding: 6px; gap: 2px; background: var(--yd-pop-bg) !important; border-color: var(--yd-pop-line) !important; box-shadow: var(--yd-pop-shadow) !important; }
.yd-address-candidate { display: block; width: 100%; border: 0; background: transparent; color: var(--yd-pop-ink); font: inherit; font-size: 14px; text-align: left; padding: 9px 10px; border-radius: var(--yd-pop-row-radius); cursor: pointer; }
.yd-address-candidate:is(:hover, :focus-visible) { background: var(--yd-pop-hover); outline: none; }
.yd-address-suggestions .yd-actions { padding: 4px 6px 2px; border-top: 1px solid #f1e4d9; margin-top: 2px; }

/* ---- Legacy "custom orders" customer search (receipt page in wp-admin, old create-order form) ----
   The bordered wrapper is the field; it matches the neighbouring inputs and carries the focus ring,
   so the borderless input inside never draws a second box. */
.yvt-co-customer-wrapper { border: 1px solid #cc6f343d !important; border-radius: 10px !important; background: #ffffffc2 !important; }
.yvt-co-customer-wrapper:focus-within { border-color: var(--yd-pop-accent) !important; box-shadow: 0 0 0 3px #ff6a0a1f !important; }
.yvt-co-customer-wrapper input:not([type=hidden]) { border: 0 !important; box-shadow: none !important; outline: none !important; background: transparent !important; border-radius: 0 !important; min-height: 0 !important; }
:is(#yvt-receipt-selected-customer, #yvt-selected-customer) { border: 1px solid #f0d2bb !important; background: #fff6ee !important; border-radius: 999px !important; color: var(--yd-pop-ink); }
/* Its list sits inside the bordered field box; stretch it over that border so both edges line up. */
.yvt-typeahead-suggestions,
#yvt-customer-suggestions {
  left: -1px !important; right: auto !important; width: calc(100% + 2px) !important; top: calc(100% + 6px) !important; margin: 0 !important;
  box-sizing: border-box !important; padding: 6px !important; max-height: 320px !important; overflow-x: hidden !important; z-index: 1000 !important;
  list-style: none !important; font-size: 14px; line-height: 1.45; text-align: left;
}
.yvt-typeahead-suggestions > li,
#yvt-customer-suggestions > li {
  margin: 0 !important; padding: 9px 10px !important; border-radius: var(--yd-pop-row-radius); color: var(--yd-pop-ink); font-weight: 600; cursor: pointer; overflow-wrap: anywhere;
}
.yvt-typeahead-suggestions > li:hover,
#yvt-customer-suggestions > li:hover { background: var(--yd-pop-active) !important; }
:is(.yvt-typeahead-suggestions, #yvt-customer-suggestions) > li[data-role="create-new"] { color: var(--yd-pop-accent); border-bottom: 1px solid #f1e4d9; border-radius: var(--yd-pop-row-radius) var(--yd-pop-row-radius) 0 0; margin-bottom: 4px !important; }
:is(.yvt-typeahead-suggestions, #yvt-customer-suggestions) > li[data-role="create-new"]::before { content: "＋"; margin-right: 6px; font-weight: 400; }
:is(.yvt-typeahead-suggestions, #yvt-customer-suggestions) > li[data-role="loading"] { color: var(--yd-pop-muted); font-weight: 400; font-size: 13px; cursor: default; background: none !important; }

/* ---- Native selects ----
   Every page: same chevron and the same themed option panel (exactly the select's width).
   The field itself follows its page: theme fields on the portal / public site / login, WordPress fields in wp-admin.
   Editors with their own control kits (Elementor, block editor) and the admin bar are left alone. */
body:not(.elementor-editor-active):not(.block-editor-page) select:not([multiple]):not([size]):not(.select2-hidden-accessible):not(#wpadminbar *) {
  -webkit-appearance: none; appearance: none;
  background-image: var(--yd-select-chevron) !important; background-repeat: no-repeat !important;
  background-position: right 11px center !important; background-size: 12px 12px !important;
  padding-right: 32px !important; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
:is(.yd-app, .yd-member-app, .yvt-phase-one-active, body.login) select:not([multiple]):not([size]) { background-color: #fff; }
:is(.yd-app, .yd-member-app, .yvt-phase-one-active, body.login) select:not([multiple]):not([size]):hover:not(:disabled) { border-color: #d6b79c; }
:is(.yd-app, .yd-member-app, .yvt-phase-one-active, body.login) select:disabled { cursor: not-allowed; background-color: #faf6f2; color: #9a8676; }
.wp-admin select:not([multiple]):not([size]):hover:not(:disabled) { color: var(--yd-pop-ink); border-color: #c89b7a; }
/* combobox.js adds .yd-base-select after locking the select's natural width; without it the field keeps the native panel. */
@supports (appearance: base-select) {
  select.yd-base-select { appearance: base-select !important; }
  select.yd-base-select::picker-icon { display: none; }
  select.yd-base-select::picker(select) {
    appearance: base-select; box-sizing: border-box; margin-block: 6px; padding: 6px;
    width: anchor-size(width); min-width: 0; max-width: anchor-size(width); max-height: min(340px, 60dvh); overflow-x: hidden;
    border: 1px solid var(--yd-pop-line); border-radius: var(--yd-pop-radius); background: var(--yd-pop-bg); box-shadow: var(--yd-pop-shadow);
    scrollbar-width: thin;
  }
  select.yd-base-select option {
    display: flex; align-items: center; gap: 8px; min-height: 36px; box-sizing: border-box; padding: 8px 10px; border-radius: var(--yd-pop-row-radius);
    font-size: 14px; line-height: 1.4; color: var(--yd-pop-ink); background: transparent; cursor: pointer;
    white-space: normal; overflow-wrap: anywhere;
  }
  select.yd-base-select option:is(:hover, :focus-visible) { background: var(--yd-pop-hover); outline: none; }
  select.yd-base-select option:checked { background: var(--yd-pop-active); color: var(--yd-pop-accent); font-weight: 600; }
  select.yd-base-select option::checkmark { display: none; }
  select.yd-base-select option:disabled { color: #b8a596; cursor: default; }
  select.yd-base-select optgroup { font-size: 12px; font-weight: 600; color: var(--yd-pop-muted); padding: 6px 10px 2px; }
}
@media (prefers-reduced-motion: reduce) {
  .yd-combo-list, .yd-order-more > div, .yd-workspace-columns > div, .yd-account-menu > div { animation: none; }
}
