/* ============================================
   AI AUTOMATION ASSISTANT - Chat Interface
   Cyberpunk terminal meets conversational UI
   ============================================ */

/* --- Page Layout --- */
.ai-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.ai-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
    position: relative;
    z-index: 1;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */
.ai-header {
    padding: 120px 0 24px;
    text-align: center;
}

.ai-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.ai-subtitle {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.ai-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 12px;
    padding: 4px 14px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    background: rgba(10, 10, 15, 0.6);
}

.ai-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #555;
    transition: background 0.3s;
}

.ai-status.online .dot {
    background: #00e676;
    box-shadow: 0 0 8px #00e676;
    animation: pulse-dot 2s infinite;
}

.ai-status.offline .dot {
    background: #ff4444;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* --- Chat Area --- */
.ai-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-bottom: 16px;
    min-height: 300px;
    max-height: calc(100vh - 380px);
    overflow-y: auto;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: var(--purple-800) transparent;
}

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

.ai-chat::-webkit-scrollbar-thumb {
    background: var(--purple-800);
    border-radius: 4px;
}

/* --- Messages --- */
.chat-msg {
    padding: 16px 20px;
    animation: msg-in 0.3s ease-out;
}

@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg.user {
    border-left: 2px solid var(--neon-purple);
    background: rgba(139, 61, 255, 0.04);
}

.chat-msg.assistant {
    border-left: 2px solid var(--neon-cyan);
    background: rgba(0, 229, 255, 0.02);
}

.chat-msg.error {
    border-left: 2px solid var(--neon-pink);
    background: rgba(255, 77, 166, 0.04);
}

.msg-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 6px;
    opacity: 0.5;
}

.msg-label.user-label { color: var(--neon-purple); }
.msg-label.ai-label { color: var(--neon-cyan); }

.msg-text {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.6;
}

/* --- Code Blocks --- */
.code-block {
    margin: 12px 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: #08080e;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: rgba(139, 61, 255, 0.08);
    border-bottom: 1px solid var(--border-color);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
}

.code-header .code-lang {
    text-transform: uppercase;
    letter-spacing: 1px;
}

.code-actions {
    display: flex;
    gap: 4px;
}

.code-btn {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.65rem;
    padding: 2px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 0.5px;
}

.code-btn:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
    background: rgba(139, 61, 255, 0.08);
}

.code-btn.copied {
    border-color: #00e676;
    color: #00e676;
}

.code-body {
    padding: 16px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre;
    tab-size: 2;
}

/* JSON Syntax Highlighting */
.json-key { color: var(--neon-purple); }
.json-string { color: #a5d6a7; }
.json-number { color: var(--neon-cyan); }
.json-bool { color: var(--neon-pink); }
.json-null { color: var(--text-muted); }

/* --- DShell Import Box --- */
.dshell-box {
    margin: 10px 0 4px;
    padding: 10px 14px;
    background: rgba(0, 229, 255, 0.03);
    border: 1px solid rgba(0, 229, 255, 0.12);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.dshell-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--neon-cyan);
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    opacity: 0.7;
}

.dshell-cmd {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-primary);
    flex: 1;
    overflow-x: auto;
    white-space: nowrap;
}

.dshell-cmd .prompt-char {
    color: var(--neon-cyan);
    user-select: none;
}

/* --- Thinking Indicator --- */
.thinking {
    padding: 16px 20px;
    border-left: 2px solid var(--neon-cyan);
    animation: msg-in 0.3s ease-out;
}

.thinking-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.thinking-dots span {
    width: 5px;
    height: 5px;
    background: var(--neon-cyan);
    border-radius: 50%;
    animation: dot-bounce 1.4s infinite;
}

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

@keyframes dot-bounce {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* --- Welcome Message --- */
.welcome {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 16px;
    opacity: 0.3;
    filter: grayscale(0.5);
}

.welcome h3 {
    font-family: var(--font-display);
    font-size: 1rem;
    letter-spacing: 2px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.welcome p {
    font-size: 0.85rem;
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

/* --- Quick Examples --- */
.quick-examples {
    padding: 12px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.quick-btn {
    background: rgba(139, 61, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 5px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.quick-btn:hover {
    border-color: var(--neon-purple);
    color: var(--neon-purple);
    background: rgba(139, 61, 255, 0.1);
    box-shadow: var(--glow-sm);
}

/* --- Input Area --- */
.ai-input-area {
    padding: 16px 0 32px;
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, var(--bg-primary) 70%, transparent);
    z-index: 5;
}

.ai-input-wrap {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    padding: 4px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.ai-input-wrap:focus-within {
    border-color: var(--neon-purple);
    box-shadow: var(--glow-sm);
}

.ai-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 12px 16px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
}

.ai-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.ai-send-btn {
    background: linear-gradient(135deg, var(--purple-600), var(--purple-800));
    border: none;
    color: white;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    letter-spacing: 1px;
    text-transform: uppercase;
    white-space: nowrap;
}

.ai-send-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--purple-500), var(--purple-700));
    box-shadow: var(--glow-md);
}

.ai-send-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- Entity Badge --- */
.entity-badge {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    padding: 2px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.entity-badge.orchestration {
    background: rgba(0, 229, 255, 0.1);
    color: var(--neon-cyan);
    border: 1px solid rgba(0, 229, 255, 0.2);
}

.entity-badge.action_template {
    background: rgba(180, 77, 255, 0.1);
    color: var(--neon-purple);
    border: 1px solid rgba(180, 77, 255, 0.2);
}

/* --- Warnings --- */
.ai-warnings {
    margin-top: 6px;
}

.ai-warning {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: #ffa726;
    padding: 2px 0;
    opacity: 0.8;
}

.ai-warning::before {
    content: "! ";
    font-weight: bold;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .ai-header { padding-top: 100px; }
    .ai-chat { max-height: calc(100vh - 340px); }
    .code-body { font-size: 0.7rem; }
    .dshell-box { flex-direction: column; align-items: flex-start; }
    .quick-examples { justify-content: flex-start; }
}
