/**
 * BM Date Picker - lịch chọn ngày dùng chung.
 * Gắn: BMDatePicker.attach(input) hoặc data-bm-date-picker trên input[type=date|text].
 */
:root {
  --bm-dp-blue: var(--shell-blue, #15733c);
  --bm-dp-blue-dark: var(--shell-blue-dark, #0f5a2e);
  --bm-dp-blue-soft: #e8f5ec;
  --bm-dp-border: #e2e8f0;
  --bm-dp-text: #0f172a;
  --bm-dp-muted: #64748b;
  --bm-dp-font: "Montserrat", "Segoe UI", Tahoma, Arial, sans-serif;
}

.bm-dp-field {
  position: relative;
  width: 100%;
}

.bm-dp-field .bm-dp-native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.bm-dp-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--bm-dp-border);
  border-radius: 4px;
  background: #fff;
  color: var(--bm-dp-text);
  font-family: var(--bm-dp-font);
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bm-dp-trigger:hover {
  border-color: #cbd5e1;
}

.bm-dp-trigger:focus {
  outline: none;
  border-color: var(--bm-dp-blue);
  box-shadow: 0 0 0 2px rgba(21, 115, 60, 0.12);
}

.bm-dp-field.is-open .bm-dp-trigger {
  border-color: var(--bm-dp-blue);
  box-shadow: 0 0 0 2px rgba(21, 115, 60, 0.12);
}

.bm-dp-trigger__text {
  flex: 1;
  min-width: 0;
  color: var(--bm-dp-text);
}

.bm-dp-trigger__text.is-placeholder {
  color: #94a3b8;
}

.bm-dp-trigger__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--bm-dp-muted);
}

.bm-dp-trigger__icon svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

/* Popover */
.bm-dp {
  position: fixed;
  z-index: 10050;
  width: min(320px, calc(100vw - 24px));
  padding: 14px 14px 10px;
  border: 1px solid var(--bm-dp-border);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14), 0 4px 12px rgba(15, 23, 42, 0.06);
  font-family: var(--bm-dp-font);
  color: var(--bm-dp-text);
  box-sizing: border-box;
  animation: bm-dp-in 0.18s ease;
}

.bm-dp[hidden] {
  display: none !important;
}

@keyframes bm-dp-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.bm-dp__title {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--bm-dp-text);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bm-dp__nav {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--bm-dp-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}

.bm-dp__nav:hover {
  background: var(--bm-dp-blue-soft);
  color: var(--bm-dp-blue);
}

.bm-dp__nav svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.bm-dp__ym {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.bm-dp__month,
.bm-dp__year {
  max-width: 100%;
  min-height: 32px;
  padding: 4px 6px;
  border: 1px solid var(--bm-dp-border);
  border-radius: 8px;
  background: #fff;
  color: var(--bm-dp-text);
  font-family: var(--bm-dp-font);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
}

.bm-dp__month {
  flex: 1.1;
  min-width: 0;
}

.bm-dp__year {
  flex: 0.9;
  min-width: 72px;
}

.bm-dp__month:focus,
.bm-dp__year:focus {
  outline: none;
  border-color: var(--bm-dp-blue);
  box-shadow: 0 0 0 2px rgba(21, 115, 60, 0.12);
}

.bm-dp--ym-pick {
  width: min(340px, calc(100vw - 24px));
}

.bm-dp__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 6px;
}

.bm-dp__weekday {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--bm-dp-muted);
  letter-spacing: 0.02em;
  padding: 4px 0;
}

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

.bm-dp__day {
  width: 100%;
  aspect-ratio: 1;
  max-height: 40px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--bm-dp-text);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  transition: background 0.12s, color 0.12s;
}

.bm-dp__day.has-lunar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: auto;
  min-height: 42px;
  max-height: none;
  border-radius: 10px;
  line-height: 1.05;
  padding: 2px 0;
}

.bm-dp.has-fares {
  width: min(360px, calc(100vw - 24px));
}

.bm-dp.has-fares .bm-dp__day.has-lunar {
  min-height: 58px;
  padding: 3px 1px 2px;
  gap: 1px;
}

.bm-dp__day-fare {
  font-size: 0.80rem;
  font-weight: 700;
  line-height: 1;
  color: #ea580c;
  letter-spacing: -0.02em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bm-dp__day-fare.is-empty {
  min-height: 0.80rem;
  color: transparent;
}

.bm-dp__day.is-selected .bm-dp__day-fare {
  color: #ecfdf5;
}

.bm-dp__day.is-outside .bm-dp__day-fare {
  opacity: 0.45;
}

.bm-dp__fare-hint {
  display: none !important;
}

.bm-dp__day-solar {
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.1;
}

.bm-dp__day-lunar {
  margin-top: 1px;
  font-size: 0.58rem;
  font-weight: 500;
  color: var(--bm-dp-muted);
  line-height: 1;
}

.bm-dp__day.is-lunar-first .bm-dp__day-lunar {
  color: #dc2626;
  font-weight: 600;
}

.bm-dp__day.is-selected .bm-dp__day-lunar {
  color: rgba(255, 255, 255, 0.88);
}

.bm-dp__day.is-selected.is-lunar-first .bm-dp__day-lunar {
  color: #fecaca;
}

.bm-dp__day.is-outside .bm-dp__day-lunar {
  color: #dbe3ee;
}

.bm-dp.has-lunar {
  width: min(336px, calc(100vw - 24px));
}

.bm-dp.has-lunar .bm-dp__day.has-lunar {
  min-height: 44px;
}

.bm-dp__day:hover:not(:disabled) {
  background: var(--bm-dp-blue-soft);
  color: var(--bm-dp-blue-dark);
}

.bm-dp__day.is-outside {
  color: #cbd5e1;
}

.bm-dp__day.is-today:not(.is-selected) {
  box-shadow: inset 0 0 0 1.5px var(--shell-accent, #f9d448);
  color: var(--bm-dp-blue);
  font-weight: 700;
}

.bm-dp__day.is-selected {
  background: var(--bm-dp-blue);
  color: #fff;
  font-weight: 700;
}

.bm-dp__day:disabled {
  cursor: default;
  opacity: 0.35;
}

.bm-dp__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #f1f5f9;
}

.bm-dp__foot-btn {
  border: none;
  background: transparent;
  color: var(--bm-dp-blue);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: 6px;
  transition: background 0.12s;
}

.bm-dp__foot-btn:hover {
  background: var(--bm-dp-blue-soft);
}

@media (max-width: 520px) {
  .bm-dp {
    width: min(300px, calc(100vw - 20px));
    padding: 12px 12px 8px;
  }

  .bm-dp__day {
    font-size: 0.8rem;
    max-height: 38px;
  }
}

.bm-dp-trigger--inp {
  border: none;
  border-radius: 0;
  box-shadow: none !important;
  background: transparent;
  min-height: 0;
  height: 100%;
  padding: 0 10px;
  font-weight: 500;
}

.bm-dp-trigger--inp:hover {
  border-color: transparent;
  background: transparent;
}

.bm-dp-trigger--inp:focus {
  box-shadow: none !important;
}

.bm-dp-trigger--inp .bm-dp-trigger__icon {
  display: none;
}

.bm-dp-field.is-disabled .bm-dp-trigger {
  pointer-events: none;
  cursor: not-allowed;
  color: #94a3b8;
}

/* Typeable - nhập tay dd/mm/yyyy, chỉ icon mở lịch */
.bm-dp-field--typeable {
  display: flex;
  align-items: stretch;
  width: 100%;
  border: 1px solid var(--bm-dp-border);
  border-radius: 4px;
  background: #fff;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bm-dp-field--typeable:focus-within {
  border-color: var(--bm-dp-blue);
  box-shadow: 0 0 0 2px rgba(21, 115, 60, 0.12);
}

.bm-dp-field--typeable.is-open {
  border-color: var(--bm-dp-blue);
  box-shadow: 0 0 0 2px rgba(21, 115, 60, 0.12);
}

.bm-dp-field--typeable .bm-dp-native {
  position: static;
  flex: 1;
  min-width: 0;
  width: auto;
  height: auto;
  min-height: 36px;
  padding: 8px 10px;
  margin: 0;
  border: none;
  border-radius: 4px 0 0 4px;
  background: transparent;
  color: var(--bm-dp-text);
  font-family: var(--bm-dp-font);
  font-size: 0.82rem;
  line-height: 1.3;
  clip: auto;
  overflow: visible;
  opacity: 1;
  pointer-events: auto;
  box-sizing: border-box;
}

.bm-dp-field--typeable .bm-dp-native:focus {
  outline: none;
}

.bm-dp-field--typeable .bm-dp-native::placeholder {
  color: #94a3b8;
}

.bm-dp-trigger--icon-only {
  flex-shrink: 0;
  width: 32px;
  min-width: 32px;
  min-height: 34px;
  padding: 0;
  margin: 0;
  border: none;
  border-left: 1px solid var(--bm-dp-border);
  border-radius: 0 4px 4px 0;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: none;
}

.bm-dp-trigger--icon-only:hover {
  background: var(--bm-dp-blue-soft);
  border-color: var(--bm-dp-border);
}

.bm-dp-trigger--icon-only:focus {
  outline: none;
  background: var(--bm-dp-blue-soft);
}

.bm-dp-trigger--icon-only .bm-dp-trigger__icon {
  width: 15px;
  height: 15px;
  color: var(--bm-dp-muted);
}

.bm-dp-field--typeable.is-invalid {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.bm-dp-field--typeable.is-invalid:focus-within {
  border-color: #dc2626;
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.12);
}

.bm-dp-field--typeable.is-disabled {
  opacity: 0.65;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .bm-dp {
    animation: none;
  }
}
