/* AI Button and Slideout Chat Styles */
.ai-button-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 999;
}

.ai-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 24px;
    color: white;
    animation: pulse 2s ease-in-out infinite;
}

.ai-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.ai-button:active {
    transform: scale(0.95);
}

/* AI Slideout (Chat) */
.ai-slideout {
    position: fixed;
    top: 0;
    right: -420px;
    width: 420px;
    height: calc(100vh - 40px);
    background: var(--window-bg);
    border-left: 2px solid var(--border-color);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-slideout.active {
    right: 0;
}

.ai-slideout-header {
    background: linear-gradient(to bottom, #667eea, #764ba2);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-slideout-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-slideout-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s ease;
}

.ai-slideout-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.ai-slideout-body {
    flex: 1;
    overflow: hidden;
}

.ai-messages-container {
    height: 100%;
    padding: 16px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text-color);
}

.ai-messages-container::-webkit-scrollbar {
    width: 8px;
}

.ai-messages-container::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.ai-messages-container::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

.ai-messages-container::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.ai-message {
    max-width: 90%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    animation: aiMessageIn 0.18s ease-out;
}

.ai-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
}

.ai-message.assistant {
    align-self: flex-start;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    border-bottom-left-radius: 6px;
}

.ai-message.error {
    border-color: #d9534f;
    background: rgba(217, 83, 79, 0.08);
}

.ai-message-meta {
    margin-top: 6px;
    font-size: 11px;
    opacity: 0.85;
    color: var(--text-color-secondary);
}

.ai-message.user .ai-message-meta {
    color: rgba(255, 255, 255, 0.85);
}

.ai-loading {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
}

.ai-loading span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-color-secondary);
    opacity: 0.6;
    animation: aiDot 1.2s infinite ease-in-out;
}

.ai-loading span:nth-child(2) {
    animation-delay: 0.15s;
}

.ai-loading span:nth-child(3) {
    animation-delay: 0.3s;
}

.ai-slideout-footer {
    border-top: 1px solid var(--border-color);
    background: var(--window-bg);
    padding: 12px;
}

.ai-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-input {
    flex: 1;
    min-height: 42px;
    max-height: 150px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-color);
    font-family: inherit;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.ai-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.25);
}

.ai-send-button {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, opacity 0.2s ease;
}

.ai-send-button:hover {
    transform: translateY(-1px);
}

.ai-send-button:active {
    transform: translateY(0);
}

.ai-send-button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
    transform: none;
}

.ai-status {
    margin-top: 8px;
    min-height: 16px;
    font-size: 12px;
    color: var(--text-color-secondary);
}

@media (max-width: 768px) {
    .ai-slideout {
        width: 100%;
        right: -100%;
    }

    .ai-button-container {
        bottom: 20px;
        right: 20px;
    }

    .ai-button {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.6);
    }
}

@keyframes aiMessageIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes aiDot {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    40% {
        transform: translateY(-3px);
        opacity: 0.9;
    }
}
