/*
  styles/research_post.css
  v3 - Perfected two-column active state based on your detailed feedback.
*/

/* --- 1. Base Layout & Reading Experience --- */
.research-container {
    padding: 2rem 3rem;
    max-width: 900px;
    margin: 0 auto;
    transition: all 0.5s ease-in-out;
}

.paper-column {
    width: 100%;
    transition: all 0.5s ease-in-out;
}

/* --- 2. Initial, WIDGET-LIKE Chatbot State --- */
.chatbot-column {
    position: sticky;
    bottom: 2rem;
    max-width: 700px;
    margin: 2rem auto 0 auto;
    z-index: 1000;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    transform: translateY(150%);
    transition: transform 0.5s cubic-bezier(0.25, 1, 0.5, 1),
                box-shadow 0.3s ease,
                max-width 0.5s ease-in-out,
                margin 0.5s ease-in-out;
}

.chatbot-column.loaded {
    transform: translateY(0);
}

.chatbot-column:not(.chatbot-active):hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.chatbot-column h2 {
    display: none;
    margin-bottom: 1.5rem;
}

#chat-box {
    border: none;
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

#chat-log {
    display: none;
    max-height: 50vh;
    overflow-y: auto;
    padding: 15px;
    line-height: 1.6;
}

#chat-input {
    border: none;
    padding: 16px;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    font-size: 1rem;
    background: transparent;
    transition: background-color 0.2s ease;
}

#chat-input:disabled {
    background-color: #f1f1f1;
    cursor: not-allowed;
}

/* --- 3. PERFECTED 'ACTIVE' STATE (Your Detailed UI/UX Fixes) --- */
.research-container.chatbot-active {
    max-width: 100%;
    display: flex;
    /* 
      KEY FIX: Calculate height based on viewport minus the navbar height. 
      Assuming a navbar height of approx. 70px. 
    */
    height: calc(100vh - 70px);
    padding: 0;
    margin: 70px 0 0 0; /* Align container below the navbar */
    box-sizing: border-box;
    overflow: hidden;
}

.chatbot-active .paper-column {
    flex: 3;
    overflow-y: auto; /* Independent scrolling */
    padding: 2rem 3rem;
    height: 100%; /* Column fills the calculated height */
}

.chatbot-active .chatbot-column {
    position: static;
    transform: none !important;
    flex: 2;
    max-width: none;
    margin: 0;
    border-radius: 0;
    border-left: 1px solid #e0e0e0;
    height: 100%; /* Column fills the calculated height */
    box-shadow: none;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 2rem;
}

.chatbot-active .chatbot-column h2 {
    display: block;
    flex-shrink: 0; /* Prevent title from shrinking */
}

.chatbot-active #chat-box {
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Take up all available space */
    min-height: 0; /* Allow shrinking within the flex container */
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
}

.chatbot-active #chat-log {
    display: block;
    flex-grow: 1;
    overflow-y: auto; /* Independent scrolling for chat history */
    padding: 15px;
}

.chatbot-active #chat-input {
    flex-shrink: 0; /* Prevent input from shrinking */
    border-top: 1px solid #ddd;
    background: #fff;
    border-radius: 0 0 7px 7px;
    padding: 12px; /* KEY FIX: Reduced padding for a sleeker input */
}

/* --- 4. Mobile Responsiveness --- */
@media (max-width: 768px) {
    .research-container {
        padding: 1.5rem 1rem;
    }
    
    .chatbot-column {
        bottom: 1rem;
    }
    
    .research-container.chatbot-active {
        display: block;
        height: auto;
        padding: 0;
        margin-top: 70px;
    }

    .chatbot-active .paper-column {
        height: auto;
        overflow-y: visible;
        padding: 1.5rem 1rem;
    }
    
    .chatbot-active .chatbot-column {
        margin-top: 2rem;
        height: 85vh; /* Adjusted for better mobile experience */
        border-left: none;
        border-top: 2px solid #e0e0e0;
        padding: 1rem;
    }
}
