/* ==========================================================================
   Date + time picker (shared component)

   Used by the admin changelog form, the Events editor's "Event date" field,
   the Events announcement "Hide after" and the Tasks deadline. The closed
   control is a readonly <input> inside a `.dt-trigger` div (so it keeps form
   semantics and label association); the calendar/time panel is a
   viewport-fixed popover appended to the page (so card `overflow` can never
   clip it), positioned by the JS and clamped to the viewport — same approach
   as context_menu.css.

   Host theming: everything reads `--dt-*` custom properties that default to
   the shared palette tokens (colors.css / ui-elements.css). A host whose
   palette differs (e.g. the admin console) overrides these on its own
   `.dt-trigger` / `.dt-pop` scope. No hardcoded theme colours below.
   ========================================================================== */

.dt {
    position: relative;
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
}

/* token defaults — resolved against the host's neutral palette */
.dt-trigger,
.dt-pop {
    --dt-accent: var(--accent, #C77400);
    --dt-accent-soft: var(--accent-soft, rgba(199, 116, 0, .14));
    --dt-accent-ink: var(--accent-ink, #1C0D04);
    --dt-text: var(--text, #EDEDF0);
    --dt-muted: var(--text-muted, #9A9AA6);
    --dt-surface-2: var(--surface-2, #1E1E24);
    --dt-line: var(--line, #2A2A32);
    --dt-line-strong: var(--line-strong, #3C3C46);
    --dt-pop-bg: var(--surface-strong, var(--surface, #16161A));
    --dt-radius: var(--radius-sm, 10px);
    --dt-radius-lg: var(--radius-md, 14px);
    --dt-shadow: var(--shadow-3, 0 16px 36px rgba(0, 0, 0, .5));
    --dt-font: var(--font-body, inherit);
    /* shared icon set, applied as a mask so the glyph follows --dt-muted */
    --dt-icon-cal: url("/static/img/icons/calendar.svg");
    --dt-icon-clock: url("/static/img/icons/clock.svg");
    --dt-icon-chevron: url("/static/img/icons/chevron-down.svg");
}

/* ---- the closed control (looks like the host's text input) ---- */

.dt-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 10px 12px;
    background: var(--dt-surface-2);
    color: var(--dt-text);
    border: 1px solid var(--dt-line);
    border-radius: var(--dt-radius);
    font-family: var(--dt-font);
    font-size: 14px;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.dt-trigger:hover { border-color: var(--dt-line-strong); }

.dt-trigger:focus-within {
    outline: none;
    border-color: var(--dt-accent);
    box-shadow: 0 0 0 3px var(--dt-accent-soft);
}

.dt.open .dt-trigger { border-color: var(--dt-accent); }

.dt-icon,
.dt-chevron {
    flex: none;
    background: var(--dt-muted);
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}
.dt-icon {
    width: 16px; height: 16px;
    -webkit-mask-image: var(--dt-icon-cal);
    mask-image: var(--dt-icon-cal);
    -webkit-mask-size: 16px 16px;
    mask-size: 16px 16px;
}
.dt-chevron {
    width: 14px; height: 14px;
    -webkit-mask-image: var(--dt-icon-chevron);
    mask-image: var(--dt-icon-chevron);
    -webkit-mask-size: 14px 14px;
    mask-size: 14px 14px;
}

/* time-only mode swaps the calendar glyph for a clock */
.dt[data-mode="time"] .dt-icon {
    -webkit-mask-image: var(--dt-icon-clock);
    mask-image: var(--dt-icon-clock);
}

.dt-trigger .dt-input {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    border: none;
    border-radius: 0;
    box-shadow: none;
    font: inherit;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
    outline: none;
    text-overflow: ellipsis;
}
.dt-trigger .dt-input:focus {
    border: none;
    box-shadow: none;
}
.dt-trigger .dt-input::placeholder { color: var(--dt-muted); opacity: 1; }
.dt.is-empty .dt-input { color: var(--dt-muted); }

/* ---- the popover ---- */

.dt-pop {
    position: fixed;
    z-index: 1200;
    width: 288px;
    max-width: calc(100vw - 16px);
    box-sizing: border-box;
    padding: 12px;
    background: var(--dt-pop-bg);
    color: var(--dt-text);
    border: 1px solid var(--dt-line);
    border-radius: var(--dt-radius-lg);
    box-shadow: var(--dt-shadow);
    font-family: var(--dt-font);
    font-size: 14px;
    line-height: 1.4;
    user-select: none;
}

.dt-pop[hidden] { display: none; }

.dt-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.dt-month {
    font-weight: 600;
    color: var(--dt-text);
    font-variant-numeric: tabular-nums;
}

.dt-nav {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--dt-muted);
    border: 1px solid transparent;
    border-radius: var(--dt-radius);
    font: inherit;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.dt-nav:hover { background: var(--dt-surface-2); color: var(--dt-text); }
.dt-nav:focus-visible { outline: none; border-color: var(--dt-accent); color: var(--dt-text); }

.dt-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 4px;
}
.dt-weekdays span {
    text-align: center;
    font-size: 11px;
    color: var(--dt-muted);
    padding: 2px 0;
}

.dt-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}

.dt-day {
    height: 34px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--dt-text);
    border: 1px solid transparent;
    border-radius: var(--dt-radius);
    font: inherit;
    font-variant-numeric: tabular-nums;
    cursor: pointer;
}
.dt-day:hover { background: var(--dt-surface-2); }
.dt-day:focus-visible { outline: none; border-color: var(--dt-accent); }
.dt-day.other { color: var(--dt-muted); opacity: .55; }
.dt-day.today { border-color: var(--dt-accent); }
.dt-day.selected {
    background: var(--dt-accent);
    color: var(--dt-accent-ink);
    border-color: var(--dt-accent);
    font-weight: 600;
}

/* ---- time row ---- */

.dt-time {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--dt-line);
}

.dt-time-label {
    margin-right: auto;
    font-size: 12px;
    color: var(--dt-muted);
}

.dt-time-input {
    width: 46px;
    box-sizing: border-box;
    padding: 6px 4px;
    text-align: center;
    background: var(--dt-surface-2);
    color: var(--dt-text);
    border: 1px solid var(--dt-line);
    border-radius: var(--dt-radius);
    font: inherit;
    font-variant-numeric: tabular-nums;
    -moz-appearance: textfield;
}
.dt-time-input::-webkit-outer-spin-button,
.dt-time-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dt-time-input:focus {
    outline: none;
    border-color: var(--dt-accent);
    box-shadow: 0 0 0 3px var(--dt-accent-soft);
}
.dt-colon { color: var(--dt-muted); }

.dt-now {
    margin-left: 4px;
    padding: 6px 10px;
    background: transparent;
    color: var(--dt-muted);
    border: 1px solid var(--dt-line);
    border-radius: var(--dt-radius);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.dt-now:hover { background: var(--dt-surface-2); color: var(--dt-text); }

/* ---- footer actions ---- */

.dt-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 12px;
}

.dt-clear {
    padding: 6px 10px;
    background: transparent;
    color: var(--dt-muted);
    border: 1px solid transparent;
    border-radius: var(--dt-radius);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.dt-clear:hover { background: var(--dt-surface-2); color: var(--dt-text); }

.dt-done {
    margin-left: auto;
    padding: 7px 16px;
    background: var(--dt-accent);
    color: var(--dt-accent-ink);
    border: 1px solid var(--dt-accent);
    border-radius: var(--dt-radius);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.dt-done:hover { filter: brightness(1.06); }

.dt-done:focus-visible,
.dt-clear:focus-visible,
.dt-now:focus-visible {
    outline: 2px solid var(--dt-accent);
    outline-offset: 1px;
}
