/**
 * CSS cho tab Trợ lý AI - Dashboard Analytics
 */

/* Quick Actions */
.ai-quick-action {
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ai-quick-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Chat Container */
.ai-chat-container {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 20px;
    min-height: 500px;
    display: flex;
    flex-direction: column;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
    max-height: 600px;
    padding: 12px;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 8px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

/* Messages */
.ai-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-message.ai-user {
    flex-direction: row-reverse;
}

.ai-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background: var(--bg-primary);
    border: 2px solid var(--border);
}

.ai-user .ai-message-avatar {
    background: var(--primary);
    color: white;
    font-size: 16px;
}

.ai-message-content {
    flex: 1;
    max-width: 80%;
}

.ai-message-text {
    background: var(--bg-primary);
    padding: 14px 16px;
    border-radius: 12px;
    line-height: 1.6;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.ai-user .ai-message-text {
    background: var(--primary);
    color: white;
}

.ai-message-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
    padding: 0 4px;
}

/* Loading indicator */
.ai-message-loading {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
}

.ai-message-loading span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: dotBounce 1.4s infinite ease-in-out both;
}

.ai-message-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-message-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Chat Input */
.ai-chat-input-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-chat-input {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Chart Area */
#ai-chart-area {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

#ai-chart-container {
    min-height: 400px;
    padding: 20px;
}

/* Data Table in Messages */
.ai-data-table {
    width: 100%;
    margin: 12px 0;
    border-collapse: collapse;
    font-size: 13px;
}

.ai-data-table th,
.ai-data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.ai-data-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
}

.ai-data-table tr:hover {
    background: var(--bg-secondary);
}

/* Insights Cards in Messages */
.ai-insight-card {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: 8px;
    margin: 8px 0;
    border-left: 3px solid var(--primary);
}

.ai-insight-card strong {
    color: var(--primary);
    display: block;
    margin-bottom: 4px;
}

/* Chart Preview in Messages */
.ai-chart-preview {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 8px;
    margin: 12px 0;
    text-align: center;
}

.ai-chart-preview canvas {
    max-width: 100%;
    height: auto !important;
}

/* Action Buttons in Messages */
.ai-action-buttons {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.ai-action-btn {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.ai-action-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Responsive */
@media (max-width: 768px) {
    .ai-message-content {
        max-width: 90%;
    }
    
    .ai-quick-action {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    .ai-chat-messages {
        max-height: 400px;
    }
}

/* Dark mode specific adjustments */
body.dark-mode .ai-message-text {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-mode .ai-data-table th {
    background: var(--bg-tertiary);
}

body.dark-mode .ai-insight-card {
    background: var(--bg-tertiary);
    border-left-color: #667eea;
}
