:root {
    --chat-background: #f4f6fb;
    --chat-surface: #ffffff;
    --chat-surface-soft: #f8faff;
    --chat-text: #10182f;
    --chat-text-soft: #68758d;
    --chat-border: #e1e6f0;
    --chat-primary: #315cf4;
    --chat-primary-dark: #2549cf;
    --chat-purple: #7437f5;
    --chat-success: #087d5c;
    --chat-danger: #c83232;
    --chat-sidebar: #111a32;
    --chat-shadow:
        0 18px 50px rgba(22, 35, 74, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--chat-background);
    color: var(--chat-text);
    font-family:
        Inter,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

button,
textarea,
a {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

a {
    color: inherit;
    text-decoration: none;
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================
   ESTRUTURA PRINCIPAL
========================================================== */

.financial-chat-app {
    min-height: 100vh;
    display: grid;
    grid-template-columns:
        330px
        minmax(0, 1fr);
}

.financial-chat-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    padding: 28px 24px;
    background:
        radial-gradient(
            circle at 20% 0%,
            rgba(83, 94, 245, 0.22),
            transparent 33%
        ),
        var(--chat-sidebar);
    color: #ffffff;
}

.financial-chat-main {
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ==========================================================
   SIDEBAR
========================================================== */

.financial-chat-sidebar .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 30px;
}

.financial-chat-sidebar .sidebar-brand strong {
    font-size: 24px;
    line-height: 1;
}

.financial-chat-sidebar .sidebar-brand strong span {
    color: #9eb5ff;
}

.financial-chat-back {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    margin-bottom: 28px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 11px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
    font-weight: 700;
    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.financial-chat-back:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.financial-specialist-card {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 28px;
    padding: 20px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.06);
}

.financial-specialist-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    border-radius: 14px;
    background:
        linear-gradient(
            135deg,
            var(--chat-primary),
            var(--chat-purple)
        );
    color: #ffffff;
    font-size: 14px;
    font-weight: 900;
}

.financial-specialist-card > div {
    min-width: 0;
}

.financial-specialist-status {
    display: block;
    margin-bottom: 6px;
    color: #83e0be;
    font-size: 12px;
    font-weight: 800;
}

.financial-specialist-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
}

.financial-specialist-card p {
    margin: 0;
    color: rgba(255, 255, 255, 0.68);
    font-size: 13px;
    line-height: 1.55;
}

.financial-chat-sidebar-section {
    margin-top: 14px;
    padding: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.04);
}

.financial-chat-sidebar-title {
    display: block;
    margin-bottom: 7px;
    color: rgba(255, 255, 255, 0.58);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.financial-chat-sidebar-section strong {
    display: block;
    font-size: 18px;
}

.financial-chat-sidebar-section p {
    margin: 8px 0 0;
    color: rgba(255, 255, 255, 0.64);
    font-size: 13px;
    line-height: 1.5;
}

/* ==========================================================
   CABEÇALHO
========================================================== */

.financial-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 28px 34px;
    border-bottom: 1px solid var(--chat-border);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
}

.financial-chat-header h1 {
    margin: 7px 0 8px;
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.15;
    letter-spacing: -0.04em;
}

.financial-chat-header p {
    max-width: 720px;
    margin: 0;
    color: var(--chat-text-soft);
    line-height: 1.6;
}

.financial-chat-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.financial-chat-connection-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 13px;
    border-radius: 999px;
    background: #eafbf4;
    color: var(--chat-success);
    font-size: 13px;
    font-weight: 800;
}

.financial-chat-connection-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.financial-chat-connection-status.offline {
    background: #fff0f0;
    color: var(--chat-danger);
}

/* ==========================================================
   CONTEÚDO DO CHAT
========================================================== */

.financial-chat-content {
    width: min(100%, 980px);
    min-height: 0;
    margin: 0 auto;
    padding: 28px 30px 24px;
    display: flex;
    flex: 1;
    flex-direction: column;
}

.financial-chat-messages {
    min-height: 430px;
    max-height: calc(100vh - 350px);
    overflow-y: auto;
    padding: 6px 8px 24px;
    scroll-behavior: smooth;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    margin-bottom: 22px;
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-message-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 12px;
    background:
        linear-gradient(
            135deg,
            var(--chat-primary),
            var(--chat-purple)
        );
    color: #ffffff;
    font-size: 14px;
    font-weight: 900;
}

.chat-message.user .chat-message-avatar {
    background: #dfe6ff;
    color: var(--chat-primary);
}

.chat-message-body {
    max-width: min(76%, 720px);
}

.chat-message.user .chat-message-body {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-message-author {
    display: block;
    margin: 0 0 7px 4px;
    color: var(--chat-text-soft);
    font-size: 12px;
    font-weight: 750;
}

.chat-message-bubble {
    padding: 15px 17px;
    border: 1px solid var(--chat-border);
    border-radius:
        5px
        17px
        17px
        17px;
    background: var(--chat-surface);
    box-shadow:
        0 8px 26px rgba(30, 45, 80, 0.05);
    line-height: 1.62;
    white-space: pre-line;
    word-break: break-word;
}

.chat-message.user .chat-message-bubble {
    border-color: transparent;
    border-radius:
        17px
        5px
        17px
        17px;
    background:
        linear-gradient(
            135deg,
            var(--chat-primary),
            var(--chat-purple)
        );
    color: #ffffff;
}

/* ==========================================================
   DIGITAÇÃO
========================================================== */

.financial-chat-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 32px;
    margin: 0 0 14px 58px;
    color: var(--chat-text-soft);
}

.financial-chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--chat-primary);
    animation: financial-chat-pulse 1.2s infinite ease-in-out;
}

.financial-chat-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.financial-chat-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

.financial-chat-typing small {
    margin-left: 8px;
}

@keyframes financial-chat-pulse {
    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: 0.35;
    }

    40% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* ==========================================================
   SUGESTÕES
========================================================== */

.financial-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-bottom: 14px;
}

.chat-suggestion-button {
    min-height: 38px;
    padding: 0 13px;
    border: 1px solid var(--chat-border);
    border-radius: 999px;
    background: var(--chat-surface);
    color: var(--chat-text-soft);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition:
        border-color 0.2s ease,
        color 0.2s ease,
        transform 0.2s ease;
}

.chat-suggestion-button:hover {
    transform: translateY(-1px);
    border-color: var(--chat-primary);
    color: var(--chat-primary);
}

/* ==========================================================
   FORMULÁRIO
========================================================== */

.financial-chat-form {
    display: grid;
    grid-template-columns:
        minmax(0, 1fr)
        auto;
    align-items: end;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--chat-border);
    border-radius: 18px;
    background: var(--chat-surface);
    box-shadow: var(--chat-shadow);
}

.financial-chat-form textarea {
    width: 100%;
    min-height: 48px;
    max-height: 180px;
    resize: none;
    padding: 13px 12px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--chat-text);
    line-height: 1.5;
}

.financial-chat-form textarea::placeholder {
    color: #8994a9;
}

.financial-chat-send-button {
    min-height: 46px;
    padding: 0 21px;
    border: 0;
    border-radius: 13px;
    background:
        linear-gradient(
            110deg,
            var(--chat-primary),
            var(--chat-purple)
        );
    color: #ffffff;
    font-weight: 800;
    cursor: pointer;
    transition:
        transform 0.2s ease,
        opacity 0.2s ease;
}

.financial-chat-send-button:hover {
    transform: translateY(-1px);
}

.financial-chat-send-button:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    transform: none;
}

.financial-chat-form-message {
    min-height: 22px;
    margin: 9px 4px 0;
    color: var(--chat-danger);
    font-size: 13px;
}

/* ==========================================================
   BOTÕES COMPARTILHADOS
========================================================== */

.financial-chat-page .primary-button,
.financial-chat-page .secondary-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.financial-chat-page .secondary-button {
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--chat-border);
    border-radius: 11px;
    background: #ffffff;
    color: var(--chat-text);
    font-weight: 750;
    cursor: pointer;
}

/* ==========================================================
   RESPONSIVIDADE
========================================================== */

@media (max-width: 980px) {
    .financial-chat-app {
        grid-template-columns:
            270px
            minmax(0, 1fr);
    }

    .financial-chat-sidebar {
        padding: 24px 18px;
    }

    .financial-chat-header {
        padding: 24px;
    }

    .financial-chat-content {
        padding:
            24px
            22px
            20px;
    }
}

@media (max-width: 760px) {
    .financial-chat-app {
        display: block;
    }

    .financial-chat-sidebar {
        position: static;
        width: 100%;
        height: auto;
        overflow: visible;
    }

    .financial-chat-sidebar-section {
        display: none;
    }

    .financial-specialist-card {
        margin-bottom: 0;
    }

    .financial-chat-header {
        flex-direction: column;
        align-items: stretch;
    }

    .financial-chat-header-actions {
        justify-content: space-between;
    }

    .financial-chat-content {
        width: 100%;
        padding:
            20px
            15px
            18px;
    }

    .financial-chat-messages {
        min-height: 390px;
        max-height: none;
    }

    .chat-message-body {
        max-width: 86%;
    }
}

@media (max-width: 520px) {
    .financial-chat-sidebar {
        padding: 20px 15px;
    }

    .financial-chat-header {
        padding: 20px 16px;
    }

    .financial-chat-header-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .financial-chat-connection-status {
        width: fit-content;
    }

    .financial-chat-suggestions {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .chat-suggestion-button {
        flex-shrink: 0;
    }

    .financial-chat-form {
        grid-template-columns:
            minmax(0, 1fr);
    }

    .financial-chat-send-button {
        width: 100%;
    }

    .chat-message-body {
        max-width: calc(100% - 48px);
    }
}

/* ==========================================================
   AJUSTES DE COMPACTAÇÃO DO CHAT
========================================================== */

.financial-chat-content {
    width: min(100%, 1120px);
    padding:
        20px
        26px
        18px;
}

.financial-chat-messages {
    min-height: 320px;
    max-height: calc(100vh - 300px);
    padding:
        0
        6px
        16px;
}

.chat-message {
    gap: 12px;
    margin-bottom: 16px;
}

.chat-message-body {
    width: auto;
    min-width: 0;
    max-width: min(88%, 980px);
    height: auto !important;
}

.chat-message-author {
    margin:
        0
        0
        5px
        4px;
    font-size: 12px;
}

.chat-message-bubble {
    padding:
        12px
        15px;
    border-radius:
        5px
        15px
        15px
        15px;
    line-height: 1.48;
    font-size: 15px;
}

.chat-message.user .chat-message-bubble {
    border-radius:
        15px
        5px
        15px
        15px;
}

.chat-message-avatar {
    width: 34px;
    height: 34px;
    border-radius: 10px;
}

.financial-chat-suggestions {
    margin-bottom: 10px;
}

.financial-chat-form {
    padding: 9px;
    border-radius: 16px;
}

.financial-chat-form textarea {
    min-height: 42px;
    padding:
        10px
        10px;
}

.financial-chat-send-button {
    min-height: 42px;
    padding:
        0
        18px;
}

@media (max-width: 760px) {
    .financial-chat-content {
        padding:
            16px
            12px
            14px;
    }

    .financial-chat-messages {
        min-height: 300px;
        max-height: none;
    }

    .chat-message-body {
        max-width: calc(100% - 46px);
    }
}
/* ==========================================================
   CORREÇÃO FINAL DE ESPAÇAMENTO DO CHAT
========================================================== */

.financial-chat-main {
    height: 100vh;
    overflow: hidden;
}

.financial-chat-header {
    flex-shrink: 0;
    padding: 20px 28px;
}

.financial-chat-header h1 {
    margin-top: 4px;
    margin-bottom: 5px;
    font-size: 28px;
}

.financial-chat-content {
    width: min(100%, 1120px);
    min-height: 0;
    height: 100%;
    padding: 16px 24px;
    overflow: hidden;
}

/*
 * Impede qualquer regra anterior de distribuir
 * as mensagens pelo espaço vertical.
 */
.financial-chat-messages {
    display: block !important;
    flex: 1 1 auto;
    min-height: 0 !important;
    height: auto;
    max-height: none;
    overflow-y: auto;
    padding: 8px 8px 14px;
}

/*
 * Cada mensagem ocupa somente a altura
 * necessária para seu conteúdo.
 */
.chat-message {
    display: flex;
    width: 100%;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 0 14px !important;
    padding: 0 !important;
    align-items: flex-start;
    justify-content: flex-start;
}

.chat-message.user {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

/*
 * Evita largura e altura exageradas.
 */
.chat-message-body {
    width: auto;
    min-width: 0;
    max-width: min(72%, 760px);
    height: auto !important;
}

.chat-message.user .chat-message-body {
    margin-left: auto;
}

.chat-message-bubble {
    display: block;
    width: fit-content;
    min-width: 0;
    min-height: 0 !important;
    height: auto !important;
    padding: 11px 14px;
    text-align: left;
    line-height: 1.5;
    font-size: 15px;
}

.chat-message.user .chat-message-bubble {
    margin-left: auto;
}

/*
 * A mensagem inicial não deve virar um card enorme.
 */
.chat-message.assistant .chat-message-bubble {
    max-width: 700px;
}

/*
 * Mantém sugestões e campo de envio fixos
 * abaixo da área rolável.
 */
.financial-chat-typing,
.financial-chat-suggestions,
.financial-chat-form,
.financial-chat-form-message {
    flex-shrink: 0;
}

.financial-chat-suggestions {
    margin: 8px 0 10px;
}

.financial-chat-form {
    margin: 0;
}

@media (max-width: 760px) {
    .financial-chat-main {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .financial-chat-content {
        height: auto;
        overflow: visible;
        padding: 14px 12px;
    }

    .financial-chat-messages {
        min-height: 360px !important;
        max-height: 60vh;
    }

    .chat-message-body {
        max-width: calc(100% - 45px);
    }
}
.chat-message-bubble {
    white-space: pre-line !important;
    text-indent: 0;
}

.chat-message-bubble::first-line {
    line-height: inherit;
}

.chat-actions-list {
    display: grid;
    gap: 14px;
    margin-top: 12px;
}

.chat-action-card {
    padding: 18px 20px;
    border: 1px solid var(--chat-border);
    border-radius: 15px;
    background: var(--chat-surface);
    box-shadow:
        0 6px 18px rgba(30, 45, 80, 0.04);
}

.chat-action-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 6px;
}

.chat-action-card-number {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 32px;
    height: 32px;

    flex-shrink: 0;

    border-radius: 10px;

    background: #eef3ff;

    color: #315cf4;

    font-size: 13px;
    font-weight: 700;
}
.chat-action-card-title {
    flex: 1;

    color: #182338;

    font-size: 17px;

    font-weight: 600;

    line-height: 1.35;

    letter-spacing: -.01em;
}

.chat-action-card-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}

.chat-action-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 5px 10px;
    border: 1px solid #e5e9f1;
    border-radius: 8px;
    background: #f8fafc;
    color: #526079;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
}

.chat-action-tag::before {
    content: "";
    width: 7px;
    height: 7px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #94a3b8;
}

.chat-action-tag.status-pendente {
    border-color: #f2dfb6;
    background: #fffaf0;
    color: #946000;
}

.chat-action-tag.status-pendente::before {
    background: #e7a21a;
}

.chat-action-tag.status-em_andamento {
    border-color: #cad7ff;
    background: #f5f7ff;
    color: #3153bd;
}

.chat-action-tag.status-em_andamento::before {
    background: var(--chat-primary);
}

.chat-action-tag.status-concluido {
    border-color: #bfe9d9;
    background: #f2fbf7;
    color: var(--chat-success);
}

.chat-action-tag.status-concluido::before {
    background: var(--chat-success);
}

.chat-action-tag.status-cancelado {
    border-color: #f1caca;
    background: #fff7f7;
    color: var(--chat-danger);
}

.chat-action-tag.status-cancelado::before {
    background: var(--chat-danger);
}

.chat-action-tag.priority-alta {
    border-color: #f1caca;
    background: #fff7f7;
    color: #b33636;
}

.chat-action-tag.priority-alta::before {
    background: #dc4b4b;
}

.chat-action-tag.priority-media {
    border-color: #f2dfb6;
    background: #fffaf0;
    color: #946000;
}

.chat-action-tag.priority-media::before {
    background: #e7a21a;
}

.chat-action-tag.priority-baixa {
    border-color: #bfe9d9;
    background: #f2fbf7;
    color: var(--chat-success);
}

.chat-action-tag.priority-baixa::before {
    background: var(--chat-success);
}

.chat-action-tag.neutral {
    border-color: #e3e8f0;
    background: #f8fafc;
    color: #64748b;
}

.chat-action-tag.neutral::before {
    background: #94a3b8;
}
.chat-action-card-description {
    margin: 14px 0 0;
    color: #64748b;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.6;
}

.chat-message.assistant .chat-actions-list {
    width: min(100%, 900px);
}

@media (max-width: 760px) {
    .chat-action-card {
        padding: 13px;
    }

    .chat-action-card-tags {
        gap: 6px;
    }
}

.chat-action-card-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

.chat-action-button {
    min-height: 36px;
    padding: 0 13px;
    border: 1px solid #dbe3f0;
    border-radius: 9px;
    background: #ffffff;
    color: var(--chat-primary);
    font-size: 12px;
    font-weight: 650;
    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.chat-action-button:hover {
    transform: translateY(-1px);
    border-color: var(--chat-primary);
    background: #f5f7ff;
}

.chat-action-completed-button {
    border-color: #bfe9d9;
    background: #f2fbf7;
    color: var(--chat-success);
    cursor: default;
    opacity: 1;
}

.chat-action-completed-button:hover {
    transform: none;
    border-color: #bfe9d9;
    background: #f2fbf7;
}
