/* Chat page — extends styles.css, reuses the same palette & shell */

/* Active nav link */
.nav-link.active {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Turn the right panel into a fixed-height flex column:
   header (static) + messages (scroll) + input (pinned bottom) */
.chat-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden; /* inner .chat-messages handles scrolling */
    padding: 30px 35px;
}

.chat-header {
    flex: 0 0 auto;
    margin-bottom: 18px;
}

.chat-header h2 {
    margin-bottom: 8px;
}

.chat-subtitle {
    font-size: 0.82rem;
    color: #666;
    margin-bottom: 0;
    line-height: 1.5;
}

.chat-disclaimer {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    color: #999;
}

.chat-disclaimer a {
    color: var(--dark-blue);
    text-decoration: underline;
}

/* Scrollable message list */
.chat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding-right: 10px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scrollbar-color: #ccc transparent;
    scrollbar-width: thin;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: #aaa;
}

/* Message bubbles */
.message {
    display: flex;
    max-width: 85%;
    font-size: 0.88rem;
    line-height: 1.55;
}

.message.user {
    align-self: flex-end;
}

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

.message .bubble {
    padding: 10px 14px;
    border-radius: 14px;
}

.message.user .bubble {
    background-color: var(--dark-blue);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant .bubble {
    background-color: #fff;
    color: #333;
    border: 1px solid #e2e2e2;
    border-bottom-left-radius: 4px;
}

/* Light markdown styling inside assistant bubbles */
.message .bubble p {
    font-size: inherit;
    margin-bottom: 8px;
}

.message .bubble p:last-child {
    margin-bottom: 0;
}

.message .bubble ul,
.message .bubble ol {
    margin: 6px 0 8px 20px;
}

.message .bubble li {
    margin-bottom: 4px;
}

.message .bubble a {
    color: var(--dark-blue);
    text-decoration: underline;
}

.message.user .bubble a {
    color: #fff;
}

.message .bubble code {
    background-color: rgba(26, 54, 93, 0.08);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}

.message .bubble strong {
    color: inherit;
}

/* Typing indicator */
.typing .bubble {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 12px 14px;
}

.typing .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background-color: #bbb;
    animation: typing-bounce 1.2s infinite ease-in-out;
}

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

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Error message */
.message.error .bubble {
    background-color: #fdf0f0;
    border: 1px solid #f0c6c6;
    color: #a33;
}

/* Suggested prompts */
.chat-suggestions {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 14px 0 12px;
}

.chat-suggestions.hidden {
    display: none;
}

.suggestion-chip {
    font-family: var(--font-family);
    font-size: 0.78rem;
    color: var(--dark-blue);
    background-color: #fff;
    border: 1px solid #d4d8df;
    border-radius: 16px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.suggestion-chip:hover {
    background-color: #eef1f6;
    border-color: var(--dark-blue);
}

/* Input row */
.chat-input-row {
    flex: 0 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    border-top: 1px solid #e2e2e2;
    padding-top: 14px;
}

.chat-input {
    flex: 1 1 auto;
    font-family: var(--font-family);
    font-size: 0.88rem;
    line-height: 1.5;
    color: #333;
    background-color: #fff;
    border: 1px solid #d4d8df;
    border-radius: 14px;
    padding: 10px 14px;
    resize: none;
    max-height: 140px;
    overflow-y: auto;
}

.chat-input:focus {
    outline: none;
    border-color: var(--dark-blue);
}

.chat-send {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background-color: var(--dark-blue);
    color: #fff;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-send:hover:not(:disabled) {
    opacity: 0.85;
}

.chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Live handoff — Mohammed's (human) messages */
.message.host {
    align-self: flex-start;
    flex-direction: column;
    max-width: 85%;
}

.message.host .msg-name {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--dark-blue);
    margin-bottom: 3px;
    padding-left: 2px;
}

.message.host .bubble {
    background-color: #eef1f6;
    color: #333;
    border: 1px solid #d4d8df;
    border-bottom-left-radius: 4px;
}

/* Centered status lines ("Mohammed has joined…") */
.chat-system {
    align-self: center;
    max-width: 90%;
    text-align: center;
    font-size: 0.74rem;
    color: #777;
    background-color: #f0f0f0;
    padding: 5px 12px;
    border-radius: 12px;
}

/* Confirm card for looping in Mohammed */
.handoff-card {
    align-self: flex-start;
    max-width: 85%;
    background-color: #fff;
    border: 1px solid #d4d8df;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    padding: 12px 14px;
}

.handoff-card p {
    font-size: 0.85rem;
    margin: 0 0 10px;
    color: #333;
}

.handoff-name {
    display: block;
    width: 100%;
    font-family: var(--font-family);
    font-size: 0.8rem;
    border: 1px solid #d4d8df;
    border-radius: 10px;
    padding: 7px 10px;
    margin-bottom: 10px;
}

.handoff-name:focus {
    outline: none;
    border-color: var(--dark-blue);
}

.handoff-actions {
    display: flex;
    gap: 8px;
}

.handoff-confirm,
.handoff-decline {
    font-family: var(--font-family);
    font-size: 0.8rem;
    border-radius: 16px;
    padding: 6px 14px;
    cursor: pointer;
    border: 1px solid #d4d8df;
    transition: opacity 0.15s, background-color 0.15s;
}

.handoff-confirm {
    background-color: var(--dark-blue);
    color: #fff;
    border-color: var(--dark-blue);
}

.handoff-confirm:hover { opacity: 0.85; }

.handoff-decline {
    background-color: #fff;
    color: #555;
}

.handoff-decline:hover { background-color: #f0f0f0; }

/* Mobile */
@media (max-width: 768px) {
    .chat-panel {
        padding: 20px;
        min-height: 70vh;
    }

    .message {
        max-width: 90%;
    }
}
