/* =====================================================================
   iTrend Solution — premium select
   ---------------------------------------------------------------------
   Styles the custom listbox built by assets/js/select.js. The native
   <select> stays in the DOM (it is what submits) but is visually removed;
   the trigger below is what the visitor sees and operates.

   Without JS, or on touch devices, none of this applies and the plain
   native select is used instead — so the form always works.
   ===================================================================== */

.ps { position: relative; display: block; width: 100%; }

/* The real control: present for submission, invisible to the eye.
   Not display:none — a hidden field cannot be focused by validation, and
   the browser would skip it when reporting a missing required value. */
.ps-native {
  position: absolute !important;
  opacity: 0 !important;
  pointer-events: none !important;
  width: 100% !important;
  height: 100% !important;
  top: 0; left: 0;
  margin: 0 !important;
  border: 0 !important;
  padding: 0 !important;
}

/* ---------- Trigger ---------- */
.ps-trigger {
  /* Matches the sibling inputs exactly so the form reads as one set. */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  width: 100%;
  min-height: 48px;
  padding: .8rem 2.6rem .8rem .95rem;
  font-family: inherit;
  font-size: 16px;              /* ≥16px keeps iOS from zooming on focus */
  line-height: 1.4;
  text-align: left;
  color: var(--text-dark, #1f2937);
  background: #fff;
  border: 1px solid rgba(31, 38, 135, 0.16);
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
.ps-trigger:hover { border-color: rgba(124, 46, 133, .38); }
.ps-trigger:focus-visible,
.ps.is-open .ps-trigger {
  outline: none;
  border-color: #7c2e85;
  box-shadow: 0 0 0 3px rgba(124, 46, 133, .14);
}
/* Placeholder state reads lighter, like an unfilled input */
.ps-trigger.is-placeholder { color: #9ca3af; }
.ps-trigger.is-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, .15) !important;
}

/* Chevron, drawn in CSS so there is no extra request or icon dependency */
.ps-trigger::after {
  content: '';
  position: absolute;
  right: 1rem;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -3px;
  border-right: 2px solid #6b7280;
  border-bottom: 2px solid #6b7280;
  border-radius: 1px;
  transform: rotate(45deg);
  transform-origin: center;
  transition: transform .22s ease, border-color .18s ease;
}
.ps.is-open .ps-trigger::after {
  transform: rotate(-135deg);
  margin-top: 1px;
  border-color: #7c2e85;
}

/* ---------- List ---------- */
/* The list is moved to <body> and positioned against the viewport (see
   select.js). `fixed` rather than `absolute` because the form card and the
   page canvas both clip overflow and create containing blocks — an
   absolutely-positioned menu is trapped inside them and never appears. */
.ps-list {
  position: fixed;
  z-index: 2000;                /* above the fixed navbar (1030) and modals */
  max-height: 264px;
  overflow-y: auto;
  overscroll-behavior: contain; /* scrolling the list never scrolls the page */
  padding: .35rem;
  background: #fff;
  border: 1px solid rgba(31, 38, 135, .12);
  border-radius: 14px;
  box-shadow:
    0 4px 10px rgba(79, 31, 86, .06),
    0 20px 44px rgba(79, 31, 86, .16);
  animation: psIn .16s cubic-bezier(.16, 1, .3, 1);
}
.ps-list[hidden] { display: none; }

@keyframes psIn { from { opacity: 0; transform: translateY(-4px); } }

/* Slim, branded scrollbar rather than the OS default */
.ps-list::-webkit-scrollbar { width: 10px; }
.ps-list::-webkit-scrollbar-track { background: transparent; }
.ps-list::-webkit-scrollbar-thumb {
  background: rgba(124, 46, 133, .22);
  border: 3px solid #fff;
  border-radius: 999px;
}
.ps-list::-webkit-scrollbar-thumb:hover { background: rgba(124, 46, 133, .38); }

/* ---------- Options ---------- */
.ps-option {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .62rem .75rem;
  border-radius: 9px;
  font-size: .95rem;
  line-height: 1.35;
  color: var(--text-dark, #1f2937);
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
/* One highlight for both hover and keyboard focus, so mouse and keyboard
   users see the same affordance. */
.ps-option:hover,
.ps-option.is-active {
  background: rgba(124, 46, 133, .07);
  color: #7c2e85;
}
.ps-option.is-selected {
  font-weight: 600;
  color: #7c2e85;
}
/* Tick on the selected row — shape, not colour alone, marks the state */
.ps-option.is-selected::after {
  content: '';
  margin-left: auto;
  width: 6px;
  height: 11px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  flex-shrink: 0;
  margin-right: 2px;
}
.ps-option[aria-disabled="true"] {
  color: #b6bcc7;
  cursor: not-allowed;
}
.ps-option[aria-disabled="true"]:hover { background: transparent; color: #b6bcc7; }

/* ---------- Dark theme ---------- */
[data-theme="dark"] .ps-trigger {
  background: rgba(255, 255, 255, .06);
  border-color: rgba(255, 255, 255, .14);
  color: #e9edf8;
}
[data-theme="dark"] .ps-trigger.is-placeholder { color: #8d93a6; }
[data-theme="dark"] .ps-trigger::after { border-color: #b9c0d6; }
[data-theme="dark"] .ps-list {
  background: #1b2136;
  border-color: rgba(255, 255, 255, .12);
  box-shadow: 0 20px 44px rgba(0, 0, 0, .5);
}
[data-theme="dark"] .ps-option { color: #e9edf8; }
[data-theme="dark"] .ps-option:hover,
[data-theme="dark"] .ps-option.is-active,
[data-theme="dark"] .ps-option.is-selected {
  background: rgba(255, 255, 255, .08);
  color: #e9b3ff;
}
[data-theme="dark"] .ps-list::-webkit-scrollbar-thumb { border-color: #1b2136; }

/* ---------- Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ps-list { animation: none; }
  .ps-trigger, .ps-trigger::after, .ps-option { transition: none; }
}
