/* =========================================
   AI Chat Panel - Right Side Sliding Design
   ========================================= */

/* Backdrop Overlay */
.ai-chat-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1100;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ai-chat-backdrop.active {
    opacity: 1;
    visibility: visible;
}

/* Chat Panel Container - Right Side */
.ai-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    transform: translateX(100%);
    width: 420px;
    height: 100vh;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-subtle);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.5);
    z-index: 1200;
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

/* Chat Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-body);
    flex-shrink: 0;
}

.ai-chat-header h5 {
    margin: 0;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.ai-chat-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: var(--text-xl);
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.ai-chat-close:hover {
    background: var(--bg-surface-2);
    color: var(--text-primary);
}

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

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

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--border-medium);
}

/* Message Bubble */
.ai-message {
    display: flex;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.ai-message.visible {
    opacity: 1;
    transform: translateY(0);
}

.ai-message-user {
    justify-content: flex-end;
}

.ai-message-assistant {
    justify-content: flex-start;
}

.ai-message-bubble {
    max-width: 75%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-message-user .ai-message-bubble {
    background: var(--text-primary);
    color: var(--bg-body);
    border-bottom-right-radius: var(--radius-sm);
}

.ai-message-assistant .ai-message-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border-bottom-left-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.ai-message-bubble p {
    margin: 0 !important;
    padding: 0 !important;
}

.ai-message-user p {
    color: var(--bg-body);
}

/* Input Wrapper at Bottom */
.ai-chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-body);
    flex-shrink: 0;
}

.ai-chat-input-wrapper input {
    flex: 1;
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    padding: var(--space-3) var(--space-4);
    color: var(--text-primary);
    font-size: var(--text-sm);
    outline: none;
    transition: all 0.2s ease;
}

.ai-chat-input-wrapper input:focus {
    border-color: var(--border-subtle);
    background: rgba(255, 255, 255, 0.05);
}

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

.ai-send-btn {
    background: var(--text-primary);
    border: none;
    color: var(--bg-body);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.ai-send-btn:active {
    transform: scale(0.95);
}

.ai-send-btn i {
    font-size: var(--text-sm);
}

/* Typing Indicator */
.ai-typing-indicator {
    display: none;
    padding: var(--space-3) var(--space-4);
    background: var(--bg-surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    border-bottom-left-radius: var(--radius-sm);
    width: fit-content;
    margin: var(--space-5) var(--space-5);
}

.ai-typing-indicator.active {
    display: flex;
    gap: 6px;
    align-items: center;
}

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

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

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

@keyframes typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .ai-chat-panel {
        width: 100%;
        max-width: 100%;
    }

    .ai-message-bubble {
        max-width: 85%;
    }
}

/* Responsive - Tablet */
@media (max-width: 1024px) and (min-width: 769px) {
    .ai-chat-panel {
        width: 380px;
    }
}