:root {
    --bg-color: #041010;
    --text-primary: #E6E8E6;
    --text-secondary: #a0a0a0;
    --brand-green: #6FB03A;
    --brand-blue: #31A8A8;
    --brand-gradient: linear-gradient(135deg, var(--brand-green), var(--brand-blue));
    --msg-bot-bg: #0f1315;
    --msg-bot-border: #1a2225;
    --msg-user-bg: var(--brand-gradient);
    --input-bg: #0f1315;
    --input-border: #1a2225;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    min-height: 100vh;
    overflow-x: hidden;
}

.chat-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

.chat-header {
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--msg-bot-border);
    background-color: rgba(4, 16, 16, 0.8);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 10;
    gap: 20px;
}

.brand-logo {
    height: 100px;
    width: auto;
}

.chat-history {
    flex-grow: 1;
    padding: 30px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: transparent;
}

.chat-history::-webkit-scrollbar-thumb {
    background: var(--msg-bot-border);
    border-radius: 4px;
}

.message-wrapper {
    display: flex;
    width: 100%;
    animation: fadeIn 0.4s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-wrapper.bot {
    justify-content: flex-start;
}

.message-wrapper.user {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-wrapper.bot .message-bubble {
    background-color: var(--msg-bot-bg);
    border: 1px solid var(--msg-bot-border);
    border-bottom-left-radius: 4px;
    color: var(--text-primary);
}

.message-wrapper.user .message-bubble {
    background: var(--brand-gradient);
    border-bottom-right-radius: 4px;
    color: #ffffff;
    font-weight: 500;
}

.input-container {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
    width: 100%;
    opacity: 0;
    transition: opacity 0.3s ease;
    order: 999;
    /* Garante que fique sempre no final da lista de mensagens */
}

.input-container.visible {
    opacity: 1;
}

.chat-form {
    display: flex;
    gap: 8px;
    background-color: #555555;
    /* Cor cinza parecida com a referência */
    border: 1px solid #444;
    border-radius: 8px;
    padding: 6px;
    max-width: 90%;
    min-width: 380px;
}

.chat-form:focus-within {
    border-color: #777;
}

.user-input {
    flex-grow: 1;
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    padding-left: 10px;
    width: 100%;
}

.user-input::placeholder {
    color: #aaaaaa;
}

.user-input:disabled {
    cursor: not-allowed;
}

.send-button {
    background: #ffffff;
    border: none;
    border-radius: 6px;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--brand-green);
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.send-button:hover:not(:disabled) {
    transform: scale(1.05);
}

.send-button:disabled {
    background: #cccccc;
    color: #666666;
    cursor: not-allowed;
}

/* Button Choices */
.button-choices {
    display: flex;
    flex-direction: row;
    justify-content: center;
    width: 100%;
    gap: 16px;
}

.choice-btn {
    background-color: #555555;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    min-width: 100px;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.choice-btn:hover {
    background-color: #666666;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
    background-color: var(--msg-bot-bg);
    border: 1px solid var(--msg-bot-border);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* Custom Inputs for Select, Date and Checkbox */
.custom-input-container, .custom-checkbox-container {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
    justify-content: flex-end;
}

.custom-select, .custom-date {
    flex-grow: 1;
    background-color: #555555;
    color: white;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 10px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
    max-width: 70%;
}

.custom-select:focus, .custom-date:focus {
    border-color: #777;
}

.send-custom-btn {
    padding: 10px 20px;
    min-width: auto;
}

.send-custom-btn:disabled {
    background-color: #444;
    color: #888;
    cursor: not-allowed;
}

.custom-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #555555;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    flex-grow: 1;
    max-width: 70%;
}

.custom-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

@keyframes typing {

    0%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    50% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .chat-header {
        flex-direction: row;
        gap: 10px;
    }

    .brand-logo {
        height: 80px;
    }

    .chat-history {
        padding: 20px 15px;
    }

    .message-bubble {
        max-width: 90%;
        font-size: 0.95rem;
    }

    .chat-form {
        min-width: unset;
        width: 100%;
        max-width: 100%;
    }

    .button-choices {
        flex-direction: column;
        align-items: stretch;
    }

    .choice-btn {
        width: 100%;
    }
}