:root {
    --primary-color: #005f73;
    --secondary-color: #0a9396;
    --background-color: #f8f9fa;
    --surface-color: #ffffff;
    --text-color: #343a40;
    --light-gray: #dee2e6;
    --font-family: 'Inter', sans-serif;
}

/* html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
} */

/* === CONTAINER PRINCIPAL === */
#app-container {
    width: 100%;
    /* height: 100%; */
    min-height: 100vh;
    background-color: var(--surface-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === CABEÇALHO === */
.app-header {
    background-color: var(--primary-color);
    color: white;
    padding: 1.2rem;
    text-align: center;
    border-bottom: 4px solid var(--secondary-color);
     
    justify-content: center; 
    align-items: center; 
    position: relative; 
}

.app-header.chat-header {
    display: flex;
}

.app-header h1 {
    margin: 0;
    font-size: 1.5rem;
}

.app-header .header-highlight {
    font-weight: 900;
    color: #94d2bd;
}

.app-header p {
    margin: 0.25rem 0 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* === CHAT === */
.chat-page{
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
}

#chat-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    /* padding-bottom: 120px; */
}

#chat-messages {
    /* flex-grow: 1; */
    padding-bottom: 200px;
}

/* BOLHAS DE MENSAGENS */
.message {
    display: flex;
    margin-bottom: 1rem;
    max-width: 85%;
    align-items: flex-start;
}

.message .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 0.8rem;
    flex-shrink: 0;
}

.message .text {
    padding: 0.8rem 1rem;
    border-radius: 18px;
    line-height: 1.6;
}

/* Mensagem da IA */
.ia-message {
    align-self: flex-start;
}
.ia-message .avatar {
    background-color: var(--primary-color);
    color: white;
}
.ia-message .text {
    background-color: #e9ecef;
    border-top-left-radius: 0;
}

/* Mensagem do usuário */
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
}
.user-message .avatar {
    background-color: var(--secondary-color);
    color: white;
    margin-left: 0.8rem;
}
.user-message .text {
    background-color: var(--primary-color);
    color: white;
    border-top-right-radius: 0;
}

/* INPUT DO CHAT */
#chat-input-container {
    padding: 1rem;
    background-color: #f1f3f5;
    border-top: 1px solid var(--light-gray);
    display: flex;
    justify-content: center;
    flex-direction: column;
    
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    align-items: center;
}


.input-wrapper {
    display: flex;
    align-items: center;
    background-color: white;
    border-radius: 25px;
    padding: 0.3rem;
    border: 1px solid var(--light-gray);
    width: 75%;
}

.input-wrapper button {
  background-color: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.7rem;
  transition: transform 0.2s;
}

#message-input {
    flex-grow: 1;
    border: none;
    outline: none;
    padding: 0.8rem 1rem;
    background: transparent;
    resize: none;
    font-family: var(--font-family);
    font-size: 1rem;
    max-height: 120px;
    overflow-y: auto;
}

#send-button {
  background-color: transparent;
  color: var(--secondary-color);
}

#send-button:hover {
  transform: scale(1.1); 
}


.hidden {
display: none !important;
}

#loading-indicator {
display: flex;
align-items: center;
justify-content: center; 
padding: 10px;
margin: 10px auto;
background-color: #f0f4f8;
border-radius: 8px;
width: fit-content;
color: #555;
}

.spinner {
width: 20px;
height: 20px;
border: 3px solid rgba(0, 0, 0, 0.1);
border-top-color: #007bff;
border-radius: 50%; 
animation: spin 1s linear infinite;
margin-right: 10px;
}

@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

/* Estilo para o botão de anexo (o clipe de papel) */
#attach-file-button {
  font-size: 1.5rem;
  color: var(--text-color); 
}

#attach-file-button:hover {
  transform: scale(1.1);
  color: var(--primary-color);
}

.message-bubble {
    background-color: #e6e6e6; 
    padding: 10px 15px;
    border-radius: 20px;
    max-width: 70%;
    margin: 5px;
    word-wrap: break-word; 
}

.bot-message {
    align-self: flex-start;
}

/* Estilo para o preview do arquivo */
/* Container dos arquivos anexados */
#file-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    max-height: 120px; /* Limita a altura do preview */
    overflow-y: auto; /* Scroll se muitos arquivos */
}

/* Estilo de cada arquivo em preview */
#file-preview-container .file-item {
    background: #e9ecef;
    border-radius: 8px;
    padding: 0.3rem 0.6rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* Botão para remover arquivo */
#file-preview-container .remove-file {
    cursor: pointer;
    font-weight: bold;
    color: #d00000;
}

.file-pill {
    background: #e9ecef;
    border-radius: 20px;
    padding: 0.3rem 0.8rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.file-pill span {
white-space: nowrap; /* Impede que o nome do ficheiro quebre a linha */
overflow: hidden; /* Esconde o excesso de texto */
text-overflow: ellipsis; /* Adiciona "..." ao final de nomes de ficheiro longos \*/
}

.file-pill .remove-file-btn {
    background: transparent;
    border: none;
    font-weight: bold;
    color: #d00000;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}


.file-pill .remove-file-btn:hover {
color: #343a40;
}

@keyframes fadeIn {
from {
opacity: 0;
transform: scale(0.9);
}
to {
opacity: 1;
transform: scale(1);
}
}

/* BOTÃO FLUTUANTE LIMPAR CHAT */
#clear-chat-button {
    position: absolute;
    bottom: 12px;
    right: 5%;
    
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 17px 19px;
    font-size: 0.9em;
    font-weight: 600;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s;
}

#clear-chat-button:hover {
    background-color: var(--primary-color);
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}

/* === Pop-up === */

#confirmation-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.popup-content {
    background-color: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.popup-content p {
    margin-bottom: 15px;
    color: var(--text-color);
}

.popup-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 20px;
}

.popup-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: background-color 0.3s;
}

#confirm-yes {
    background-color: var(--primary-color);
    color: white;
}

#confirm-no {
    background-color: #e0e0e0;
    color: var(--text-color);
}

/* === LOGIN PAGE === */
.page-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background-color:white
}

.login-page {
    margin: 0;
    padding: 0;
    width: 100%;
    min-height: 100vh; /* Permite que a página de login role */
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
}

.login-container {
    width: 100%;
    height: 100%;
    padding: 2rem;
    background: var(--surface-color);
    border-radius: 0;
    box-shadow: none;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-main {
    text-align: center;
    width: 100%;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: #6c757d;
    margin-bottom: 2rem;
}

/* Botão de usuário do Clerk */
#user-button-container {
  position: absolute; 
  right: 30px;
  transform: scale(1.5);
}

/* ERROS LOGIN */
.login-error {
    color: #991b1b; 
    background-color: #fee2e2;
    border: 1px solid #fca5a5;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    text-align: center;
}

#sign-in-button-container .cl-root-box {
    margin: 0 auto;
}

/* === RESPONSIVIDADE (MOBILE) === */
@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }

    .app-header h1 {
        font-size: 1.2rem;
    }

    #chat-container {
        padding: 0.8rem;
    }

    .message {
        max-width: 100%;
    }

    .message .avatar {
        width: 32px;
        height: 32px;
        margin-right: 0.5rem;
    }

    .message .text {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }

    #message-input {
        font-size: 0.9rem;
        padding: 0.6rem 0.8rem;
    }

    .login-container {
        padding: 1rem;
    }

    .login-title {
        font-size: 1.2rem;
    }

    .login-subtitle {
        font-size: 0.9rem;
    }

    #clear-chat-button {
        width: 50px;
        height: 50px;
        bottom: 20px;
        right: 20px;
    }
}
