/* =========================================================
   calendar.css — Custom date range picker
   aeroplan.bg booking engine
   ========================================================= */

/* ===== Calendar popup container ===== */
#cal-popup {
    display: none;
    position: absolute;
    z-index: 9999;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 48px rgba(0, 0, 0, 0.18);
    border: 1px solid #e5e7eb;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.17s ease, transform 0.17s ease;
}
#cal-popup.open {
    opacity: 1;
    transform: translateY(0);
}

.cal-inner {
    padding: 0 0 14px;
}

/* ===== Mode banner (top of calendar) ===== */
.cal-mode-banner {
    background: linear-gradient(135deg, #002955 0%, #1f74dc 100%);
    color: #fff;
    text-align: center;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    padding: 11px 20px;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 40px;
}

/* ===== Header: nav arrows + two-month grid ===== */
.cal-header {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 16px 16px 0;
}

.cal-nav {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    margin-top: 2px;
    border-radius: 50%;
    border: 1.5px solid #e5e7eb;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--aeroplan-blue);
    font-size: 0.72rem;
    transition: all 0.15s;
}
.cal-nav:hover {
    background: #f0f7ff;
    border-color: var(--aeroplan-sky-blue);
    color: var(--aeroplan-sky-blue);
}

.cal-months {
    flex: 1;
    display: flex;
    gap: 20px;
    padding: 0 4px;
}

/* ===== Single month ===== */
.cal-month { flex: 1; min-width: 0; }

.cal-month-title {
    text-align: center;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--aeroplan-blue);
    margin-bottom: 10px;
    padding: 2px 0;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px 0;
}

/* ===== Weekday header ===== */
.cal-dow {
    text-align: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #9ca3af;
    padding: 4px 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

/* ===== Day cells ===== */
.cal-day {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    cursor: pointer;
    user-select: none;
}
.cal-empty { cursor: default; }
.cal-past  { cursor: not-allowed; }

/* Range fill band — sits behind the circle via ::before */
.cal-day::before {
    content: '';
    position: absolute;
    inset: 3px 0;           /* small vertical inset so bands don't touch row edges */
    z-index: 0;
}
/* In-range days: full band */
.cal-in-range::before    { background: #dbeafe; }
/* Start day: right half of band */
.cal-sel-start::before   { background: linear-gradient(to right, transparent 50%, #dbeafe 50%); }
/* End day: left half of band */
.cal-sel-end::before     { background: linear-gradient(to left,  transparent 50%, #dbeafe 50%); }
/* Single selection: no band */
.cal-sel-single::before  { background: transparent; }

/* ===== Day circle (the inner span) ===== */
.cal-day-inner {
    position: relative;
    z-index: 1;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 500;
    color: #374151;
    transition: background 0.12s, color 0.12s;
}

/* Hover: light blue circle */
.cal-day:not(.cal-past):not(.cal-empty):hover .cal-day-inner {
    background: #e0f0ff;
    color: var(--aeroplan-blue);
}

/* Past days */
.cal-past .cal-day-inner {
    color: #d1d5db;
    font-weight: 400;
}

/* Today: outlined circle */
.cal-today .cal-day-inner {
    border: 2px solid var(--aeroplan-sky-blue);
    color: var(--aeroplan-sky-blue);
    font-weight: 700;
}

/* In-range text colour */
.cal-in-range .cal-day-inner {
    color: #1e3a8a;
    font-weight: 600;
}

/* Selected start / end / single — dark blue filled circle */
.cal-sel-start  .cal-day-inner,
.cal-sel-end    .cal-day-inner,
.cal-sel-single .cal-day-inner {
    background: var(--aeroplan-blue);
    color: white;
    font-weight: 700;
}
/* Override today border when selected */
.cal-sel-start.cal-today  .cal-day-inner,
.cal-sel-end.cal-today    .cal-day-inner,
.cal-sel-single.cal-today .cal-day-inner {
    border: none;
}

/* ===== Footer ===== */
.cal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 14px;
    padding: 12px 16px 0;
    border-top: 1px solid #f1f5f9;
}
.cal-done-btn {
    padding: 7px 20px;
    background: var(--aeroplan-blue);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.cal-done-btn:hover { background: var(--aeroplan-sky-blue); }

/* ===== Active segment highlight ===== */
.seg-dep.cal-active,
.seg-ret.cal-active {
    background: #f0f7ff;
}
.seg-dep.cal-active .seg-label,
.seg-ret.cal-active .seg-label {
    color: var(--aeroplan-sky-blue);
}

/* ===== Date display in segment ===== */
.date-val-row {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}
.date-val-row .seg-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.seg-value.placeholder {
    color: #9ca3af;
    font-weight: 400;
}

/* Clear (×) button inside segment */
.date-clear-btn {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: #e5e7eb;
    color: #6b7280;
    font-size: 0.6rem;
    cursor: pointer;
    display: none;         /* shown via JS when date is set */
    align-items: center;
    justify-content: center;
    transition: background 0.12s, color 0.12s;
    line-height: 1;
}
.date-clear-btn:hover { background: #fecaca; color: #ef4444; }

/* ===== Mobile: single month ===== */
@media (max-width: 640px) {
    .cal-months { gap: 0; }
    .cal-month:last-child { display: none; }
    #cal-popup { left: 8px !important; right: 8px !important; width: auto !important; }
}