/* Basic Reset & Font */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

.container {
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 800px;
    /* Wider default */
    height: 85vh;
    /* Responsive height */
    max-width: 95vw;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

h1 {
    text-align: left;
    color: #444;
    margin: 0;
    font-size: 1.5rem;
}

#user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.85rem;
}

#username {
    font-weight: bold;
    color: #333;
}

.logout-link {
    color: #0078d4;
    text-decoration: none;
    font-size: 0.8rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #ddd;
}

/* Loan Context Bar */
#loan-context {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

#loan-guid-input {
    flex-grow: 1;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Login Container Styling */
#login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    text-align: center;
}

#login-container p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 25px;
}

#login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    color: #3c4043;
    border: 1px solid #dadce0;
    border-radius: 4px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Google Sans', Roboto, Arial, sans-serif;
    letter-spacing: 0.25px;
    cursor: pointer;
    box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
    transition: background-color 0.2s, box-shadow 0.2s;
}

#login-btn:hover {
    background-color: #f8f9fa;
    box-shadow: 0 1px 3px 0 rgba(60,64,67,0.3), 0 4px 8px 3px rgba(60,64,67,0.15);
}

#login-btn svg {
    margin-right: 12px;
    width: 20px;
    height: 20px;
}

#app-container {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
}

/* Chat Container */
#chat-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
}

.agent-message {
    align-self: flex-start;
    background-color: #e8e8e8;
    color: #333;
    border-bottom-left-radius: 2px;
}

.user-message {
    align-self: flex-end;
    background-color: #0078d4;
    /* Encompass Blue-ish */
    color: white;
    border-bottom-right-radius: 2px;
}

/* Input Area */
#input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

textarea#chat-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    max-height: 100px;
    overflow-y: auto;
}

textarea#chat-input:focus {
    outline: none;
    border-color: #0078d4;
}

button#send-btn {
    padding: 10px 20px;
    background-color: #0078d4;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    height: 40px;
    /* Match textarea default roughly */
}

button#send-btn:hover {
    background-color: #005a9e;
}

button#send-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Typing Indicator Animation */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background-color: #e8e8e8;
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    align-self: flex-start;
    width: fit-content;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: #666;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Markdown-like styling for agent responses */
.agent-message p {
    margin: 0 0 8px 0;
}

.agent-message p:last-child {
    margin: 0;
}

.agent-message ul,
.agent-message ol {
    margin: 8px 0;
    padding-left: 20px;
}

.agent-message code {
    background-color: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

/* Agent Tooltip Tags */
.agent-tag {
    font-weight: bold;
    color: #0078d4;
    cursor: help;
    background-color: rgba(0, 120, 212, 0.1);
    padding: 2px 5px;
    border-radius: 4px;
    border: 1px dashed #0078d4;
    transition: background-color 0.2s;
}

.agent-tag:hover {
    background-color: rgba(0, 120, 212, 0.2);
}

.user-message .agent-tag {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.8);
}

.user-message .agent-tag:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Autocomplete Menu */
.autocomplete-menu {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 5px;
    background-color: white;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 200px;
    max-height: 150px;
    overflow-y: auto;
    z-index: 1000;
}

.autocomplete-item {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #333;
    transition: background-color 0.2s;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #f0f0f0;
}