/* --- Brand Palette & Global Styles --- */
:root {
    --bg-dark: #0a192f;
    --bg-light: #f8f9fa;
    --border-light: #dee2e6;
    --text-dark-primary: #212529;
    --text-dark-secondary: #6c757d;
    --accent-gold: #f0b90b;
    --sidebar-width: 320px;
    
    /* Variables from your old CSS for the sidebar */
    --bg-medium: #172a45;
    --border-color: #233554;
    --text-primary: #ccd6f6;
    --text-secondary: #8892b0;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    background-color: var(--bg-dark); 
    color: var(--text-dark-primary); 
    min-height: 100vh; 
    -webkit-font-smoothing: antialiased; 
    -moz-osx-font-smoothing: grayscale; 
}

/* --- Login Page Styles --- */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: var(--bg-dark);
    padding: 20px;
}
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    width: 100%;
    max-width: 400px;
    text-align: center;
    color: var(--text-dark-primary);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}
.login-logo {
    max-width: 300px;
    margin-bottom: 10px;
}
.login-box h2 {
    font-size: 1.8rem;
    margin-bottom: 8px;
}
.login-box p {
    color: var(--text-dark-secondary);
    margin-bottom: 24px;
}
#loginForm .form-group {
    text-align: left;
    margin-bottom: 20px;
}
#loginForm .form-group label {
    color: var(--text-dark-secondary);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
    display: inline-block;
}
#loginForm .form-group input {
    width: 100%;
    background-color: #fff;
    color: var(--text-dark-primary);
    border: 1px solid #ced4da;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
#loginForm .form-group input:focus {
    border-color: var(--accent-gold);
    box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.2);
    outline: none;
}
#loginButton {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
}
.error-message {
    color: #e84a5f;
    font-size: 0.9rem;
    min-height: 20px;
    margin-bottom: 16px;
}

/* --- Page Wrapper for two-column layout --- */
.page-wrapper { 
    width: 100%; 
    display: grid; 
    grid-template-columns: 1fr 600px; 
}
.page-wrapper.chat-active { 
    grid-template-columns: var(--sidebar-width) 1fr; 
}
.page-wrapper.sidebar-collapsed { 
    --sidebar-width: 80px; 
}
/* --- Welcome Section Styles --- */
.welcome-section { 
    display: flex; 
    flex-direction: column; 
    gap: 16px; 
    justify-content: center;
    align-items: center;
    padding: 48px;
    height: 100vh;
}
.welcome-title { 
    font-size: 2.5rem; 
    font-weight: 700; 
    color: #fff; 
    line-height: 1.2; 
    text-align: center;
}
.welcome-subtitle { 
    font-size: 1rem; 
    color: #8892b0; 
    line-height: 1.6; 
    max-width: 500px; 
    text-align: center;
}
.features-list { 
    list-style: none; 
    margin-top: 24px; 
    display: flex; 
    flex-direction: column; 
    gap: 24px; 
}
.feature-item { 
    display: flex; 
    align-items: flex-start; 
    gap: 16px; 
}
.feature-icon { 
    flex-shrink: 0; 
    width: 32px; 
    height: 32px; 
    background-color: #172a45; 
    border-radius: 8px; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
}
.feature-icon svg { 
    width: 20px; 
    height: 20px; 
    color: var(--accent-gold); 
}
.feature-item h3 { 
    font-size: 1.1rem; 
    font-weight: 600; 
    color: #ccd6f6; 
    margin-bottom: 4px; 
}
.feature-item p { 
    font-size: 0.9rem; 
    color: #8892b0; 
    line-height: 1.5; 
}

/* --- CHAT HISTORY STYLES START --- */
.session-sidebar { 
    display: none; 
    background: var(--bg-medium); 
    border-right: 1px solid var(--border-color);
    flex-direction: column; 
    overflow: hidden; 
    height: 100vh;
    transition: width 0.3s ease-in-out; 
}
.sidebar-header { 
    padding: 16px; 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    border-bottom: 1px solid var(--border-color); 
    flex-shrink: 0; 
    justify-content: space-between; 
}
.sidebar-title { 
    font-size: 1.1rem; 
    font-weight: 600; 
    transition: opacity 0.2s, transform 0.2s; 
    white-space: nowrap; 
    color: var(--text-primary); 
}
.new-chat-icon-button { 
    background: transparent; 
    border: none; 
    color: var(--text-secondary); 
    cursor: pointer; 
    padding: 6px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    transition: background-color 0.2s, color 0.2s; 
}
.new-chat-icon-button:hover { 
    background-color: var(--border-color); 
    color: var(--text-primary); 
}
.new-chat-icon-button svg { 
    width: 20px; 
    height: 20px; 
}
.session-nav { 
    overflow-y: auto; 
    padding: 16px; 
}
.session-list { 
    list-style: none; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}
.session-list-item { 
    padding: 12px 16px; 
    border-radius: 6px; 
    cursor: pointer; 
    transition: background-color 0.2s; 
    color: var(--text-secondary); 
    font-size: 0.9rem; 
    position: relative; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}
.session-title { 
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis; 
    flex-grow: 1; 
    min-width: 0; 
    transition: opacity 0.2s, transform 0.2s; 
}
.session-list-item:hover { 
    background-color: var(--border-color); 
    color: var(--text-primary); 
}
.session-list-item.active { 
    background-color: #233554; 
    color: #fff; 
    font-weight: 600; 
}

/* --- Chat Container & Component Styles --- */
.chat-container { 
    width: 100%; 
    height: 100vh;
    background: var(--bg-light); 
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1); 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
}
.chat-header { 
    background: transparent; 
    padding: 16px 24px; 
    border-bottom: 1px solid var(--border-light); 
    display: flex; 
    align-items: center; 
    justify-content: space-between;
    flex-shrink: 0; 
}
.header-logo-group {
    display: flex;
    align-items: center;
    gap: 24px;
}
.header-classicbrain-logo { 
    max-height: 60px; 
    width: auto; 
    object-fit: contain; 
}
.header-gcp-logo {
    max-height: 35px;
    width: auto;
    object-fit: contain;
}
.connection-status { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    color: var(--text-dark-secondary); 
    font-size: 12px; 
}
.connection-status::before { 
    content: ''; 
    width: 8px; 
    height: 8px; 
    border-radius: 50%; 
    background-color: #e84a5f; 
}
.connection-status.connecting::before { 
    background-color: #f0b90b; 
}
.connection-status.connected::before { 
    background-color: #25d366; 
}

/* --- NEW & IMPROVED SETUP SECTION STYLES --- */
.setup-section { 
    padding: 32px 40px; 
    display: flex; 
    flex-direction: column; 
    gap: 16px;
    max-width: 500px;
    margin: 48px auto;
    background: #ffffff;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}
.config-row { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}
.config-row input { 
    padding: 12px 14px; 
    background-color: #fff; 
    border: 1px solid #ced4da; 
    border-radius: 8px;
    font-size: 16px;
    color: var(--text-dark-primary); 
    transition: border-color 0.2s, box-shadow 0.2s; 
}
.config-row input:focus { 
    outline: none; 
    border-color: var(--accent-gold); 
    box-shadow: 0 0 0 4px rgba(240, 185, 11, 0.2); 
}
.config-row label { 
    font-weight: 600; 
    color: #495057; 
    font-size: 14px; 
}
.init-button, .review-button {
    padding: 14px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    border: 1px solid transparent;
    width: 100%;
}
.init-button { 
    background-color: var(--accent-gold); 
    color: #111; 
    border-color: var(--accent-gold); 
}
.init-button:hover:not(:disabled) { 
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 185, 11, 0.3);
}
.init-button:disabled { 
    opacity: 0.6; 
    cursor: not-allowed; 
}
.review-button {
    background-color: transparent;
    color: var(--text-dark-secondary);
    border-color: #ced4da;
}
.review-button:hover {
    background-color: #f8f9fa;
    color: var(--text-dark-primary);
    border-color: #adb5bd;
}
.section-divider {
    width: 100%;
    height: 1px;
    background-color: #e9ecef;
    margin: 8px 0;
}
.manual-trigger-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.manual-trigger-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark-primary);
}
.manual-trigger-section p {
    font-size: 0.9rem;
    color: var(--text-dark-secondary);
    line-height: 1.5;
    margin-top: -8px; 
}
.analysis-status {
    font-size: 0.9rem;
    padding: 10px 12px;
    border-radius: 6px;
    min-height: 20px;
    display: none;
    margin-top: -8px;
    text-align: center;
}
.analysis-status.success {
    color: #146c43;
    background-color: #d1e7dd;
    display: block;
}
.analysis-status.error {
    color: #b02a37;
    background-color: #f8d7da;
    display: block;
}

.chat-section { 
    display: none; 
    flex: 1; 
    flex-direction: column; 
    overflow: hidden; 
}
.chat-section.active { 
    display: flex; 
}
.session-info { 
    padding: 8px 24px; 
    background: #fff; 
    border-bottom: 1px solid var(--border-light); 
    font-size: 12px; 
    color: var(--text-dark-secondary); 
    text-align: center; 
    font-family: monospace; 
}
.chat-messages { 
    flex: 1; 
    padding: 24px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 24px; 
}
.message-group-agent { 
    display: flex; 
    align-items: flex-start; 
    gap: 12px; 
    align-self: flex-start; 
    max-width: 85%; 
}
.agent-avatar { 
    width: 32px; 
    height: 32px; 
    border-radius: 50%; 
    margin-top: 4px; 
    flex-shrink: 0; 
}
.message { 
    padding: 12px 16px; 
    border-radius: 12px; 
    line-height: 1.6; 
    animation: fadeIn 0.3s ease-out; 
}
.message.user { 
    align-self: flex-end; 
    background: var(--accent-gold); 
    color: #111; 
    border-radius: 12px 12px 0 12px; 
    max-width: 80%; 
}
.message.agent { 
    background: #e9ecef; 
    color: var(--text-dark-primary); 
    border-radius: 0 12px 12px 12px; 
}
.message.error, .message.system { 
    align-self: center; 
    background: var(--bg-light); 
    color: var(--text-dark-secondary); 
    font-size: 13px; 
    text-align: center; 
}
.chat-input-container { 
    padding: 16px 24px; 
    background: #fff; 
    border-top: 1px solid var(--border-light); 
    flex-shrink: 0; 
}
.chat-input-row { 
    display: flex; 
    gap: 12px; 
    align-items: flex-end; 
}
.chat-input { 
    flex: 1; 
    padding: 10px 16px; 
    background-color: #fff; 
    border: 1px solid #ced4da; 
    border-radius: 6px; 
    font-size: 16px; 
    color: var(--text-dark-primary); 
    resize: none; 
    max-height: 150px; 
    min-height: 44px; 
}
.send-button { 
    width: 44px; 
    height: 44px; 
    background: transparent; 
    border: 1px solid #ced4da; 
    border-radius: 6px; 
    cursor: pointer; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    transition: background-color 0.2s; 
}
.send-button:hover { 
    background-color: #f8f9fa; 
}
.send-button svg { 
    fill: var(--text-dark-secondary); 
}
.typing-indicator { 
    display: none; 
    padding: 0 24px 12px 24px; 
    color: var(--text-dark-secondary); 
    font-style: italic; 
    font-size: 14px; 
}
.typing-indicator.show { 
    display: block; 
}
.session-menu-button { 
    background: transparent; 
    border: none; 
    cursor: pointer; 
    padding: 4px; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    opacity: 0; 
    transition: opacity 0.2s, background-color 0.2s; 
}
.session-list-item:hover .session-menu-button { 
    opacity: 1; 
}
.session-menu-button:hover { 
    background-color: rgba(255, 255, 255, 0.1); 
}
.session-menu-button svg { 
    width: 20px; 
    height: 20px; 
    fill: var(--text-secondary); 
}
.context-menu { 
    display: none; 
    position: absolute; 
    background-color: #233554; 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); 
    padding: 8px; 
    z-index: 1000; 
    width: 150px; 
}
.context-menu ul { 
    list-style: none; 
}
.context-menu li { 
    padding: 8px 12px; 
    border-radius: 4px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-size: 0.9rem; 
    color: var(--text-primary); 
}
.context-menu li:hover { 
    background-color: var(--bg-medium); 
}
.context-menu li svg { 
    width: 16px; 
    height: 16px; 
    fill: var(--text-primary); 
}
.session-title-input {
    width: 100%;
    padding: 0;
    margin-right: 10px;
    font-size: inherit;
    font-family: inherit;
    color: var(--text-primary);
    background-color: var(--bg-dark);
    border: 1px solid var(--accent-gold);
    border-radius: 4px;
    outline: none;
}

/* --- Media Query for Responsiveness --- */
@media (max-width: 900px) {
    .page-wrapper { 
        grid-template-columns: 1fr; 
        max-width: 100%;
    }
    .welcome-section { 
        text-align: center; 
        align-items: center; 
    }
    .session-sidebar { 
        display: none !important; 
    }
    .chat-container { 
        height: 100vh;
    }
    .setup-section {
        margin: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
        height: 100%;
        justify-content: center;
    }
}
/* --- Animation keyframes --- */
@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

/* Modal Styles */
.modal-overlay { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    background: rgba(0, 0, 0, 0.7); 
    z-index: 1000; 
    justify-content: center; 
    align-items: center; 
}
.modal-overlay.active { 
    display: flex; 
}
.modal-content { 
    background: #fff; 
    padding: 32px; 
    border-radius: 12px; 
    border: 1px solid var(--border-light); 
    width: 100%; 
    max-width: 500px; 
    position: relative; 
    animation: fadeIn 0.3s ease-out; 
}
.modal-close-button { 
    position: absolute; 
    top: 10px; 
    right: 16px; 
    background: none; 
    border: none; 
    color: var(--text-dark-secondary); 
    font-size: 2rem; 
    cursor: pointer; 
}
.review-form h2 { 
    font-size: 1.5rem; 
    margin-bottom: 8px; 
    color: var(--text-dark-primary); 
}
.review-form p { 
    color: #495057; 
    margin-bottom: 24px; 
}
.review-form.hidden { 
    display: none; 
}
.form-group { 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
    margin-bottom: 16px; 
}
.form-group label { 
    font-weight: 600; 
    color: #495057; 
    font-size: 0.9rem; 
}
.form-group input, .form-group textarea { 
    padding: 12px 14px; 
    background-color: var(--bg-light); 
    border: 1px solid #ced4da; 
    border-radius: 6px; 
    font-size: 1rem; 
    color: var(--text-dark-primary); 
    transition: border-color 0.2s, box-shadow 0.2s; 
}
.form-group input:focus, .form-group textarea:focus { 
    outline: none; 
    border-color: var(--accent-gold); 
    box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.2); 
}
.form-group textarea { 
    resize: vertical; 
    min-height: 80px; 
}
.submit-review-button { 
    padding: 12px; 
    background-color: var(--accent-gold); 
    color: #111; 
    border: none; 
    border-radius: 6px; 
    font-size: 1rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: opacity 0.2s; 
}
.submit-review-button:hover { 
    opacity: 0.9; 
}
.submit-review-button:disabled { 
    opacity: 0.5; 
    cursor: not-allowed; 
}
.form-success-message { 
    display: none; 
    flex-direction: column; 
    align-items: center; 
    text-align: center; 
    padding: 24px 0; 
}
.form-success-message.active { 
    display: flex; 
}
.success-icon { 
    width: 48px; 
    height: 48px; 
    color: #25d366; 
    margin-bottom: 16px; 
}
.form-success-message h3 { 
    font-size: 1.5rem; 
    margin-bottom: 8px; 
    color: var(--text-dark-primary); 
}
.form-success-message p { 
    color: #495057; 
}