/* ============================================
   AI Assistant Panel & Chat
   ============================================ */

/* --- AI Module Layout --- */
.ai-advisor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

@media (max-width: 1100px) {
    .ai-advisor-layout {
        grid-template-columns: 1fr;
    }
}

/* --- Quick Action Cards --- */
.ai-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

@media (max-width: 900px) {
    .ai-actions-grid { grid-template-columns: 1fr; }
}

.ai-action-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: center;
}

.ai-action-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
    border-color: var(--dts-secondary);
}

.ai-action-card .action-icon {
    font-size: 2rem;
    margin-bottom: var(--space-sm);
}

.ai-action-card .action-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.ai-action-card .action-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* --- Chat Container --- */
.ai-chat-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: 600px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(0, 62, 81, 0.03), rgba(0, 176, 185, 0.03));
}

.ai-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--dts-primary), var(--dts-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.ai-chat-header-text h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.ai-chat-header-text p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

/* --- Messages --- */
.ai-chat-messages {
    flex: 1;
    padding: var(--space-lg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.ai-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

.chat-message {
    display: flex;
    gap: var(--space-sm);
    max-width: 85%;
    animation: fadeInUp 0.3s ease;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.chat-message.assistant .chat-message-avatar {
    background: linear-gradient(135deg, var(--dts-primary), var(--dts-secondary));
}

.chat-message.user .chat-message-avatar {
    background: var(--dts-secondary);
}

.chat-message-bubble {
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    line-height: 1.6;
}

.chat-message.assistant .chat-message-bubble {
    background: var(--bg-card-hover);
    border: 1px solid var(--border-color);
    border-top-left-radius: 4px;
    color: var(--text-primary);
}

.chat-message.user .chat-message-bubble {
    background: linear-gradient(135deg, var(--dts-primary), var(--dts-primary-light));
    color: white;
    border-top-right-radius: 4px;
}

.chat-message-bubble h4 {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    color: var(--dts-primary);
}

[data-theme="dark"] .chat-message.assistant .chat-message-bubble h4 {
    color: var(--dts-secondary);
}

.chat-message-bubble ul, .chat-message-bubble ol {
    padding-left: 18px;
    margin: var(--space-sm) 0;
}

.chat-message-bubble li {
    margin-bottom: 4px;
}

.chat-message-bubble code {
    background: rgba(0, 176, 185, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.chat-message-bubble strong {
    color: var(--dts-primary);
}

.chat-message.user .chat-message-bubble strong {
    color: white;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: var(--space-md);
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--dts-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

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

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* --- Chat Input --- */
.ai-chat-input-area {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border-color);
    background: var(--bg-card);
}

.ai-chat-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.9rem;
    resize: none;
    height: 42px;
    transition: border-color var(--transition-fast);
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--dts-secondary);
}

.ai-chat-input::placeholder {
    color: var(--text-muted);
}

.ai-chat-send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--dts-primary), var(--dts-secondary));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.ai-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 176, 185, 0.3);
}

.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ai-chat-send svg {
    width: 18px;
    height: 18px;
}

/* --- AI Report Panel --- */
.ai-report-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.ai-report-header {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    color: var(--dts-primary);
}

[data-theme="dark"] .ai-report-header {
    color: var(--dts-secondary);
}

.ai-report-content {
    padding: var(--space-lg);
    font-size: 0.9rem;
    line-height: 1.7;
    max-height: 500px;
    overflow-y: auto;
}

.ai-report-content h4 {
    font-size: 0.95rem;
    color: var(--dts-primary);
    margin: var(--space-md) 0 var(--space-sm);
}

[data-theme="dark"] .ai-report-content h4 {
    color: var(--dts-secondary);
}

.ai-report-content ul {
    padding-left: 20px;
    margin-bottom: var(--space-md);
}

.ai-report-content li {
    margin-bottom: 6px;
    color: var(--text-secondary);
}

/* --- Settings Modal --- */
.ai-settings-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: rgba(0, 176, 185, 0.04);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-lg);
}

.ai-settings-bar label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.ai-settings-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.ai-settings-bar input:focus {
    outline: none;
    border-color: var(--dts-secondary);
}
