/* ====================================================================
   CSS VARIABLES - White Theme Configuration
   ==================================================================== */

:root {
    --primary-color: #0066cc;
    --sidebar-bg: rgba(248, 249, 250, 0.95);
    --main-bg: rgba(255, 255, 255, 0.95);
    --text-color: #1a1a1a;
    --secondary-text: #666666;
    --border-color: rgba(0, 0, 0, 0.1);
    --hover-color: rgba(0, 102, 204, 0.1);
    --user-message-bg: rgba(0, 102, 204, 0.1);
    --bot-message-bg: rgba(245, 245, 245, 0.9);
    --input-bg: rgba(255, 255, 255, 0.9);
    --button-bg: rgba(0, 102, 204, 0.9);
    --button-text: #ffffff;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --glass-effect: blur(10px);
}

/* ====================================================================
   RESET AND BASE STYLES
   ==================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    color: var(--text-color);
    background: linear-gradient(135deg, #f5f7fa, #e8eef5);
    background-attachment: fixed;
    line-height: 1.6;
    height: 100vh;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    backdrop-filter: var(--glass-effect);
    -webkit-backdrop-filter: var(--glass-effect);
}
/* ====================================================================
   SIDEBAR STYLES
   ==================================================================== */

.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 16px;
    box-shadow: var(--card-shadow);
    backdrop-filter: var(--glass-effect);
    -webkit-backdrop-filter: var(--glass-effect);
    z-index: 10;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.logo {
    width: 240px;
    height: auto;
    margin-bottom: 12px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary-color);
    text-shadow: none;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

#new-chat-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #0066cc, #0052a3);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 102, 204, 0.3);
}

#new-chat-btn i {
    margin-right: 8px;
}
/* ====================================================================
   MAIN CONTENT STYLES
   ==================================================================== */

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--main-bg);
    backdrop-filter: var(--glass-effect);
    -webkit-backdrop-filter: var(--glass-effect);
}

.chat-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) rgba(240, 240, 240, 0.9);
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: rgba(240, 240, 240, 0.9);
}

.chat-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-color);
    border-radius: 6px;
}

/* ====================================================================
   WELCOME MESSAGE
   ==================================================================== */

.welcome-message {
    text-align: center;
    margin: auto;
    max-width: 600px;
    padding: 30px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
}

.welcome-message h1 {
    font-size: 32px;
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--primary-color);
    text-shadow: none;
}

.welcome-message p {
    color: #000000; /* Changed from var(--secondary-text) to solid black */
    font-size: 16px;
    opacity: 1; /* Fully opaque */
}

/* ====================================================================
   MESSAGE STYLES
   ==================================================================== */

.message {
    max-width: 80%;
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;
}

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

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-right: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--border-color);
}

.message-content {
    background-color: var(--bot-message-bg);
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    min-width: 0;            /* allow flex child to shrink so inner pre can scroll */
    overflow: hidden;        /* clip content to bubble boundary */
    overflow-wrap: break-word;
    word-break: break-word;  /* wrap long unbroken strings (variable names, URLs) */
}

.user-message .message-content {
    background-color: var(--user-message-bg);
    color: var(--text-color);
    border-color: rgba(0, 102, 204, 0.3);
}

.message-text {
    font-size: 15px;
    white-space: pre-wrap;
    color: #000000; /* Black text for all messages */
}

.message-text p {
    margin-bottom: 8px;
    color: #000000; /* Black text for paragraphs */
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text pre {
    background-color: rgba(240, 240, 240, 0.9);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
    white-space: pre;   /* preserve exact code formatting, do not word-wrap */
    max-width: 100%;    /* constrain to parent bubble width */
}

.message-text code {
    font-family: 'Courier New', monospace;
    color: #0066cc;
}


/* ====================================================================
   MARKDOWN FORMATTING STYLES
   ==================================================================== */

.message-text h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 16px 0 12px 0;
    color: #000000; /* Black color for headers */
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.message-text h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 14px 0 10px 0;
    color: #000000; /* Black color for headers */
}

.message-text h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 12px 0 8px 0;
    color: #000000; /* Black color for headers */
}

.message-text h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 10px 0 6px 0;
    color: #000000; /* Black color for headers */
}

.message-text strong {
    font-weight: 600;
    color: #000000; /* Black color for bold text */
}

.message-text em {
    font-style: italic;
    color: #000000; /* Black color for italic text */
}

/* Fixed bullet point alignment */
.message-text ul {
    margin: 12px 0;
    padding-left: 28px; /* Increased from 24px to 28px */
    list-style-type: disc;
    list-style-position: outside; /* Ensures bullets are outside content */
}

.message-text ol {
    margin: 12px 0;
    padding-left: 28px; /* Increased from 24px to 28px */
    list-style-type: decimal;
    list-style-position: outside; /* Ensures numbers are outside content */
}

.message-text li {
    margin: 6px 0;
    line-height: 1.6;
    color: #000000; /* Black color for list items */
    padding-left: 8px; /* Added padding for better spacing */
}

/* Nested lists */
.message-text ul ul,
.message-text ol ul {
    margin: 6px 0;
    padding-left: 24px;
    list-style-type: circle; /* Different bullet for nested lists */
}

.message-text ul ol,
.message-text ol ol {
    margin: 6px 0;
    padding-left: 24px;
}

.message-text hr {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 16px 0;
}

.message-text blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 16px;
    margin: 12px 0;
    color: var(--secondary-text);
    font-style: italic;
}

.message-text code {
    font-family: 'Courier New', monospace;
    color: #0066cc;
    background-color: rgba(0, 102, 204, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}


/* ====================================================================
   INPUT AREA STYLES
   ==================================================================== */

.input-container {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: var(--glass-effect);
    -webkit-backdrop-filter: var(--glass-effect);
}

.input-box {
    display: flex;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    align-items: center;
}

#message-input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 12px 0;
    resize: none;
    max-height: 200px;
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    outline: none;
    color: var(--text-color);
    line-height: 1.5;
}

#message-input::placeholder {
    color: var(--secondary-text);
}

#send-button {
    background: transparent;
    border: none;
    color: var(--primary-color);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin-left: 8px;
}

#send-button:hover {
    background-color: rgba(0, 102, 204, 0.1);
    transform: scale(1.1);
}

#send-button:disabled {
    color: var(--secondary-text);
    cursor: not-allowed;
}

#message-input:disabled {
    opacity: 0.7;
}

/* Disclaimer text - Black color */
/* Disclaimer text - Solid black color */
.disclaimer {
    text-align: center;
    color: #000000;
    font-size: 12px;
    margin-top: 8px;
    opacity: 1; /* Fully opaque */
}


/* ====================================================================
   TYPING INDICATOR WITH ANIMATION
   ==================================================================== */

.typing-dots {
    display: inline-flex;
    align-items: center;
}

.typing-dots span {
    height: 8px;
    width: 8px;
    margin: 0 2px;
    background-color: var(--primary-color);
    border-radius: 50%;
    display: inline-block;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% { 
        transform: scale(0); 
    }
    40% { 
        transform: scale(1); 
    }
}
/* ====================================================================
   FEEDBACK BUTTONS STYLING
   ==================================================================== */

.feedback-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.feedback-btn {
    background: transparent;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    /* Default gray color for both buttons */
    color: #666666;
    display: flex;
    align-items: center;
    gap: 4px;
}

.feedback-btn:hover:not(:disabled) {
    background: rgba(0, 102, 204, 0.05);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
}

.feedback-btn:active:not(:disabled) {
    transform: translateY(0);
}

.feedback-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Green color when thumbs up is active */
.feedback-btn.active.thumbs-up {
    background: #4CAF50;
    color: white;
    border-color: #4CAF50;
}

/* Red color when thumbs down is active */
.feedback-btn.active.thumbs-down {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.feedback-btn i {
    font-size: 16px;
}

.feedback-thumbs {
    display: flex;
    flex-direction: row;
    gap: 8px;
}

.feedback-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.feedback-form-hidden {
    display: none !important;
}

.feedback-slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.feedback-label {
    font-size: 13px;
    color: var(--secondary-text);
    white-space: nowrap;
}

.feedback-slider {
    flex: 1;
    min-width: 120px;
    max-width: 220px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

.feedback-slider-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    min-width: 16px;
    text-align: center;
}

.feedback-scale-hint {
    font-size: 12px;
    color: var(--secondary-text);
}

.feedback-comment {
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    padding: 8px 10px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.feedback-comment:focus {
    border-color: var(--primary-color);
}

.feedback-comment::placeholder {
    color: var(--secondary-text);
}

.feedback-submit {
    align-self: flex-start;
    background: var(--button-bg);
    border: none;
    border-radius: 6px;
    color: var(--button-text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 16px;
    transition: opacity 0.2s;
}

.feedback-submit:hover {
    opacity: 0.85;
}

.feedback-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.feedback-error {
    color: #d32f2f;
    font-size: 12px;
}

.feedback-thanks {
    color: var(--secondary-text);
    font-size: 13px;
    padding: 6px 0;
}
/* ====================================================================
   RESPONSIVE DESIGN - TABLET (768px and below)
   ==================================================================== */

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }
    
    .message {
        max-width: 90%;
    }
    
    .feedback-buttons {
        gap: 6px;
    }
    
    .feedback-btn {
        padding: 5px 10px;
        font-size: 13px;
    }
    
    .feedback-btn i {
        font-size: 14px;
    }
}

/* ====================================================================
   RESPONSIVE DESIGN - MOBILE (480px and below)
   ==================================================================== */

@media (max-width: 480px) {
    .sidebar-header {
        align-items: center;
    }
    
    .logo {
        width: 180px;
    }
    
    .welcome-message {
        padding: 20px;
    }
    
    .welcome-message h1 {
        font-size: 24px;
    }
    
    .welcome-message p {
        font-size: 14px;
        color: #000000; /* Solid black for mobile too */
        opacity: 1;
    }
    
    .message {
        max-width: 95%;
    }
    
    .message-text {
        font-size: 14px;
    }
    
    .message-avatar {
        width: 32px;
        height: 32px;
    }
    
    .message-content {
        padding: 12px;
    }
    
    .input-container {
        padding: 12px;
    }
    
    .input-box {
        padding: 6px 12px;
    }
    
    #message-input {
        font-size: 14px;
        padding: 10px 0;
    }
    
    #send-button {
        font-size: 18px;
        padding: 6px;
    }
}


/* Nested list styling */
.message-content ul,
.message-content ol {
    margin: 10px 0;
    padding-left: 20px;
}

.message-content ul ul,
.message-content ol ol,
.message-content ul ol,
.message-content ol ul {
    margin: 5px 0;
    padding-left: 25px;
}

.message-content li {
    margin: 5px 0;
    line-height: 1.6;
}

/* Different bullet styles for nested lists */
.message-content ul {
    list-style-type: disc;
}

.message-content ul ul {
    list-style-type: circle;
}

.message-content ul ul ul {
    list-style-type: square;
}


/* Remove extra spacing from paragraphs in lists */
.message-content li p {
    margin: 0;
    display: inline;
}

/* Ensure consistent text spacing */
.message-text {
    white-space: normal;
    word-wrap: break-word;
}

/* ── Markdown table rendering ─────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    margin: 12px 0;
}

.table-wrapper table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9em;
    background: var(--main-bg);
}

.table-wrapper table thead tr {
    background-color: var(--primary-color);
    color: #ffffff;
    text-align: left;
}

.table-wrapper table th,
.table-wrapper table td {
    padding: 8px 12px;
    border: 1px solid #d0d7de;
}

.table-wrapper table tbody tr:nth-child(even) {
    background-color: rgba(0, 102, 204, 0.05);
}

.table-wrapper table tbody tr:hover {
    background-color: rgba(0, 102, 204, 0.1);
}

/* ── Knowledge Gap Notice ─────────────────────────────────────────────────── */

.kb-gap-notice {
    margin: 12px 0 4px 0;
    padding: 8px 12px;
    background-color: rgba(255, 193, 7, 0.08);
    border-left: 3px solid #e6a817;
    border-radius: 0 4px 4px 0;
    font-size: 0.88em;
    color: #5a4a00;
}

.kb-gap-notice strong {
    color: #7a5c00;
}
