/* =========================================================
   Gravity Forms accessible datepicker (.gform-datepicker-calendar)
   Scoped to: body.gf-date-fix .gfield--type-date
   ========================================================= */

/* ---------- 1. Input + calendar toggle icon ---------- */
body.gf-date-fix .gfield--type-date .ginput_container_date {
  position: relative;
}
body.gf-date-fix .gfield--type-date .ginput_container_date input.datepicker {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding-right: 48px;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 44px;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  cursor: pointer;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-toggle:focus-visible {
  outline: 2px solid #1b2b4b;
  outline-offset: -4px;
  border-radius: 4px;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-toggle .gform-calendar-icon {
  display: block;
  width: 20px;
  height: 20px;
  font-size: 0;
  line-height: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235b6b80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4.5' width='18' height='16.5' rx='2.5'/%3E%3Cpath d='M3 9.5h18M8 2.5v4M16 2.5v4'/%3E%3C/svg%3E") center / contain no-repeat;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-toggle .gform-calendar-icon::before {
  content: none !important;
}

/* ---------- 2. Calendar container ---------- */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar {
  /* Adjust colours/sizes here only */
  --gfdp-navy: #1b2b4b;
  --gfdp-text: #1b2b4b;
  --gfdp-muted: #6b7280;
  --gfdp-arrow: #5b6b80;
  --gfdp-stripe: #f5f5f5;
  --gfdp-accent: #4f6bd8;
  --gfdp-border: #e3e6ea;
  --gfdp-control-h: 44px;
  --gfdp-cell-h: 44px;

  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 9999;
  width: 320px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--gfdp-border);
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
  color: var(--gfdp-text);
  font-family: inherit;
  text-align: center;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar [hidden] {
  display: none !important;
}

/* ---------- 3. Table reset (beats theme table/td/th styles) ---------- */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar table.calendar {
  width: 100%;
  margin: 0;
  border: 0 !important;
  border-collapse: collapse;
  border-spacing: 0;
  table-layout: fixed;
  background: transparent;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar table.calendar tr {
  background: transparent !important;
  border: 0 !important;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar table.calendar td,
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar table.calendar th {
  padding: 0;
  border: 0 !important;
  box-shadow: none;
  background: transparent !important;
  text-align: center;
  vertical-align: middle;
  font-size: 15px;
  font-weight: 400;
  color: var(--gfdp-text);
}

/* ---------- 4. Year / month navigation rows ---------- */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar tr.yearSelector > td,
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar tr.monthSelector > td {
  padding-bottom: 10px;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar tr.monthSelector > td {
  padding-bottom: 14px;
}

/* Prev / next buttons: 1/7 of the width each, chevron instead of text glyph */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.nav {
  width: 14.2857%;
  color: var(--gfdp-arrow);
  cursor: pointer;
  transition: color .15s ease;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.nav:hover {
  color: var(--gfdp-navy);
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.nav:focus-visible {
  outline-offset: -2px;
  border-radius: 4px;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.nav > span {
  position: relative;
  display: block;
  width: 100%;
  height: var(--gfdp-control-h);
  font-size: 0;      /* hides the ⇐ ⇒ ← → glyphs, text stays in DOM */
  line-height: 0;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.nav > span::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(135deg);   /* ‹ */
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.nav.next > span::before {
  transform: translate(-50%, -50%) rotate(-45deg);   /* › */
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.nav[aria-disabled="true"],
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.nav.disabled {
  opacity: .35;
  cursor: default;
  pointer-events: none;
}

/* Year / month dropdowns */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar select.nav.current.select {
  display: block;
  width: 100%;
  height: var(--gfdp-control-h);
  margin: 0;
  padding: 0 36px 0 14px;
  box-sizing: border-box;
  font: inherit;
  font-size: 16px;
  color: var(--gfdp-text);
  text-align: center;
  text-align-last: center;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%235b6b80' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1.5 1.5 6 6l4.5-4.5'/%3E%3C/svg%3E") no-repeat right 14px center / 12px 8px;
  border: 2px solid var(--gfdp-navy);
  border-radius: 2px;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar select.nav.current.select:focus-visible {
  outline: none;
}

/* ---------- 5. Weekday header ---------- */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar table.calendar th.week {
  padding: 14px 0;
  background: var(--gfdp-stripe) !important;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  color: var(--gfdp-navy);
  text-transform: none;
}

/* ---------- 6. Date grid ---------- */
/* Rows: 1 year, 2 month, 3 weekdays, 4+ weeks → 5th, 7th, 9th row are grey */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar table.calendar tr:nth-child(n+5):nth-child(odd) {
  background: var(--gfdp-stripe) !important;
}

body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day,
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.empty {
  height: var(--gfdp-cell-h);
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day > span {
  display: block;
  width: calc(100% - 4px);
  height: calc(var(--gfdp-cell-h) - 4px);
  margin: 2px auto;
  box-sizing: border-box;
  border: 1px solid transparent;
  border-radius: 3px;
  line-height: calc(var(--gfdp-cell-h) - 6px);
  color: var(--gfdp-text);
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease;
}

/* Hover / pressed (colours are neutral; not visible in the references) */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day:hover > span {
  background: rgba(27, 43, 75, .08);
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day:active > span {
  background: rgba(27, 43, 75, .16);
}

/* Today / current selection: thin blue outlined box (as in reference 2) */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day.dayToday > span,
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day.selected > span {
  border-color: var(--gfdp-accent);
}

/* Keyboard focus */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day:focus {
  outline: none;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day:focus-visible > span {
  border-color: var(--gfdp-accent);
}

/* Empty (outside-month) cells */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.empty {
  cursor: default;
  pointer-events: none;
}

/* Disabled / unavailable (no such cells in your current markup; class names are best guesses) */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day[aria-disabled="true"],
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day.disabled,
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.day.dayDisabled {
  opacity: .35;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- 7. Footer message ---------- */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar .monthMessage {
  margin: 12px 0 0;
  padding: 0;
}
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar .monthMessage p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--gfdp-muted);
}

/* ===== Fix: align nav arrows (draw chevron on the td, not the span) ===== */
/* ===== Undo the theme's global .nav { display:flex / inline-flex } inside the GF calendar ===== */

/* Arrow cells must be real table cells again */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar table.calendar td.nav {
  display: table-cell !important;
}

/* Year / month dropdowns */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar select.nav {
  display: block !important;
  float: none !important;
  margin: 0 !important;
  list-style: none !important;
  padding: 0 36px 0 14px !important;
}

/* Hidden fallback spans also carry .nav, so the theme's display rule beats the [hidden] attribute */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar span.nav,
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar [hidden] {
  display: none !important;
}

/* The arrow glyph span inside the arrow cell must not inherit the flex rule */
body.gf-date-fix .gfield--type-date .gform-datepicker-calendar td.nav > span {
  display: block !important;
}


/* ---------- 8. Mobile: match the input width ---------- */
@media (max-width: 480px) {
  body.gf-date-fix .gfield--type-date .gform-datepicker-calendar {
    right: 0;
    width: auto;
    max-width: none;
    padding: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.gf-date-fix .gfield--type-date .gform-datepicker-calendar * {
    transition: none !important;
  }
}