/* wk-form-controls.css — coded select + date popovers */

/* ── Custom <select> button ───────────────────────────────── */
.wk-cs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: #fff;
  color: var(--ink, #0f172a);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s, box-shadow .15s;
  width: 100%;
}
.wk-cs-btn:hover:not(:disabled) {
  border-color: #cbd5e1;
  background: #f8fafc;
}
.wk-cs-btn:focus-visible {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
.wk-cs-btn.is-open {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
.wk-cs-btn:disabled { opacity: .55; cursor: not-allowed; }
.wk-cs-btn-label {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wk-cs-btn-label.is-placeholder { color: var(--ink3, #94a3b8); font-weight: 400; }
.wk-cs-btn-caret {
  flex: 0 0 auto;
  color: var(--ink3, #94a3b8);
  transition: transform .18s;
}
.wk-cs-btn.is-open .wk-cs-btn-caret { transform: rotate(180deg); color: #6366f1; }

/* ── Custom <select> popover ───────────────────────────────── */
.wk-cs-pop {
  position: fixed;
  /* Above every modal/drawer in the app (max seen ~2,000,600) so the menu
     always pops on top, never behind the dialog that opened it. */
  z-index: 2147483000;
  min-width: 180px;
  max-width: 360px;
  max-height: 320px;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: wk-cs-fade .12s ease-out;
}
@keyframes wk-cs-fade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.wk-cs-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  color: var(--ink3, #94a3b8);
}
.wk-cs-search input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: 13px;
  color: var(--ink, #0f172a);
}
/* Pinned action row(s) — stay fixed at the top while the list below scrolls. */
.wk-cs-pinned {
  flex: 0 0 auto;
  padding: 4px;
  border-bottom: 1px solid var(--border, #eef2f7);
}
.wk-cs-row--pin {
  color: #4f46e5;
  font-weight: 600;
}
.wk-cs-row--pin:hover { background: rgba(99, 102, 241, .1); }
.wk-cs-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px;
}
.wk-cs-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--ink, #0f172a);
  font: inherit;
  font-size: 13px;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  transition: background .12s;
}
.wk-cs-row:hover { background: #f1f5f9; }
.wk-cs-row.is-selected {
  background: rgba(99, 102, 241, .08);
  color: #4f46e5;
  font-weight: 600;
}
.wk-cs-row-label { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-cs-row-check { color: #4f46e5; flex: 0 0 auto; }

/* ── Custom date button ────────────────────────────────────── */
.wk-cd-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: #fff;
  color: var(--ink, #0f172a);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color .15s, background .15s, box-shadow .15s;
  width: 100%;
}
.wk-cd-btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.wk-cd-btn:focus-visible {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
.wk-cd-btn.is-open {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .18);
}
.wk-cd-btn-icon { color: var(--ink3, #94a3b8); flex: 0 0 auto; }
.wk-cd-btn.is-open .wk-cd-btn-icon { color: #6366f1; }
.wk-cd-btn-text {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.wk-cd-btn-text.is-placeholder { color: var(--ink3, #94a3b8); font-weight: 400; }

/* ── Custom date popover (calendar) ────────────────────────── */
.wk-cd-pop {
  position: fixed;
  z-index: 2147483000;
  width: 280px;
  background: #fff;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .06);
  padding: 10px;
  animation: wk-cs-fade .12s ease-out;
  user-select: none;
}
.wk-cd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 8px;
}
.wk-cd-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink, #0f172a);
  letter-spacing: .01em;
}
.wk-cd-nav {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  border-radius: 8px;
  color: var(--ink2, #475569);
  font-size: 16px;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.wk-cd-nav:hover { background: #f1f5f9; color: #6366f1; }
.wk-cd-dow {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 0 2px 4px;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink3, #94a3b8);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.wk-cd-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 0 2px;
}
.wk-cd-day {
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink, #0f172a);
  cursor: pointer;
  transition: background .12s, color .12s, transform .08s;
}
.wk-cd-day:hover:not(.is-blank):not(:disabled) {
  background: #f1f5f9;
  color: #4f46e5;
}
.wk-cd-day:active:not(.is-blank):not(:disabled) { transform: scale(.95); }
.wk-cd-day.is-blank { cursor: default; pointer-events: none; }
.wk-cd-day.is-today {
  color: #6366f1;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, .35);
}
.wk-cd-day.is-selected {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff !important;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .35);
}
.wk-cd-day.is-selected:hover { background: linear-gradient(135deg, #4f46e5, #6d28d9); color: #fff; }
/* A day outside the field's min/max. It is drawn, so the month still reads as
   a month, and it is dead, so the range is a fact rather than a promise the
   save is left to break. */
.wk-cd-day.is-out { opacity: .3; cursor: not-allowed; pointer-events: none; }
.wk-cd-nav:disabled { opacity: .28; cursor: not-allowed; pointer-events: none; }
.wk-cd-foot {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 2px;
  border-top: 1px solid var(--border, #f1f5f9);
  margin-top: 6px;
}
.wk-cd-btn-foot {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  background: #fff;
  color: var(--ink2, #475569);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.wk-cd-btn-foot:hover { background: #f8fafc; color: var(--ink, #0f172a); border-color: #cbd5e1; }
.wk-cd-btn-foot.is-primary {
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  border-color: transparent;
  color: #fff;
}
.wk-cd-btn-foot.is-primary:hover { background: linear-gradient(135deg, #4f46e5, #6d28d9); color: #fff; }

/* Dark mode parity (uses the existing design-system tokens). */
[data-theme="dark"] .wk-cs-btn,
[data-theme="dark"] .wk-cd-btn {
  background: var(--surface, #0f172a);
  border-color: var(--border, #1e293b);
  color: var(--ink, #f1f5f9);
}
[data-theme="dark"] .wk-cs-btn:hover,
[data-theme="dark"] .wk-cd-btn:hover {
  background: var(--surface-2, #1e293b);
  border-color: #334155;
}
[data-theme="dark"] .wk-cs-pop,
[data-theme="dark"] .wk-cd-pop {
  background: var(--surface, #0f172a);
  border-color: var(--border, #1e293b);
}
[data-theme="dark"] .wk-cs-pinned { border-bottom-color: var(--border, #1e293b); }
[data-theme="dark"] .wk-cs-row--pin { color: #a5b4fc; }
[data-theme="dark"] .wk-cs-row--pin:hover { background: rgba(129, 140, 248, .16); }
[data-theme="dark"] .wk-cs-row:hover,
[data-theme="dark"] .wk-cd-day:hover:not(.is-blank):not(:disabled),
[data-theme="dark"] .wk-cd-nav:hover,
[data-theme="dark"] .wk-cd-btn-foot:hover {
  background: var(--surface-2, #1e293b);
}
