/*
 * Pagina publica de marcacao (/agendar/{slug}).
 *
 * Escrita para esta pagina e so para esta pagina. Substitui o dashboard.css,
 * que sao 365 KB de tema de backoffice para um cartao com campos, um
 * calendario e um spinner.
 *
 * A cor vem da clinica (Booking.color) por variavel, definida no <head>.
 * O contraste do texto por cima dela e calculado em PHP, nao adivinhado.
 */

:root {
    --cor: #4188c9;
    --cor-texto: #fff;
    --cor-clara: #eef4fb;

    --tinta: #24292f;
    --tinta-fraca: #656d76;
    --linha: #d8dee4;
    --fundo: #f6f8fa;
    --branco: #fff;
    --erro: #cf222e;
    --ok: #1a7f37;

    --raio: 12px;
    --raio-g: 16px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--fundo);
    color: var(--tinta);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; height: auto; }

/* ---------------------------------------------------------------- pagina */

.bk-page {
    max-width: 880px;
    margin: 0 auto;
    padding: 16px;
}

.bk-card {
    background: var(--branco);
    border: 1px solid var(--linha);
    border-radius: var(--raio-g);
    padding: 20px;
}

@media (min-width: 768px) {
    .bk-page { padding: 32px 16px; }
    .bk-card { padding: 32px; }
}

/* ------------------------------------------------------------- cabecalho */

.bk-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    margin-bottom: 24px;
}

.bk-head img {
    width: 250px;
    /* o 100% e a rede: num ecra estreito o logo encolhe em vez de rebentar
       a pagina com scroll horizontal */
    max-width: 100%;
    height: auto;
}

.bk-head h1 {
    font-size: 20px;
    line-height: 1.25;
    margin: 0;
    font-weight: 600;
}

/* --------------------------------------------------------------- stepper */

.bk-steps {
    display: flex;
    list-style: none;
    margin: 0 0 24px;
    padding: 0;
    counter-reset: passo;
}

.bk-steps li {
    flex: 1;
    text-align: center;
    position: relative;
    font-size: 13px;
    color: var(--tinta-fraca);
}

/* o botao cobre a bola e o rotulo, para o numero tambem ser clicavel */
.bk-step-btn {
    display: block;
    width: 100%;
    padding: 34px 2px 0;
    background: none;
    border: 0;
    font: inherit;
    font-size: 13px;
    color: inherit;
    cursor: pointer;
}

.bk-step-btn:disabled { cursor: default; }
.bk-step-btn:focus-visible { outline: 2px solid var(--cor); outline-offset: 2px; border-radius: var(--raio); }

/*
 * A bola e o traco sao pseudo-elementos do <li>, logo ficam por cima do botao
 * e apanhavam o clique em vez dele. Sem pointer-events o clique atravessa e
 * chega ao botao, que e quem sabe se o passo esta acessivel -- incluindo
 * engoli-lo quando esta disabled.
 */
.bk-steps li::before,
.bk-steps li::after { pointer-events: none; }

.bk-steps li::before {                      /* a bola */
    counter-increment: passo;
    content: counter(passo);
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 26px;
    height: 26px;
    line-height: 24px;
    border-radius: 50%;
    border: 2px solid var(--linha);
    background: var(--branco);
    color: var(--tinta-fraca);
    font-weight: 600;
    font-size: 13px;
    z-index: 1;
}

.bk-steps li::after {                       /* o traco entre bolas */
    content: "";
    position: absolute;
    top: 13px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--linha);
    /* nao pode ser z-index negativo: o <li> nao cria contexto de empilhamento,
       por isso o traco caia para tras do fundo branco do .bk-card e nunca se
       via. A 0 fica na camada dos posicionados, acima do cartao e abaixo da
       bola, que leva 1. */
    z-index: 0;
}

.bk-steps li:first-child::after { display: none; }

.bk-steps li[aria-current="step"] { color: var(--tinta); font-weight: 600; }

.bk-steps li[aria-current="step"]::before,
.bk-steps li.bk-feito::before {
    border-color: var(--cor);
    background: var(--cor);
    color: var(--cor-texto);
}

.bk-steps li.bk-feito::before { content: "\2713"; }

/* --------------------------------------------------------------- passos */

.bk-passo > h2 {
    font-size: 17px;
    margin: 0 0 16px;
    font-weight: 600;
}

.bk-passo:focus { outline: none; }

.bk-cols { display: flex; flex-direction: column; gap: 20px; }

@media (min-width: 768px) {
    .bk-cols { flex-direction: row; }
    .bk-cols > * { flex: 1; min-width: 0; }
}

/* --------------------------------------------------------------- campos */

.bk-campo { margin-bottom: 16px; }

.bk-campo label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
}

.bk-campo input[type="text"],
.bk-campo input[type="email"],
.bk-campo input[type="tel"],
.bk-campo select,
.bk-campo textarea {
    width: 100%;
    min-height: 44px;                        /* alvo de toque */
    padding: 10px 12px;
    font: inherit;
    color: inherit;
    background: var(--branco);
    border: 1px solid var(--linha);
    border-radius: var(--raio);
}

.bk-campo textarea { min-height: 80px; resize: vertical; }

.bk-campo select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23656d76' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.bk-campo input:focus-visible,
.bk-campo select:focus-visible,
.bk-campo textarea:focus-visible,
.bk-btn:focus-visible,
.bk-slot:focus-visible {
    outline: 2px solid var(--cor);
    outline-offset: 2px;
}

.bk-campo.bk-mal input,
.bk-campo.bk-mal select,
.bk-campo.bk-mal textarea { border-color: var(--erro); }

.bk-erro {
    display: none;
    color: var(--erro);
    font-size: 13px;
    margin-top: 6px;
}

.bk-campo.bk-mal .bk-erro { display: block; }

.bk-radios { display: flex; gap: 20px; }

.bk-radios label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    min-height: 44px;
    cursor: pointer;
}

.bk-radios input { width: 20px; height: 20px; accent-color: var(--cor); }

/* ---------------------------------------------------------------- horas */

.bk-slots {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 8px;
    margin-top: 4px;
}

.bk-slot {
    min-height: 44px;
    padding: 10px 4px;
    font: inherit;
    font-variant-numeric: tabular-nums;
    color: var(--tinta);
    background: var(--branco);
    border: 1px solid var(--linha);
    border-radius: var(--raio);
    cursor: pointer;
}

.bk-slot:hover { border-color: var(--cor); background: var(--cor-clara); }

.bk-slot[aria-pressed="true"] {
    background: var(--cor);
    border-color: var(--cor);
    color: var(--cor-texto);
    font-weight: 600;
}

.bk-vazio { color: var(--tinta-fraca); font-size: 14px; margin: 8px 0 0; }

/* -------------------------------------------------------------- botoes */

.bk-accoes {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--linha);
}

.bk-accoes .bk-avanca { margin-left: auto; }

.bk-btn {
    min-height: 44px;
    padding: 11px 20px;
    font: inherit;
    font-weight: 600;
    border-radius: var(--raio);
    border: 1px solid transparent;
    cursor: pointer;
}

.bk-btn-primario { background: var(--cor); color: var(--cor-texto); }
.bk-btn-primario:hover:not(:disabled) { filter: brightness(0.92); }

.bk-btn-secundario {
    background: var(--branco);
    color: var(--tinta);
    border-color: var(--linha);
}

.bk-btn:disabled { opacity: .45; cursor: not-allowed; }

@media (max-width: 480px) {
    .bk-accoes .bk-avanca { flex: 1; }
}

/* -------------------------------------------------------------- resumo */

.bk-resumo {
    background: var(--cor-clara);
    border-radius: var(--raio);
    padding: 14px 16px;
    margin-bottom: 20px;
    font-size: 15px;
}

.bk-resumo dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.bk-resumo dt { color: var(--tinta-fraca); font-size: 14px; }
.bk-resumo dd { margin: 0; font-weight: 500; }

/* --------------------------------------------------------------- estado */

.bk-estado { text-align: center; padding: 24px 0; }
.bk-estado h2 { font-size: 19px; margin: 0 0 8px; }
.bk-estado p { margin: 0 0 8px; color: var(--tinta-fraca); }
.bk-estado.bk-estado-ok h2 { color: var(--ok); }
.bk-estado.bk-estado-erro h2 { color: var(--erro); }

.bk-obs-clinica {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--linha);
    font-size: 14px;
    color: var(--tinta-fraca);
}

/* -------------------------------------------------------------- spinner */

.bk-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, .75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.bk-roda {
    width: 40px;
    height: 40px;
    border: 3px solid var(--linha);
    border-top-color: var(--cor);
    border-radius: 50%;
    animation: bk-gira .8s linear infinite;
}

@keyframes bk-gira { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
    .bk-roda { animation-duration: 3s; }
}

/* ----------------------------------------------------------- flatpickr */

.flatpickr-calendar.inline { width: 100%; max-width: 340px; box-shadow: none; }
.flatpickr-days, .dayContainer { width: 100%; min-width: 0; max-width: none; }
.flatpickr-day { max-width: none; height: 40px; line-height: 40px; }

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: var(--cor);
    border-color: var(--cor);
    color: var(--cor-texto);
}

/* dias em que aquele terapeuta trabalha -- a classe vem do onDayCreate */
.flatpickr-day.enable-date { background: var(--cor-clara); border-color: var(--cor-clara); font-weight: 600; }
.flatpickr-day.enable-date.selected { background: var(--cor); border-color: var(--cor); }
.flatpickr-day.flatpickr-disabled { color: var(--linha); }

[hidden] { display: none !important; }
