/* =====================================================================
 * v6.4 — Correções de interface
 *
 *  1) Grelha de horários dos profissionais (painel da empresa) alinhada,
 *     com o dia da semana destacado e empilhamento limpo em telemóvel;
 *  2) Campo «/@» (identificador da comunidade) deixa de ficar vertical no
 *     registo e na edição do cliente;
 *  3) Links clicáveis dentro das mensagens do chat (VIX).
 *
 * Carregado SEMPRE depois das folhas anteriores.
 * ===================================================================== */

/* ---------------------------------------------------------------------
 * 1) Horários por dia da semana (modal do profissional + ausências)
 * ------------------------------------------------------------------ */
.schedule-grid {
    --sched-day: 170px;
    --sched-closed: 108px;
    --sched-col: minmax(190px, 1fr);

    display: block;
    width: 100%;
    margin-top: 10px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 14px;
    background: var(--surface, #fff);
    overflow: hidden;
}

.schedule-grid__head,
.schedule-grid__row {
    display: grid;
    grid-template-columns: var(--sched-day) var(--sched-closed) var(--sched-col) var(--sched-col);
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
}

.schedule-grid__head {
    background: var(--surface-2, #f8fafc);
    border-bottom: 1px solid var(--border, #e5e7eb);
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted, #64748b);
}

.schedule-grid__row + .schedule-grid__row,
.schedule-grid__head + .schedule-grid__row {
    border-top: 1px solid var(--border-soft, rgba(148, 163, 184, .28));
}

.schedule-grid__row:nth-child(even) {
    background: color-mix(in srgb, var(--surface-2, #f8fafc) 55%, transparent);
}

.schedule-grid__row:hover {
    background: color-mix(in srgb, var(--brand-50, #f5f3ff) 70%, transparent);
}

/* Dia da semana bem visível (pedido: destacar schedule-grid__day). */
.schedule-grid__day {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 6px 12px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--brand-600, #6d28d9), var(--brand-500, #7c3aed));
    color: #fff;
    font-weight: 800;
    font-size: .86rem;
    line-height: 1.1;
    letter-spacing: .01em;
    white-space: nowrap;
    box-shadow: 0 6px 14px rgba(109, 40, 217, .18);
}

.schedule-grid__day i {
    font-size: .95rem;
    opacity: .9;
}

.schedule-grid__day-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

.schedule-grid__row.is-weekend .schedule-grid__day {
    background: linear-gradient(135deg, #0f766e, #14b8a6);
    box-shadow: 0 6px 14px rgba(13, 148, 136, .18);
}

.schedule-grid__row.is-closed .schedule-grid__day {
    background: linear-gradient(135deg, #64748b, #94a3b8);
    box-shadow: none;
}

.schedule-grid__row.is-closed .sched-hours,
.schedule-grid__row.is-closed .sched-break {
    opacity: .45;
}

/* Linhas de horas: campos sempre alinhados e do mesmo tamanho. */
.sched-hours,
.sched-break {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: 0;
}

.sched-hours .input,
.sched-break .input {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    max-width: 150px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.sched-sep,
.sched-hours > span,
.sched-break > span {
    flex: 0 0 auto;
    color: var(--muted, #6b7280);
    font-weight: 700;
}

.sched-closed {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    background: var(--surface-2, #f8fafc);
    cursor: pointer;
    font-size: .8rem;
    font-weight: 700;
    color: var(--muted, #475569);
    white-space: nowrap;
}

.sched-closed input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin: 0;
    accent-color: var(--brand-600, #6d28d9);
    cursor: pointer;
}

.schedule-grid__row.is-closed .sched-closed {
    border-color: #ef4444;
    background: rgba(239, 68, 68, .08);
    color: #b91c1c;
}

/* Ausências: a mesma linha de horas fora da grelha. */
.field > .sched-hours {
    margin-top: 4px;
}

@media (max-width: 1100px) {
    .schedule-grid {
        --sched-day: 150px;
        --sched-closed: 96px;
    }
}

/* Telemóvel/tablet: cada dia passa a ser um cartão com etiquetas. */
@media (max-width: 860px) {
    .schedule-grid__head {
        display: none;
    }

    .schedule-grid__row {
        grid-template-columns: 1fr 1fr;
        gap: 10px 12px;
        padding: 14px;
    }

    .schedule-grid__day {
        grid-column: 1 / -1;
        justify-content: center;
    }

    .sched-closed {
        grid-column: 1 / -1;
        justify-content: center;
    }

    .sched-hours,
    .sched-break {
        grid-column: 1 / -1;
        flex-wrap: nowrap;
    }

    .sched-hours::before,
    .sched-break::before {
        content: attr(data-label);
        flex: 0 0 auto;
        min-width: 86px;
        font-size: .72rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: .03em;
        color: var(--muted, #64748b);
    }
}

@media (max-width: 480px) {
    .sched-hours::before,
    .sched-break::before {
        min-width: 70px;
    }

    .sched-hours .input,
    .sched-break .input {
        max-width: none;
        padding-left: 6px;
        padding-right: 6px;
    }
}

/* Tema escuro */
[data-theme="dark"] .schedule-grid {
    background: var(--surface, #0f172a);
    border-color: rgba(148, 163, 184, .25);
}

[data-theme="dark"] .schedule-grid__head {
    background: rgba(148, 163, 184, .10);
}

[data-theme="dark"] .sched-closed {
    background: rgba(148, 163, 184, .12);
    border-color: rgba(148, 163, 184, .25);
    color: #cbd5e1;
}

/* ---------------------------------------------------------------------
 * 2) Identificador da comunidade (/@utilizador) — registo e perfil
 * ------------------------------------------------------------------ */
.cm-handle-input-wrap {
    display: flex;
    flex-direction: row !important;
    align-items: stretch;
    flex-wrap: nowrap;
    min-width: 0;
    min-height: 42px;
}

/* O prefixo «/@» deixa de encolher (era isso que o punha na vertical). */
.cm-handle-prefix {
    flex: 0 0 auto !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: auto !important;
    min-width: 42px;
    height: auto;
    padding: 0 12px;
    white-space: nowrap !important;
    word-break: keep-all;
    writing-mode: horizontal-tb !important;
    line-height: 1;
    letter-spacing: 0;
}

.cm-handle-input-wrap .input {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent;
}

.cm-handle-setup__form {
    align-items: stretch;
}

.cm-handle-setup__form .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

@media (max-width: 520px) {
    .cm-handle-setup__form {
        flex-direction: column;
        align-items: stretch;
    }

    .cm-handle-input-wrap {
        flex: 1 1 auto;
        width: 100%;
    }
}

/* ---------------------------------------------------------------------
 * 3) Chat VIX — links clicáveis dentro das mensagens
 * ------------------------------------------------------------------ */
.vix__bubble a,
.vix__link {
    color: inherit;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.vix__msg--bot .vix__bubble a,
.vix__msg--admin .vix__bubble a {
    color: var(--vix-color, #6d28d9);
}

.vix__msg--client .vix__bubble a {
    color: #fff;
    text-decoration-color: rgba(255, 255, 255, .7);
}

.vix__bubble a:hover {
    text-decoration-thickness: 2px;
    opacity: .9;
}

.vix__bubble a:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 4px;
}
