/* Fit Schedule — frontend calendar */
.fs-schedule {
    --fs-green: #65bd91;
    --fs-green-dark: #009b50;
    --fs-white: #fff;
    --fs-gray: #858585;
    width: 100%;
    color: #fff;
    font-family: Verdana, Geneva, sans-serif;
    box-sizing: border-box;
}

.fs-schedule *,
.fs-schedule *::before,
.fs-schedule *::after {
    box-sizing: border-box;
    font-family: Verdana, Geneva, sans-serif !important;
}

.fs-schedule-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 12px;
}

.fs-week-navigation,
.fs-schedule-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.fs-week-navigation {
    flex: 1 1 auto;
    max-width: 390px;
}

.fs-week-arrow {
    display: inline-flex;
    flex: 0 0 40px;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0 0 4px;
    border: 1px solid var(--fs-green);
    border-radius: 50%;
    background: #fff;
    color: var(--fs-green);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, opacity .15s ease;
}

.fs-week-arrow:not(:disabled):hover {
    background: var(--fs-green);
    color: #fff;
}

.fs-week-arrow:disabled {
    cursor: not-allowed;
    opacity: .45;
}

.fs-week-range {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 40px;
    padding: 6px 14px;
    border: 1px solid var(--fs-green);
    border-radius: 24px;
    color: var(--fs-green);
    background: #fff;
    font-size: 14px;
    line-height: 1.25;
    text-align: center;
    white-space: nowrap;
}

.fs-schedule-filters {
    flex: 0 1 488px;
    justify-content: flex-end;
}

.fs-filter-control {
    position: relative;
    display: block;
    flex: 1 1 0;
    min-width: 0;
    height: 48px;
    border-radius: 28px;
    background: var(--fs-green);
    overflow: hidden;
}

.fs-filter-control select {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0 48px 0 18px;
    border: 0;
    border-radius: inherit;
    outline-offset: -3px;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-overflow: ellipsis;
}

.fs-filter-control select:focus-visible {
    outline: 2px solid #fff;
}

.fs-filter-control select option {
    color: #222;
    background: #fff;
}

.fs-filter-lines {
    position: absolute;
    top: 50%;
    right: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 24px;
    transform: translateY(-50%);
    pointer-events: none;
}

.fs-filter-lines i {
    display: block;
    width: 100%;
    height: 1px;
    background: #fff;
}

.fs-week-area {
    width: 100%;
}

.fs-week-header {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0;
    min-height: 48px;
    overflow: hidden;
    border-radius: 24px;
    background: var(--fs-gray);
}

.fs-day-heading {
    display: flex;
    min-width: 0;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1px;
    padding: 5px 3px;
    border-right: 1px solid rgba(255,255,255,.35);
    color: #fff;
    text-align: center;
    line-height: 1.15;
}

.fs-day-heading:last-child {
    border-right: 0;
}

.fs-day-name {
    font-size: 11px;
    font-weight: 700;
    text-transform: lowercase;
}

.fs-day-date {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.fs-event-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-auto-rows: minmax(144px, auto);
    gap: 10px;
    align-items: stretch;
    margin-top: 12px;
}

.fs-calendar-empty {
    min-width: 0;
    min-height: 144px;
    border-radius: 22px;
    background: var(--fs-green);
}

.fs-class-card {
    position: relative;
    z-index: 1;
    display: flex;
    min-width: 0;
    min-height: 144px;
    flex-direction: column;
    align-items: flex-start;
    padding: 14px 11px 12px;
    overflow: visible;
    border-radius: 22px;
    background: var(--fs-green);
    color: #fff;
    cursor: pointer;
    outline-offset: 2px;
    transition: background .15s ease, box-shadow .15s ease;
}

.fs-class-card:hover,
.fs-class-card:focus-visible,
.fs-class-card.is-open {
    z-index: 20;
    background: #5ab587;
    box-shadow: 0 3px 14px rgba(0,0,0,.12);
}

.fs-class-card[hidden] {
    display: none !important;
}

.fs-card-time {
    max-width: 100%;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
}

.fs-card-divider {
    width: 100%;
    height: 1px;
    margin: 9px 0 13px;
    background: rgba(255,255,255,.55);
}

.fs-card-duration {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    margin: 0 0 8px;
    padding: 5px 8px 4px;
    border-radius: 4px;
    background: var(--fs-green-dark);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.fs-card-title {
    width: 100%;
    margin: 0 0 7px;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.18;
    overflow-wrap: anywhere;
}

.fs-card-trainer {
    width: 100%;
    margin-top: auto;
    color: #fff;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

/* Базовый стиль всплывающего окна на компьютере. */
.fs-card-tooltip {
    position: absolute;
    top: 30%;
    left: 30%;
    z-index: 50;
    display: none;
    width: min(520px, calc(100vw - 32px));
    padding: 20px 17px 15px;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 10px 35px rgba(0,0,0,.2);
    color: #26332c;
    cursor: default;
    text-align: left;
    white-space: normal;
}

/* Убираем промежуток, чтобы окно не закрывалось
   при движении курсора с карточки к описанию. */
.fs-card-tooltip::before {
    content: "";
    position: absolute;
    top: -9px;
    left: 0;
    right: 0;
    height: 10px;
}

/* Не даём окнам у субботы и воскресенья уходить за правый край. */
.fs-class-card[data-day="5"] .fs-card-tooltip,
.fs-class-card[data-day="6"] .fs-card-tooltip {
    right: 0;
    left: auto;
}

.fs-card-tooltip h3 {
    margin: 0 28px 10px 0;
    color: #26332c;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.3;
}

.fs-tooltip-close {
    position: absolute;
    top: 7px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #56615b;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.fs-tooltip-close:hover {
    background: #eef3f0;
}

.fs-tooltip-description {
    color: #49554e;
    font-size: 13px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.fs-tooltip-description p {
    margin: 0 0 8px;
}

.fs-tooltip-description p:last-child {
    margin-bottom: 10px;
}

.fs-tooltip-meta {
    margin: 5px 0 0;
    color: #49554e;
    font-size: 12px;
    line-height: 1.4;
}

.fs-no-events {
    display: flex;
    min-height: 90px;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border-radius: 18px;
    background: #f2f6f4;
    color: #66736c;
    font-size: 14px;
    text-align: center;
}

.fs-schedule-live {
    margin: 0;
    color: #66736c;
    font-size: 12px;
}

.fs-schedule-live:empty {
    display: none;
}

.fs-schedule button:focus-visible,
.fs-schedule select:focus-visible {
    outline: 2px solid #147d4b;
    outline-offset: 2px;
}

.fs-schedule .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ПК: окно открывается только при наведении. */
@media (hover: hover) and (pointer: fine) {
    .fs-schedule .fs-class-card:hover .fs-card-tooltip {
        display: block;
    }

    /* После ухода курсора окно не остаётся открытым
       из-за фокуса, который браузер мог дать карточке при клике. */
    .fs-schedule .fs-class-card:focus-within:not(:hover) .fs-card-tooltip,
    .fs-schedule .fs-class-card.is-open .fs-card-tooltip {
        display: none !important;
    }

    .fs-schedule .fs-tooltip-close {
        display: none;
    }
}

/* Адаптация панели управления календарём. */
@media (max-width: 1050px) {
    .fs-schedule-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .fs-week-navigation {
        max-width: 100%;
    }

    .fs-schedule-filters {
        flex: 1 1 auto;
        justify-content: stretch;
    }
}

@media (max-width: 720px) {
    .fs-schedule {
        overflow: visible;
    }

    .fs-week-area {
        overflow-x: auto;
        padding-bottom: 5px;
    }

    .fs-week-header,
    .fs-event-grid {
        min-width: 850px;
    }

    .fs-week-range {
        padding-right: 8px;
        padding-left: 8px;
        font-size: 12px;
    }

    .fs-week-arrow {
        flex-basis: 36px;
        width: 36px;
        height: 36px;
    }

    .fs-filter-control {
        height: 44px;
    }

    .fs-filter-control select {
        padding-left: 13px;
        font-size: 12px;
    }
}

/* Мобильная версия: затемнённый фон и окно по центру экрана.
   JavaScript переносит выбранное описание в этот контейнер,
   поэтому горизонтальная прокрутка календаря ему не мешает. */
@media (max-width: 767px), (hover: none), (pointer: coarse) {
    .fs-schedule .fs-class-card:hover .fs-card-tooltip,
    .fs-schedule .fs-class-card:focus-within .fs-card-tooltip,
    .fs-schedule .fs-class-card.is-open .fs-card-tooltip {
        display: none !important;
    }

    .fs-mobile-tooltip-backdrop {
        position: fixed;
        inset: 0;
        z-index: 999999;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        padding: 20px 16px;
        background: rgba(0,0,0,.58);
        overscroll-behavior: contain;
        -webkit-tap-highlight-color: transparent;
    }

    .fs-mobile-tooltip-backdrop .fs-card-tooltip {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        display: block !important;
        flex: 0 1 480px;
        width: min(480px, 100%) !important;
        max-width: 100% !important;
        max-height: calc(100vh - 40px);
        max-height: calc(100dvh - 40px);
        margin: 0;
        padding: 24px 18px 20px;
        overflow-x: hidden;
        overflow-y: auto;
        border: 0;
        border-radius: 16px;
        background: #fff;
        box-shadow: 0 16px 55px rgba(0,0,0,.3);
        color: #26332c;
        text-align: left;
        white-space: normal;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .fs-mobile-tooltip-backdrop .fs-card-tooltip::before {
        display: none;
    }

    .fs-mobile-tooltip-backdrop .fs-tooltip-close {
        position: absolute;
        top: 8px;
        right: 8px;
        z-index: 2;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        width: 34px;
        height: 34px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: #eef3f0;
        color: #36453c;
        font-size: 27px;
        line-height: 1;
        cursor: pointer;
    }

    .fs-mobile-tooltip-backdrop .fs-tooltip-close:hover {
        background: #e0eae4;
    }

    .fs-mobile-tooltip-backdrop .fs-card-tooltip h3 {
        margin-right: 34px;
        font-size: 17px;
    }

    body.fs-schedule-modal-open {
        overflow: hidden !important;
        overscroll-behavior: none;
    }
}