/**
 * Financial Management calendar, used for every date field on the website.
 */
:root {
  --line: #d7dee7;
  --text: #1c2430;
}

@keyframes ds-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.bs-date-input,
input.modern-date,
input.fq-leg-date-display.bs-date-input {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  min-height: var(--ds-control-height, 40px);
  padding: 10px 14px !important;
  padding-right: 40px !important;
  border: 1px solid var(--line) !important;
  border-radius: var(--ds-radius-sm, 10px) !important;
  background-color: var(--ds-surface, #fff) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='18' rx='2' ry='2'/%3E%3Cline x1='16' y1='2' x2='16' y2='6'/%3E%3Cline x1='8' y1='2' x2='8' y2='6'/%3E%3Cline x1='3' y1='10' x2='21' y2='10'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
  color: var(--text) !important;
  font: inherit;
  font-size: var(--ds-text-base, 14px) !important;
  font-weight: 400;
  line-height: 1.35;
  cursor: pointer !important;
  pointer-events: auto !important;
  box-shadow: none !important;
  transition:
    border-color var(--ds-transition, 0.22s ease),
    box-shadow var(--ds-transition, 0.22s ease),
    background-color var(--ds-transition, 0.22s ease);
}

.bs-date-input::placeholder,
input.modern-date::placeholder {
  color: var(--ds-muted, #64748b) !important;
  opacity: 1 !important;
}

.bs-date-input:hover:not(:disabled):not(.bs-date-input--disabled),
input.modern-date:hover:not(:disabled) {
  border-color: rgba(0, 150, 214, 0.45) !important;
}

.bs-date-input:focus,
.bs-date-input:focus-visible,
input.modern-date:focus,
input.modern-date:focus-visible {
  outline: none !important;
  border-color: var(--ds-accent, #0096d6) !important;
  box-shadow: 0 0 0 3px var(--ds-accent-soft, rgba(0, 150, 214, 0.12)) !important;
  transform: none !important;
}

.bs-date-input:disabled,
.bs-date-input--disabled,
.bs-date-input[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  background-color: var(--ds-soft, #f8fafc) !important;
}

.bs-date-input.bs-date-input--error,
.bs-date-input:invalid:not(:placeholder-shown) {
  border-color: var(--ds-danger, #d13438) !important;
  box-shadow: 0 0 0 3px rgba(209, 52, 56, 0.12) !important;
}

.bs-date-input::-webkit-calendar-picker-indicator {
  display: none;
}

/* Hide native date inputs if any remain in DOM */
input[type="date"]:not([data-native-date-ok]),
input[type="datetime-local"]:not([data-native-date-ok]) {
  appearance: none;
  -webkit-appearance: none;
  min-height: var(--ds-control-height, 40px);
  border-radius: var(--ds-radius-sm, 10px);
  border: 1px solid var(--line);
  padding: 10px 14px;
  font-size: var(--ds-text-base, 14px);
  background: var(--ds-surface, #fff);
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  opacity: 0.65;
  cursor: pointer;
}

.bs-date-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.bs-date-field > input[type="hidden"] {
  display: none !important;
}

.bs-date-field > label {
  display: grid;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.bs-date-field .bs-date-input,
.bs-date-field input.modern-date {
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Popup calendar ===== */

.bs-date-popup {
  position: fixed;
  z-index: 10150;
  display: none;
  min-width: 280px;
  width: 300px;
  max-width: calc(100vw - 24px);
  pointer-events: auto;
}

.bs-date-popup.bs-date-popup--open {
  display: block;
  animation: ds-fade-in 0.2s ease;
}

.bs-date-popup.hidden {
  display: none !important;
}

.bs-date-popup__card {
  border-radius: var(--ds-radius, 14px);
  background: var(--ds-surface, #fff);
  box-shadow: var(--ds-shadow-modal, 0 24px 48px rgba(15, 23, 42, 0.18));
  padding: var(--ds-space-4, 16px);
  border: 1px solid var(--line);
  overflow: hidden;
}

.bs-date-popup__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-2, 8px);
  margin-bottom: var(--ds-space-3, 12px);
  padding-bottom: var(--ds-space-3, 12px);
  border-bottom: 1px solid var(--line);
}

.bs-date-popup__month {
  flex: 1;
  font-size: var(--ds-text-base, 14px);
  font-weight: 700;
  text-align: center;
  color: var(--text);
  letter-spacing: -0.01em;
}

.bs-date-popup__nav {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border: 1px solid var(--line);
  border-radius: var(--ds-radius-sm, 10px);
  background: var(--ds-soft, #f8fafc);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ds-transition, 0.22s ease), transform var(--ds-transition, 0.22s ease);
}

.bs-date-popup__nav:hover {
  background: var(--ds-accent-soft, rgba(0, 150, 214, 0.12));
  transform: translateY(-1px);
}

.bs-date-popup__nav:focus-visible {
  outline: 2px solid var(--ds-accent, #0096d6);
  outline-offset: 2px;
}

.bs-date-popup__weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 8px;
  text-align: center;
}

.bs-date-popup__weekday {
  font-size: var(--ds-text-xs, 11px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ds-muted, #64748b);
}

.bs-date-popup__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.bs-date-popup__day {
  width: 100%;
  aspect-ratio: 1;
  max-height: 36px;
  border: none;
  border-radius: var(--ds-radius-sm, 10px);
  background: transparent;
  color: var(--text);
  font-size: var(--ds-text-sm, 13px);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--ds-transition, 0.22s ease), color var(--ds-transition, 0.22s ease);
}

.bs-date-popup__day:hover:not(:disabled) {
  background: var(--ds-accent-soft, rgba(0, 150, 214, 0.12));
}

.bs-date-popup__day--muted {
  color: var(--ds-muted, #94a3b8);
  opacity: 0.55;
  cursor: default;
}

.bs-date-popup__day--today:not(.bs-date-popup__day--selected) {
  box-shadow: inset 0 0 0 1px var(--ds-accent, #0096d6);
}

.bs-date-popup__day--selected {
  background: linear-gradient(135deg, var(--ds-accent, #0096d6), #0078a8) !important;
  color: #fff !important;
}

.bs-date-popup__footer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--ds-space-2, 8px);
  margin-top: var(--ds-space-4, 16px);
  padding-top: var(--ds-space-3, 12px);
  border-top: 1px solid var(--line);
}

.bs-date-popup__btn {
  width: 100%;
  min-height: var(--ds-control-height-sm, 36px);
}

@media (max-width: 480px) {
  .bs-date-popup {
    width: min(300px, calc(100vw - 16px));
  }
}

/* Flight itinerary leg dates — inherit row control height from .fq-flight-row */
#flightQuotationView .fq-flight-row .bs-date-input {
  height: var(--fq-control-height, var(--ds-control-height, 40px)) !important;
  min-height: var(--fq-control-height, var(--ds-control-height, 40px)) !important;
  max-height: var(--fq-control-height, var(--ds-control-height, 40px)) !important;
  padding: 0 12px !important;
  padding-right: 40px !important;
  line-height: calc(var(--fq-control-height, var(--ds-control-height, 40px)) - 2px) !important;
  font-size: var(--ds-text-sm, 13px) !important;
  background-position: right 12px center;
  background-size: 18px 18px;
}

.docs-page .bs-date-input {
  min-height: 44px !important;
  padding: 0.375rem 2.4rem 0.375rem 0.75rem !important;
  border: 1px solid #e1e7e1 !important;
  border-radius: 12px !important;
  background-color: #f8faf8 !important;
  color: #14202b !important;
  font-size: 1rem !important;
  font-weight: 400 !important;
  line-height: 1.5 !important;
  box-shadow: none !important;
}

.docs-page .bs-date-input:hover:not(:disabled):not(.bs-date-input--disabled) {
  border-color: #e1e7e1 !important;
}

.docs-page .bs-date-input:focus,
.docs-page .bs-date-input:focus-visible {
  border-color: #0c4f3e !important;
  background-color: #fff !important;
  box-shadow: 0 0 0 3px rgba(12, 79, 62, 0.12) !important;
}

.form-control-lg.bs-date-input {
  min-height: calc(1.5em + 1rem + 2px);
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
  font-size: 1.25rem !important;
}

.bs-date-popup .btn-green {
  background: #0c4f3e;
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
}

.bs-date-popup .btn-green:hover {
  background: #157a56;
  color: #fff;
}

.bs-date-popup .btn-secondary {
  background: #f4f7f6;
  color: #1c2430;
  border: 1px solid #d7dee7;
  border-radius: 10px;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  .bs-date-popup.bs-date-popup--open {
    animation: none;
  }

  .bs-date-popup__nav:hover,
  .bs-date-popup__day:hover {
    transform: none;
  }
}
