/* 
 * AI Assistant Vanilla Widget Styles 
 * Strictly isolated with ai-chat- prefix
 */

.ai-chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2147483647;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    pointer-events: none;
}

.ai-chat-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    line-height: normal;
}

/* Chat Window */
.ai-chat-window {
    width: 380px;
    height: 600px;
    max-height: 80vh;
    background: #f8fafc;
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.2);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
    overflow: hidden;
    transform: scale(0.95);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
}

.ai-chat-window.ai-chat-open {
    transform: scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.ai-chat-header {
    background: #10b981; /* emerald-500 */
    color: #fff;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    z-index: 2;
}

.ai-chat-header-avatar {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 16px;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.ai-chat-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ai-chat-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ai-chat-header-title {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px !important;
}

.ai-chat-header-subtitle {
    font-size: 14px;
    font-weight: 500;
    color: #d1fae5; /* very light emerald */
    margin-bottom: 6px !important;
}

.ai-chat-header-disclaimer {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.75);
    line-height: 1.3 !important;
}

.ai-chat-header-disclaimer.font-bold {
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    margin-top: 4px !important;
}

.ai-chat-close-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.ai-chat-close-btn:hover {
    background: #059669;
}

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

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}
.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.ai-chat-messages::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

/* Message Row */
.ai-msg-row {
    display: flex;
    width: 100%;
}

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

.ai-msg-content {
    max-width: 85%;
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.ai-msg-row.ai-user .ai-msg-content {
    flex-direction: row-reverse;
}

/* Avatars */
.ai-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-msg-row.ai-user .ai-avatar {
    background: #d1fae5;
    color: #047857;
}

.ai-msg-row.ai-bot .ai-avatar {
    background: #e2e8f0;
    color: #475569;
}

/* Bubbles */
.ai-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.ai-msg-row.ai-user .ai-bubble {
    background: #10b981;
    color: #000;
    border-bottom-right-radius: 4px;
}

.ai-msg-row.ai-bot .ai-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* Markdown styling inside bot bubble */
.ai-msg-row.ai-bot .ai-bubble p {
    margin-bottom: 12px !important;
    line-height: 1.5 !important;
}
.ai-msg-row.ai-bot .ai-bubble p:last-child {
    margin-bottom: 0 !important;
}
.ai-msg-row.ai-bot .ai-bubble ul,
.ai-msg-row.ai-bot .ai-bubble ol {
    margin-left: 20px !important;
    margin-bottom: 12px !important;
}
.ai-msg-row.ai-bot .ai-bubble li {
    margin-bottom: 4px !important;
}
.ai-msg-row.ai-bot .ai-bubble strong {
    font-weight: 600 !important;
}

/* Loading Dots */
.ai-typing-indicator {
    display: none;
    align-items: center;
    gap: 4px;
}
.ai-typing-indicator.ai-active {
    display: flex;
}
.ai-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: ai-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 ai-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Input Area */
.ai-chat-input-area {
    padding: 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 12px;
}

.ai-chat-input {
    flex: 1;
    background: #f1f5f9;
    border: 2px solid transparent;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    color: #0f172a;
}

.ai-chat-input:focus {
    background: #fff;
    border-color: #10b981;
}

.ai-chat-submit {
    background: #10b981;
    color: #000;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.ai-chat-submit:hover:not(:disabled) {
    background: #059669;
}

.ai-chat-submit:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

/* Toggle Button */
.ai-chat-toggle {
    background: #10b981;
    color: #000;
    pointer-events: auto;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
    position: relative;
}

.ai-chat-toggle:hover {
    background: #059669;
    transform: scale(1.05);
}

.ai-chat-toggle:active {
    transform: scale(0.95);
}

.ai-chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 48px);
        height: 70vh;
    }
}
