/* ==========================================================================
   Assistente do site -- botao "Chat with us" + janela
   7 Set 2026. Substitui o widget generico (Bootstrap azul, bolhas redondas).

   O BOTAO e' o do prototipo v5 (GlobalNav.tsx:300 / Hero.tsx:345):
     fixed bottom 50px / right 51px, 123x43, rgba(0,71,108,.38) com
     backdrop-blur 2.55px, Kanit 13px weight 300 branco, so' desktop
     (hidden md:block). Esbate-se com o rodape pela mesma classe da barra
     de navegacao (.sa-nav-oculta), para os dois sairem juntos.

   A JANELA nao esta no prototipo. Segue a pagina de contactos: sem cantos
   redondos, cabecalho --color-dark, botoes como o .sa-contacts-form-submit
   (Kanit 300, 13px, letter-spacing 1.6px, maiusculas), tokens do custom.css.
   ========================================================================== */

/* z-index: acima do cabecalho (.sa-header, 100) e dos popups do site
   (.sa-bm-modal / .sa-bpop-overlay, 300-320). O botao ia em 50 e a barra de
   Log in tapava a janela do chat (7 Set 2026). Abaixo dos 9999 do Bootstrap,
   para um modal proprio ainda poder cobrir o chat. */
.sa-chat-launcher {
    position: fixed;
    bottom: 50px;
    right: 51px;
    width: 123px;
    height: 43px;
    z-index: 400;
    display: none;                       /* desktop only, como no prototipo */
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: rgba(0, 71, 108, 0.38);
    -webkit-backdrop-filter: blur(2.55px);
    backdrop-filter: blur(2.55px);
    color: #ffffff;
    font-family: var(--font-family, 'Kanit', sans-serif);
    font-weight: 300;
    font-size: 13px;
    line-height: normal;
    cursor: pointer;
    transition: opacity 320ms ease, transform 320ms ease, background-color 200ms ease;
}
@media (min-width: 768px) {
    .sa-chat-launcher { display: flex; }
}
.sa-chat-launcher:hover,
.sa-chat-launcher:focus-visible {
    background: rgba(0, 71, 108, 0.55);
    outline: none;
}
/* O mesmo esbatimento da .sa-nav: a classe e' posta pelo chat-widget.js
   quando o rodape entra no ecra. */
.sa-chat-launcher.sa-nav-oculta {
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
}
/* Com a janela aberta o botao nao faz falta. */
.sa-chat-launcher.sa-chat-launcher-hidden {
    opacity: 0;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Janela
   -------------------------------------------------------------------------- */
.sa-chat {
    position: fixed;
    bottom: 50px;
    right: 51px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 80px);
    z-index: 401;
    display: none;
    flex-direction: column;
    background: #ffffff;
    box-shadow: 0 12px 40px rgba(0, 21, 36, 0.22);
    font-family: var(--font-family, 'Kanit', sans-serif);
    color: var(--color-text, #4a5565);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 240ms ease, transform 240ms ease;
}
.sa-chat.sa-chat-open {
    display: flex;
}
.sa-chat.sa-chat-visible {
    opacity: 1;
    transform: translateY(0);
}
@media (max-width: 767px) {
    /* O botao nao aparece em mobile; se a janela for aberta por JS
       (window.saChat.open) ocupa o ecra todo. */
    .sa-chat {
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
    }
}
@media (prefers-reduced-motion: reduce) {
    .sa-chat, .sa-chat-launcher { transition: opacity 240ms ease; }
    .sa-chat, .sa-chat-launcher.sa-nav-oculta { transform: none; }
}

/* cabecalho */
.sa-chat-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 56px;
    padding: 0 12px 0 20px;
    background: var(--color-dark, #001524);
    color: #ffffff;
}
.sa-chat-head-dot {
    width: 8px;
    height: 8px;
    background: var(--color-energy, #8FD400);
    flex: 0 0 auto;
}
.sa-chat-head-title {
    flex: 1 1 auto;
    min-width: 0;
    font-weight: 400;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sa-chat-head-btn {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: color 150ms ease;
}
.sa-chat-head-btn:hover,
.sa-chat-head-btn:focus-visible {
    color: #ffffff;
    outline: none;
}
.sa-chat-head-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* mensagens */
.sa-chat-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 20px 8px;
    background: #ffffff;
    scroll-behavior: smooth;
}
.sa-chat-msg {
    display: flex;
    margin: 0 0 12px;
}
.sa-chat-msg-agent { justify-content: flex-start; }
.sa-chat-msg-user  { justify-content: flex-end; }
.sa-chat-bubble {
    max-width: 84%;
    padding: 10px 14px;
    font-weight: 300;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.sa-chat-msg-agent .sa-chat-bubble {
    background: var(--color-bg-light, #f5f7f9);
    color: var(--color-dark, #001524);
}
.sa-chat-msg-user .sa-chat-bubble {
    background: var(--color-primary, #00476c);
    color: #ffffff;
}
.sa-chat-bubble p { margin: 0 0 8px; }
.sa-chat-bubble p:last-child { margin-bottom: 0; }
.sa-chat-bubble ul,
.sa-chat-bubble ol {
    margin: 4px 0 8px;
    padding-left: 18px;
}
.sa-chat-bubble li { margin: 0 0 2px; }
.sa-chat-bubble strong { font-weight: 500; }
/* Links no texto (30 Out 2026, opcao A da Sofia): o azul dos botoes com um
   sublinhado leve que fica cheio ao passar o rato. O --color-accent de antes
   parecia link de browser e lia-se mal no cinzento (~2,6:1). */
.sa-chat-bubble a {
    color: var(--color-primary, #00476c);
    font-weight: 400;
    text-decoration: underline;
    text-decoration-color: rgba(0, 71, 108, 0.35);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: text-decoration-color 150ms ease;
}
.sa-chat-msg-user .sa-chat-bubble a { color: #ffffff; text-decoration-color: currentColor; }
.sa-chat-bubble a:hover,
.sa-chat-bubble a:focus-visible { color: var(--color-primary, #00476c); text-decoration-color: currentColor; }
.sa-chat-msg-user .sa-chat-bubble a:hover { color: rgba(255, 255, 255, 0.8); }

/* botao de accao no fim da resposta (23 Out 2026) -- ver botaoDeAccao() no
   chat-widget.js; mesma letra do .sa-chat-cta do rodape */
.sa-chat-bubble p.sa-chat-accao { margin: 12px 0 2px; }
.sa-chat-bubble a.sa-chat-accao-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 9px 14px;
    background: var(--color-primary, #00476c);
    color: #ffffff;
    font-weight: 400;
    font-size: 12px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    text-decoration: none;
    transition: background-color 150ms ease;
}
.sa-chat-bubble a.sa-chat-accao-btn:hover,
.sa-chat-bubble a.sa-chat-accao-btn:focus-visible {
    background: var(--color-dark, #001524);
    color: #ffffff;
    outline: none;
}
.sa-chat-bubble a.sa-chat-accao-btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}

.sa-chat-error {
    margin: 0 0 12px;
    padding: 10px 14px;
    background: rgba(237, 110, 0, 0.08);
    border-left: 2px solid var(--color-orange, #ED6E00);
    color: var(--color-dark, #001524);
    font-weight: 300;
    font-size: 13px;
    line-height: 1.5;
}

/* "a escrever..." */
.sa-chat-typing {
    display: none;
    align-items: center;
    gap: 4px;
    margin: 0 0 12px;
    padding: 12px 14px;
    width: max-content;
    background: var(--color-bg-light, #f5f7f9);
}
.sa-chat-typing.sa-chat-typing-on { display: inline-flex; }
.sa-chat-typing span {
    width: 6px;
    height: 6px;
    background: var(--color-text-muted, #99a1af);
    animation: sa-chat-blink 1.2s infinite ease-in-out;
}
.sa-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.sa-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes sa-chat-blink {
    0%, 80%, 100% { opacity: 0.25; }
    40%           { opacity: 1; }
}

/* rodape: encaminhamento + caixa de texto */
.sa-chat-foot {
    flex: 0 0 auto;
    border-top: 1px solid var(--color-border, rgba(0, 71, 108, 0.08));
    background: #ffffff;
}
.sa-chat-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 20px;
    font-weight: 300;
    font-size: 12px;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--color-primary, #00476c);
    text-decoration: none;
    border-bottom: 1px solid var(--color-border, rgba(0, 71, 108, 0.08));
    transition: background-color 150ms ease;
}
.sa-chat-cta:hover,
.sa-chat-cta:focus-visible {
    background: var(--color-bg-light, #f5f7f9);
    color: var(--color-primary, #00476c);
    outline: none;
}
.sa-chat-cta svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex: 0 0 auto;
}
.sa-chat-form {
    display: flex;
    align-items: flex-end;
    gap: 0;
    margin: 0;
}
.sa-chat-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 52px;
    max-height: 120px;
    padding: 15px 16px 15px 20px;
    border: 0;
    background: #ffffff;
    color: var(--color-dark, #001524);
    font-family: var(--font-family, 'Kanit', sans-serif);
    font-weight: 300;
    font-size: 14px;
    line-height: 1.45;
    resize: none;
    outline: none;
}
.sa-chat-input::placeholder { color: var(--color-text-muted, #99a1af); }
.sa-chat-input:disabled { background: var(--color-bg-light, #f5f7f9); }
.sa-chat-send {
    flex: 0 0 auto;
    height: 52px;
    padding: 0 20px;
    border: 0;
    background: var(--color-primary, #00476c);
    color: #ffffff;
    font-family: var(--font-family, 'Kanit', sans-serif);
    font-weight: 300;
    font-size: 13px;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 200ms ease;
}
.sa-chat-send:hover,
.sa-chat-send:focus-visible {
    background: var(--color-dark, #001524);
    outline: none;
}
.sa-chat-send:disabled {
    background: var(--color-text-muted, #99a1af);
    cursor: default;
}
