/* =========================
   General Page & Setup
   ========================= */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f4f7fb;
    color: #222;
}

/* =========================
   Homepage Elements
   ========================= */
.homepage {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
}

.homepage h1 {
    font-size: 42px;
    margin-bottom: 10px;
}

.homepage p {
    color: #666;
    margin-bottom: 25px;
}

.start-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #169ec5; /* Updated to custom teal */
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(22, 158, 197, 0.3); /* Themed shadow */
    transition: transform 0.2s, background-color 0.2s;
    cursor: move; 
    touch-action: none; 
}

.start-button:hover {
    transform: scale(1.1);
    background-color: #117b99; /* Darker teal variant */
}

/* =========================
   Chatbot Panel Window
   ========================= */
.chatbot {
    position: fixed;
    right: 25px;
    bottom: 25px;
    width: 360px;
    height: 520px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 1000;
}

/* =========================
   Chat Window Header
   ========================= */
.chat-header {
    background: #169ec5; /* Updated to custom teal */
    color: white;
    padding: 16px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer; 
}

.chat-header h2 {
    color: white;
    margin: 0;
    font-size: 18px;
}

.chat-header span {
    font-size: 12px;
    color: #e2f5fa; /* Softened light teal contrast text */
}

.close-button {
    background: transparent;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

/* =========================
   Conversation Messages Stream
   ========================= */
.messages {
    flex: 1;
    padding: 18px;
    overflow-y: auto;
    gap: 10px;
    background: #f8fafc;
}

.message {
    max-width: 80%;
    padding: 11px 14px;
    margin-bottom: 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.bot-message {
    background: #e5e7eb;
    color: #222;
    border-bottom-left-radius: 4px;
}

.user-message {
    background: #169ec5; /* Updated to custom teal */
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

/* =========================
   Bottom Input Layout Section
   ========================= */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.chat-input-area input {
    flex: 1;
    min-width: 0;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    padding: 11px 12px;
    outline: none;
    font-size: 14px;
}

.chat-input-area input:focus {
    border-color: #169ec5; /* Updated focus border */
}

.chat-input-area button {
    border: none;
    background: #169ec5; /* Updated to custom teal */
    color: white;
    padding: 0 16px;
    border-radius: 9px;
    cursor: pointer;
}

.chat-input-area button:hover {
    background: #117b99; /* Darker teal variant */
}

/* Flashes input border red when backend character validation fails */
.chat-input-area input.input-error {
    border-color: #dc3545 !important;
    background-color: #fff5f5;
    box-shadow: 0 0 5px rgba(220, 53, 69, 0.3);
    transition: all 0.15s ease-in-out;
}

/* =========================
   Floating Icon & Launcher
   ========================= */
.chat-icon {
    position: fixed;
    right: 25px;
    bottom: 25px;
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 50%;
    background: #169ec5; /* Updated to custom teal */
    color: white;
    font-size: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(22, 158, 197, 0.4); /* Themed shadow */
    transition: transform 0.2s, background 0.2s;
    z-index: 999;
}

.chat-icon:hover {
    background: #117b99; /* Darker teal variant */
    transform: scale(1.08);
}

.chatbot.open ~ .chat-icon {
    display: none;
}

/* =========================
   Attention Bubble Badge
   ========================= */
#chatAttentionBadge {
    position: fixed;
    right: 25px;
    bottom: 95px; 
    background-color: #169ec5; /* Updated to custom teal */
    color: white;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 16px 16px 4px 16px; 
    box-shadow: 0 4px 15px rgba(22, 158, 197, 0.3); /* Themed shadow */
    z-index: 1001; 
    pointer-events: none;   
    animation: popBounceIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes popBounceIn {
    0% {
        transform: scale(0.6) translateY(15px);
        opacity: 0;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* ==================================================
   Chat Quick Menu Options & Internal Document Links
   ================================================== */
.chat-menu-container {
    display: flex;
    flex-direction: column;
    
    margin-bottom: 12px;
    max-width: 85%;
    animation: popBounceIn 0.3s ease-out forwards;
}

.chat-menu-btn {
    background-color: white;
    color: #169ec5; /* Updated to custom teal */
    border: 1px solid #169ec5; /* Updated border */
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    margin-top: 6px;
}

.chat-menu-btn:hover {
    background-color: #169ec5; /* Updated to custom teal */
    color: white;
}

/* Hyperlinks injected inside the responses */
.chat-link {
    color: #169ec5; /* Updated to custom teal */
    text-decoration: underline;
    font-weight: 500;
}

.chat-link:hover {
    color: #117b99; /* Darker teal variant */
}

/* =========================
   Responsive Media Queries
   ========================= */
@media (max-width: 500px) {
    .chatbot {
        right: 10px;
        bottom: 10px;
        width: calc(100% - 20px);
        height: 80vh;
    }
    .homepage h1 {
        font-size: 32px;
    }
}
/* ==================================================
   UPDATED MESSAGE ALIGNMENT RULES
   ================================================== */

/* Parent layout wrapper holding text + avatar side-by-side */
.message-wrapper {
    display: flex;
    align-items: flex-end; /* Keeps the avatar at the bottom edge of long text blocks */
    margin-bottom: 12px;
    width: 100%; /* Spans the full chat area width */
}

/* User alignment pushes right, Bot alignment stays left */
.user-wrapper {
    justify-content: flex-end; 
}

/* Base message structural layout block modification */
.message {
    max-width: 70%; /* Soft decrease to make reliable space for the avatar image */
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    margin-bottom: 0; /* Let message-wrapper handle spacing */
}

.user-message {
    background: #169ec5;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Profile Picture Layout Properties */
.chat-profile-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0; /* CRITICAL: Stops the image from getting squished by long text strings */
    border: 1px solid #d1d5db;
}

/* Username Label element details */
.chat-profile-name {
    display: block;
    font-size: 10px;
    font-weight: bold;
    color: rgba(255, 255, 255, 0.85); 
    margin-bottom: 2px;
}

.chat-text-content {
    margin: 0;
    padding: 0;
}
/* Bot-specific wrapper alignment to ensure it sits left */
.bot-wrapper {
    justify-content: flex-start;
}

/* Specific styling for the bot name tag inside the gray bubble */
.chat-profile-name.bot-name {
    color: #666666; /* Muted gray text color to look professional on the light gray background */
}

/* Gives the bot icon badge a unique accent border line if wanted */
.chat-profile-avatar.bot-avatar {
    border: 1px solid #169ec5; /* Accent teal border ring matching your theme */
}
