/* =============================================
   TM DATEPICKER
   ============================================= */

.tm-dp {
    --tm-dp-accent: var(--mainColor, #FFC100);
    --tm-dp-on-accent: var(--mainTextColor, #000);
    --tm-dp-ink: #16161A;
    --tm-dp-muted: #8A8A93;
    --tm-dp-line: #EDECE8;
    --tm-dp-surface: #FFFFFF;
    --tm-dp-hover: #F4F3F0;
    --tm-dp-range: rgba(0, 0, 0, 0.05);
    --tm-dp-range-soft: rgba(0, 0, 0, 0.03);
    --tm-dp-glow: rgba(0, 0, 0, 0.18);

    position: fixed;
    inset: 0;
    z-index: 100050;
    pointer-events: none;
    display: none;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@supports (background: color-mix(in srgb, red 50%, white)) {
    .tm-dp {
        --tm-dp-range: color-mix(in srgb, var(--tm-dp-accent) 26%, #fff);
        --tm-dp-range-soft: color-mix(in srgb, var(--tm-dp-accent) 13%, #fff);
        --tm-dp-glow: color-mix(in srgb, var(--tm-dp-accent) 42%, transparent);
    }
}

.tm-dp.is-open {
    display: block;
}

/* ---------- scrim (bottom sheet only) ---------- */
.tm-dp__scrim {
    position: absolute;
    inset: 0;
    background: rgba(12, 12, 14, 0.45);
    opacity: 0;
    transition: opacity 0.28s ease;
    display: none;
}

/* ---------- panel ---------- */
.tm-dp__panel {
    position: absolute;
    top: var(--tm-dp-top, 0px);
    left: var(--tm-dp-left, 0px);
    width: 360px;
    max-width: calc(100vw - 24px);
    background: var(--tm-dp-surface);
    border: 1px solid var(--tm-dp-line);
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(16, 16, 20, 0.16), 0 6px 18px rgba(16, 16, 20, 0.08);
    padding: 18px 18px 16px;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
    transform-origin: top center;
    transition: opacity 0.22s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.26s cubic-bezier(0.34, 1.3, 0.64, 1);
    will-change: transform, opacity;
}

.tm-dp.is-visible .tm-dp__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.tm-dp.is-flipped .tm-dp__panel {
    transform-origin: bottom center;
    transform: translateY(10px) scale(0.97);
}

.tm-dp.is-flipped.is-visible .tm-dp__panel {
    transform: translateY(0) scale(1);
}

/* ---------- grabber (bottom sheet only) ---------- */
.tm-dp__grabber {
    display: none;
    width: 100%;
    padding: 2px 0 10px;
    cursor: grab;
    touch-action: none;
}

.tm-dp__grabber::after {
    content: '';
    display: block;
    width: 44px;
    height: 5px;
    margin: 0 auto;
    border-radius: 99px;
    background: #D8D6D1;
}

/* ---------- header ---------- */
.tm-dp__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.tm-dp__head > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.tm-dp__eyebrow {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--tm-dp-muted);
    margin-bottom: 3px;
}

.tm-dp__title {
    margin: 0;
    font-size: 19px;
    line-height: 1.25;
    font-weight: 700;
    color: var(--tm-dp-ink);
    letter-spacing: -0.01em;
}

.tm-dp__reset {
    flex-shrink: 0;
    border: 0;
    background: transparent;
    padding: 4px 2px;
    margin-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--tm-dp-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.tm-dp__reset:hover {
    color: var(--tm-dp-ink);
}

.tm-dp__reset[disabled] {
    opacity: 0.35;
    cursor: default;
}

.tm-dp__close {
    display: none;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: var(--tm-dp-hover);
    color: #5B5B63;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease;
}

.tm-dp__close:hover {
    background: #E6E4DF;
}

/* ---------- presets ---------- */
.tm-dp__presets {
    display: flex;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
    margin: 0 -18px 16px;
    padding: 2px 18px 4px;
}

.tm-dp__presets::-webkit-scrollbar {
    display: none;
}

.tm-dp__presets.is-dragging {
    cursor: grabbing;
    user-select: none;
}

.tm-dp__presets.is-dragging .tm-dp__preset {
    transform: none;
    cursor: grabbing;
}

.tm-dp__preset {
    flex: 0 0 auto;
    border: 1.5px solid var(--tm-dp-line);
    background: #FFF;
    color: #3A3A40;
    border-radius: 100px;
    padding: 7px 14px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.18s ease, background 0.18s ease,
                color 0.18s ease, transform 0.18s ease;
}

.tm-dp__preset:hover {
    border-color: #C9C6BF;
    transform: translateY(-1px);
}

.tm-dp__preset.is-active {
    background: var(--tm-dp-accent);
    border-color: var(--tm-dp-accent);
    color: var(--tm-dp-on-accent);
    box-shadow: 0 4px 12px var(--tm-dp-glow);
}

/* ---------- month navigation ---------- */
.tm-dp__nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 8px;
}

.tm-dp__navbtn {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--tm-dp-ink);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.tm-dp__navbtn:hover:not([disabled]) {
    background: var(--tm-dp-hover);
}

.tm-dp__navbtn:active:not([disabled]) {
    transform: scale(0.9);
}

.tm-dp__navbtn[disabled] {
    opacity: 0.25;
    cursor: default;
}

.tm-dp__monthbtn {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    font-size: 15px;
    font-weight: 700;
    color: var(--tm-dp-ink);
    cursor: pointer;
    padding: 7px 10px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.18s ease;
}

.tm-dp__monthbtn:hover {
    background: var(--tm-dp-hover);
}

.tm-dp__monthbtn svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.tm-dp.is-picking-month .tm-dp__monthbtn svg {
    transform: rotate(180deg);
}

/* ---------- calendar body ---------- */
.tm-dp__body {
    position: relative;
}

.tm-dp__dow {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 2px;
}

.tm-dp__dow span {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--tm-dp-muted);
    padding: 6px 0;
}

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

.tm-dp__grid.is-sliding-next {
    animation: tmDpSlideNext 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

.tm-dp__grid.is-sliding-prev {
    animation: tmDpSlidePrev 0.26s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes tmDpSlideNext {
    from { opacity: 0; transform: translateX(14px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes tmDpSlidePrev {
    from { opacity: 0; transform: translateX(-14px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ---------- day cell ---------- */
.tm-dp__day {
    position: relative;
    height: 42px;
    border: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--tm-dp-ink);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.tm-dp__day::before {
    content: '';
    position: absolute;
    top: 1px;
    bottom: 1px;
    inset-inline: -1px;
    background: transparent;
    transition: background 0.18s ease;
}

.tm-dp__day > span {
    position: relative;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease,
                box-shadow 0.2s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tm-dp__day:hover:not(.is-disabled) > span {
    background: var(--tm-dp-hover);
}

.tm-dp__day.is-outside {
    color: #C4C2BD;
}

.tm-dp__day.is-disabled {
    color: #D2D0CB;
    cursor: default;
    pointer-events: none;
}

.tm-dp__day.is-today > span::after {
    content: '';
    position: absolute;
    bottom: 6px;
    left: 50%;
    width: 4px;
    height: 4px;
    margin-left: -2px;
    border-radius: 50%;
    background: var(--tm-dp-accent);
}

.tm-dp__day.is-in-range::before {
    background: var(--tm-dp-range);
}

.tm-dp__day.is-preview::before {
    background: var(--tm-dp-range-soft);
}

.tm-dp__day.is-preview-edge > span {
    box-shadow: inset 0 0 0 2px var(--tm-dp-accent);
}

.tm-dp__day.is-start::before,
.tm-dp__day.is-end::before {
    background: var(--tm-dp-range);
}

.tm-dp__day.is-start::before {
    inset-inline-start: 2px;
    border-start-start-radius: 99px;
    border-end-start-radius: 99px;
}

.tm-dp__day.is-end::before {
    inset-inline-end: 2px;
    border-start-end-radius: 99px;
    border-end-end-radius: 99px;
}

.tm-dp__day.is-start.is-end::before {
    background: transparent;
}

.tm-dp__day.is-start > span,
.tm-dp__day.is-end > span {
    background: var(--tm-dp-accent);
    color: var(--tm-dp-on-accent);
    font-weight: 700;
    box-shadow: 0 6px 16px var(--tm-dp-glow);
    animation: tmDpPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tm-dp__day.is-start.is-today > span::after,
.tm-dp__day.is-end.is-today > span::after {
    background: var(--tm-dp-on-accent);
    opacity: 0.6;
}

@keyframes tmDpPop {
    0%   { transform: scale(0.6); }
    60%  { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.tm-dp__day:focus-visible {
    outline: none;
}

.tm-dp__day:focus-visible > span {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--tm-dp-ink);
}

/* ---------- month / year overlay ---------- */
.tm-dp__months {
    position: absolute;
    inset: 0;
    background: var(--tm-dp-surface);
    display: none;
    flex-direction: column;
    gap: 10px;
    padding-top: 2px;
    z-index: 3;
}

.tm-dp.is-picking-month .tm-dp__months {
    display: flex;
    animation: tmDpFadeUp 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes tmDpFadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.tm-dp__years {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tm-dp__year {
    font-size: 15px;
    font-weight: 700;
    color: var(--tm-dp-ink);
}

.tm-dp__monthgrid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.tm-dp__monthcell {
    border: 0;
    background: var(--tm-dp-hover);
    border-radius: 12px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--tm-dp-ink);
    cursor: pointer;
    padding: 10px 4px;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.tm-dp__monthcell:hover:not([disabled]) {
    transform: translateY(-1px);
    background: #EAE8E3;
}

.tm-dp__monthcell.is-active {
    background: var(--tm-dp-accent);
    color: var(--tm-dp-on-accent);
    box-shadow: 0 4px 12px var(--tm-dp-glow);
}

.tm-dp__monthcell[disabled] {
    opacity: 0.35;
    cursor: default;
}

/* ---------- footer ---------- */
.tm-dp__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--tm-dp-line);
}

.tm-dp__hint {
    font-size: 12px;
    line-height: 1.35;
    color: var(--tm-dp-muted);
    min-width: 0;
}

.tm-dp__apply {
    flex-shrink: 0;
    border: 0;
    border-radius: 100px;
    background: var(--tm-dp-accent);
    color: var(--tm-dp-on-accent);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    padding: 11px 26px;
    cursor: pointer;
    box-shadow: 0 6px 16px var(--tm-dp-glow);
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.tm-dp__apply:hover:not([disabled]) {
    transform: translateY(-1px);
    box-shadow: 0 10px 22px var(--tm-dp-glow);
}

.tm-dp__apply:active:not([disabled]) {
    transform: translateY(0) scale(0.98);
}

.tm-dp__apply[disabled] {
    opacity: 0.45;
    box-shadow: none;
    cursor: default;
}

@media (min-width: 992px) and (max-height: 780px) {
    .tm-dp__panel {
        max-height: calc(100vh - 24px);
        overflow-y: auto;
        overflow-x: hidden;
    }
}

/* =============================================
   BOTTOM SHEET (below Bootstrap lg = 992px)
   ============================================= */
@media (max-width: 991.98px) {
    .tm-dp__scrim {
        display: block;
        pointer-events: auto;
    }

    .tm-dp.is-visible .tm-dp__scrim {
        opacity: 1;
    }

    .tm-dp__panel {
        top: auto;
        inset-inline: 0;
        bottom: 0;
        width: auto;
        max-width: none;
        border-radius: 28px 28px 0 0;
        border-bottom: 0;
        padding: 10px 20px calc(18px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 -18px 50px rgba(16, 16, 20, 0.22);
        transform: translateY(100%);
        transform-origin: bottom center;
        transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1),
                    opacity 0.2s ease;
        opacity: 1;
        max-height: 92vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tm-dp.is-visible .tm-dp__panel,
    .tm-dp.is-flipped.is-visible .tm-dp__panel {
        transform: translateY(0);
    }

    .tm-dp.is-flipped .tm-dp__panel {
        transform: translateY(100%);
    }

    .tm-dp.is-dragging .tm-dp__panel {
        transition: none;
    }

    .tm-dp__grabber {
        display: block;
    }

    .tm-dp__close {
        display: flex;
    }

    .tm-dp__reset {
        display: none;
    }

    .tm-dp__presets {
        margin-inline: -20px;
        padding-inline: 20px;
    }

    .tm-dp__title {
        font-size: 20px;
    }

    .tm-dp__day {
        height: 46px;
    }

    .tm-dp__day > span {
        width: 40px;
        height: 40px;
    }

    .tm-dp__foot {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        position: sticky;
        bottom: 0;
        background: var(--tm-dp-surface);
    }

    .tm-dp__hint {
        text-align: center;
        order: 2;
    }

    .tm-dp__apply {
        order: 1;
        width: 100%;
        padding: 15px 20px;
        font-size: 15px;
    }
}

/* =============================================
   RTL — the body carries .toRtl, which also mirrors
   ============================================= */
[dir="rtl"] .tm-dp,
.toRtl .tm-dp {
    direction: rtl;
}

/* =============================================
   REDUCED MOTION
   ============================================= */
@media (prefers-reduced-motion: reduce) {
    .tm-dp__panel,
    .tm-dp__grid,
    .tm-dp__day > span,
    .tm-dp__apply,
    .tm-dp__preset {
        transition-duration: 0.01ms !important;
        animation: none !important;
    }
}
