/* ════════════════════════════════════════════════════════════════════
 * BALIVI Premium Date Picker — CSS
 * Airbnb / Traveloka / Booking.com inspired design
 * Design tokens: navy #0F172A, blue #1A56DB
 * Typography: Plus Jakarta Sans (UI) + Playfair Display (titles)
 * ════════════════════════════════════════════════════════════════════ */

/* ── Display button (replaces native input) ───────────── */
.bvi-dp-display {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    background: #fff;
    border: 1.5px solid #E2E8F0;
    border-radius: 10px;
    cursor: pointer;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #0F172A;
    text-align: left;
    transition: all .18s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    line-height: 1.3;
}
.bvi-dp-display:hover {
    border-color: #1A56DB;
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.08);
    transform: translateY(-1px);
}
.bvi-dp-display:focus,
.bvi-dp-display:focus-visible {
    outline: none;
    border-color: #1A56DB;
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}
.bvi-dp-display.is-empty .bvi-dp-label {
    color: #94A3B8;
    font-weight: 500;
}

.bvi-dp-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: #1A56DB;
}
.bvi-dp-label {
    flex: 1;
    font-weight: 600;
    color: #0F172A;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bvi-dp-chevron {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: #94A3B8;
    transition: transform .2s;
}
.bvi-dp-display:hover .bvi-dp-chevron {
    color: #1A56DB;
}

/* ── Popup overlay ────────────────────────────────────── */
.bvi-dp-popup {
    position: fixed;
    inset: 0;
    z-index: 999999;
    opacity: 0;
    transition: opacity .2s ease;
    pointer-events: none;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}
.bvi-dp-popup.bvi-dp-open {
    opacity: 1;
    pointer-events: auto;
}

.bvi-dp-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity .25s ease;
}
.bvi-dp-popup.bvi-dp-open .bvi-dp-backdrop {
    opacity: 1;
}

/* ── Panel (desktop centered, mobile bottom sheet) ────── */
.bvi-dp-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -48%) scale(.96);
    width: 360px;
    max-width: calc(100vw - 24px);
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    box-shadow:
        0 24px 64px -12px rgba(15, 23, 42, 0.25),
        0 12px 32px -8px rgba(26, 86, 219, 0.12),
        0 0 0 1px rgba(15, 23, 42, 0.05);
    padding: 20px 18px 16px;
    opacity: 0;
    transition: all .28s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}
.bvi-dp-popup.bvi-dp-open .bvi-dp-panel {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* When _position() runs, it switches to position:fixed top/left → reset transform */
.bvi-dp-panel[style*="position: fixed"] {
    transform: scale(.96);
    top: auto;
    left: auto;
}
.bvi-dp-popup.bvi-dp-open .bvi-dp-panel[style*="position: fixed"] {
    transform: scale(1);
}

/* ── Header ───────────────────────────────────────────── */
.bvi-dp-header {
    display: grid;
    grid-template-columns: 36px 1fr 36px 28px;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}
.bvi-dp-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* Month & Year selects (custom-styled native selects) */
.bvi-dp-month-sel,
.bvi-dp-year-sel {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 1.5px solid transparent;
    border-radius: 8px;
    padding: 6px 22px 6px 10px;
    font-family: inherit;
    font-weight: 700;
    font-size: 15px;
    color: #0F172A;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 6px center;
    background-size: 10px;
    transition: all .15s;
}
.bvi-dp-month-sel:hover,
.bvi-dp-year-sel:hover {
    background-color: #F1F5F9;
    border-color: #E2E8F0;
}
.bvi-dp-month-sel:focus,
.bvi-dp-year-sel:focus {
    outline: none;
    border-color: #1A56DB;
    background-color: #EFF6FF;
}

.bvi-dp-nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #F8FAFC;
    border: 1.5px solid #E2E8F0;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s cubic-bezier(0.16, 1, 0.3, 1);
}
.bvi-dp-nav-btn:hover {
    background: #1A56DB;
    border-color: #1A56DB;
    color: #fff;
    transform: scale(1.08);
}
.bvi-dp-nav-btn:active {
    transform: scale(0.95);
}
.bvi-dp-nav-btn svg {
    width: 16px;
    height: 16px;
}

.bvi-dp-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
    font-size: 22px;
    font-weight: 400;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.bvi-dp-close-btn:hover {
    background: #F1F5F9;
    color: #DC2626;
    transform: scale(1.1);
}

/* ── Weekdays row ─────────────────────────────────────── */
.bvi-dp-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 6px;
    padding: 0 4px;
}
.bvi-dp-wd {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    color: #94A3B8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 4px 0;
}
.bvi-dp-wd:first-child,
.bvi-dp-wd:last-child {
    color: #EF4444;
}

/* ── Day grid ─────────────────────────────────────────── */
.bvi-dp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    margin-bottom: 14px;
    padding: 4px;
    transition: transform .2s ease, opacity .2s ease;
}
.bvi-dp-grid.slide-left {
    transform: translateX(-8px);
    opacity: 0.5;
}
.bvi-dp-grid.slide-right {
    transform: translateX(8px);
    opacity: 0.5;
}

.bvi-dp-day {
    position: relative;
    aspect-ratio: 1;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: #334155;
    transition: all .15s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    overflow: hidden;
}
.bvi-dp-day span {
    position: relative;
    z-index: 1;
}
.bvi-dp-day:hover:not(.is-disabled):not(.is-selected) {
    background: #EFF6FF;
    color: #1A56DB;
    transform: scale(1.05);
}
.bvi-dp-day:active:not(.is-disabled) {
    transform: scale(0.94);
}

.bvi-dp-day.is-outside {
    color: #CBD5E1;
    font-weight: 500;
}
.bvi-dp-day.is-weekend:not(.is-outside) {
    color: #DC2626;
}
.bvi-dp-day.is-weekend.is-outside {
    color: #FCA5A5;
}

.bvi-dp-day.is-today:not(.is-selected) {
    background: #FEF3C7;
    color: #92400E;
    font-weight: 800;
}
.bvi-dp-day.is-today:not(.is-selected)::before {
    content: '';
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #F59E0B;
}

.bvi-dp-day.is-selected {
    background: linear-gradient(135deg, #1A56DB 0%, #2563EB 100%);
    color: #fff !important;
    font-weight: 800;
    box-shadow: 0 6px 14px rgba(26, 86, 219, 0.35);
    transform: scale(1.02);
}
.bvi-dp-day.is-selected::before {
    display: none;
}

.bvi-dp-day.is-disabled {
    color: #E2E8F0 !important;
    cursor: not-allowed;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(226, 232, 240, 0.3) 4px,
        rgba(226, 232, 240, 0.3) 5px
    );
}
.bvi-dp-day.is-disabled:hover {
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(226, 232, 240, 0.3) 4px,
        rgba(226, 232, 240, 0.3) 5px
    );
    color: #E2E8F0 !important;
    transform: none;
}

/* ── Quick-select chips ───────────────────────────────── */
.bvi-dp-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 4px;
    border-top: 1px solid #F1F5F9;
    border-bottom: 1px solid #F1F5F9;
    margin-bottom: 12px;
}
.bvi-dp-chip {
    flex: 0 1 auto;
    padding: 7px 12px;
    background: #F8FAFC;
    border: 1.5px solid #E2E8F0;
    border-radius: 100px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    transition: all .15s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}
.bvi-dp-chip:hover:not(.is-disabled) {
    background: #EFF6FF;
    border-color: #1A56DB;
    color: #1A56DB;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(26, 86, 219, 0.12);
}
.bvi-dp-chip:active:not(.is-disabled) {
    transform: translateY(0);
}
.bvi-dp-chip.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ── Footer / action buttons ──────────────────────────── */
.bvi-dp-foot {
    display: flex;
    gap: 8px;
    justify-content: space-between;
    padding: 4px;
}
.bvi-dp-btn {
    flex: 1;
    padding: 11px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1.5px solid transparent;
    letter-spacing: -0.1px;
}
.bvi-dp-btn-clear {
    background: #fff;
    border-color: #E2E8F0;
    color: #64748B;
    flex: 0 0 auto;
    padding: 11px 18px;
}
.bvi-dp-btn-clear:hover {
    background: #FEF2F2;
    border-color: #FCA5A5;
    color: #DC2626;
}
.bvi-dp-btn-confirm {
    background: linear-gradient(135deg, #1A56DB 0%, #2563EB 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(26, 86, 219, 0.3);
}
.bvi-dp-btn-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(26, 86, 219, 0.4);
}
.bvi-dp-btn-confirm:active {
    transform: translateY(0);
}

/* ════════════════════════════════════════════════════════
 * MOBILE — Fullscreen bottom sheet
 * ════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    .bvi-dp-popup.bvi-dp-mobile .bvi-dp-panel {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        transform: translateY(100%);
        border-radius: 24px 24px 0 0;
        padding: 24px 18px max(20px, env(safe-area-inset-bottom));
        max-height: 92vh;
        overflow-y: auto;
    }
    .bvi-dp-popup.bvi-dp-mobile.bvi-dp-open .bvi-dp-panel {
        transform: translateY(0);
    }

    /* Drag handle */
    .bvi-dp-popup.bvi-dp-mobile .bvi-dp-panel::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        border-radius: 100px;
        background: #CBD5E1;
    }

    .bvi-dp-popup.bvi-dp-mobile .bvi-dp-header {
        margin-top: 8px;
    }

    .bvi-dp-popup.bvi-dp-mobile .bvi-dp-day {
        font-size: 15px;
    }
    .bvi-dp-popup.bvi-dp-mobile .bvi-dp-wd {
        font-size: 12px;
    }
    .bvi-dp-popup.bvi-dp-mobile .bvi-dp-month-sel,
    .bvi-dp-popup.bvi-dp-mobile .bvi-dp-year-sel {
        font-size: 16px;
    }

    /* Sticky bottom buttons */
    .bvi-dp-popup.bvi-dp-mobile .bvi-dp-foot {
        position: sticky;
        bottom: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        padding: 12px 4px 0;
        margin: 0 -4px;
        z-index: 2;
    }
}

/* ── Body scroll lock on mobile ───────────────────────── */
body.bvi-dp-body-lock {
    overflow: hidden;
}

/* ── Dark mode (auto via prefers-color-scheme) ────────── */
@media (prefers-color-scheme: dark) {
    /* Only apply dark theme if the page actually supports it
     * (BALIVI is mostly light-mode; this is a defensive default) */
    .bvi-dp-display:not([data-light-only]) {
        /* Keep light for now since main site is light-mode */
    }
}

/* ── Reduced motion ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .bvi-dp-display,
    .bvi-dp-panel,
    .bvi-dp-day,
    .bvi-dp-chip,
    .bvi-dp-btn,
    .bvi-dp-nav-btn,
    .bvi-dp-grid {
        transition: none !important;
        animation: none !important;
    }
}

/* ── Small fix: when input was inside a flex container with width: auto */
.bvi-dp-display + input[type="date"] {
    display: none !important;
}

/* ── Z-index sanity: must beat modals, navbars, etc ───── */
.bvi-dp-popup {
    z-index: 2147483000;
}
