/* ==========================================
   STAFFOPTIMIZE.IO - MODERN SAAS CHAT STYLES
   ========================================== */

/* 1. Main Chat Layout Container */
.chat-container {
    max-width: 1000px;
    margin: 1.5rem auto;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08); /* Soft SaaS Shadow */
    overflow: hidden;
    border: 1px solid #eaeaea;
}

/* 2. The Message Area (The "Scrollable" Window) */
.chat-window {
    flex-grow: 1;
    overflow-y: auto;
    background-color: #0f172a; /* Deep Midnight Navy for SaaS feel */
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* 3. Message Rows & Bubbles */
.message-row {
    display: flex;
    margin-bottom: 0.5rem;
    width: 100%;
    animation: fadeIn 0.3s ease; /* Smooth message appearance */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-row.from-user { justify-content: flex-end; }
.message-row.from-ai { justify-content: flex-start; }

.chat-message {
    padding: 12px 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 80%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); /* Deeper shadow for dark mode */
    position: relative;
}

/* User Message: Modern Purple/Violet SaaS Gradient */
.chat-message.from-user {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: #ffffff;
    border-radius: 18px 18px 2px 18px; /* Bubble tail on right */
}

/* AI Message: Glass-Dark Aesthetic */
.chat-message.from-ai {
    background: #1e293b; /* Slightly lighter navy for contrast */
    color: #f1f5f9; /* Off-white text for readability */
    border: 1px solid #334155;
    border-radius: 18px 18px 18px 2px; /* Bubble tail on left */
}

/* 4. Labels (Adasa / You) */
.message-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: none;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    color: #b2bec3;
}
.message-label.user { text-align: right; margin-right: 5px; color: #007bff; }
.message-label.ai   { text-align: left; margin-left: 5px; color: #636e72; }

/* 5. Input Area Styling */
.input-group {
    padding: 1.2rem;
    background: #ffffff;
    border-top: 1px solid #eee;
}

#chat-input {
    border-radius: 25px;
    padding: 12px 20px;
    border: 1px solid #dfe6e9;
    transition: all 0.3s ease;
}

#chat-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

#chat-send {
    border-radius: 25px;
    padding: 0 25px;
    margin-left: 10px;
    font-weight: 600;
}

/* 6. ANALYTICS: Tables & Charts Styling */
/* This makes the AI-generated Markdown tables look professional */
.chat-message table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 0.85rem;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #f1f1f1;
    color: #1f2937; /* Ensure table text does not inherit the bubble text color */
}

.chat-message th {
    background-color: #f8f9fa;
    color: #111827;
    padding: 10px;
    border-bottom: 2px solid #dee2e6;
    text-align: left;
    font-weight: 600;
}

.chat-message td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    color: #1f2937;              /* Fix washed-out body cell text */
    background-color: #ffffff;   /* Keep cells readable inside dark AI bubble */
}

.chat-message tr:last-child td {
    border-bottom: none;
}

/* Responsive Chart Container inside a bubble */
canvas {
    max-width: 100% !important;
    height: auto !important;
    margin-top: 10px;
}