/**
 * ═══════════════════════════════════════════════════════════════════════════════
 * ALAM AL-RAYA TRAVEL - MOBILE FLIGHT CALENDAR SHEET (ALMOSAFER / SKYSCANNER STYLE)
 * ═══════════════════════════════════════════════════════════════════════════════
 * Continuous vertical scroll date picker for mobile touchscreens with:
 * - Dual departure / return interactive capsules
 * - Dynamic nights counter
 * - Sticky weekday header (accurate RTL/LTR flow)
 * - 12-month vertical infinite scroll
 * - Touch-optimized 44px+ tap targets
 * - Instant calendar mode switcher (Vertical Sheet / Drawer / Classic)
 */

:root {
  --mcal-primary: var(--q8by-c_2563eb, #2563eb);
  --mcal-primary-dark: var(--q8by-c_1d4ed8, #1d4ed8);
  --mcal-primary-light: var(--q8by-c_eff6ff, #eff6ff);
  --mcal-range-bg: var(--q8by-c_dbeafe, #dbeafe);
  --mcal-range-text: var(--q8by-c_1e40af, #1e40af);
  --mcal-ink: var(--q8by-c_0f172a, #0f172a);
  --mcal-muted: var(--q8by-c_64748b, #64748b);
  --mcal-disabled: var(--q8by-c_cbd5e1, #cbd5e1);
  --mcal-border: var(--q8by-c_e2e8f0, #e2e8f0);
  --mcal-radius: 16px;
  --mcal-shadow: 0 10px 30px var(--q8by-c_0f172a1f, rgba(15, 23, 42, 0.12));
}

/* ═══════════════════════════════════════════════════════════════
   FULLSCREEN / BOTTOMSHEET OVERLAY
   ═══════════════════════════════════════════════════════════════ */
.mobile-date-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: var(--q8by-c_0f172aa6, rgba(15, 23, 42, 0.65));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  font-family: inherit;
}

.mobile-date-sheet-overlay.active {
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

.mobile-date-sheet-overlay:not(.active) {
  pointer-events: none !important;
}

.mobile-date-sheet-overlay.active .mobile-date-sheet-dialog {
  transform: translateY(0) !important;
}

.mobile-date-sheet-dialog {
  width: 100%;
  max-width: 520px;
  height: 94vh;
  max-height: 94vh;
  background: var(--q8by-c_ffffff, #ffffff);
  border-top-left-radius: 26px;
  border-top-right-radius: 26px;
  box-shadow: 0 -10px 40px var(--q8by-c_00000047, rgba(0, 0, 0, 0.28));
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
  position: relative;
}

.mobile-date-sheet-overlay.active .mobile-date-sheet-dialog {
  transform: translateY(0);
}

/* Drag Handle */
.mobile-date-sheet-handle-bar {
  width: 100%;
  padding: 10px 0 4px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
  flex-shrink: 0;
}

.mobile-date-sheet-handle {
  width: 44px;
  height: 5px;
  background: var(--q8by-c_cbd5e1, #cbd5e1);
  border-radius: 999px;
  transition: background 0.2s;
}

/* ═══════════════════════════════════════════════════════════════
   HEADER & TOP CONTROLS
   ═══════════════════════════════════════════════════════════════ */
.mobile-date-sheet-header {
  padding: 6px 18px 0;
  background: var(--q8by-c_ffffff, #ffffff);
  flex-shrink: 0;
  border-bottom: 1px solid var(--q8by-c_f1f5f9, #f1f5f9);
}

.mobile-date-sheet-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.mobile-date-sheet-close {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--mcal-border);
  background: var(--q8by-c_f8fafc, #f8fafc);
  color: var(--mcal-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s ease;
}

.mobile-date-sheet-close:hover,
.mobile-date-sheet-close:active {
  background: var(--q8by-c_ef4444, #ef4444);
  color: var(--q8by-c_ffffff, #ffffff);
  border-color: var(--q8by-c_ef4444, #ef4444);
  transform: scale(0.96);
}

.mobile-date-sheet-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--mcal-ink);
  letter-spacing: -0.2px;
}

/* Mode Switcher Pill (Vertical Sheet / Drawer / Classic) */
.mobile-date-sheet-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--q8by-c_f1f5f9, #f1f5f9);
  border: 1px solid var(--mcal-border);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--mcal-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mobile-date-sheet-mode-toggle:hover,
.mobile-date-sheet-mode-toggle:active {
  background: var(--mcal-primary-light);
  color: var(--mcal-primary);
  border-color: var(--q8by-c_bfdbfe, #bfdbfe);
}

.mobile-date-sheet-mode-toggle i {
  font-size: 0.8rem;
}

/* Mode Switcher Dropdown Menu */
.mobile-date-mode-menu {
  position: absolute;
  top: 50px;
  left: 18px;
  background: var(--q8by-c_ffffff, #ffffff);
  border: 1px solid var(--mcal-border);
  border-radius: 14px;
  box-shadow: 0 10px 25px var(--q8by-c_00000026, rgba(0,0,0,0.15));
  padding: 6px;
  z-index: 100;
  display: none;
  min-width: 190px;
}

html[dir="rtl"] .mobile-date-mode-menu {
  left: auto;
  right: 18px;
}

.mobile-date-mode-menu.show {
  display: block;
}

.mobile-date-mode-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--mcal-ink);
  border-radius: 8px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: inherit;
  transition: background 0.15s ease;
}

.mobile-date-mode-item:hover,
.mobile-date-mode-item.active {
  background: var(--mcal-primary-light);
  color: var(--mcal-primary);
}

.mobile-date-mode-item.active {
  font-weight: 800;
}

/* ═══════════════════════════════════════════════════════════════
   DEPARTURE & RETURN CAPSULES
   ═══════════════════════════════════════════════════════════════ */
.mobile-date-capsules-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--q8by-c_f8fafc, #f8fafc);
  padding: 6px;
  border-radius: 16px;
  border: 1px solid var(--mcal-border);
  margin-bottom: 12px;
}

.mobile-date-capsule {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  background: transparent;
  border: 2px solid transparent;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.mobile-date-capsule.active {
  background: var(--q8by-c_ffffff, #ffffff);
  border-color: var(--mcal-primary);
  box-shadow: 0 4px 12px var(--q8by-c_2563eb1f, rgba(37, 99, 235, 0.12));
}

.mobile-date-capsule .capsule-sub {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--mcal-muted);
  margin-bottom: 2px;
  text-transform: uppercase;
}

.mobile-date-capsule.active .capsule-sub {
  color: var(--mcal-primary);
}

.mobile-date-capsule .capsule-val {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--mcal-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-date-capsule.active .capsule-val {
  color: var(--mcal-primary-dark);
}

.mobile-date-capsule-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mcal-muted);
  font-size: 0.85rem;
  padding: 0 4px;
}

html[dir="rtl"] .rtl-flip {
  transform: scaleX(-1);
}

/* Dynamic Nights Pill */
.mobile-date-duration-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: -4px auto 10px;
  padding: 4px 14px;
  background: var(--q8by-c_ecfdf5, #ecfdf5);
  color: var(--q8by-c_065f46, #065f46);
  border: 1px solid var(--q8by-c_a7f3d0, #a7f3d0);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  width: fit-content;
  animation: mcalFadeIn 0.25s ease;
}

@keyframes mcalFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════════════════════
   STICKY WEEKDAYS BAR
   ═══════════════════════════════════════════════════════════════ */
.mobile-date-weekdays-sticky {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  padding: 8px 12px;
  background: var(--q8by-c_ffffff, #ffffff);
  border-top: 1px solid var(--q8by-c_f1f5f9, #f1f5f9);
  border-bottom: 1px solid var(--q8by-c_e2e8f0, #e2e8f0);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--q8by-c_475569, #475569);
  letter-spacing: -0.1px;
}

.mobile-weekday {
  padding: 2px 0;
}

/* In Arabic (RTL), Friday & Saturday weekend styling */
html[dir="rtl"] .mobile-weekday:first-child,
html[dir="rtl"] .mobile-weekday:last-child {
  color: var(--q8by-c_2563eb, #2563eb);
}

/* ═══════════════════════════════════════════════════════════════
   CONTINUOUS VERTICAL MONTHS SCROLL FEED
   ═══════════════════════════════════════════════════════════════ */
.mobile-date-months-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 12px 100px;
  scroll-behavior: smooth;
}

.mobile-month-block {
  margin-bottom: 24px;
}

.mobile-month-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--mcal-ink);
  padding: 12px 6px 8px;
  position: sticky;
  top: 0;
  background: var(--q8by-c_fffffff0, rgba(255, 255, 255, 0.94));
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 5;
  border-bottom: 1px solid var(--q8by-c_e2e8f066, rgba(226, 232, 240, 0.4));
}

.mobile-month-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 4px;
  column-gap: 0;
  padding: 6px 0;
}

/* Individual Day Cell */
.mobile-day-cell {
  position: relative;
  height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--mcal-ink);
  transition: all 0.15s ease;
}

.mobile-day-cell.empty {
  cursor: default;
  pointer-events: none;
}

.mobile-day-cell.past {
  color: var(--mcal-disabled);
  cursor: not-allowed;
  pointer-events: none;
}

.mobile-day-cell .day-number {
  position: relative;
  z-index: 2;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.mobile-day-cell .day-badge {
  position: relative;
  z-index: 2;
  font-size: 0.62rem;
  font-weight: 800;
  line-height: 1;
  margin-top: 3px;
  white-space: nowrap;
}

/* Today Indicator */
.mobile-day-cell.is-today:not(.selected-dep):not(.selected-ret) .day-number::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  background: var(--mcal-primary);
  border-radius: 50%;
}

/* Selected Start / End Days */
.mobile-day-cell.selected-dep,
.mobile-day-cell.selected-ret {
  color: var(--q8by-c_ffffff, #ffffff) !important;
  font-weight: 800;
}

.mobile-day-cell.selected-dep::before,
.mobile-day-cell.selected-ret::before {
  content: '';
  position: absolute;
  width: 38px;
  height: 38px;
  background: var(--mcal-primary);
  border-radius: 50%;
  z-index: 1;
  box-shadow: 0 4px 12px var(--q8by-c_2563eb59, rgba(37, 99, 235, 0.35));
}

.mobile-day-cell.selected-dep .day-badge,
.mobile-day-cell.selected-ret .day-badge {
  color: var(--q8by-c_ffffff, #ffffff);
}

/* Range In-between Highlighting */
.mobile-day-cell.in-range {
  background: var(--mcal-range-bg) !important;
  color: var(--mcal-range-text) !important;
  font-weight: 700;
}

/* RTL Range Connecting Wings */
html[dir="rtl"] .mobile-day-cell.selected-dep.has-range::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  background: var(--mcal-range-bg);
  z-index: 0;
}

html[dir="rtl"] .mobile-day-cell.selected-ret.has-range::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 50%;
  background: var(--mcal-range-bg);
  z-index: 0;
}

/* LTR Range Connecting Wings */
html[dir="ltr"] .mobile-day-cell.selected-dep.has-range::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 50%;
  background: var(--mcal-range-bg);
  z-index: 0;
}

html[dir="ltr"] .mobile-day-cell.selected-ret.has-range::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  background: var(--mcal-range-bg);
  z-index: 0;
}

/* Same Day Departure & Return */
.mobile-day-cell.selected-dep.selected-ret::after {
  display: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   BOTTOM CONFIRMATION FLOATING BAR
   ═══════════════════════════════════════════════════════════════ */
.mobile-date-sheet-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--q8by-c_ffffff, #ffffff);
  border-top: 1px solid var(--mcal-border);
  padding: 12px 18px env(safe-area-inset-bottom, 16px);
  box-shadow: 0 -8px 25px var(--q8by-c_0f172a14, rgba(15, 23, 42, 0.08));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  z-index: 10;
}

.mobile-date-footer-summary {
  flex: 1;
  min-width: 0;
}

.mobile-date-footer-summary .summary-dates {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--mcal-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-date-footer-summary .summary-sub {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--mcal-muted);
}

.mobile-date-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-mcal-clear {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--mcal-border);
  background: var(--q8by-c_f8fafc, #f8fafc);
  color: var(--q8by-c_ef4444, #ef4444);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-mcal-clear:hover,
.btn-mcal-clear:active {
  background: var(--q8by-c_fee2e2, #fee2e2);
  border-color: var(--q8by-c_fca5a5, #fca5a5);
}

.btn-confirm-dates {
  padding: 12px 24px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--mcal-primary), var(--mcal-primary-dark));
  color: var(--q8by-c_ffffff, #ffffff);
  border: none;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 14px var(--q8by-c_2563eb4c, rgba(37, 99, 235, 0.3));
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.btn-confirm-dates:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  background: var(--q8by-c_94a3b8, #94a3b8);
}

.btn-confirm-dates:not(:disabled):hover,
.btn-confirm-dates:not(:disabled):active {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--q8by-c_2563eb66, rgba(37, 99, 235, 0.4));
}

/* ═══════════════════════════════════════════════════════════════
   MODE 2: ENHANCED BOTTOM DRAWER (FOR FLATPICKR MODE)
   ═══════════════════════════════════════════════════════════════ */
body.cal-mode-drawer .flatpickr-calendar {
  position: fixed !important;
  bottom: 0 !important;
  top: auto !important;
  left: 0 !important;
  right: 0 !important;
  width: 100vw !important;
  max-width: 100vw !important;
  border-radius: 24px 24px 0 0 !important;
  transform: none !important;
  box-shadow: 0 -10px 40px var(--q8by-c_0000004c, rgba(0,0,0,0.3)) !important;
  z-index: 999999 !important;
  padding-bottom: env(safe-area-inset-bottom, 12px) !important;
}
