@import url('ui/tokens.css');
@import url('ui/components.css');
/* #region zone:desk.ui.controls — SelectMenu และ DatePicker กลาง */
.ui-select,
.ui-date {
  min-width: 0;
}
.ui-control-trigger {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  justify-content: space-between;
  text-align: left;
}
.ui-control-value {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--sp-2);
}
.ui-control-value > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ui-chevron,
.ui-calendar-icon {
  flex: 0 0 auto;
  color: var(--muted);
}
.ui-popover {
  position: fixed;
  z-index: var(--z-popover, 130);
  margin: 0;
}
.ui-select-popover {
  /* the script sets max-height to the room really left; the list is the only part that scrolls */
  max-height: 320px;
  overflow: hidden;
}
.ui-select-popover:popover-open {
  display: flex;
  flex-direction: column;
}
.ui-options {
  display: grid;
  gap: var(--sp-2);
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  /* the last option stays fully inside the scrolled area, with room below it */
  padding: 0;
  scroll-padding-block: 6px 8px;
}
.ui-option-search {
  display: block;
  flex: none;
  padding-bottom: var(--sp-2);
}
.ui-select-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  cursor: pointer;
  justify-content: flex-start;
  border-color: transparent;
  font-weight: 400;
  text-align: left;
}
.ui-select-option:hover,
.ui-select-option:focus-visible,
.ui-select-option.is-active {
  background: var(--hover);
}
.ui-select-option[aria-selected='true'] {
  color: var(--accent-text);
  font-weight: 600;
}
.ui-option-check {
  margin-left: auto;
  opacity: 0;
}
.ui-select-option[aria-selected='true'] .ui-option-check {
  opacity: 1;
}
.ui-option-logo {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 8px;
  object-fit: contain;
  padding: 3px;
  background: var(--panel2);
}
.ui-option-monogram {
  display: grid;
  place-items: center;
  padding: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
}
.ui-date-popover {
  width: min(400px, calc(100vw - 16px));
}
.ui-calendar-head {
  display: grid;
  grid-template-columns: var(--u-tap) minmax(0, 1fr) var(--u-tap);
  align-items: center;
  gap: var(--sp-2);
}
.ui-calendar-head button,
.ui-date-quick button,
.ui-calendar-grid button,
.ui-month-grid button,
.ui-year-grid button {
  min-height: 40px;
  padding: 6px;
  border-color: transparent;
  background: transparent;
}
.ui-calendar-title {
  font-weight: 650 !important;
}
.ui-weekdays,
.ui-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--sp-2);
}
.ui-weekdays span {
  padding: var(--sp-2) 0 var(--sp-1);
  color: var(--muted);
  font-size: var(--t-caption, 12px);
  text-align: center;
}
.ui-calendar-grid button {
  /* a fixed square cell, centred in its column, so the today ring and the selected fill are true circles */
  width: 40px;
  height: 40px;
  min-height: 0;
  aspect-ratio: 1;
  padding: 0;
  justify-self: center;
  border-radius: 50%;
  font-weight: 400;
}
.ui-calendar-grid button.is-outside {
  color: var(--muted);
}
.ui-calendar-grid [role='row'] {
  display: contents;
}
.ui-calendar-grid button.is-today {
  box-shadow: inset 0 0 0 1px var(--accent);
}
.ui-calendar-grid button[aria-selected='true'] {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 650;
}
.ui-calendar-grid button:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}
.ui-date-quick {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line);
}
.ui-date-quick button {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--u-radius-pill);
  font-size: var(--t-caption, 12px);
}
.ui-month-grid,
.ui-year-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
}
.ui-year-grid {
  border-top: 1px solid var(--line);
}
@media (max-width: 820px) {
  /* 44px touch cells plus the shared 8px gutter fit the wider picker and 390px sheet. */
  .ui-calendar-grid {
    column-gap: var(--sp-2);
  }
  .ui-calendar-grid button {
    width: 44px;
    height: 44px;
  }
  .ui-calendar-head {
    grid-template-columns: 44px 1fr 44px;
  }
}
@media (max-width: 480px) {
  .ui-popover {
    inset: auto 0 0 !important;
    width: 100% !important;
    max-height: min(78dvh, 560px);
    padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: var(--r-card) var(--r-card) 0 0;
  }
  .ui-popover::before {
    content: '';
    display: block;
    flex: none;
    width: 40px;
    height: 4px;
    margin: -8px auto var(--sp-3);
    border-radius: var(--u-radius-pill);
    background: var(--line);
  }
  .ui-date-popover {
    width: 100%;
  }
}
/* #endregion */

/* #region zone:desk.ui.checkbox — ช่องติ๊กของระบบ (CSS ล้วน) ใต้ปุ่มจริง input[type=checkbox] */
.ui-check {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
}
.ui-check-input {
  /* visually hidden but still focusable, and still the real form control */
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.ui-check-box {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--muted);
  border-radius: 6px;
  background: var(--panel);
  color: var(--on-accent, #fff);
  transition:
    background 120ms ease-out,
    border-color 120ms ease-out,
    box-shadow 120ms ease-out;
}
.ui-check-mark {
  grid-area: 1 / 1;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.ui-check-dash {
  stroke-dasharray: none;
  stroke-dashoffset: 0;
  opacity: 0;
}
.ui-check:hover .ui-check-input:not(:disabled, :checked, :indeterminate) + .ui-check-box {
  border-color: var(--accent);
  background: var(--acc-soft);
}
.ui-check-input:focus-visible + .ui-check-box {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--acc-ring);
}
.ui-check-input:checked + .ui-check-box,
.ui-check-input:indeterminate + .ui-check-box {
  border-color: var(--accent);
  background: var(--accent);
}
.ui-check-input:checked + .ui-check-box .ui-check-mark:not(.ui-check-dash) {
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 180ms ease-out;
}
.ui-check-input:indeterminate + .ui-check-box .ui-check-mark:not(.ui-check-dash) {
  stroke-dashoffset: 1;
}
.ui-check-input:indeterminate + .ui-check-box .ui-check-dash {
  opacity: 1;
}
.ui-check-input:disabled + .ui-check-box {
  opacity: 0.55;
}
/* a whole chip is the target; a ticked chip is tinted with an accent border */
.ui-check-chip {
  padding: var(--sp-2) 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-control);
  background: var(--panel2);
  transition:
    background 120ms ease-out,
    border-color 120ms ease-out;
}
.ui-check-chip:hover {
  border-color: var(--accent);
}
.ui-check-chip:has(:checked),
.ui-check-chip:has(:indeterminate) {
  background: var(--acc-soft);
  border-color: var(--accent);
}
@media (prefers-reduced-motion: reduce) {
  .ui-check-box,
  .ui-check-chip,
  .ui-check-input:checked + .ui-check-box .ui-check-mark {
    transition: none;
  }
}
/* #endregion */
