/**
 * AI Chat Widget Styles
 *
 * @package ultimate-real-estate-media-template
 */

/* Chat Widget Container */
.flavor-ai-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
.flavor-ai-toggle {
    position: relative;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: var(--flavor-ai-primary, #e94560);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    padding: 0;
    overflow: visible;
}

/* When showing avatar, remove background */
.flavor-ai-toggle:has(.toggle-avatar) {
    background: transparent;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.flavor-ai-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.3);
}

.flavor-ai-toggle:focus {
    outline: 3px solid var(--flavor-ai-primary, #e94560);
    outline-offset: 3px;
}

.flavor-ai-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: transform 0.3s ease;
}

.flavor-ai-toggle .toggle-avatar {
    width: calc(100% + 6px);
    height: calc(100% + 6px);
    margin: -3px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center 20%;
    transition: transform 0.3s ease;
    border: 3px solid #fff;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

/* Online indicator on avatar */
.flavor-ai-toggle::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 16px;
    height: 16px;
    background: #22c55e;
    border: 3px solid #fff;
    border-radius: 50%;
    z-index: 10;
    animation: pulse 2s ease-in-out infinite;
}

.flavor-ai-widget.open .flavor-ai-toggle::after {
    display: none;
}

.flavor-ai-widget.open .flavor-ai-toggle svg.chat-icon,
.flavor-ai-widget.open .flavor-ai-toggle .toggle-avatar {
    display: none;
}

.flavor-ai-widget:not(.open) .flavor-ai-toggle svg.close-icon {
    display: none;
}

/* Notification Badge - hidden when using avatar (online dot replaces it) */
.flavor-ai-badge {
    display: none; /* Hidden - replaced by online indicator on toggle */
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Greeting Prompt Bubble */
.flavor-ai-prompt {
    position: absolute;
    bottom: 75px;
    right: 0;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 12px 16px;
    padding-right: 32px;
    max-width: 220px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s ease;
    pointer-events: none;
}

.flavor-ai-widget.prompt-visible .flavor-ai-prompt {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.flavor-ai-widget.open .flavor-ai-prompt,
.flavor-ai-widget.prompt-dismissed .flavor-ai-prompt {
    display: none;
}

/* Prompt arrow pointing to avatar */
.flavor-ai-prompt::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    width: 16px;
    height: 16px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.05);
    border-radius: 0 0 4px 0;
}

.flavor-ai-prompt-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 20px;
    height: 20px;
    background: none;
    border: none;
    font-size: 18px;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.flavor-ai-prompt-close:hover {
    color: #666;
}

.flavor-ai-prompt-text {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    line-height: 1.4;
    cursor: pointer;
}

.flavor-ai-prompt-text:hover {
    color: var(--flavor-ai-primary, #e94560);
}

/* Animate prompt entrance */
@keyframes promptBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-5px) scale(1.02); }
}

.flavor-ai-widget.prompt-visible .flavor-ai-prompt {
    animation: promptBounce 2s ease-in-out 1s 2;
}

/* Chat Window */
.flavor-ai-chat {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.flavor-ai-widget.open .flavor-ai-chat {
    display: flex;
}

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

/* Chat Header */
.flavor-ai-header {
    background: var(--flavor-ai-primary, #e94560);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.flavor-ai-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.flavor-ai-avatar svg {
    width: 24px;
    height: 24px;
    fill: #fff;
}

.flavor-ai-avatar.has-image {
    background: #fff;
    border: 2px solid rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.flavor-ai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    border-radius: 50%;
}

.flavor-ai-header-info {
    flex: 1;
}

.flavor-ai-header-name {
    font-weight: 600;
    font-size: 16px;
    margin: 0 0 2px;
}

.flavor-ai-header-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.flavor-ai-header-status .status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.flavor-ai-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flavor-ai-close svg {
    width: 20px;
    height: 20px;
    fill: #fff;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.flavor-ai-close:hover svg {
    opacity: 1;
}

/* Messages Container */
.flavor-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

/* Scrollbar */
.flavor-ai-messages::-webkit-scrollbar {
    width: 6px;
}

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

.flavor-ai-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.flavor-ai-messages::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Message Bubble */
.flavor-ai-message {
    display: flex;
    gap: 8px;
    max-width: 85%;
}

.flavor-ai-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

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

.flavor-ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--flavor-ai-primary, #e94560);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.flavor-ai-message.user .flavor-ai-message-avatar {
    background: #667eea;
}

.flavor-ai-message-avatar svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

.flavor-ai-message-avatar.has-image {
    background: #fff;
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.flavor-ai-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    border-radius: 50%;
}

.flavor-ai-message-content {
    background: #fff;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.flavor-ai-message.user .flavor-ai-message-content {
    background: var(--flavor-ai-primary, #e94560);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.flavor-ai-message.assistant .flavor-ai-message-content {
    border-bottom-left-radius: 4px;
}

/* Links in messages */
.flavor-ai-message-content a {
    color: inherit;
    text-decoration: underline;
}

.flavor-ai-message.assistant .flavor-ai-message-content a {
    color: var(--flavor-ai-primary, #e94560);
}

/* Typing Indicator */
.flavor-ai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.flavor-ai-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Input Area */
.flavor-ai-input {
    padding: 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.flavor-ai-input input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.flavor-ai-input input:focus {
    border-color: var(--flavor-ai-primary, #e94560);
    box-shadow: 0 0 0 3px rgba(233, 69, 96, 0.1);
}

.flavor-ai-input input::placeholder {
    color: #999;
}

.flavor-ai-send {
    width: 44px;
    height: 44px;
    background: var(--flavor-ai-primary, #e94560);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.2s;
}

.flavor-ai-send:hover {
    background: #d63850;
    transform: scale(1.05);
}

.flavor-ai-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.flavor-ai-send svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* Quick Actions */
.flavor-ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px 15px;
    background: #f8f9fa;
}

.flavor-ai-quick-action {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.flavor-ai-quick-action:hover {
    border-color: var(--flavor-ai-primary, #e94560);
    color: var(--flavor-ai-primary, #e94560);
    background: rgba(233, 69, 96, 0.05);
}

/* Responsive */
@media (max-width: 480px) {
    .flavor-ai-widget {
        bottom: 15px;
        right: 15px;
    }

    .flavor-ai-chat {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        bottom: 70px;
        right: -15px;
        border-radius: 12px;
    }

    .flavor-ai-toggle {
        width: 58px;
        height: 58px;
    }

    .flavor-ai-toggle::after {
        width: 14px;
        height: 14px;
        bottom: 2px;
        right: 2px;
        border-width: 2px;
    }

    .flavor-ai-prompt {
        bottom: 68px;
        right: -5px;
        max-width: 180px;
        padding: 10px 14px;
        padding-right: 28px;
        font-size: 13px;
    }

    .flavor-ai-prompt::after {
        right: 20px;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .flavor-ai-toggle,
    .flavor-ai-chat,
    .flavor-ai-message-content,
    .flavor-ai-send {
        transition: none;
    }

    .flavor-ai-badge,
    .flavor-ai-typing span {
        animation: none;
    }

    @keyframes slideUp {
        from, to {
            opacity: 1;
            transform: none;
        }
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .flavor-ai-chat {
        background: #1a1a2e;
    }

    .flavor-ai-messages {
        background: #16162a;
    }

    .flavor-ai-message.assistant .flavor-ai-message-content {
        background: #252542;
        color: #e0e0e0;
    }

    .flavor-ai-input {
        background: #1a1a2e;
        border-color: #333;
    }

    .flavor-ai-input input {
        background: #252542;
        border-color: #444;
        color: #fff;
    }

    .flavor-ai-input input::placeholder {
        color: #888;
    }

    .flavor-ai-typing {
        background: #252542;
    }

    .flavor-ai-quick-action {
        background: #252542;
        border-color: #444;
        color: #ccc;
    }

    .flavor-ai-prompt {
        background: #252542;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }

    .flavor-ai-prompt::after {
        background: #252542;
    }

    .flavor-ai-prompt-text {
        color: #e0e0e0;
    }

    .flavor-ai-prompt-close {
        color: #888;
    }

    .flavor-ai-prompt-close:hover {
        color: #ccc;
    }
}
