/* =================================================================
   MESSAGES V2 - "THE INTEGRATED APP" STYLES
   ================================================================= */

/* --- Full-Screen App Layout --- */
body.full-screen-app-layout {
    overflow: hidden; /* Prevents the main page from scrolling */
}

#react-chat-app-container {
    height: calc(100vh - 70px);
    height: calc(89svh - 70px); /* Better for mobile browser chrome */
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f7f7f7; /* A neutral background for the page */
    padding-top: 5px;
}

.vibrant-focus-chat {
    display: flex;
    height: 100%;
    width: 100%;
    background: #fff;
    max-width: 1100px; /* On desktop, it has a max-width */
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9e9e9;
}
   
/* ----------------------------------
   Conversation Sidebar (Left - 30%)
   ---------------------------------- */
.conversation-sidebar {
    width: 30%;
    min-width: 300px;
    border-right: 1px solid #e9e9e9;
    display: flex;
    flex-direction: column;
    background: #FEF6EF; /* Parchment */
}
.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e9e9e9;
    position: relative;
}
.sidebar-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
}
.conversation-list {
    overflow-y: auto;
    flex-grow: 1;
}
.no-conversations {
    padding: 20px;
    text-align: center;
    color: #888;
}
.conversation-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    border-bottom: 1px solid #e9e9e9;
    transition: background-color 0.2s ease;
}
.conversation-item:last-child { border-bottom: none; }
.conversation-item:hover { background-color: #F8EFE7; }
.conversation-item.active { background-color: #fff; }
.conversation-item .avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    margin-right: 15px;
    object-fit: cover;
}
.convo-details { overflow: hidden; }
.convo-name { font-weight: 700; font-size: 16px; color: #111; }
.convo-excerpt { margin: 2px 0 0; font-size: 14px; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread-dot {
    width: 10px;
    height: 10px;
    background-color: #F99D18; /* Ayekoo Orange */
    border-radius: 50%;
    margin-left: auto;
    align-self: center;
}

/* ----------------------------------
   Chat Window (Right - 70%)
   ---------------------------------- */
.chat-window {
    width: 70%;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.chat-window.empty {
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #999;
    background-color: #fdfdfd;
}
.empty-state img { max-width: 150px; opacity: 0.8; margin-bottom: 20px; }
.empty-state h2 { font-size: 20px; color: #333; font-weight: 600; margin:0 0 10px; }
.chat-header-link { display: block; text-decoration: none; color: inherit; }
.chat-header {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    border-bottom: 1px solid #e9e9e9;
    background-color: #fff;
    transition: background-color 0.2s ease;
}
.chat-header-link:hover .chat-header { background-color: #f9f9f9; }
.chat-header .avatar { width: 44px; height: 44px; border-radius: 50%; margin-right: 15px; object-fit: cover; }
.chat-header h3 { margin: 0; font-size: 18px; font-weight: 700; }
.message-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 25px;
}
.message-bubble-wrapper {
    display: flex;
    flex-direction: column;
    margin-bottom: 18px;
    max-width: 95%;
}
.message-bubble {
    padding: 14px 20px;
    border-radius: 25px; /* Fully rounded "pill" shape */
    font-size: 16px;
    line-height: 1.5;
}
.message-bubble p { margin: 0; }
.message-timestamp { font-size: 12px; color: #999; margin-top: 6px; }
.message-bubble-wrapper.sent {
    align-self: flex-end; /* Pushes the whole wrapper to the right */
    align-items: flex-end; /* Aligns the timestamp to the right */
}
.message-bubble-wrapper.sent .message-bubble {
    background-color: #137057; /* Heritage Green */
    color: #fff;
}
.message-bubble-wrapper.received { align-self: flex-start; align-items: flex-start; }
.message-bubble-wrapper.received .message-bubble {
    background-color: #f1f0f0;
    color: #333;
}
.message-input-area {
    padding: 15px 25px;
    border-top: 1px solid #e9e9e9;
    display: flex;
    background-color: #f9f9f9;
}
.message-input-area textarea {
    flex-grow: 1;
    border: 1px solid #ddd;
    border-radius: 25px;
    padding: 12px 20px;
    font-size: 16px;
    font-family: inherit; /* Ensure it uses the theme's font */
    resize: none; /* Disable manual resizing */
    line-height: 1.5;
    max-height: 120px; /* Limit height to prevent it from taking over the screen */
    overflow-y: auto;
}
.message-input-area button[type="button"] {
    background-color: #137057;
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    margin-left: 12px;
    padding: 12px 25px;
    border: none;
    border-radius: 20px; /* This creates the pill shape */
    width: 60px; /* Wider than it is tall */
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 10px;
    transition: background-color 0.2s ease;
}

.message-input-area button:hover { background-color: #0f5a45; }
.chat-loading { padding: 40px; text-align: center; color: #888; }
.header-details { display: flex; flex-direction: column; }
.typing-indicator { font-size: 12px; font-style: italic; color: #888; height: 14px; }
.mobile-back-btn { display: none; margin-right: 15px; font-size: 28px; text-decoration: none; color: #333; padding: 5px; }
.mobile-back-btn:hover { color: #000; }
.user-search-wrapper { margin-top: 15px; position: relative; }
.user-search-input { width: 90%; padding: 10px 15px; border-radius: 20px; border: 1px solid #ddd; font-size: 14px; }
.user-search-results {
    position: absolute;
    top: 100%;
    left: 0; right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
}
.search-result-item { display: flex; align-items: center; padding: 10px 15px; cursor: pointer; border-bottom: 1px solid #f0f0f0; }
.search-result-item:hover { background-color: #f5f5f5; }
.search-result-item:last-child { border-bottom: none; }
.search-result-item .avatar { width: 32px; height: 32px; border-radius: 50%; margin-right: 10px; }

/* --- RESPONSIVE & PWA OPTIMIZATIONS --- */
@media (max-width: 992px) {
    .vibrant-focus-chat {
        flex-direction: column;
        border-radius: 0;
        border: none;
        box-shadow: none;
        max-width: none;
    }
    .conversation-sidebar {
        width: 100%;
        height: 100%; /* Take full height on mobile */
        border-right: none;
    }
    .chat-window {
        width: 100%;
        height: 20%;
    }
    .conversation-sidebar.mobile-hidden,
    .chat-window.mobile-hidden {
        display: none;
    }
    .mobile-back-btn { display: block; }

    /* On mobile, account for the PWA bottom nav */
    .full-width-app-container {
        height: calc(10vh - 70px - 60px);
        height: calc(10svh - 70px - 60px);
    }
}

/* ==============================================
   HYPERLINK STYLES
   ============================================== */

.message-bubble a {
    text-decoration: underline;
}

.message-bubble-wrapper.sent a {
    color: #fff; /* White links on dark background */
}

.message-bubble-wrapper.received a {
    color: #137057; /* Heritage Green links on light background */
}