/* AI Chatbot Styles for Beauty Atelier IN */
:root {
    --chat-primary: #C49A45;
    --chat-primary-hover: #E2C279;
    --chat-bg: #ffffff;
    --chat-text: #333333;
    --chat-border: #e0e0e0;
    --chat-user-msg: #f0f0f0;
    --chat-ai-msg: #fdfaf3;
}

/* Floating Action Button */
#ai-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background-color: var(--chat-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(196, 154, 69, 0.4);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s ease;
    border: none;
}

#ai-chat-fab:hover {
    background-color: var(--chat-primary-hover);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(196, 154, 69, 0.6);
}

#ai-chat-fab.ai-chat-hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

#ai-chat-fab svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
}

/* Chat Window */
#ai-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: calc(100vw - 48px);
    max-width: 380px;
    height: 550px;
    max-height: calc(100vh - 48px);
    background-color: var(--chat-bg);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 10000;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    transform-origin: bottom right;
    border: 1px solid var(--chat-border);
    overflow: hidden;
    font-family: 'Manrope', sans-serif;
}

#ai-chat-window.ai-chat-hidden {
    transform: scale(0.9);
    opacity: 0;
    pointer-events: none;
}

/* Header */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background-color: #fafafa;
    border-bottom: 1px solid var(--chat-border);
}

.ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    width: 36px;
    height: 36px;
    background-color: var(--chat-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-avatar svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.ai-chat-title h3 {
    margin: 0;
    font-size: 15px;
    color: #111;
    font-weight: 600;
}

.ai-chat-title p {
    margin: 0;
    font-size: 12px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-chat-status-dot {
    width: 8px;
    height: 8px;
    background-color: #4caf50;
    border-radius: 50%;
    display: inline-block;
    animation: ai-chat-pulse 2s infinite;
}

@keyframes ai-chat-pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }

    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(76, 175, 80, 0);
    }

    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

.ai-chat-close {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    border-radius: 8px;
    padding: 8px;
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-close:hover {
    background-color: #f0f0f0;
    color: #111;
}

.ai-chat-close svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

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

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

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

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

.ai-message {
    display: flex;
    gap: 12px;
    max-width: 85%;
}

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

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

.ai-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background-color: var(--chat-primary);
    color: #fff;
    align-self: flex-end;
}

.ai-message.ai-role-user .ai-message-avatar {
    background-color: #999;
}

.ai-message-avatar svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

.ai-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--chat-text);
    word-wrap: break-word;
}

.ai-message.ai-role-user .ai-message-bubble {
    background-color: var(--chat-user-msg);
    border-bottom-right-radius: 4px;
}

.ai-message.ai-role-assistant .ai-message-bubble {
    background-color: var(--chat-ai-msg);
    border: 1px solid var(--chat-primary);
    border-bottom-left-radius: 4px;
}

/* Loading state */
.ai-chat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background-color: var(--chat-ai-msg);
    border: 1px solid var(--chat-primary);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-items: center;
    width: fit-content;
}

.ai-chat-dot {
    width: 6px;
    height: 6px;
    background-color: var(--chat-primary);
    border-radius: 50%;
    animation: ai-chat-typing-anim 1.4s infinite ease-in-out both;
}

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

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

@keyframes ai-chat-typing-anim {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.ai-chat-input-area {
    padding: 16px;
    background-color: #fff;
    border-top: 1px solid var(--chat-border);
}

.ai-chat-form {
    display: flex;
    position: relative;
    align-items: center;
}

.ai-chat-input {
    flex: 1;
    border: 1px solid var(--chat-border);
    border-radius: 20px;
    padding: 12px 48px 12px 16px;
    /* 16px minimum prevents iOS Safari from auto-zooming on focus */
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
    font-family: 'Manrope', sans-serif;
    color: var(--chat-text);
}

.ai-chat-input:focus {
    border-color: var(--chat-primary);
}

.ai-chat-submit {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--chat-primary);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

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

.ai-chat-submit:disabled {
    color: #ccc;
    cursor: not-allowed;
}

.ai-chat-submit svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Mobile responsive */
@media (max-width: 480px) {
    #ai-chat-window {
        /* Use dynamic viewport height so the window shrinks when the iOS keyboard appears */
        bottom: 0;
        right: 0;
        width: 100vw;
        /* dvh (dynamic viewport height) shrinks with the keyboard on iOS Safari */
        height: 100dvh;
        max-height: 100dvh;
        max-width: none;
        border-radius: 0;
        z-index: 100000;
        /* Respect iPhone notch / home bar */
        padding-bottom: env(safe-area-inset-bottom);
    }

    .ai-chat-header {
        /* Keep the header fully visible at all times */
        position: sticky;
        top: 0;
        z-index: 1;
        flex-shrink: 0;
        /* Respect iPhone notch on top */
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .ai-chat-input-area {
        /* Stick input to the visible bottom above the keyboard */
        flex-shrink: 0;
    }

    #ai-chat-fab {
        width: 50px;
        height: 50px;
        bottom: 16px;
        right: 16px;
    }

    #ai-chat-fab svg {
        width: 24px;
        height: 24px;
    }
}