/* Chatbot Subject Styles */
.chatbot-subject-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    border: 1px solid #e1e1e1;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatbot-subject-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-subject-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.chatbot-subject-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
}

.status-dot.online {
    background: #4ade80;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* User Info Section */
.chatbot-user-info {
    padding: 15px 20px;
    background: #f8fafc;
    border-bottom: 1px solid #e1e1e1;
}

.user-info-fields {
    display: flex;
    gap: 15px;
    align-items: end;
}

.user-info-fields .form-group {
    flex: 1;
    margin-bottom: 0;
}

.user-info-fields label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

.user-info-fields input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.2s ease;
}

.user-info-fields input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.user-info-fields input:invalid {
    border-color: #ef4444;
}

/* Messages Area */
.chatbot-subject-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
    max-height: calc(100% - 200px);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatbot-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 85%;
}

.chatbot-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chatbot-message.bot {
    align-self: flex-start;
}

.chatbot-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
    margin-top: 4px;
}

.chatbot-message.user .chatbot-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.chatbot-message.bot .chatbot-avatar {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
}

.chatbot-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-message.user .chatbot-message-content {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-bottom-right-radius: 6px;
}

.chatbot-message.bot .chatbot-message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
}

.chatbot-message-meta {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

/* Input Area */
.chatbot-subject-input-area {
    padding: 20px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.chatbot-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    padding: 8px;
    transition: all 0.2s ease;
}

.chatbot-input-wrapper:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 16px;
    font-size: 14px;
    resize: none;
    min-height: 24px;
    max-height: 120px;
    outline: none;
    line-height: 1.5;
}

.chatbot-send-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.chatbot-send-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.chatbot-send-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    color: #6b7280;
    font-style: italic;
}

.chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.chatbot-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: chatbot-typing 1.4s infinite ease-in-out;
}

.chatbot-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.chatbot-typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes chatbot-typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Error Messages */
.chatbot-subject-error {
    background: #fef2f2;
    color: #dc2626;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid #ef4444;
    font-size: 14px;
}

.chatbot-subject-warning {
    background: #fffbeb;
    color: #92400e;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 10px 0;
    border-left: 4px solid #f59e0b;
    font-size: 14px;
}

/* Teacher Upload Styles */
.chatbot-teacher-upload-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.chatbot-teacher-upload-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.chatbot-teacher-upload-header h3 {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 700;
}

.chatbot-teacher-upload-header p {
    margin: 0;
    opacity: 0.9;
    font-size: 16px;
}

.chatbot-teacher-upload-form {
    background: white;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 30px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    flex: 1;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 300px;
    line-height: 1.6;
    font-family: 'Courier New', monospace;
}

.content-info {
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-info.warning {
    color: #dc2626;
}

.recommendation {
    color: #9ca3af;
    font-style: italic;
}

/* File Upload Styles */
.file-upload-area {
    position: relative;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: #fafafa;
}

.file-upload-area:hover {
    border-color: #667eea;
    background: #f0f4ff;
}

.file-upload-area.dragover {
    border-color: #667eea;
    background: #e0e7ff;
    transform: scale(1.02);
}

.file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-placeholder .upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
    opacity: 0.7;
}

.upload-placeholder p {
    margin: 0 0 8px 0;
    color: #6b7280;
    font-size: 16px;
}

.upload-placeholder small {
    color: #9ca3af;
}

/* Form Actions */
.form-actions {
    text-align: center;
    margin-top: 30px;
}

.submit-button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.submit-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.submit-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Recent Textbooks */
.recent-textbooks {
    background: white;
    padding: 24px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.recent-textbooks h4 {
    margin: 0 0 20px 0;
    color: #374151;
    font-size: 18px;
}

.textbooks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.textbook-item {
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.textbook-item:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

.textbook-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.subject-badge {
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.textbook-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #6b7280;
}

.status {
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
}

.status.active {
    background: #d1fae5;
    color: #065f46;
}

.status.inactive {
    background: #fef3c7;
    color: #92400e;
}

/* Form Messages */
.form-message {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
}

.form-message.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.form-message.error {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Responsive Design */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .chatbot-message {
        max-width: 90%;
    }
    
    .user-info-fields {
        flex-direction: column;
        gap: 12px;
    }
    
    .chatbot-teacher-upload-container {
        padding: 10px;
    }
    
    .chatbot-teacher-upload-form {
        padding: 20px;
    }
    
    .textbook-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .textbook-meta {
        flex-wrap: wrap;
    }
}

/* Loading Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}


/* ===== MATH RENDERING STYLES ===== */
/* Enhanced Math Rendering Styles */
.math-content mjx-container {
    display: inline-block !important;
    margin: 0 2px !important;
    vertical-align: middle !important;
    line-height: normal !important;
}

.math-content mjx-container[jax="CHTML"][display="true"] {
    display: block !important;
    margin: 10px 0 !important;
    text-align: center !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
}

/* Ensure proper spacing in messages */
.chatbot-message-content.math-content,
.ms-chatbot-message-bubble.math-content,
.message-content.math-content {
    line-height: 1.6 !important;
    overflow-wrap: break-word !important;
}

/* Math in user messages */
.chatbot-message.user .math-content mjx-container,
.ms-chatbot-message.user .math-content mjx-container,
.user-message .math-content mjx-container {
    color: inherit !important;
}

/* Math in bot messages */  
.chatbot-message.bot .math-content mjx-container,
.ms-chatbot-message.bot .math-content mjx-container,
.bot-message .math-content mjx-container {
    color: inherit !important;
}

/* Fix for inline math alignment */
.math-content mjx-container mjx-math {
    font-size: inherit !important;
}

/* Ensure math doesn't break message layout */
.math-content {
    min-height: 1em;
}

/* Scrollable math for large equations */
.math-content mjx-container {
    max-width: 100%;
}

.math-content mjx-container[jax="CHTML"][display="true"] {
    max-width: 100%;
    overflow-x: auto;
}




