/* =========================================================
   CHAT JURÍDICO UNIVERSAL
   Arquivo central de aparência de todos os assistentes
   ========================================================= */

:root {
    --primary: #4338ca;
    --primary-hover: #3730a3;
    --primary-soft: #eef2ff;

    --background: #f7f8fc;
    --surface: #ffffff;
    --surface-secondary: #f3f4f6;

    --text: #16181d;
    --text-secondary: #667085;
    --text-light: #98a2b3;

    --border: #e4e7ec;
    --border-strong: #d0d5dd;

    --user-bubble: #4338ca;
    --user-text: #ffffff;

    --assistant-bubble: #ffffff;

    --success: #12b76a;
    --danger: #d92d20;

    --shadow-sm:
        0 1px 2px rgba(16, 24, 40, 0.04);

    --shadow:
        0 4px 18px rgba(16, 24, 40, 0.08);

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;

    --max-chat-width: 980px;
}


/* =========================================================
   RESET
   ========================================================= */

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
}

body {
    font-family:
        Inter,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        Helvetica,
        Arial,
        sans-serif;

    background: var(--background);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}


/* =========================================================
   APLICAÇÃO
   ========================================================= */

.app {
    width: 100%;
    min-height: 100vh;
    height: 100vh;

    display: flex;
    flex-direction: column;

    background: var(--background);
    overflow: hidden;
}


/* =========================================================
   CABEÇALHO
   ========================================================= */

.chat-header {
    width: 100%;
    min-height: 86px;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;

    padding: 15px 26px;

    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--border);

    box-shadow: var(--shadow-sm);

    z-index: 10;
}

.assistant-info {
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 14px;
}

.assistant-icon {
    width: 48px;
    height: 48px;

    flex: 0 0 48px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 14px;

    background: var(--primary-soft);

    font-size: 24px;
}

.assistant-info h1 {
    margin: 0;

    font-size: 18px;
    line-height: 1.35;
    font-weight: 700;

    color: var(--text);

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assistant-info p {
    margin: 4px 0 0;

    max-width: 680px;

    font-size: 13px;
    line-height: 1.4;

    color: var(--text-secondary);

    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.new-conversation-button {
    flex: 0 0 auto;

    min-height: 42px;

    padding: 0 16px;

    border: 1px solid var(--border-strong);
    border-radius: 12px;

    background: var(--surface);

    color: var(--text);
    font-size: 14px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background 0.18s ease,
        border-color 0.18s ease,
        transform 0.18s ease;
}

.new-conversation-button:hover {
    background: var(--surface-secondary);
    border-color: #b9c0cc;
}

.new-conversation-button:active {
    transform: scale(0.98);
}


/* =========================================================
   ÁREA DE MENSAGENS
   ========================================================= */

.messages {
    flex: 1;

    width: 100%;

    overflow-y: auto;
    overflow-x: hidden;

    padding: 36px 22px 26px;

    scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
    width: 8px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: #d0d5dd;
    border-radius: 20px;
}


/* =========================================================
   TELA INICIAL
   ========================================================= */

.welcome {
    max-width: 640px;

    margin: 12vh auto 0;

    padding: 34px;

    text-align: center;
}

.welcome-icon {
    width: 70px;
    height: 70px;

    display: flex;
    align-items: center;
    justify-content: center;

    margin: 0 auto 18px;

    border-radius: 22px;

    background: var(--primary-soft);

    font-size: 34px;
}

.welcome h2 {
    margin: 0 0 10px;

    font-size: 28px;
    line-height: 1.2;
    font-weight: 700;

    color: var(--text);
}

.welcome p {
    max-width: 520px;

    margin: 0 auto;

    font-size: 15px;
    line-height: 1.65;

    color: var(--text-secondary);
}


/* =========================================================
   MENSAGENS
   ========================================================= */

.message-row {
    width: 100%;
    max-width: var(--max-chat-width);

    margin: 0 auto 24px;

    display: flex;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.assistant {
    justify-content: flex-start;
}

.message {
    position: relative;

    max-width: 82%;

    font-size: 15px;
    line-height: 1.7;

    word-break: break-word;
}

.message-user {
    padding: 13px 17px;

    border-radius:
        18px
        18px
        5px
        18px;

    background: var(--user-bubble);
    color: var(--user-text);

    box-shadow: var(--shadow-sm);
}

.message-assistant {
    width: min(100%, 820px);

    padding: 20px 22px;

    border: 1px solid var(--border);
    border-radius:
        18px
        18px
        18px
        5px;

    background: var(--assistant-bubble);

    color: var(--text);

    box-shadow: var(--shadow-sm);
}


/* =========================================================
   CONTEÚDO FORMATADO DAS RESPOSTAS
   ========================================================= */

.message-assistant p {
    margin:
        0
        0
        14px;
}

.message-assistant p:last-child {
    margin-bottom: 0;
}

.message-assistant h1,
.message-assistant h2,
.message-assistant h3,
.message-assistant h4 {
    margin:
        24px
        0
        10px;

    color: var(--text);

    line-height: 1.3;
}

.message-assistant h1 {
    font-size: 22px;
}

.message-assistant h2 {
    font-size: 19px;
}

.message-assistant h3 {
    font-size: 17px;
}

.message-assistant h4 {
    font-size: 15px;
}

.message-assistant ul,
.message-assistant ol {
    margin:
        10px
        0
        16px;

    padding-left: 24px;
}

.message-assistant li {
    margin-bottom: 7px;
}

.message-assistant strong {
    font-weight: 700;
}

.message-assistant blockquote {
    margin: 16px 0;

    padding:
        10px
        15px;

    border-left: 4px solid var(--primary);

    background: var(--primary-soft);

    border-radius:
        0
        10px
        10px
        0;

    color: #344054;
}

.message-assistant code {
    padding: 2px 6px;

    border-radius: 6px;

    background: #f2f4f7;

    font-family:
        Consolas,
        Monaco,
        monospace;

    font-size: 13px;
}

.message-assistant pre {
    overflow-x: auto;

    margin: 16px 0;

    padding: 16px;

    border-radius: 12px;

    background: #101828;
    color: #f9fafb;

    line-height: 1.55;
}

.message-assistant pre code {
    padding: 0;

    background: transparent;
    color: inherit;
}


/* =========================================================
   TABELAS
   ========================================================= */

.message-assistant table {
    width: 100%;

    margin: 18px 0;

    border-collapse: collapse;

    overflow: hidden;

    border: 1px solid var(--border);
    border-radius: 10px;

    font-size: 14px;
}

.message-assistant th,
.message-assistant td {
    padding: 11px 12px;

    border:
        1px solid
        var(--border);

    text-align: left;
    vertical-align: top;
}

.message-assistant th {
    background: #f8f9fc;

    font-weight: 700;
}


/* =========================================================
   AÇÕES DAS RESPOSTAS
   ========================================================= */

.message-actions {
    display: flex;
    align-items: center;
    gap: 8px;

    margin-top: 14px;
}

.copy-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    padding: 7px 10px;

    border: 0;
    border-radius: 8px;

    background: transparent;

    color: var(--text-secondary);

    font-size: 12px;
    font-weight: 600;

    cursor: pointer;
}

.copy-button:hover {
    background: var(--surface-secondary);
    color: var(--text);
}


/* =========================================================
   INDICADOR "ANALISANDO"
   ========================================================= */

.typing-message {
    display: inline-flex;
    align-items: center;
    gap: 5px;

    padding: 14px 18px;

    border: 1px solid var(--border);
    border-radius:
        18px
        18px
        18px
        5px;

    background: var(--surface);

    box-shadow: var(--shadow-sm);
}

.typing-dot {
    width: 7px;
    height: 7px;

    border-radius: 50%;

    background: #98a2b3;

    animation:
        typingBounce
        1.15s
        infinite
        ease-in-out;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.14s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.28s;
}

@keyframes typingBounce {
    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.45;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}


/* =========================================================
   ARQUIVO SELECIONADO
   ========================================================= */

.file-preview {
    width: calc(100% - 40px);
    max-width: var(--max-chat-width);

    margin: 0 auto 8px;

    padding:
        9px
        12px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--surface);

    font-size: 13px;
    color: var(--text-secondary);

    box-shadow: var(--shadow-sm);
}

.file-preview > div {
    min-width: 0;

    display: flex;
    align-items: center;
    gap: 8px;
}

#file-name {
    display: block;

    max-width: 600px;

    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.file-preview button {
    border: 0;

    background: transparent;

    color: var(--text-secondary);

    font-size: 22px;

    cursor: pointer;
}

.file-preview button:hover {
    color: var(--danger);
}

.hidden {
    display: none !important;
}


/* =========================================================
   ÁREA DE DIGITAÇÃO
   ========================================================= */

.composer-wrapper {
    width: 100%;

    padding:
        10px
        20px
        14px;

    background:
        linear-gradient(
            180deg,
            rgba(247, 248, 252, 0),
            rgba(247, 248, 252, 0.96) 15%,
            rgba(247, 248, 252, 1) 45%
        );
}

.composer {
    width: 100%;
    max-width: var(--max-chat-width);

    min-height: 62px;

    margin: 0 auto;

    padding:
        8px
        9px;

    display: flex;
    align-items: flex-end;
    gap: 8px;

    border:
        1px solid
        var(--border-strong);

    border-radius: 18px;

    background: var(--surface);

    box-shadow: var(--shadow);
}

.composer:focus-within {
    border-color: #a5b4fc;

    box-shadow:
        0 0 0 3px rgba(99, 102, 241, 0.08),
        var(--shadow);
}

#message-input {
    flex: 1;

    max-height: 170px;
    min-height: 42px;

    padding:
        11px
        4px;

    resize: none;

    border: 0;
    outline: 0;

    background: transparent;

    color: var(--text);

    font-family: inherit;
    font-size: 15px;
    line-height: 1.45;
}

#message-input::placeholder {
    color: var(--text-light);
}

.icon-button,
.send-button {
    width: 44px;
    height: 44px;

    flex: 0 0 44px;

    display: flex;
    align-items: center;
    justify-content: center;

    border: 0;
    border-radius: 12px;

    cursor: pointer;

    transition:
        background 0.18s ease,
        transform 0.18s ease;
}

.icon-button {
    background: transparent;

    color: var(--text-secondary);

    font-size: 20px;
}

.icon-button:hover {
    background: var(--surface-secondary);
}

.send-button {
    background: var(--primary);

    color: white;

    font-size: 19px;
}

.send-button:hover {
    background: var(--primary-hover);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    cursor: not-allowed;

    opacity: 0.45;
}


/* =========================================================
   TEXTO ABAIXO DO CAMPO
   ========================================================= */

.composer-note {
    max-width: var(--max-chat-width);

    margin:
        8px
        auto
        0;

    padding: 0 10px;

    text-align: center;

    color: var(--text-light);

    font-size: 11px;
    line-height: 1.4;
}


/* =========================================================
   ARQUIVOS DENTRO DE UMA MENSAGEM
   ========================================================= */

.message-file {
    margin-bottom: 10px;

    padding:
        9px
        11px;

    display: flex;
    align-items: center;
    gap: 8px;

    border-radius: 10px;

    background:
        rgba(255, 255, 255, 0.14);

    font-size: 12px;
}

.message-assistant .message-file {
    background: var(--surface-secondary);
}


/* =========================================================
   ERROS
   ========================================================= */

.error-message {
    max-width: var(--max-chat-width);

    margin:
        10px
        auto;

    padding:
        12px
        14px;

    border:
        1px solid
        #fecdca;

    border-radius: 10px;

    background: #fef3f2;

    color: #b42318;

    font-size: 13px;
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 720px) {

    .chat-header {
        min-height: 72px;

        padding:
            11px
            14px;
    }

    .assistant-icon {
        width: 42px;
        height: 42px;

        flex-basis: 42px;

        border-radius: 12px;

        font-size: 21px;
    }

    .assistant-info h1 {
        font-size: 15px;
    }

    .assistant-info p {
        display: none;
    }

    .new-conversation-button {
        min-height: 38px;

        padding: 0 11px;

        font-size: 12px;
    }

    .messages {
        padding:
            24px
            12px
            20px;
    }

    .welcome {
        margin-top: 8vh;

        padding:
            24px
            12px;
    }

    .welcome h2 {
        font-size: 23px;
    }

    .message {
        max-width: 92%;
    }

    .message-assistant {
        padding:
            16px
            16px;
    }

    .composer-wrapper {
        padding:
            8px
            10px
            11px;
    }

    .composer {
        min-height: 58px;

        border-radius: 16px;
    }

    .icon-button,
    .send-button {
        width: 40px;
        height: 40px;

        flex-basis: 40px;
    }

    .composer-note {
        font-size: 10px;
    }

    .message-assistant table {
        display: block;

        overflow-x: auto;
    }
}


/* =========================================================
   TELAS MUITO PEQUENAS
   ========================================================= */

@media (max-width: 420px) {

    .new-conversation-button {
        font-size: 0;
    }

    .new-conversation-button::after {
        content: "+";

        font-size: 21px;
        font-weight: 500;
    }

    .assistant-info {
        gap: 9px;
    }

    .message {
        max-width: 96%;
    }
}