/* ==========================================
   Flatpickr Date Picker Theme
   - Minimal overrides using existing CSS variables
   - Compatible with light/dark theme system
   - Respects existing font and text size
   ========================================== */

/* Flatpickr wrapper - positions input and icon */
.flatpickr-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 140px;
  max-width: 180px;
}

/* Input field styling */
.flatpickr-wrapper input[data-input] {
  flex: 1;
  padding-right: 2.5rem; /* Make room for icon */
  cursor: pointer;
}

/* Calendar icon button */
.flatpickr-calendar-icon {
  position: absolute;
  right: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--theme-text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.flatpickr-calendar-icon:hover {
  background: var(--theme-hover);
  color: var(--theme-text-primary);
}

.flatpickr-calendar-icon:active {
  transform: scale(0.95);
}

/* Main calendar container */
.flatpickr-calendar {
  background: var(--theme-bg-primary);
  border: 1px solid var(--theme-border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-family: inherit;
  font-size: var(--text-sm);
  overflow: visible !important;
}

.flatpickr-calendar.open {
  z-index: 9999;
  overflow: visible !important;
}

.flatpickr-calendar .flatpickr-innerContainer {
  overflow: visible !important;
}

.flatpickr-calendar .flatpickr-rContainer {
  overflow: visible !important;
}

/* Month navigation */
.flatpickr-months {
  background: var(--theme-bg-secondary);
  border-bottom: 1px solid var(--theme-border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: visible !important;
  z-index: 1;
  padding: 0.5rem;
  width: 100%;
  height: 52px !important;
  min-height: 52px;
  max-height: 52px;
  box-sizing: border-box;
}

.flatpickr-month {
  color: var(--theme-text-primary);
  fill: var(--theme-text-primary);
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
}

.flatpickr-current-month {
  font-size: var(--text-base);
  color: var(--theme-text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 28px;
  padding: 0;
  position: static !important;
  left: auto !important;
  transform: none !important;
  overflow: visible !important;
  z-index: 2;
}

/* Static month text (when using monthSelectorType: 'static') */
.flatpickr-current-month .cur-month {
  font-weight: 600;
  color: var(--theme-text-primary);
  font-size: var(--text-sm);
  margin-right: 0.25rem;
}

/* Month dropdown (fallback if using dropdown mode) */
select.flatpickr-monthDropdown-months {
  background: var(--theme-bg-primary);
  color: var(--theme-text-primary);
  border: 1px solid var(--theme-border-primary);
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.5rem;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  outline: none;
  width: auto !important;
  min-width: 90px;
}

select.flatpickr-monthDropdown-months:hover {
  background-color: var(--theme-hover);
  border-color: var(--theme-border-secondary);
}

select.flatpickr-monthDropdown-months:focus {
  border-color: var(--primary-color);
  background-color: var(--theme-bg-primary);
}

/* Style dropdown options */
select.flatpickr-monthDropdown-months option {
  background: var(--theme-bg-primary);
  color: var(--theme-text-primary);
  padding: 0.5rem;
}

/* Hide the default month dropdown text when using static mode */
.flatpickr-current-month .flatpickr-monthDropdown-month {
  display: none;
}

/* Year input */
.flatpickr-current-month input.cur-year {
  font-weight: 600;
  color: var(--theme-text-primary);
  background: transparent;
  border: none;
  padding: 0.25rem 0.5rem;
  font-size: var(--text-sm);
  width: 60px;
}

.flatpickr-current-month input.cur-year:hover {
  background: var(--theme-hover);
  border-radius: var(--radius-sm);
}

.flatpickr-current-month input.cur-year:focus {
  outline: none;
  background: var(--theme-hover);
  border-radius: var(--radius-sm);
}

/* Ensure month text doesn't overflow */
.flatpickr-current-month .flatpickr-monthDropdown-month {
  display: none; /* Hide if both dropdown and text are showing */
}

/* Navigation arrows - make them more obvious */
.flatpickr-prev-month,
.flatpickr-next-month {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 52px !important;
  height: 52px !important;
  min-height: 52px !important;
  flex-shrink: 0 !important;
  padding: 0 !important;
  color: var(--theme-text-primary);
  fill: var(--theme-text-primary);
  background: var(--theme-bg-tertiary);
  border: 1px solid var(--theme-border-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.flatpickr-prev-month:hover,
.flatpickr-next-month:hover {
  color: var(--theme-text-primary);
  fill: var(--theme-text-primary);
  background: var(--theme-hover);
  border-color: var(--theme-border-secondary);
  transform: scale(1.05);
}

.flatpickr-prev-month svg,
.flatpickr-next-month svg {
  width: 14px;
  height: 14px;
  fill: var(--theme-text-primary);
}

.flatpickr-prev-month:hover svg,
.flatpickr-next-month:hover svg {
  fill: var(--primary-color);
}

/* Weekday labels */
.flatpickr-weekdays {
  background: var(--theme-bg-secondary);
  border-bottom: 1px solid var(--theme-border-primary);
}

span.flatpickr-weekday {
  color: var(--theme-text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* Days grid */
.flatpickr-days {
  background: var(--theme-bg-primary);
  position: relative;
  z-index: 1;
}

.dayContainer {
  background: var(--theme-bg-primary);
  position: relative;
  z-index: 1;
}

/* Individual day cells */
.flatpickr-day {
  color: var(--theme-text-primary);
  border: 1px solid transparent;
  font-size: var(--text-sm);
}

/* Hover state */
.flatpickr-day:hover {
  background: var(--theme-hover);
  border-color: var(--theme-border-secondary);
}

/* Today */
.flatpickr-day.today {
  border-color: var(--primary-color);
  background: transparent;
}

.flatpickr-day.today:hover {
  background: var(--theme-hover);
  border-color: var(--primary-color);
}

/* Selected date */
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.startRange.inRange,
.flatpickr-day.endRange.inRange,
.flatpickr-day.selected:focus,
.flatpickr-day.startRange:focus,
.flatpickr-day.endRange:focus,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange:hover,
.flatpickr-day.endRange:hover,
.flatpickr-day.selected.prevMonthDay,
.flatpickr-day.startRange.prevMonthDay,
.flatpickr-day.endRange.prevMonthDay,
.flatpickr-day.selected.nextMonthDay,
.flatpickr-day.startRange.nextMonthDay,
.flatpickr-day.endRange.nextMonthDay {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

/* Days from adjacent months */
.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
  color: var(--theme-text-tertiary);
}

.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover {
  color: var(--theme-text-primary);
  background: var(--theme-hover);
}

/* Disabled days */
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
  color: var(--theme-text-tertiary);
  background: transparent;
  cursor: not-allowed;
  opacity: 0.4;
}

/* Week numbers (if enabled) */
.flatpickr-day.inRange {
  background: var(--theme-bg-secondary);
  border-color: var(--theme-border-secondary);
  box-shadow: -5px 0 0 var(--theme-bg-secondary), 5px 0 0 var(--theme-bg-secondary);
}

/* Footer buttons */
.flatpickr-months .flatpickr-month {
  background: transparent;
}

/* Time picker (if enabled) */
.flatpickr-time {
  border-top: 1px solid var(--theme-border-primary);
  background: var(--theme-bg-secondary);
}

.flatpickr-time input {
  color: var(--theme-text-primary);
  background: var(--theme-bg-primary);
  border: 1px solid var(--theme-border-primary);
}

.flatpickr-time input:hover {
  background: var(--theme-hover);
}

.flatpickr-time .flatpickr-time-separator,
.flatpickr-time .flatpickr-am-pm {
  color: var(--theme-text-primary);
}

/* Animation */
.flatpickr-calendar.animate.open {
  animation: fpFadeInDown 300ms cubic-bezier(0.23, 1, 0.32, 1);
}

@keyframes fpFadeInDown {
  from {
    opacity: 0;
    transform: translate3d(0, -20px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

