/* ============================================
   AI-CHAT.CSS - AI Tutor Chat Interface Styles
   ============================================ */

/* ============================================
   CHAT CONTAINER & LAYOUT
   ============================================ */
#ai-messages {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    overflow-y: auto;
    background: #f8fafc;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 40px 20px;
    color: #64748b;
}

.welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.welcome-message h3 {
    font-size: 24px;
    color: #1e293b;
    margin-bottom: 8px;
    font-weight: 600;
}

.welcome-message p {
    font-size: 16px;
    color: #64748b;
    line-height: 1.6;
}

/* ============================================
   MESSAGE BUBBLES
   ============================================ */
.message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    max-width: 85%;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User Messages (Right-aligned, Blue) */
.message.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* AI Messages (Left-aligned, White) */
.message.ai-message {
    align-self: flex-start;
}

/* ============================================
   AVATARS
   ============================================ */
.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* AI Avatar (Purple) */
.ai-message .message-avatar {
    background: var(--gradient-primary);
    color: white;
    font-size: 24px;
}

/* User Avatar (Blue) */
.user-message .message-avatar {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
}

/* ============================================
   MESSAGE CONTENT BUBBLES
   ============================================ */
.message-content {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 16px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
}

/* AI Message Bubble (White with border) */
.ai-message .message-content {
    background: white;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

/* User Message Bubble (Blue) */
.user-message .message-content {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: white;
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
}

/* ============================================
   MESSAGE CONTENT FORMATTING
   ============================================ */
.message-content strong {
    font-weight: 600;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.user-message .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

.message-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 8px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */
.message.thinking {
    opacity: 0.7;
}

.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing 1.4s infinite;
}

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

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ============================================
   BADGES & STATUS INDICATORS
   ============================================ */
.success-badge, .error-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
}

.success-badge {
    background: rgba(16, 185, 129, 0.15);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.error-badge {
    background: rgba(239, 68, 68, 0.15);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Override for user messages (white text) */
.user-message .success-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

.user-message .error-badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

/* ============================================
   ERROR MESSAGES
   ============================================ */
.message.error .message-content {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.error-text {
    color: #dc2626;
    font-weight: 500;
}

/* ============================================
   AI FEEDBACK (Challenge Mode)
   ============================================ */
.ai-feedback-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    background: white;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.ai-avatar {
    font-size: 32px;
    flex-shrink: 0;
}

.ai-message {
    flex: 1;
    color: #1e293b;
    line-height: 1.6;
}

.ai-thinking {
    text-align: center;
    padding: 20px;
    color: #64748b;
    font-size: 16px;
}

.ai-error {
    background: #fef2f2;
    color: #991b1b;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid #fecaca;
}

/* ============================================
   CHAT INPUT AREA
   ============================================ */
#ai-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-family: inherit;
    resize: vertical;
    min-height: 44px;
    transition: border-color 0.2s;
}

#ai-input:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

#send-message {
    padding: 12px 24px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-standard);
}

#send-message:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
}

#send-message:active {
    transform: translateY(0);
}

#send-message:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    .message {
        max-width: 90%;
    }
    
    .message-avatar {
        width: 36px;
        height: 36px;
    }
    
    .ai-message .message-avatar {
        font-size: 20px;
    }
    
    .message-content {
        font-size: 15px;
        padding: 10px 14px;
    }
}
