/* NewCon custom form controls — on-brand dropdown + calendar that replace the
   native OS menus. Progressive enhancement: the native <select> / <input type=date>
   stays in the DOM as the source of truth for form value, i18n and submission.
   Theme per instance via data attributes -> --cs-gold / --cs-glow CSS vars. */

:root {
  --cs-gold: #C6A45F;
  --cs-glow: rgba(198, 164, 95, 0.18);
  --cs-radius: 12px;
  --cs-dur: 0.2s;
}

/* Visually hide the enhanced native control but keep it available to forms/JS/AT-fallback */
.cs-native-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.cs-wrap { position: relative; width: 100%; font-family: inherit; }

/* ---------- Trigger ---------- */
.cs-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-radius: var(--cs-radius);
  font-size: 13px;
  font-weight: 600;
  padding: 13px 14px;
  text-align: start;
  cursor: pointer;
  transition: border-color var(--cs-dur) ease, background-color var(--cs-dur) ease, box-shadow var(--cs-dur) ease;
}
.cs-trigger .cs-value { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Rounded flag icon (flagsapi.com) used in flag-bearing options + trigger */
.cs-flag {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.10);
}
.cs-wrap.cs--glass .cs-flag { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18); }
.cs-wrap.cs--compact .cs-flag { width: 18px; height: 18px; }
.cs-trigger .cs-value.cs-placeholder { opacity: 0.55; font-weight: 500; }
.cs-trigger .cs-chevron {
  flex: none; width: 14px; height: 14px;
  color: var(--cs-gold);
  transition: transform var(--cs-dur) ease;
}
.cs-wrap.cs-open .cs-chevron { transform: rotate(180deg); }

/* ---------- Menu ---------- */
.cs-menu {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  z-index: 60;
  max-height: 280px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  border-radius: var(--cs-radius);
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.35);
  animation: cs-in 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.cs-menu[hidden] { display: none; }

/* Subtle themed scrollbar (replaces the jarring native one on dark menus) */
.cs-menu { scrollbar-width: thin; scrollbar-color: rgba(148, 163, 184, 0.5) transparent; }
.cs-menu::-webkit-scrollbar { width: 8px; }
.cs-menu::-webkit-scrollbar-track { background: transparent; }
.cs-menu::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.45); border-radius: 8px; }
.cs-menu::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.7); }
.cs-wrap.cs--glass .cs-menu { scrollbar-color: rgba(255, 255, 255, 0.3) transparent; }
.cs-wrap.cs--glass .cs-menu::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); }
.cs-wrap.cs--glass .cs-menu::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.4); }

@keyframes cs-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cs-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.cs-option .cs-option-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cs-option[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.cs-option .cs-check {
  flex: none;
  margin-inline-start: auto;
  width: 14px; height: 14px;
  color: var(--cs-gold);
  opacity: 0;
}
.cs-option[aria-selected="true"] .cs-check { opacity: 1; }

/* ---------- Light theme (default) ---------- */
.cs-trigger {
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  color: #0F172A;
}
.cs-wrap:hover .cs-trigger { border-color: var(--cs-gold); }
.cs-wrap.cs-open .cs-trigger,
.cs-trigger:focus-visible {
  outline: none;
  border-color: var(--cs-gold);
  background: #fff;
  box-shadow: 0 0 0 3px var(--cs-glow);
}
.cs-menu { background: #fff; border: 1px solid #F1F5F9; }
.cs-option:hover,
.cs-option.cs-active { background: #F8FAFC; color: var(--cs-gold); }
.cs-option[aria-selected="true"] { color: var(--cs-gold); }

/* ---------- Glass theme (dark surfaces) ---------- */
.cs-wrap.cs--glass .cs-trigger {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
}
.cs-wrap.cs--glass:hover .cs-trigger {
  border-color: var(--cs-gold);
  background: rgba(255, 255, 255, 0.09);
}
.cs-wrap.cs--glass.cs-open .cs-trigger,
.cs-wrap.cs--glass .cs-trigger:focus-visible {
  border-color: var(--cs-gold);
  box-shadow: 0 0 0 3px var(--cs-glow);
}
.cs-wrap.cs--glass .cs-menu { background: #0d1b31; border: 1px solid rgba(255, 255, 255, 0.12); }
.cs-wrap.cs--glass .cs-option { color: #e2e8f0; }
.cs-wrap.cs--glass .cs-option:hover,
.cs-wrap.cs--glass .cs-option.cs-active { background: rgba(255, 255, 255, 0.08); color: var(--cs-gold); }
.cs-wrap.cs--glass .cs-option[aria-selected="true"] { color: var(--cs-gold); }

/* ---------- Compact variant (e.g. header language switcher) ---------- */
.cs-wrap.cs--compact { width: auto; display: inline-block; }
.cs-wrap.cs--compact .cs-trigger {
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-width: 2px;
}
.cs-wrap.cs--compact .cs-menu { left: auto; right: 0; min-width: 120px; }

/* ---------- Calendar (custom date picker) ---------- */
.cs-date .cs-trigger .cs-chevron { display: none; }
.cs-date .cs-trigger svg { flex: none; color: var(--cs-gold); }

.cs-cal {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 60;
  width: 280px;
  max-width: calc(100vw - 24px);
  padding: 12px;
  background: #fff;
  border: 1px solid #F1F5F9;
  border-radius: 14px;
  box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.35);
  animation: cs-in 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}
.cs-cal[hidden] { display: none; }
.cs-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cs-cal-title { font-size: 13px; font-weight: 800; color: #0F172A; }
.cs-cal-nav {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid #E2E8F0;
  background: #F8FAFC;
  color: #334155;
  font-size: 16px; line-height: 1;
  cursor: pointer;
  transition: 0.15s;
}
.cs-cal-nav:hover { border-color: var(--cs-gold); color: var(--cs-gold); }
.cs-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cs-cal-dow span { text-align: center; font-size: 10px; font-weight: 700; color: #94A3B8; padding: 4px 0; }
.cs-cal-day {
  aspect-ratio: 1;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
  color: #334155;
  cursor: pointer;
  transition: 0.12s;
}
.cs-cal-day:hover:not(:disabled) { background: #F1F5F9; color: var(--cs-gold); }
.cs-cal-day:disabled { opacity: 0.3; cursor: not-allowed; }
.cs-cal-day.cs-today { box-shadow: inset 0 0 0 1px var(--cs-gold); }
.cs-cal-day.cs-sel { background: var(--cs-gold); color: #fff; }
.cs-cal-day.cs-sel:hover { color: #fff; }
