/* Запись к врачу на карточке: блок услуг и окно выбора времени.
   Разметка — doctor-booking.php, логика — booking.js.
   Свои классы с префиксом bk-, без Tailwind (пересборка dist/output.css не нужна).
   Mobile-first: базовые правила — для телефона, десктоп добавляется media-query.
   Радиусы по правилу сайта: блоки и окно 10px, кнопки и поля 8px. */

.bk-block,
.bk-dialog {
    --bk-red: #d63c3c;
    --bk-red-dark: #bd3030;
    --bk-red-soft: #fdeded;
    --bk-ink: #1d1d1f;
    --bk-muted: #6b6b70;
    --bk-line: #e6e3df;
    --bk-surface: #f6f5f3;
    --bk-focus: 0 0 0 3px rgba(214, 60, 60, 0.28);
    color: var(--bk-ink);
    font-family: inherit;
}

.bk-block [hidden],
.bk-dialog [hidden] {
    display: none !important;
}

/* ---------- блок услуг ---------- */

.bk-block {
    margin: 32px 0 8px;
}

.bk-block[hidden] {
    display: none;
}

.bk-heading {
    margin: 0 0 8px;
}

.bk-lead {
    margin: 0 0 16px;
    color: var(--bk-muted);
    font-size: 16px;
}

/* Поиск по услугам: вид как на /stoimost/ (лупа, при вводе — крестик). */
.bk-search {
    position: relative;
    margin-bottom: 16px;
}

.bk-search-input {
    box-sizing: border-box;
    width: 100%;
    height: 44px;
    padding: 0 46px 0 16px;
    border: 1px solid #dbdbdb;
    border-radius: 10px;
    background: #fff;
    color: var(--bk-ink);
    font: inherit;
    font-size: 16px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bk-search-input::placeholder {
    color: #a3a3a8;
}

.bk-search-input:focus {
    border-color: var(--bk-red);
    box-shadow: var(--bk-focus);
}

.bk-search-icon {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    color: #b5b5b5;
    pointer-events: none;
}

.bk-search-clear {
    position: absolute;
    top: 50%;
    right: 4px;
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #b5b5b5;
    cursor: pointer;
    transform: translateY(-50%);
}

.bk-search-clear:hover {
    color: #8c8c8c;
}

.bk-search-clear:focus-visible {
    outline: none;
    box-shadow: var(--bk-focus);
}

.bk-search.has-value .bk-search-icon {
    display: none;
}

.bk-search.has-value .bk-search-clear {
    display: flex;
}

.bk-status {
    margin: 0 0 12px;
    color: var(--bk-muted);
    font-size: 15px;
}

.bk-services {
    margin: 0;
    padding: 0;
    list-style: none;
    border-top: 1px solid var(--bk-line);
}

.bk-service {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
        "info info"
        "price action";
    align-items: center;
    gap: 12px 16px;
    padding: 18px 0;
    border-bottom: 1px solid var(--bk-line);
}

/* Пока идёт поиск, показываем все найденные услуги, а не первые пять. */
.bk-collapsed:not(.bk-searching) .bk-service--extra {
    display: none;
}

.bk-services:empty {
    border-top: 0;
}

.bk-service-info {
    grid-area: info;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.bk-service-name {
    font-size: 18px;
    font-weight: 500;
    line-height: 1.35;
}

.bk-service-hint {
    color: var(--bk-muted);
    font-size: 14px;
}

.bk-service-price {
    grid-area: price;
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
}

.bk-btn,
.bk-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 22px;
    border: 0;
    border-radius: 8px;
    background: var(--bk-red);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.1s ease;
}

.bk-btn {
    grid-area: action;
}

.bk-btn:hover,
.bk-submit:hover {
    background: var(--bk-red-dark);
}

.bk-btn:active,
.bk-submit:active {
    transform: translateY(1px);
}

.bk-btn:focus-visible,
.bk-submit:focus-visible,
.bk-more:focus-visible,
.bk-close:focus-visible,
.bk-month:focus-visible,
.bk-day:focus-visible,
.bk-time:focus-visible {
    outline: none;
    box-shadow: var(--bk-focus);
}

.bk-more {
    margin-top: 16px;
    min-height: 44px;
    padding: 0 20px;
    border: 1px solid var(--bk-line);
    border-radius: 8px;
    background: #fff;
    color: var(--bk-ink);
    font: inherit;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.bk-more:hover {
    background: var(--bk-surface);
}

/* ---------- окно записи ---------- */

html.bk-lock {
    overflow: hidden;
}

.bk-dialog {
    width: 100%;
    max-width: none;
    max-height: 94dvh;
    margin: auto 0 0;
    padding: 0;
    border: 0;
    border-radius: 10px 10px 0 0;
    background: #fff;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.bk-dialog[open] {
    display: flex;
    animation: bk-sheet 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.bk-dialog::backdrop {
    background: rgba(20, 20, 22, 0.55);
    backdrop-filter: blur(3px);
}

.bk-dialog[open]::backdrop {
    animation: bk-fade 0.2s ease;
}

.bk-dialog-inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
}

.bk-dialog-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 16px 12px;
}

.bk-dialog-titles {
    min-width: 0;
}

.bk-dialog-title {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
    outline: none;
}

.bk-dialog-service {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
}

.bk-dialog-doctor {
    margin: 2px 0 0;
    color: var(--bk-muted);
    font-size: 14px;
}

.bk-close {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: -6px -8px 0 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--bk-muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.bk-close:hover {
    background: var(--bk-surface);
    color: var(--bk-ink);
}

.bk-dialog-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 16px 16px;
}

.bk-note {
    margin: 0 0 20px;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--bk-surface);
    color: var(--bk-muted);
    font-size: 14px;
    line-height: 1.45;
}

.bk-grid {
    display: grid;
    gap: 28px;
}

/* ----- выбор дня и времени ----- */

.bk-sub {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.bk-sub--time {
    margin-top: 24px;
}

.bk-icon {
    flex: none;
    color: var(--bk-red);
}

.bk-months {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.bk-month-static {
    color: var(--bk-muted);
    font-size: 15px;
    font-weight: 500;
}

.bk-month {
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--bk-line);
    border-radius: 999px;
    background: #fff;
    color: var(--bk-ink);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.bk-month:hover {
    background: var(--bk-surface);
}

.bk-month.is-active {
    border-color: var(--bk-ink);
    background: var(--bk-ink);
    color: #fff;
}

.bk-days {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
}

.bk-times {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
}

.bk-day,
.bk-time {
    border: 1px solid var(--bk-line);
    border-radius: 8px;
    background: #fff;
    color: var(--bk-ink);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.bk-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 64px;
    padding: 6px 0;
}

.bk-day-week {
    color: var(--bk-muted);
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.bk-day-num {
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
}

.bk-time {
    min-height: 44px;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.bk-day:hover,
.bk-time:hover {
    border-color: var(--bk-red);
}

.bk-day.is-active,
.bk-time.is-active {
    border-color: var(--bk-red);
    background: var(--bk-red);
    color: #fff;
}

.bk-day.is-active .bk-day-week {
    color: rgba(255, 255, 255, 0.85);
}


.bk-empty {
    margin: 0;
    padding: 16px;
    border-radius: 8px;
    background: var(--bk-surface);
    font-size: 15px;
    line-height: 1.5;
}

/* ----- форма ----- */

.bk-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
}

.bk-field {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.bk-field label,
.bk-field legend {
    display: block;
    margin: 0 0 6px;
    padding: 0;
    color: var(--bk-muted);
    font-size: 13px;
    font-weight: 500;
}

.bk-optional {
    font-weight: 400;
    opacity: 0.8;
}

.bk-field .bk-input {
    width: 100%;
    height: 48px;
    padding: 0 14px;
    border: 1px solid var(--bk-line);
    border-radius: 8px;
    background: #fff;
    color: var(--bk-ink);
    font: inherit;
    font-size: 16px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bk-field .bk-input::placeholder,
.bk-phone .bk-phone-input::placeholder {
    color: #a3a3a8;
    text-transform: none;
}

.bk-field .bk-input:hover,
.bk-field .bk-phone:hover {
    border-color: #cfcbc6;
}

.bk-field .bk-input:focus,
.bk-field .bk-phone:focus-within {
    outline: none;
    border-color: var(--bk-red);
    box-shadow: var(--bk-focus);
}

.bk-field .bk-input[aria-invalid="true"],
.bk-field .bk-phone:has(input[aria-invalid="true"]) {
    border-color: var(--bk-red);
}

/* Телефон: «+7» отдельным блоком слева, в поле — пример номера; формат подставляет маска. */
.bk-phone {
    display: flex;
    align-items: stretch;
    height: 48px;
    border: 1px solid var(--bk-line);
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bk-phone-prefix {
    display: flex;
    align-items: center;
    padding: 0 12px 0 14px;
    border-right: 1px solid var(--bk-line);
    color: var(--bk-ink);
    font-size: 16px;
    font-weight: 500;
    user-select: none;
}

.bk-phone .bk-phone-input {
    flex: 1;
    min-width: 0;
    padding: 0 14px;
    border: 0;
    border-radius: 0 8px 8px 0;
    background: transparent;
    color: var(--bk-ink);
    font: inherit;
    font-size: 16px;
    font-variant-numeric: tabular-nums;
    outline: none;
}

.bk-row {
    display: grid;
    gap: 14px;
}

.bk-segment {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 3px;
    border: 1px solid var(--bk-line);
    border-radius: 8px;
    background: var(--bk-surface);
}

.bk-segment label {
    margin: 0;
    cursor: pointer;
}

.bk-segment input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.bk-segment span {
    display: grid;
    place-items: center;
    height: 44px;
    border-radius: 6px;
    color: var(--bk-ink);
    font-size: 15px;
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.bk-segment input:checked + span {
    background: #fff;
    color: var(--bk-red);
    box-shadow: 0 0 0 1.5px var(--bk-red) inset;
}

.bk-segment input:focus-visible + span {
    box-shadow: var(--bk-focus);
}

.bk-check {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;
    margin: 0 !important;
    color: var(--bk-muted) !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    line-height: 1.5;
    cursor: pointer;
}

.bk-check input {
    flex: none;
    width: 22px;
    height: 22px;
    margin: 1px 0 0;
    accent-color: var(--bk-red);
    cursor: pointer;
}

.bk-check a {
    color: var(--bk-ink);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.bk-error {
    margin: 6px 0 0;
    color: var(--bk-red-dark);
    font-size: 13px;
    line-height: 1.35;
}

.bk-error--form {
    margin: 0 0 10px;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--bk-red-soft);
}

.bk-actions {
    position: sticky;
    bottom: 0;
    margin: 0 -16px -16px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--bk-line);
    background: #fff;
}

.bk-summary {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 64px;
    margin: 0 0 10px;
    padding: 10px 14px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--bk-surface);
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.bk-summary-label {
    color: var(--bk-muted);
    font-size: 13px;
    font-weight: 500;
}

.bk-summary-value {
    color: var(--bk-muted);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
}

.bk-summary.is-set {
    background: var(--bk-red-soft);
}

.bk-summary.is-set .bk-summary-label {
    color: var(--bk-red-dark);
    opacity: 0.8;
}

.bk-summary.is-set .bk-summary-value {
    color: var(--bk-red-dark);
}

.bk-summary.is-error {
    border-color: var(--bk-red);
}

.bk-summary.is-error .bk-summary-value {
    color: var(--bk-red-dark);
}

.bk-submit {
    width: 100%;
    min-height: 52px;
    font-size: 17px;
    font-weight: 600;
}

.bk-submit:disabled {
    opacity: 0.6;
    cursor: progress;
}

/* ----- успех ----- */

.bk-done {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 16px 32px;
    text-align: center;
}

.bk-done-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    border-radius: 50%;
    background: #e7f5ec;
    color: #2a9a58;
}

.bk-done-title {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 700;
}

.bk-done-text {
    max-width: 420px;
    margin: 0 0 24px;
    color: var(--bk-muted);
    font-size: 16px;
    line-height: 1.5;
}

.bk-submit--inline {
    width: auto;
    min-width: 160px;
}

/* ---------- планшет и десктоп ---------- */

@media (min-width: 560px) {
    .bk-service {
        grid-template-columns: 1fr auto auto;
        grid-template-areas: "info price action";
        gap: 16px 24px;
    }

    .bk-row {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 720px) {
    .bk-dialog {
        width: min(980px, calc(100vw - 32px));
        max-height: calc(100dvh - 48px);
        margin: auto;
        border-radius: 10px;
        box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
    }

    .bk-dialog[open] {
        animation: bk-pop 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
    }

    .bk-dialog-head {
        padding: 28px 32px 16px;
    }

    .bk-dialog-title {
        font-size: 30px;
    }

    .bk-dialog-body {
        padding: 0 32px 32px;
    }

    .bk-grid {
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
        gap: 40px;
    }

    .bk-actions {
        position: static;
        margin: 6px 0 0;
        padding: 0;
        border-top: 0;
    }
}

@keyframes bk-sheet {
    from {
        transform: translateY(24px);
        opacity: 0;
    }
}

@keyframes bk-pop {
    from {
        transform: scale(0.97);
        opacity: 0;
    }
}

@keyframes bk-fade {
    from {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bk-dialog[open],
    .bk-dialog[open]::backdrop {
        animation: none;
    }

    .bk-btn,
    .bk-submit,
    .bk-day,
    .bk-time,
    .bk-month {
        transition: none;
    }
}
