/**
 * Mai Chat UI Enhanced Styles
 * 
 * Enhanced UI components for Mai Brain chat:
 * - Typing indicators
 * - Progress indicators
 * - Error states
 * - Quick chips
 * 
 * @package NSM_Audit_SEO
 * @since 2.3.0
 */

/* ========================================
   Typing Indicator Enhancement
   ======================================== */

.nsm-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #f3f4f6;
    border-radius: 16px;
    max-width: fit-content;
    animation: fadeIn 0.3s ease;
}

.nsm-typing-indicator .nsm-typing-dots {
    display: flex;
    gap: 4px;
}

.nsm-typing-indicator .nsm-typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: typing 1.4s infinite;
}

.nsm-typing-indicator .nsm-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.nsm-typing-indicator .nsm-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.nsm-typing-indicator .nsm-typing-text {
    font-size: 13px;
    color: #6b7280;
    font-style: italic;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ========================================
   Progress Indicator (Slow Response)
   ======================================== */

.nsm-progress-indicator {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    margin: 12px 0;
    animation: slideIn 0.3s ease;
}

.nsm-progress-indicator .nsm-progress-icon {
    font-size: 20px;
    animation: spin 2s linear infinite;
}

.nsm-progress-indicator .nsm-progress-text {
    font-size: 14px;
    color: #92400e;
    font-weight: 500;
}

.nsm-progress-indicator .nsm-progress-bar {
    width: 100%;
    height: 4px;
    background: #fde68a;
    border-radius: 2px;
    overflow: hidden;
}

.nsm-progress-indicator .nsm-progress-bar-fill {
    height: 100%;
    background: #f59e0b;
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% {
        width: 0%;
        transform: translateX(0);
    }
    50% {
        width: 70%;
    }
    100% {
        width: 100%;
        transform: translateX(100%);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================
   Error State with Retry
   ======================================== */

.nsm-error-message {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    margin: 12px 0;
    animation: shake 0.5s ease;
}

.nsm-error-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nsm-error-icon {
    font-size: 20px;
}

.nsm-error-title {
    font-size: 14px;
    font-weight: 600;
    color: #991b1b;
    margin: 0;
}

.nsm-error-text {
    font-size: 13px;
    color: #7f1d1d;
    margin: 0;
    line-height: 1.5;
}

.nsm-error-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.nsm-error-retry,
.nsm-error-cancel {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.nsm-error-retry {
    background: #ef4444;
    color: white;
}

.nsm-error-retry:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.nsm-error-cancel {
    background: #fee2e2;
    color: #991b1b;
}

.nsm-error-cancel:hover {
    background: #fecaca;
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

/* ========================================
   Quick Chips Enhancement
   ======================================== */

.nsm-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
    animation: fadeIn 0.3s ease;
}

.nsm-quick-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: white;
    border: 1.5px solid #e5e7eb;
    border-radius: 20px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.nsm-quick-chip:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.nsm-quick-chip .nsm-chip-icon {
    font-size: 16px;
    line-height: 1;
}

.nsm-quick-chip .nsm-chip-text {
    font-weight: 500;
}

/* Chip animation on load */
.nsm-quick-chip {
    animation: chipSlideIn 0.3s ease backwards;
}

.nsm-quick-chip:nth-child(1) {
    animation-delay: 0.1s;
}

.nsm-quick-chip:nth-child(2) {
    animation-delay: 0.2s;
}

.nsm-quick-chip:nth-child(3) {
    animation-delay: 0.3s;
}

.nsm-quick-chip:nth-child(4) {
    animation-delay: 0.4s;
}

@keyframes chipSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Brain Routing Indicator
   ======================================== */

.nsm-brain-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: #667eea;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nsm-brain-indicator.brain-system {
    background: rgba(16, 185, 129, 0.1);
    color: #10b981;
}

.nsm-brain-indicator.brain-sales {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.nsm-brain-indicator .nsm-brain-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.8);
    }
}

/* ========================================
   Message Status Indicators
   ======================================== */

.nsm-message-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #9ca3af;
    margin-left: 4px;
}

.nsm-message-status.status-sending {
    color: #f59e0b;
}

.nsm-message-status.status-sent {
    color: #10b981;
}

.nsm-message-status.status-error {
    color: #ef4444;
}

.nsm-message-status .status-icon {
    font-size: 12px;
}

/* ========================================
   Animations
   ======================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Mobile Responsive
   ======================================== */

@media (max-width: 480px) {
    .nsm-quick-chips {
        flex-direction: column;
    }
    
    .nsm-quick-chip {
        width: 100%;
        justify-content: center;
    }
    
    .nsm-error-actions {
        flex-direction: column;
    }
    
    .nsm-error-retry,
    .nsm-error-cancel {
        width: 100%;
    }
}

/* ========================================
   Dark Mode Support (Optional)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .nsm-typing-indicator {
        background: #374151;
    }
    
    .nsm-typing-indicator .nsm-typing-text {
        color: #d1d5db;
    }
    
    .nsm-quick-chip {
        background: #1f2937;
        border-color: #374151;
        color: #e5e7eb;
    }
    
    .nsm-quick-chip:hover {
        background: #667eea;
        border-color: #667eea;
        color: white;
    }
}
