/*
================================================================
|                                                              |
|    20240730-CIJEMentor-styles-AL-0003.css                    |
|    Enhanced Styles for the CIJE Mentor Flask Frontend        |
|    By Gemini                                                 |
|                                                              |
|    - Updated chat bubble colors for User/Assistant           |
|    - Switched to class-based Dark Mode for manual toggle     |
|    - Added styles for a theme toggle button                  |
|                                                              |
================================================================
*/

/* ================================================================
    1. ROOT & BRAND VARIABLES
================================================================
*/
:root {
    /* CIJE Brand Palette - Light Mode (Default) */
    --cije-primary-blue: #1673ba;
    --cije-dark-blue: #0f5a9a;
    --cije-light-blue: #e8f1f8; /* New light blue for user bubbles */
    --cije-primary-yellow: #fbbb18;
    --cije-dark-yellow: #d4a017; /* Dark yellow for highlights */
    --cije-accent-orange: #f28c0f;
    --cije-extremely-light-blue: #f0f8ff; /* Extremely light blue for assistant messages */
    --cije-accent-purple: #5e17eb;

    /* Neutrals & UI Tones */
    --brand-text: #212529;
    --brand-text-muted: #4f4f50;
    --brand-primary-bg: #ffffff;
    --brand-secondary-bg: #f8f9fa;
    --brand-ui-element-bg: #e9ecef;
    --brand-border-color: #dee2e6;
    --brand-shadow-color: rgba(0, 0, 0, 0.1);

    /* Font Definitions */
    --font-heading: 'Playfair Display', serif;
    --font-body: 'Raleway', sans-serif;

    /* UI Dimensions */
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 20px;
}

/* DAT: STYLE - Dark Mode Color Palette (Class-based) */
body.dark-mode {
    /* Re-map brand colors for dark background */
    --cije-primary-blue: #5394c6;
    --cije-dark-blue: #1673ba;
    --cije-light-blue: #2c3e50; /* Darker blue for user bubbles in dark mode */
    --cije-primary-yellow: #fbd064;
    --cije-accent-orange: #f4a261;
    --cije-accent-purple: #9b59b6;

    /* Dark Mode Neutrals */
    --brand-text: #f8f9fa;
    --brand-text-muted: #adb5bd;
    --brand-primary-bg: #212529;
    --brand-secondary-bg: #343a40;
    --brand-ui-element-bg: #495057;
    --brand-border-color: #495057;
    --brand-shadow-color: rgba(0, 0, 0, 0.4);
}


/* ================================================================
    2. GLOBAL & TYPOGRAPHY STYLES
================================================================
*/
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--brand-text);
    background-color: var(--brand-primary-bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--cije-primary-blue);
    font-weight: 700;
}

a {
    color: var(--cije-primary-blue);
    text-decoration: none;
    transition: color 0.2s ease, text-decoration 0.2s ease;
}

a:hover {
    color: var(--cije-accent-orange);
    text-decoration: underline;
}

/* Custom Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: var(--brand-secondary-bg);
}
::-webkit-scrollbar-thumb {
    background-color: var(--brand-ui-element-bg);
    border-radius: 10px;
    border: 2px solid var(--brand-secondary-bg);
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--cije-primary-blue);
}


/* ================================================================
    3. LAYOUT & MAJOR SECTIONS
================================================================
*/
main {
    flex: 1 0 auto;
}

footer {
    flex-shrink: 0;
}

.navbar-brand img {
    margin-right: 10px;
}

.welcome-message {
    padding: 1rem 0;
}
.welcome-message h2 {
    font-size: 2.2rem;
    font-weight: 700;
}
.welcome-message p {
    font-size: 1.1rem;
    color: var(--brand-text-muted);
}

/* Theme Toggle Button Style */
.theme-switch {
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1001;
    background-color: var(--brand-ui-element-bg);
    border: 1px solid var(--brand-border-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.theme-switch:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px var(--brand-shadow-color);
}


/* ================================================================
    4. SPLASH SCREEN
================================================================
*/
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--cije-dark-blue);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    animation: splashFadeOut 2s ease-out 1.5s forwards;
    overflow: hidden;
}

.splash-content {
    text-align: center;
}

.splash-content h1, .splash-content p {
    color: transparent;
    background: linear-gradient(90deg, 
        var(--cije-primary-yellow) 0%, 
        var(--cije-primary-yellow) 40%, 
        #ffffff 50%, 
        var(--cije-primary-yellow) 60%, 
        var(--cije-primary-yellow) 100%);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: backgroundSheen 1.2s ease-in-out 0.2s 1 forwards;
}

.splash-content h1 {
    font-family: var(--font-body);
    font-size: 3.5rem;
    font-weight: 700;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.splash-content p {
    font-family: 'Poppins', sans-serif;
    font-size: 2.2rem;
    font-weight: 300;
    letter-spacing: 0.03em;
}


/* ================================================================
    5. CHAT INTERFACE
================================================================
*/
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px); /* Fixed height to prevent pushing down */
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: var(--brand-secondary-bg);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 75%;
    word-break: break-word;
    line-height: 1.5;
    animation: fadeIn 0.4s ease-out;
}

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

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

.message-content {
    padding: 12px 18px;
    border-radius: var(--border-radius-lg);
    box-shadow: 0 2px 4px var(--brand-shadow-color);
    white-space: pre-wrap;
}

/* --- UPDATED BUBBLE COLORS --- */
.message.user .message-content {
    background-color: var(--cije-light-blue);
    color: var(--brand-text); /* Use main text color */
    border-bottom-right-radius: var(--border-radius-sm);
}
body.dark-mode .message.user .message-content {
    color: #f1f1f1; /* Ensure user text is light in dark mode */
}

.message.assistant .message-content {
    background-color: var(--cije-extremely-light-blue);
    color: #212529; /* Dark text for light blue background */
    border-bottom-left-radius: var(--border-radius-sm);
}

/* --- Styling for HTML rendered from structured responses --- */
.message-content h3 {
    font-size: 1.3em;
    margin-top: 0;
    margin-bottom: 0.5em;
    color: var(--cije-dark-blue);
}
.message-content h4 {
    font-size: 1.1em;
    margin-top: 1em;
    margin-bottom: 0.5em;
    color: var(--cije-primary-blue);
}
.message-content p {
    margin-top: 0;
    margin-bottom: 1em;
}
.message-content p:last-child {
    margin-bottom: 0;
}
.message-content ul,
.message-content ol {
    margin-top: 0.5em;
    margin-bottom: 1em;
    padding-left: 25px;
}
.message-content li {
    margin-bottom: 0.5em;
}
.message-content li:last-child {
    margin-bottom: 0;
}
.message-content strong {
    font-weight: bold;
    color: var(--cije-dark-yellow);
}
.message-content code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.95em;
    padding: 0.1em 0.3em;
    background-color: rgba(0,0,0,0.1);
    border-radius: 4px;
}
.message-content pre {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 1em;
    border-radius: var(--border-radius-sm);
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    margin: 1em 0;
    white-space: pre;
}

@media (prefers-color-scheme: light) {
    .assistant-message .message-content pre {
        background-color: #f1f1f1;
        color: #333;
    }
    .assistant-message .message-content code {
         background-color: #e9ecef;
         color: #333;
    }
}


/* ================================================================
    6. FORMS & INPUTS
================================================================
*/
.form-control, .form-select {
    background-color: var(--brand-ui-element-bg);
    color: var(--brand-text);
    border: 1px solid var(--brand-border-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-control:focus, .form-select:focus {
    background-color: var(--brand-ui-element-bg);
    color: var(--brand-text);
    border-color: var(--cije-primary-blue);
    box-shadow: 0 0 0 0.25rem rgba(var(--cije-primary-blue), 0.25);
}

.message-input {
    position: sticky;
    bottom: 0;
    background-color: var(--brand-primary-bg);
    padding: 15px 20px;
    border-top: 1px solid var(--brand-border-color);
    margin-top: 0;
    z-index: 100;
}
.message-input textarea {
    resize: none;
}

.auth-card {
    max-width: 450px;
    margin: 2rem auto;
    background-color: var(--brand-secondary-bg);
    border: 1px solid var(--brand-border-color);
    border-radius: var(--border-radius-md);
    box-shadow: 0 4px 15px var(--brand-shadow-color);
}
.auth-card .card-header {
    background-color: var(--cije-primary-blue);
    color: #ffffff;
    font-family: var(--font-heading);
    font-weight: bold;
    border-bottom: none;
    border-top-left-radius: var(--border-radius-md);
    border-top-right-radius: var(--border-radius-md);
}
.auth-card .card-header h4 {
    color: #ffffff;
    margin-bottom: 0;
}




/* ================================================================
    7. UI COMPONENTS
================================================================
*/
.btn {
    font-family: var(--font-body);
    font-weight: 600;
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease-in-out;
}
.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background-color: var(--cije-primary-blue);
    border-color: var(--cije-primary-blue);
    color: #ffffff;
}
.btn-primary:hover {
    background-color: var(--cije-dark-blue);
    border-color: var(--cije-dark-blue);
    color: #ffffff;
}

.btn-secondary {
    background-color: var(--cije-primary-yellow);
    border-color: var(--cije-primary-yellow);
    color: #212529;
}
.btn-secondary:hover {
    background-color: #ffd46a;
    border-color: #ffd46a;
    color: #212529;
}

.filter-chips {
    margin-bottom: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.chip {
    display: inline-block;
    padding: 8px 18px;
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    border: 1px solid var(--brand-border-color);
    background-color: var(--brand-ui-element-bg);
    color: var(--brand-text-muted);
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}
.chip:hover {
    background-color: var(--brand-border-color);
    border-color: var(--brand-text-muted);
    color: var(--brand-text);
}
.chip.active {
    background-color: var(--cije-primary-yellow);
    color: #212529;
    border-color: var(--cije-primary-yellow);
    font-weight: 700;
}
.chip.active:hover {
    background-color: #ffd46a;
    border-color: #ffd46a;
}

.feedback-buttons {
    display: flex;
    justify-content: flex-end;
    margin-top: 5px;
    gap: 8px;
}
.feedback-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--brand-text-muted);
    transition: transform 0.2s ease, color 0.2s ease;
}
.feedback-button:hover {
    transform: scale(1.2);
    color: var(--cije-primary-blue);
}

.copy-button {
    position: relative;
}

.copy-button:hover {
    color: var(--cije-accent-orange) !important;
}

.loading::after {
    content: "...";
    display: inline-block;
    animation: loadingDots 1.5s infinite;
}
.thinking-indicator, .loading-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
}
.thinking-indicator span, .loading-dots span {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--cije-primary-blue);
    opacity: 0.4;
    animation: pulseDots 1.4s infinite ease-in-out both;
}
.thinking-indicator span:nth-child(1), .loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.thinking-indicator span:nth-child(2), .loading-dots span:nth-child(2) { animation-delay: -0.16s; }


/* ================================================================
    8. ANIMATIONS
================================================================
*/
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes splashFadeOut {
    0% { opacity: 1; }
    99% { opacity: 0; }
    100% { opacity: 0; visibility: hidden; }
}

@keyframes backgroundSheen {
    0% { background-position: 150% 0; } 
    100% { background-position: -150% 0; }
}

@keyframes loadingDots {
    0% { content: "."; }
    33% { content: ".."; }
    66% { content: "..."; }
}

@keyframes pulseDots {
    0%, 80%, 100% { 
        opacity: 0.4;
        transform: scale(0.8);
    } 
    40% { 
        opacity: 1; 
        transform: scale(1.0);
        background-color: var(--cije-primary-yellow);
    }
}


/* ================================================================
    9. RESPONSIVE ADJUSTMENTS
================================================================
*/
@media (max-width: 768px) {
    .message {
        max-width: 85%;
    }
}

@media (max-width: 576px) {
    body {
        font-size: 14px;
    }
    .message {
        max-width: 95%;
    }
    .chat-container {
        height: calc(100vh - 180px);
    }
    .filter-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    .filter-chips::-webkit-scrollbar {
        display: none;
    }
    .chip {
        flex-shrink: 0;
    }
    .splash-content h1 { font-size: 2.5rem; }
    .splash-content p { font-size: 1.5rem; }
}

.feedback-section {
    background-color: var(--brand-ui-element-bg);
    border-color: var(--brand-border-color) !important;
    margin-top: 2rem;
}

.feedback-section h5 {
    color: var(--cije-primary-blue);
    font-weight: 600;
}

.feedback-section .form-label {
    font-weight: 500;
    color: var(--brand-text);
}

.feedback-section .form-control,
.feedback-section .form-select {
    border: 1px solid var(--brand-border-color);
    background-color: #ffffff;
}

.feedback-section .form-control:focus,
.feedback-section .form-select:focus {
    border-color: var(--cije-primary-blue);
    box-shadow: 0 0 0 0.2rem rgba(65, 116, 220, 0.25);
}

body.dark-mode .feedback-section {
    background-color: var(--brand-surface-alt);
}

body.dark-mode .feedback-section .form-control,
body.dark-mode .feedback-section .form-select {
    background-color: var(--brand-surface);
    border-color: var(--brand-border-color);
    color: var(--brand-text);
}

body.dark-mode .feedback-section .form-control:focus,
body.dark-mode .feedback-section .form-select:focus {
    background-color: var(--brand-surface);
    border-color: var(--cije-primary-blue);
    color: var(--brand-text);
}
