/* Chat-specific CSS - Tách riêng để tránh conflict với trang khác */

/* Đảm bảo parent containers có đủ chiều cao */
.main-container {
    min-height: calc(100vh - 100px);
}

.content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ===== CHAT CONTAINER STYLES ===== */
.chat-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    background: #f8f9fa;
    min-height: calc(100vh - 320);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    position: relative;
    height: calc(100vh - 320);
    box-sizing: border-box;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 1px solid #e9ecef;
    min-height: 0;
    max-height: none;
}

/* ===== MESSAGE STYLES ===== */
.chat-messages .message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 8px;
    line-height: 1.6;
    font-size: 15px;
}

.chat-messages .message.user {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    margin-left: 50px;
    text-align: right;
}

.chat-messages .message.assistant {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: #333;
    margin-right: 50px;
    border-left: 4px solid #28a745;
}

/* ===== LATEX MATHEMATICS STYLES ===== */
.chat-messages .message .boxed-result {
    background: linear-gradient(135deg, rgba(46, 139, 87, 0.15), rgba(237, 104, 3, 0.10));
    border: 2px solid #2e8b57;
    border-radius: 0.8rem;
    padding: 1.2em !important;
    margin: 1rem 0;
    box-shadow: 0 4px 15px rgba(46, 139, 87, 0.2);
    font-size: 16px;
    text-align: center;
}

/* MathJax rendered equations trong chat */
.chat-messages .MathJax {
    font-size: 1.1em !important;
    color: #2c3e50 !important;
}

.chat-messages .MathJax_Display {
    margin: 1em 0 !important;
    text-align: center !important;
}

/* Inline math trong chat */
.chat-messages .MathJax_CHTML {
    display: inline-block !important;
    vertical-align: middle !important;
}

/* ===== CHEMICAL FORMULA STYLES ===== */
.chat-messages .message .chemical-formula {
    font-family: 'Times New Roman', serif;
}

/* ===== TABLE STYLES ===== */
.chat-messages .message table.solver-table {
    width: 100%;
    margin: 1rem 0;
    border-collapse: collapse;
    background: linear-gradient(135deg, #28a745, #20803d);
    border-radius: 0.8rem;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-messages .message table.solver-table th {
    background: rgba(0, 0, 0, 0.2);
    color: white;
    font-weight: bold;
    padding: 12px;
    text-align: center;
    font-size: 14px;
}

.chat-messages .message table.solver-table td {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    padding: 10px;
    text-align: center;
    font-size: 13px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.chat-messages .message table.solver-table tr:last-child td {
    border-bottom: none;
}

/* ===== SECTION HEADERS ===== */
.chat-messages .message h3 {
    color: #28a745;
    font-size: 18px;
    margin: 1.5rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #28a745;
}

.chat-messages .message h4 {
    color: #17a2b8;
    font-size: 16px;
    margin: 1rem 0 0.5rem 0;
}

/* ===== CODE BLOCKS ===== */
.chat-messages .message pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.5rem;
    padding: 1rem;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
}

.chat-messages .message code {
    background: rgba(255, 193, 7, 0.1);
    padding: 0.2em 0.4em;
    border-radius: 0.3rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

/* ===== INPUT FORM STYLES ===== */
.chat-input-container {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    flex-shrink: 0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    z-index: 10;
}

.chat-input-container input[type="text"] {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.3s ease;
}

.chat-input-container input[type="text"]:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.chat-input-container button {
    padding: 12px 25px;
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    border: none;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.3s ease;
}

.chat-input-container button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 123, 255, 0.4);
}

/* ===== LOADING ANIMATION ===== */
.loading {
    display: inline-block;
    padding: 10px;
    font-style: italic;
    color: #6c757d;
}

.loading::after {
    content: '';
    animation: dots 2s infinite;
}

@keyframes dots {
    0%, 20% { content: ''; }
    40% { content: '.'; }
    60% { content: '..'; }
    80%, 100% { content: '...'; }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .main-container {
        min-height: calc(100vh - 80px);
    }
    
    .chat-container {
        padding: 15px;
        min-height: calc(100vh - 150px);
        height: calc(100vh - 150px);
        border-radius: 8px;
    }
    
    .chat-messages {
        padding: 15px;
        margin-bottom: 12px;
        border-radius: 6px;
    }
    
    .chat-messages .message.user {
        margin-left: 20px;
        font-size: 14px;
    }
    
    .chat-messages .message.assistant {
        margin-right: 20px;
        font-size: 14px;
    }
    
    .chat-messages .message .boxed-result {
        padding: 0.8em !important;
        font-size: 13px;
    }
    
    .chat-input-container {
        flex-direction: row;
        padding: 12px;
        gap: 8px;
    }
    
    .chat-input-container input[type="text"] {
        padding: 10px 12px;
        font-size: 14px;
        border-radius: 20px;
    }
    
    .chat-input-container button {
        padding: 10px 18px;
        font-size: 14px;
        min-width: 65px;
        border-radius: 20px;
    }
}

/* ===== DESKTOP IMPROVEMENTS ===== */
@media (min-width: 769px) {
    .chat-input-container input[type="text"]:focus {
        transform: scale(1.01);
        transition: all 0.2s ease;
    }
    
    .chat-messages .message {
        animation: slideIn 0.3s ease-out;
    }
    
    @keyframes slideIn {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* ===== SCROLLBAR STYLING ===== */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}