﻿/* ==========================================================================
   support_widget.css
   Estilos isolados para o widget q.track (embed). Ficheiro autocontido:
   nao depende de style.css nem partilha regras com o dashboard. Carregado
   por chat/templates/chat/support_widget.html.

   Indice:
     1. Reset + base tipografica
     2. Variaveis (cores + espacamentos)
     3. Layout: body + container (frameless embed)
     4. Estrutura: chat-area + chat-card + config-content
     5. Mensagens (visitor / assistant)
     6. Action groups (sugestoes do funil)
     7. Input area (textarea + send button)
     8. Input footer (handoff / technical help / clear)
     9. Scrollbar personalizada
    10. Media queries (mobile)
   ========================================================================== */


/* 1. Reset + base tipografica
   ------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

button {
    font-family: inherit;
    cursor: pointer;
}

textarea {
    font-family: inherit;
}


/* 2. Variaveis (cores + espacamentos)
   ------------------------------------------------------------------------- */
.support_widget_shell {
    --sw-primary: #0c4f8a;
    --sw-primary-dark: #083a66;
    --sw-accent: #0e66aa;
    --sw-success: #1f9a60;
    --sw-text: #17324d;
    --sw-text-muted: #597089;
    --sw-text-soft: #6d7f95;
    --sw-border: #d5e3ef;
    --sw-border-strong: #b9cde0;
    --sw-bg-soft: #eef3fa;
    --sw-bg-user: #dfe9f8;
    --sw-bg-user-border: #c7d8ee;
    --sw-bg-suggestion: #f1f5fb;
    --sw-footer-bg: #eaf5ff;
    --sw-footer-border: #8dbfe4;
    --sw-footer-color: #0b5e99;
    --sw-focus-outline: #8ab5d8;
    --sw-send-gradient: linear-gradient(135deg, #0c4f8a 0%, #0e66aa 100%);
    --sw-send-gradient-hover: linear-gradient(135deg, #083a66 0%, #0b548f 100%);
}


/* 3. Layout: body + container (frameless embed)
   ------------------------------------------------------------------------- */
.support_widget_body {
    background: transparent;
    font-family: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 13px;
    line-height: 1.45;
    color: var(--sw-text, #17324d);
    height: 100vh;
    overflow: hidden;
}

.support_widget_shell.support_widget_frameless {
    display: grid;
    grid-template-rows: 1fr;
    width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}


/* 4. Estrutura: chat-area + chat-card + config-content
   ------------------------------------------------------------------------- */
.support_widget_shell .chat-area {
    grid-row: 1;
    grid-column: 1;
    height: 100%;
    min-height: 0;
    padding: 0;
    background: transparent;
}

.support_widget_shell .chat-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}

.support_widget_shell .config-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 9px;
    overflow: hidden;
    scroll-behavior: smooth;
}


/* 5. Mensagens (visitor / assistant)
   ------------------------------------------------------------------------- */
.support_widget_shell .messages-container {
    flex: 1;
    min-height: 0;
    padding: 7px 4px;
    background: #f7f9fc;
    border: 1px solid var(--sw-border);
    border-radius: 12px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

.support_widget_shell .message {
    margin-bottom: 14px;
}

.support_widget_shell .message:last-child {
    margin-bottom: 0;
}

.support_widget_shell .message-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

/* Mensagens do visitante alinham o cabecalho (pill + hora) a direita,
   de modo a encostar a pill "Visitor" ao lado da bubble. A ordem
   row-reverse coloca a role primeiro (direita) e a hora a sua esquerda. */
.support_widget_shell .message.user .message-header {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

.support_widget_shell .message-role {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.support_widget_shell .message-role.user {
    background: rgba(33, 150, 243, 0.35);
    color: var(--sw-primary-dark);
}

.support_widget_shell .message-role.assistant {
    background: rgba(46, 204, 113, 0.35);
    color: var(--sw-success);
}

.support_widget_shell .message-time {
    font-size: 10.5px;
    color: var(--sw-text-soft);
}

.support_widget_shell .message-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.support_widget_shell .message-content {
    max-width: 82%;
    padding: 8px 11px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.support_widget_shell .message.user .message-content {
    background: var(--sw-bg-user);
    color: var(--sw-text);
    border: 1px solid var(--sw-bg-user-border);
    margin-left: auto;
}

.support_widget_shell .message.assistant .message-content {
    background: var(--sw-bg-soft);
    color: var(--sw-text);
    border: 1px solid var(--sw-border);
}

.support_widget_shell .message-content a {
    color: var(--sw-accent);
    text-decoration: underline;
}

.support_widget_shell .message-content strong {
    font-weight: 700;
}


/* 6. Action groups (sugestoes do funil)
   ------------------------------------------------------------------------- */
.support_widget_shell .widget_action_group_inline {
    margin-top: 8px;
}

.support_widget_shell .message.assistant .widget_action_group_inline .message-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    background: var(--sw-bg-suggestion);
    border: 1px solid var(--sw-border);
    border-radius: 8px;
}

.support_widget_shell .widget-suggestions-lead {
    width: 100%;
    margin: 0 0 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: #425a73;
    line-height: 1.3;
}

.support_widget_shell .message.assistant .widget_action_group_inline .message-suggestions .suggestion-btn {
    flex: 0 0 auto;
    min-height: 34px;
    min-width: 146px;
    padding: 6px 11px;
    background: #ffffff;
    color: #1e3f60;
    border: 1px solid var(--sw-border-strong);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    justify-content: center;
    text-align: center;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.support_widget_shell .message.assistant .widget_action_group_inline .message-suggestions .suggestion-btn:hover:not(:disabled) {
    background: #e8eff9;
    border-color: #98b5da;
}

.support_widget_shell .message.assistant .widget_action_group_inline .message-suggestions .suggestion-btn:focus-visible {
    outline: 2px solid #3569b4;
    outline-offset: 2px;
}

.support_widget_shell .message.assistant .widget_action_group_inline .message-suggestions .suggestion-btn:disabled,
.support_widget_shell .message.assistant .widget_action_group_inline .message-suggestions .suggestion-btn.used {
    cursor: default;
    opacity: 0.6;
}


/* 7. Input area (textarea + send button)
   ------------------------------------------------------------------------- */
.support_widget_shell .input-area {
    padding: 11px 0;
    background: #ffffff;
    border-top: 1px solid #e2ebf3;
    box-shadow: 0 -4px 12px rgba(9, 44, 78, 0.04);
}

.support_widget_shell .input-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.support_widget_shell .input-wrapper {
    width: 100%;
}

.support_widget_shell .input-box {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    min-height: 48px;
    padding: 4px 6px;
    background: #ffffff;
    border: 1px solid #bcd0e3;
    border-radius: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.support_widget_shell .input-box:focus-within {
    border-color: var(--sw-accent);
    box-shadow: 0 0 0 2px rgba(138, 181, 216, 0.45);
}

.support_widget_shell #message-input {
    flex: 1;
    min-height: 40px;
    max-height: 140px;
    padding: 9px 12px;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-size: 13px;
    line-height: 1.45;
    color: var(--sw-text);
}

.support_widget_shell #message-input::placeholder {
    color: #8aa0b6;
}

.support_widget_shell .input-actions {
    display: flex;
    align-items: center;
    padding: 0 2px 2px 0;
}

.support_widget_shell .btn-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: var(--sw-send-gradient);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    transition: background 0.15s ease, transform 0.1s ease;
}

.support_widget_shell .btn-send:hover:not(:disabled) {
    background: var(--sw-send-gradient-hover);
}

.support_widget_shell .btn-send:active:not(:disabled) {
    transform: scale(0.97);
}

.support_widget_shell .btn-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}


/* 8. Input footer (handoff / technical help / clear)
   ------------------------------------------------------------------------- */
.support_widget_shell .input-footer {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 5px;
}

.support_widget_shell .input-footer .btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-height: 34px;
    padding: 9px 14px;
    background: var(--sw-footer-bg);
    color: var(--sw-footer-color);
    border: 1px solid var(--sw-footer-border);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.support_widget_shell .input-footer .btn-secondary:hover:not(:disabled) {
    background: #d7ecff;
    border-color: #6aabd8;
    color: #083a66;
}

.support_widget_shell .input-footer .btn-secondary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.support_widget_shell .input-footer .btn-secondary i {
    font-size: 13px;
}

.support_widget_shell .input-footer .support_widget_clear_btn_inline {
    margin-left: auto;
}


/* 9. Scrollbar personalizada
   ------------------------------------------------------------------------- */
.support_widget_shell .messages-container::-webkit-scrollbar,
.support_widget_shell .config-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.support_widget_shell .messages-container::-webkit-scrollbar-track,
.support_widget_shell .config-content::-webkit-scrollbar-track {
    background: transparent;
}

.support_widget_shell .messages-container::-webkit-scrollbar-thumb,
.support_widget_shell .config-content::-webkit-scrollbar-thumb {
    background: #c3d4e4;
    border-radius: 999px;
}

.support_widget_shell .messages-container::-webkit-scrollbar-thumb:hover,
.support_widget_shell .config-content::-webkit-scrollbar-thumb:hover {
    background: #9fb6ca;
}


/* 10. Media queries (mobile)
   ------------------------------------------------------------------------- */
@media (max-width: 520px) {
    .support_widget_shell .message.assistant .widget_action_group_inline .message-suggestions .suggestion-btn {
        flex: 1 1 48%;
        width: 49%;
        min-width: 0;
        max-width: 49%;
        justify-content: center;
        text-align: center;
    }

    .support_widget_shell .input-footer {
        gap: 6px;
    }

    .support_widget_shell .input-footer .btn-secondary {
        padding: 8px 10px;
        font-size: 11.5px;
    }

    .support_widget_shell .input-footer .support_widget_clear_btn_inline {
        margin-left: 0;
    }

    .support_widget_shell .message-content {
        max-width: 92%;
    }
}

/* ============================================================
   11. Powered by (footer discreto)
   ============================================================ */
.support_widget_shell .support_widget_powered_by {
    margin: -6px 0 0;
    padding: 0 6px;
    text-align: center;
    font-size: 9.5px;
    line-height: 1;
    color: #b0b7c0;
    letter-spacing: 0.2px;
    user-select: none;
    pointer-events: none;
}

