:root {
    --header-height: 80px; /* Ajuste conforme a altura real do seu cabeçalho */
    --input-height: 100px; /* Ajuste conforme a altura real do seu input-container */
}

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f1e8 0%, #e6ddd2 100%);
    overflow: hidden;
}

.chat-container {
    max-width: 900px;
    margin: 0 auto;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    background: white;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.2);
}

.chat-header {
    background: white;
    color: #333;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-content {
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat-logo {
    width: 300px; /* Tamanho do logo */
    height: 90px;
    object-fit: cover; /* Garante que a imagem preencha o espaço sem distorcer */
    object-position: center; /* Centraliza a imagem */
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-buttons {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    gap: 0.5rem;
}

.reset-btn,
.help-btn {
    background: linear-gradient(135deg, #8b7355 0%, #6b5e4c 100%);
    border: none;
    color: white; /* Garante que os ícones SVG sejam brancos */
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
}

.reset-btn:hover {
    background: #a89075; /* Um tom mais claro para o hover */
    transform: rotate(180deg); /* Gira no hover */
}

.help-btn:hover {
    background: #a89075; /* Um tom mais claro para o hover */
    transform: scale(1.1);
}

.messages-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1.5rem;
    padding-top: calc(1.5rem + var(--header-height)); /* Compensar o cabeçalho fixo */
    padding-bottom: calc(1.5rem + var(--input-height)); /* Compensar o input fixo */
    background: #f7f7f8;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    padding: 2rem 1.5rem;
    color: #6b5e4c;
    max-width: 700px;
    margin: 0 auto;
}

.welcome-message h2 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.welcome-message p {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
}

.welcome-description {
    text-align: justify;
}

.message {
    margin-bottom: 1rem;
    display: flex;
    animation: fadeIn 0.3s ease;
    position: relative;
}

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

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

.message-content {
    max-width: 70%;
    padding: 1rem 1.25rem;
    border-radius: 1.25rem;
    word-wrap: break-word;
}

.message.user .message-content {
    background: linear-gradient(135deg, #8b7355 0%, #6b5e4c 100%);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 0.25rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Estilos para markdown */
.message-content h1,
.message-content h2,
.message-content h3 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.message-content p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.message-content ul,
.message-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin: 0.25rem 0;
    line-height: 1.6;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.message-content pre {
    background: #2d2d2d;
    color: #f8f8f2;
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.message-content blockquote {
    border-left: 4px solid #8b7355;
    padding-left: 1rem;
    margin: 0.5rem 0;
    color: #666;
}

.message-content a {
    color: #6b5e4c;
    text-decoration: underline;
}

.message.user .message-content a {
    color: white;
}

.input-container {
    padding: 1rem 1.5rem;
    background: white;
    border-top: 1px solid #e0e0e0;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
    background: #f7f7f8;
    border-radius: 1.5rem;
    padding: 0.5rem 0.75rem;
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 1rem;
    font-family: inherit;
    padding: 0.75rem;
    outline: none;
    max-height: 150px;
    overflow-y: auto;
}

/* Bolha de digitação dentro das mensagens */
.typing-bubble {
    display: flex;
    gap: 0.25rem;
    padding: 1rem 1.25rem !important;
    align-items: center;
    justify-content: flex-start;
}

.typing-bubble span {
    width: 8px;
    height: 8px;
    background: #6b5e4c;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

.typing-bubble span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-bubble span:nth-child(2) {
    animation-delay: -0.16s;
}

.send-btn {
    background: linear-gradient(135deg, #8b7355 0%, #6b5e4c 100%);
    border: none;
    color: white;
    padding: 0.75rem;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    width: 45px;
    height: 45px;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin: 1rem 0;
    border-left: 4px solid #c33;
}

/* Responsividade para mobile */
@media (max-width: 768px) {
    .chat-container {
        max-width: 100%;
        border-radius: 0;
    }

    .chat-header {
        padding: 1rem;
    }

    .chat-header h1 {
        font-size: 1.25rem;
    }

    .messages-container {
        padding: 1rem;
    }

    .message-content {
        max-width: 85%;
        font-size: 0.95rem;
    }

    .welcome-message {
        padding: 2rem 1rem;
    }

    .welcome-message h2 {
        font-size: 1.5rem;
    }

    .input-container {
        padding: 0.75rem 1rem;
    }
}

/* Scrollbar customizada */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-container::-webkit-scrollbar-thumb {
    background: #8b7355;
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: #a89075;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(139, 115, 85, 0.1);
    border: none;
    color: #6b5e4c;
    padding: 0.5rem;
    border-radius: 0.5rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 32px;
    height: 32px;
}

.message.assistant:not(.welcome-message):hover .copy-btn {
    display: flex;
}

.copy-btn:hover {
    background: rgba(139, 115, 85, 0.2);
    transform: scale(1.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: slideUp 0.3s ease;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-modal {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-modal:hover {
    background: #f0f0f0;
    color: #333;
}



.modal-content h2 {
    color: #6b5e4c;
    margin-bottom: 1rem;
    font-size: 1.5rem;
}

.modal-description {
    color: #666;
    line-height: 1.6;
    margin-bottom: 1.5rem;
    text-align: justify;
}

.modal-credits {
    border-top: 1px solid #e0e0e0;
    padding-top: 1rem;
    text-align: center;
}

.modal-credits p {
    color: #333;
    margin-bottom: 0.5rem;
}

.modal-credits a {
    color: #6b5e4c;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.modal-credits a:hover {
    text-decoration: underline;
}

/* Disclaimer */
.disclaimer {
    color: #6b5e4c;
    font-style: italic;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    padding: 0.75rem;
    border: 1px solid #a89075;
    border-radius: 0.5rem;
    background-color: #f9f6f0;
    text-align: center;
}
