/* Запись на сегодня: список свободных окон (today-schedule) и всплывающее окно
   с кнопкой-календарём (today-schedule-modal). Общие стили для обоих виджетов. */

/* ─── Общий блок списка ───────────────────────────────────────────────────── */
.ts-block { padding: 40px 0; }

/* Скрываем элементы с атрибутом hidden даже там, где задан display */
[data-ts-widget] [hidden],
[data-tsm-modal] [hidden] { display: none !important; }

.ts-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    margin-bottom: 18px;
}

.ts-switch {
    display: inline-flex;
    padding: 4px;
    border: 1px solid #e4edf4;
    border-radius: 30px;
    background: #f6fafc;
}

.ts-switch__btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px;
    border: 0;
    border-radius: 26px;
    background: transparent;
    color: #4a5568;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background .25s ease, color .25s ease, box-shadow .25s ease, transform .15s ease;
}

.ts-switch__btn.is-active {
    background: #1BA3D5;
    color: #fff;
    box-shadow: 0 4px 12px rgba(27, 163, 213, .3);
}

.ts-switch__btn:not(.is-active):hover { color: #1BA3D5; }
.ts-switch__btn:active { transform: scale(.97); }

/* Выпадающий выбор филиала */
.ts-select {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 210px;
    max-width: 100%;
}

.ts-select__icon {
    position: absolute;
    left: 14px;
    color: #1BA3D5;
    font-size: 14px;
    pointer-events: none;
}

.ts-select__chevron {
    position: absolute;
    right: 14px;
    color: #8d9aa6;
    font-size: 12px;
    pointer-events: none;
}

.ts-select select {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    padding: 10px 36px 10px 36px;
    border: 1px solid #e4edf4;
    border-radius: 30px;
    background: #fff;
    color: #22303e;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.ts-select select:hover { border-color: #1BA3D5; }
.ts-select select:focus { outline: none; border-color: #1BA3D5; box-shadow: 0 0 0 3px rgba(27, 163, 213, .15); }

.ts-result { position: relative; transition: opacity .2s ease; }
.ts-result.is-loading .ts-list { opacity: .45; }

/* Индикатор загрузки (спиннер) */
.ts-loading {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 40px;
    pointer-events: none;
}

.ts-spinner {
    width: 34px;
    height: 34px;
    border: 3px solid rgba(27, 163, 213, .25);
    border-top-color: #1BA3D5;
    border-radius: 50%;
    animation: tsSpin .7s linear infinite;
}

@keyframes tsSpin { to { transform: rotate(360deg); } }

/* Список специальностей: компактные строки-аккордеон */
.ts-list { border-top: 1px solid #eef2f5; }
.ts-prof { border-bottom: 1px solid #eef2f5; }

.ts-prof__head {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 4px;
    border: 0;
    background: none;
    text-align: left;
    cursor: pointer;
    transition: color .2s ease;
}

.ts-prof__head:hover .ts-prof__name { color: #1BA3D5; }
.ts-prof__icon { color: #1BA3D5; font-size: 16px; }

.ts-prof__name {
    font-size: 16px;
    font-weight: 600;
    color: #1C3343;
    transition: color .2s ease;
}

.ts-prof__count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    color: #14809f;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.ts-prof__count i { font-size: 13px; }

.ts-prof__arrow { color: #8d9aa6; font-size: 13px; transition: transform .28s ease; }
.ts-prof.is-open .ts-prof__arrow { transform: rotate(180deg); }

.ts-prof__body { display: none; overflow: hidden; }
.ts-prof.is-open .ts-prof__body { display: block; }

/* Врачи: по одному в ряд */
.ts-docs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 4px 4px 18px;
}

.ts-doc {
    padding: 14px 16px;
    border: 1px solid #eef3f7;
    border-radius: 12px;
    background: #f8fbfd;
    transition: background .2s ease, border-color .2s ease, transform .2s ease;
}

.ts-doc:hover { background: #eef7fc; border-color: #d9e9f3; transform: translateY(-1px); }

.ts-doc__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.ts-doc__name { font-weight: 600; color: #1C3343; text-decoration: none; }
.ts-doc__name:hover { color: #1BA3D5; }
.ts-doc__branch { color: #8d9aa6; font-size: 13px; }
.ts-doc__branch i { margin-right: 3px; }
.ts-doc__times { display: flex; flex-wrap: wrap; gap: 8px; }

.ts-time {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    border-radius: 8px;
    background: #eaf6fb;
    color: #14809f;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background .2s ease, color .2s ease, transform .12s ease, box-shadow .2s ease;
}

.ts-time:hover {
    background: #1BA3D5;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(27, 163, 213, .28);
}

.ts-time:active { transform: scale(.96); }
.ts-time i { font-size: 12px; }

/* Ссылка на страницу врача — после расписания */
.ts-doc__page {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #dbe7ef;
    color: #1BA3D5;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    transition: color .2s ease, gap .2s ease;
}

.ts-doc__page:hover { color: #14809f; gap: 10px; }
.ts-doc__page i { transition: transform .2s ease; }
.ts-doc__page:hover i { transform: translateX(2px); }

.ts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 20px;
    border-radius: 14px;
    background: #f6fafc;
    text-align: center;
}

.ts-empty > i { color: #14809f; font-size: 26px; }
.ts-empty p { margin: 0; color: #4a5568; }

/* Сводка выбранной записи внутри формы #callback (врач · дата · время) */
.ts-form-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #dbe7ef;
    border-radius: 12px;
    background: #f4fafd;
    color: #22303e;
    font-size: 14px;
    font-weight: 600;
}

.ts-form-summary[hidden] { display: none !important; }
.ts-form-summary span { display: inline-flex; align-items: center; gap: 6px; }
.ts-form-summary i { color: #1BA3D5; }

.ts-switch__btn:focus-visible,
.ts-select select:focus-visible,
.ts-prof__head:focus-visible,
.ts-time:focus-visible,
.ts-doc__page:focus-visible {
    outline: 2px solid #1BA3D5;
    outline-offset: 2px;
}

@media (max-width: 575px) {
    .ts-prof__count { white-space: normal; text-align: right; }
    .ts-select { min-width: 160px; flex: 1 1 100%; }
}

/* ─── Кнопка-календарь внизу слева + всплывающее окно ─────────────────────── */
.tsm-fab {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 100200;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 20px 13px 15px;
    border: 0;
    border-radius: 40px;
    background: #1BA3D5;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(27, 163, 213, .45);
    transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}

.tsm-fab:hover {
    background: #1589b4;
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(27, 163, 213, .55);
}

.tsm-fab:active { transform: scale(.97); }

.tsm-fab__icon {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    font-size: 18px;
}

/* Пульсирующее кольцо — привлекает внимание, как у flash-news */
.tsm-fab__ring {
    position: absolute;
    left: 15px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .5);
    animation: tsmPulse 2.4s ease-out infinite;
}

@keyframes tsmPulse {
    0% { transform: scale(1); opacity: .6; }
    70% { transform: scale(2.1); opacity: 0; }
    100% { transform: scale(2.1); opacity: 0; }
}

/* Не перекрываем кнопку-иконку flash-news (тоже внизу слева) */
body:has(#flash-news-fab.is-visible) .tsm-fab { bottom: 84px; }

.tsm-modal {
    position: fixed;
    inset: 0;
    z-index: 100400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.tsm-modal.is-open { display: flex; }

.tsm-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 30, 44, .72);
    animation: tsmFade .2s ease;
}

.tsm-modal__dialog {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    width: min(720px, 100%);
    max-height: min(88vh, 860px);
    background: #fff;
    border: 1px solid #dbe7ef;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 26px 70px rgba(0, 0, 0, .28);
    animation: tsmUp .25s ease;
}

@keyframes tsmFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes tsmUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* Hero окна: фон-изображение + затемнение + заголовок поверх (как hero-блок) */
.tsm-modal__hero {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    min-height: 190px;
    padding: 22px 26px;
    background: linear-gradient(135deg, #1BA3D5 0%, #14809f 100%);
    background-size: cover;
    background-position: 50% 50%;
    overflow: hidden;
}

.tsm-modal__hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(12, 30, 44, .15) 0%, rgba(12, 30, 44, .72) 100%);
    pointer-events: none;
}

.tsm-modal__hero-content { position: relative; z-index: 2; }

.tsm-modal__title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 6px rgba(0, 0, 0, .35);
}

.tsm-modal__subtitle { margin-top: 4px; color: rgba(255, 255, 255, .85); font-size: 13.5px; }

.tsm-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 3;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    color: #1C3343;
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, transform .15s ease;
}

.tsm-modal__close:hover { background: #fff; color: #1BA3D5; }
.tsm-modal__close:active { transform: scale(.94); }

/* Навигация по дням: ‹ дата › (ранее сегодня выбрать нельзя) */
.tsm-datenav {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 26px;
    border-bottom: 1px solid #eef2f5;
}

.tsm-nav {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid #e4edf4;
    border-radius: 50%;
    background: #fff;
    color: #1C3343;
    font-size: 15px;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease;
}

.tsm-nav:hover:not(:disabled) { border-color: #1BA3D5; color: #1BA3D5; transform: translateY(-1px); }
.tsm-nav:active:not(:disabled) { transform: scale(.95); }
.tsm-nav:disabled { opacity: .35; cursor: default; }

.tsm-date {
    flex: 1 1 auto;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #1C3343;
}

/* Расписание — flex-колонка: шапка/кнопки/календарь фиксированы, прокручивается список */
[data-ts-schedule] {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.tsm-datenav { flex: 0 0 auto; }

.tsm-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 26px 26px;
}

.tsm-body .ts-list { border-top: 0; }
.tsm-body .ts-empty { margin-top: 6px; }

/* Приглушение текущего расписания во время загрузки */
[data-tsm-result].is-loading .ts-list,
[data-tsm-result].is-loading .ts-empty { opacity: .45; transition: opacity .2s ease; }

.tsm-loading {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 70px;
    pointer-events: none;
}

@media (max-width: 575px) {
    .tsm-fab__label { display: none; }
    .tsm-fab { padding: 14px; border-radius: 50%; }
    .tsm-modal { padding: 12px; }
    .tsm-modal__dialog { max-height: 92vh; max-height: 92dvh; border-radius: 16px; }
    .tsm-modal__hero { min-height: 150px; padding: 18px; }
    .tsm-modal__title { font-size: 19px; }
    .tsm-datenav { padding: 14px 18px; }
    .tsm-date { font-size: 15px; }
    .tsm-body { padding: 14px 18px 22px; }
}

/* ─── Форма записи (общая для инлайн-виджета и модалки) ───────────────────── */
.ts-form { display: flex; flex-direction: column; gap: 16px; }

.ts-form__summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    padding: 12px 16px;
    border: 1px solid #dbe7ef;
    border-radius: 12px;
    background: #f4fafd;
    color: #22303e;
    font-size: 14px;
    font-weight: 600;
}

.ts-form__summary:empty { display: none; }
.ts-form__summary span { display: inline-flex; align-items: center; gap: 7px; }
.ts-form__summary i { color: #1BA3D5; }

.ts-form__form { display: flex; flex-direction: column; gap: 14px; margin: 0; }
.ts-form__field { display: flex; flex-direction: column; gap: 6px; }
.ts-form__label { font-size: 13px; font-weight: 600; color: #4a5568; }

.ts-form__input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #e4edf4;
    border-radius: 12px;
    background: #fff;
    color: #1C3343;
    font-size: 15px;
    line-height: 1.2;
    transition: border-color .2s ease, box-shadow .2s ease;
}

.ts-form__input:focus { outline: none; border-color: #1BA3D5; box-shadow: 0 0 0 3px rgba(27, 163, 213, .15); }

.ts-form__actions { display: flex; flex-wrap: wrap; gap: 10px; }

.ts-form__submit {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 22px;
    border: 0;
    border-radius: 12px;
    background: #1BA3D5;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s ease, box-shadow .2s ease, transform .15s ease;
}

.ts-form__submit:hover { background: #1589b4; box-shadow: 0 8px 20px rgba(27, 163, 213, .32); }
.ts-form__submit:active { transform: scale(.98); }
.ts-form__submit:disabled { opacity: .7; cursor: default; }

.ts-form__back {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 18px;
    border: 1px solid #e4edf4;
    border-radius: 12px;
    background: #fff;
    color: #22303e;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease, transform .15s ease;
}

.ts-form__back:hover { border-color: #1BA3D5; color: #1BA3D5; transform: translateY(-1px); }
.ts-form__back:active { transform: scale(.97); }

.ts-form__note { margin: 0; color: #8d9aa6; font-size: 12px; line-height: 1.5; }

.ts-form__status { padding: 12px 15px; border-radius: 12px; font-size: 14px; font-weight: 600; }
.ts-form__status.is-ok { background: #e9f7ee; color: #1f7a44; }
.ts-form__status.is-error { background: #fdecec; color: #c0392b; }

/* Инлайн-виджет: форма записи в своей лёгкой модалке */
.ts-form-modal {
    position: fixed;
    inset: 0;
    z-index: 100400;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.ts-form-modal.is-open { display: flex; }

.ts-form-modal__backdrop { position: absolute; inset: 0; background: rgba(12, 30, 44, .72); animation: tsmFade .2s ease; }

.ts-form-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(460px, 100%);
    max-height: 92vh;
    overflow-y: auto;
    padding: 26px;
    border: 1px solid #dbe7ef;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 26px 70px rgba(0, 0, 0, .28);
    animation: tsmUp .25s ease;
}

.ts-form-modal__title { margin: 0 0 18px; font-size: 19px; font-weight: 700; color: #1C3343; }

.ts-form-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: #f2f6f9;
    color: #4a5568;
    font-size: 21px;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, transform .15s ease;
}

.ts-form-modal__close:hover { background: #e2ecf3; color: #1C3343; }
.ts-form-modal__close:active { transform: scale(.94); }

/* Форма внутри окна записи (замещает расписание) */
.ts-form-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 26px 26px;
}
.ts-form-wrap__inner { max-width: 460px; margin: 0 auto; }

@media (max-width: 575px) {
    .ts-form-modal { padding: 12px; }
    .ts-form-modal__dialog { padding: 22px 18px; border-radius: 16px; }
    .ts-form-wrap { padding: 16px 18px 22px; }
    .ts-form__submit, .ts-form__back { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .tsm-fab,
    .tsm-fab__ring,
    .tsm-modal__backdrop,
    .tsm-modal__dialog,
    .tsm-nav,
    .ts-switch__btn,
    .ts-prof__head,
    .ts-prof__arrow,
    .ts-prof__body,
    .ts-doc,
    .ts-time,
    .ts-doc__page,
    .ts-form__input,
    .ts-form__submit,
    .ts-form__back,
    .ts-form-modal__backdrop,
    .ts-form-modal__dialog,
    .ts-spinner {
        transition: none !important;
        animation: none !important;
    }
}
