/* ═══════════════════════════════════════════════
   AI Chat Panel – rechtes Sidebar-Panel
   ═══════════════════════════════════════════════ */

.ai-chat-panel {
    position: fixed;
    top: 60px;
    right: 0;
    bottom: 0;
    width: 450px;
    background: var(--color-surface, #1a0f0f);
    border-left: 2px solid rgba(212, 175, 55, 0.3);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 250;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-panel.open {
    transform: translateX(0);
}

/* Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.2);
    flex-shrink: 0;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #d4af37;
    font-family: var(--font-fantasy, 'Cinzel', serif);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.ai-chat-close {
    background: none;
    border: 1px solid rgba(212, 175, 55, 0.25);
    color: #bbb;
    font-size: 1.3rem;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.ai-chat-close:hover {
    background: rgba(212, 175, 55, 0.15);
    color: #d4af37;
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 5px;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(212, 175, 55, 0.3);
    border-radius: 3px;
}

/* Message Bubbles */
.ai-msg {
    max-width: 90%;
    padding: 0.6rem 0.9rem;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-msg-user {
    align-self: flex-end;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: #e0e0e0;
    border-bottom-right-radius: 4px;
}

.ai-msg-assistant {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    border-bottom-left-radius: 4px;
}

/* Markdown in AI messages */
.ai-msg-assistant strong { color: #d4af37; }
.ai-msg-assistant em { color: #ddd; }
.ai-msg-assistant code {
    background: rgba(212, 175, 55, 0.1);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 0.85em;
}
.ai-msg-assistant ul, .ai-msg-assistant ol {
    padding-left: 1.2em;
    margin: 0.3rem 0;
}
.ai-msg-assistant li { margin-bottom: 0.2rem; }
.ai-msg-assistant p { margin: 0.3rem 0; }
.ai-msg-assistant p:first-child { margin-top: 0; }
.ai-msg-assistant p:last-child { margin-bottom: 0; }

/* Typing indicator */
.ai-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 0.7rem 1rem;
}

.ai-typing span {
    width: 6px;
    height: 6px;
    background: rgba(212, 175, 55, 0.5);
    border-radius: 50%;
    animation: ai-bounce 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* Welcome message */
.ai-welcome {
    text-align: center;
    color: #666;
    font-size: 0.88rem;
    padding: 2rem 1rem;
    line-height: 1.6;
}

.ai-welcome-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    display: block;
}

/* Input Area */
.ai-chat-input {
    padding: 0.8rem 1rem;
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
}

.ai-chat-input textarea {
    flex: 1;
    padding: 0.5rem 0.7rem;
    background: #1a0f0f;
    border: 1px solid rgba(212, 175, 55, 0.3);
    border-radius: 8px;
    color: #e0e0e0;
    font-size: 0.9rem;
    font-family: var(--font-primary, 'Inter', sans-serif);
    resize: none;
    min-height: 40px;
    max-height: 120px;
    line-height: 1.4;
}

.ai-chat-input textarea:focus {
    border-color: #d4af37;
    outline: none;
    box-shadow: 0 0 6px rgba(212, 175, 55, 0.2);
}

.ai-chat-input textarea::placeholder {
    color: #666;
}

.ai-chat-send {
    padding: 0 0.8rem;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.4);
    border-radius: 8px;
    color: #d4af37;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
    align-self: flex-end;
    height: 40px;
}

.ai-chat-send:hover {
    background: rgba(212, 175, 55, 0.25);
}

.ai-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Toggle Button (in sidebar) */
.ai-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    color: #d4af37;
    text-decoration: none;
    border-radius: var(--radius, 6px);
    transition: background 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    font-size: 0.9rem;
    font-family: inherit;
}

.ai-toggle-btn:hover {
    background: rgba(212, 175, 55, 0.15);
}

/* Responsive */
@media (max-width: 900px) {
    .ai-chat-panel {
        width: 100%;
        max-width: 450px;
        box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
    }
}

@media (max-width: 767px) {
    .ai-chat-panel {
        top: 0;
        max-width: 100%;
        z-index: 1100;
    }
}
