/* AI Chat Widget Styles */
:root {
    --ai-brand: #e8763c;
    --ai-brand-hover: #c9602a;
    --ai-bg-light: #f7f9fc;
    --ai-text: #2c3e50;
    --ai-text-muted: #6c7a89;
    --ai-border: #e2e8f0;
    --ai-white: #ffffff;
    --ai-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.ai-widget-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Poppins', sans-serif;
}

.ai-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--ai-brand);
    color: var(--ai-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(232, 118, 60, 0.4);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    border: none;
    outline: none;
}

.ai-fab:hover {
    transform: scale(1.08);
    background-color: var(--ai-brand-hover);
}

.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--ai-white);
    border-radius: 20px;
    box-shadow: var(--ai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(0,0,0,0.05);
}

.ai-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.ai-chat-header {
    background: var(--ai-brand);
    color: var(--ai-white);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chat-title i {
    font-size: 22px;
}

.ai-chat-title h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-chat-title p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

.ai-chat-actions button {
    background: none;
    border: none;
    color: var(--ai-white);
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0 5px;
}

.ai-chat-actions button:hover {
    opacity: 1;
}

.ai-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--ai-bg-light);
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

.ai-chat-body::-webkit-scrollbar {
    width: 6px;
}
.ai-chat-body::-webkit-scrollbar-track {
    background: transparent;
}
.ai-chat-body::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.ai-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message.user {
    align-self: flex-end;
}

.ai-message.assistant {
    align-self: flex-start;
}

.ai-message-content {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
}

.ai-message.user .ai-message-content {
    background: var(--ai-brand);
    color: var(--ai-white);
    border-bottom-right-radius: 4px;
}

.ai-message.assistant .ai-message-content {
    background: var(--ai-white);
    color: var(--ai-text);
    border: 1px solid var(--ai-border);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

/* Markdown specific styles */
.ai-message-content h1,
.ai-message-content h2,
.ai-message-content h3,
.ai-message-content h4,
.ai-message-content h5,
.ai-message-content h6 {
    margin-top: 12px;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.3;
}
.ai-message-content h1 { font-size: 18px; }
.ai-message-content h2 { font-size: 16px; }
.ai-message-content h3 { font-size: 15px; }
.ai-message-content h4, 
.ai-message-content h5, 
.ai-message-content h6 { font-size: 14px; }
.ai-message-content p {
    margin-bottom: 10px;
}
.ai-message-content p:last-child {
    margin-bottom: 0;
}
.ai-message-content strong {
    font-weight: 600;
}
.ai-message-content ul, .ai-message-content ol {
    margin-bottom: 10px;
    padding-left: 20px;
}
.ai-message-content pre {
    background: #f1f5f9;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
}

.ai-chat-footer {
    padding: 15px 20px;
    background: var(--ai-white);
    border-top: 1px solid var(--ai-border);
}

.ai-input-container {
    display: flex;
    align-items: flex-end;
    background: var(--ai-bg-light);
    border: 1px solid var(--ai-border);
    border-radius: 20px;
    padding: 8px 15px;
    transition: border-color 0.2s;
}

.ai-input-container:focus-within {
    border-color: var(--ai-brand);
    box-shadow: 0 0 0 3px rgba(232, 118, 60, 0.1);
}

.ai-input-container textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    max-height: 120px;
    font-family: inherit;
    font-size: 14px;
    color: var(--ai-text);
    padding: 4px 0;
    margin-right: 10px;
    outline: none;
}

.ai-input-container textarea::placeholder {
    color: #a0aec0;
}

.ai-send-btn {
    background: var(--ai-brand);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 2px;
}

.ai-send-btn:hover:not(:disabled) {
    background: var(--ai-brand-hover);
    transform: scale(1.05);
}

.ai-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

/* Quick Prompts */
.ai-quick-prompts {
    display: flex;
    gap: 8px;
    padding: 10px 15px;
    background: var(--ai-bg-light);
    border-top: 1px solid var(--ai-border);
    overflow-x: auto;
    white-space: nowrap;
    animation: fadeIn 0.4s ease-in-out;
}

.ai-quick-prompts::-webkit-scrollbar {
    height: 4px;
}
.ai-quick-prompts::-webkit-scrollbar-track {
    background: transparent;
}
.ai-quick-prompts::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.ai-quick-prompt-btn {
    flex-shrink: 0;
    background: var(--ai-white);
    border: 1px solid var(--ai-brand);
    color: var(--ai-brand);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.ai-quick-prompt-btn:hover:not(:disabled) {
    background: var(--ai-brand);
    color: var(--ai-white);
    transform: translateY(-2px);
}

.ai-quick-prompt-btn:disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
    border-color: #cbd5e1;
    color: #94a3b8;
}

/* Typing Indicator */
.ai-typing-indicator {
    display: none;
    padding: 12px 16px;
    background: var(--ai-white);
    border: 1px solid var(--ai-border);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    align-items: center;
    gap: 4px;
}

.ai-typing-indicator.active {
    display: flex;
}

.ai-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.ai-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Tooltip Styles */
.ai-tooltip {
    position: absolute;
    right: 80px;
    bottom: 5px;
    background: var(--ai-white);
    color: var(--ai-text);
    padding: 12px 35px 12px 15px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    font-size: 13px;
    font-weight: 500;
    width: max-content;
    max-width: 250px;
    pointer-events: none;
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid var(--ai-border);
}

.ai-tooltip.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Tooltip tail */
.ai-tooltip::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: var(--ai-white);
    border-top: 1px solid var(--ai-border);
    border-right: 1px solid var(--ai-border);
}

.ai-tooltip-close {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    color: var(--ai-text-muted);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 2px;
}
.ai-tooltip-close:hover {
    color: var(--ai-brand);
}

@media (max-width: 480px) {
    .ai-widget-container {
        bottom: 20px;
        right: 20px;
    }
    .ai-chat-window {
        position: fixed;
        bottom: 0;
        right: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
}
