/**
 * Styles for the shared date-range filter — the markup comes from
 * views/partials/date-range-filter.ejs and the behaviour from
 * public/js/dateRangeFilter.js (bundled from widgets-src/date-range-filter.js).
 *
 * Plain CSS rather than a partial under public/sass, because this workspace has
 * no Sass build: public/css/style.css ships prebuilt with the WowDash theme.
 * Everything below is expressed through that theme's custom properties, so the
 * filter follows the panel's light and dark palettes without a second set of
 * rules.
 */

.hkm-daterange {
  position: relative;
  display: inline-block;
}

/* ---- trigger ---- */

.hkm-daterange__trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 20px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--neutral-100);
  color: var(--text-primary-light);
  font-size: 0.875rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: background-color 0.15s ease-in-out;
}

.hkm-daterange__trigger:hover {
  background-color: var(--neutral-200);
}

.hkm-daterange__trigger:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: 2px;
}

/* ---- panel ---- */

.hkm-daterange__panel {
  position: absolute;
  z-index: 1055; /* above Bootstrap's dropdowns, below its modals */
  top: calc(100% + 8px);
  left: 0;
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background-color: var(--base);
  box-shadow: 0 12px 32px rgba(4, 6, 15, 0.14);
}

.hkm-daterange__panel[hidden] {
  display: none;
}

/* Flips to the right edge when the trigger sits near the viewport's edge —
   set by the partial, not measured at runtime. */
.hkm-daterange--align-end .hkm-daterange__panel {
  right: 0;
  left: auto;
}

/* ---- preset rail ---- */

.hkm-daterange__presets {
  width: 185px;
  flex-shrink: 0;
  margin: 0;
  padding: 8px 0;
  list-style: none;
  border-right: 1px solid var(--border-color);
}

.hkm-daterange__preset {
  display: block;
  width: 100%;
  padding: 10px 24px;
  border: 0;
  background: none;
  color: var(--text-secondary-light);
  font-size: 0.875rem;
  text-align: left;
  transition:
    background-color 0.15s ease-in-out,
    color 0.15s ease-in-out;
}

.hkm-daterange__preset:hover {
  background-color: var(--neutral-100);
  color: var(--text-primary-light);
}

.hkm-daterange__preset.is-active,
.hkm-daterange__preset.is-active:hover {
  background-color: var(--primary-600);
  color: #fff;
  font-weight: 500;
}

.hkm-daterange__preset:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: -2px;
}

/* ---- months ---- */

.hkm-daterange__months {
  display: flex;
  gap: 32px;
  padding: 16px 24px;
}

.hkm-daterange__month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.hkm-daterange__month-label {
  color: var(--text-primary-light);
  font-size: 0.875rem;
  font-weight: 500;
}

.hkm-daterange__nav,
.hkm-daterange__nav-spacer {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-secondary-light);
}

.hkm-daterange__nav:hover {
  background-color: var(--neutral-100);
  color: var(--text-primary-light);
}

.hkm-daterange__nav:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: -2px;
}

.hkm-daterange__grid {
  width: auto;
  border-collapse: collapse;
  table-layout: fixed;
}

/* WowDash styles `.table` cells globally; this grid is not one of those tables,
   so every inherited box property is reset rather than worked around. */
.hkm-daterange__grid th,
.hkm-daterange__grid td {
  width: 40px;
  padding: 0;
  border: 0;
  background: none;
  text-align: center;
  vertical-align: middle;
}

.hkm-daterange__grid th {
  height: 34px;
  color: var(--text-secondary-light);
  font-size: 0.75rem;
  font-weight: 500;
}

/* The in-range band lives on the cell so it runs unbroken across a week; the
   rounded chip marking an endpoint lives on the button inside it. */
.hkm-daterange__grid td.is-in-range,
.hkm-daterange__grid td.is-range-start,
.hkm-daterange__grid td.is-range-end {
  background-color: var(--primary-50);
}

.hkm-daterange__grid td.is-range-start {
  border-radius: 8px 0 0 8px;
}

.hkm-daterange__grid td.is-range-end {
  border-radius: 0 8px 8px 0;
}

/* Centred with flex, not just `text-align`: the panel inherits
   `text-align: start` from the theme's button styles, which left-aligns every
   date inside its cell and pulls the whole grid out of line with the weekday
   headings above it. */
.hkm-daterange__day {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-primary-light);
  font-size: 0.8125rem;
  line-height: 1;
  text-align: center;
  transition:
    background-color 0.15s ease-in-out,
    color 0.15s ease-in-out;
}

.hkm-daterange__day:hover {
  background-color: var(--neutral-200);
}

/* Days bleeding in from the neighbouring months: still pickable, just quiet. */
.hkm-daterange__day.is-outside {
  color: var(--text-secondary-light);
  opacity: 0.65;
}

.hkm-daterange__day.is-in-range {
  color: var(--primary-700);
}

.hkm-daterange__day.is-today {
  box-shadow: inset 0 0 0 1px var(--neutral-300);
}

.hkm-daterange__day.is-edge,
.hkm-daterange__day.is-edge:hover {
  background-color: var(--primary-600);
  color: #fff;
  font-weight: 500;
}

.hkm-daterange__day:focus-visible {
  outline: 2px solid var(--primary-600);
  outline-offset: -2px;
}

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

.hkm-daterange__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 24px;
  border-top: 1px solid var(--border-color);
}

.hkm-daterange__label {
  margin-right: 8px;
  color: var(--text-secondary-light);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

/* On a narrow screen the two months no longer fit beside the rail. */
@media (max-width: 767.98px) {
  .hkm-daterange__panel {
    flex-direction: column;
  }

  .hkm-daterange__presets {
    width: 100%;
    border-right: 0;
    border-bottom: 1px solid var(--border-color);
  }

  .hkm-daterange__months {
    flex-direction: column;
    gap: 16px;
  }
}
