/* Amavi AI Chat Widget — Luxury Caribbean Aesthetic */
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@400;500;600&family=DM+Sans:wght@300;400;500&display=swap');

:root {
    --amavi-color: #c8a96e;
    --amavi-dark: #1a1a1a;
    --amavi-white: #faf9f7;
    --amavi-gray: #f0ede8;
    --amavi-text: #2c2c2c;
    --amavi-muted: #8a8078;
    --amavi-radius: 18px;
    --amavi-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.1);
    --amavi-font-display: 'Cormorant Garamond', Georgia, serif;
    --amavi-font-body: 'DM Sans', -apple-system, sans-serif;
}

/* Container */
#amavi-chat-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    font-family: var(--amavi-font-body);
}

/* Toggle Button */
#amavi-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--amavi-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 6px 24px rgba(200, 169, 110, 0.45);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease;
    position: relative;
    z-index: 1;
}

#amavi-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 30px rgba(200, 169, 110, 0.55);
}

#amavi-chat-toggle svg {
    width: 24px;
    height: 24px;
    transition: opacity 0.2s, transform 0.2s;
}

/* Pulse animation on load */
#amavi-chat-toggle::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    background: var(--amavi-color);
    opacity: 0;
    animation: amavi-pulse 2.5s ease-out 1s 3;
}

@keyframes amavi-pulse {
    0% { opacity: 0.4; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.6); }
}

/* Notification dot */
#amavi-chat-toggle .amavi-unread-dot {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 11px;
    height: 11px;
    background: #e74c3c;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* Chat Window */
#amavi-chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 360px;
    max-height: 540px;
    background: var(--amavi-white);
    border-radius: var(--amavi-radius);
    box-shadow: var(--amavi-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.3, 0.64, 1);
    border: 1px solid rgba(200,169,110,0.15);
}

#amavi-chat-window.amavi-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
#amavi-chat-header {
    background: var(--amavi-dark);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

#amavi-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--amavi-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#amavi-chat-avatar svg {
    width: 20px;
    height: 20px;
    color: #fff;
}

#amavi-chat-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#amavi-chat-name {
    font-family: var(--amavi-font-display);
    font-weight: 500;
    font-size: 17px;
    color: var(--amavi-white);
    letter-spacing: 0.02em;
    line-height: 1.2;
}

#amavi-chat-status {
    font-size: 11px;
    color: var(--amavi-muted);
    display: flex;
    align-items: center;
    gap: 5px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.amavi-status-dot {
    width: 7px;
    height: 7px;
    background: #4caf7d;
    border-radius: 50%;
    display: inline-block;
    animation: amavi-blink 2.5s ease infinite;
}

@keyframes amavi-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

#amavi-chat-minimize {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--amavi-muted);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

#amavi-chat-minimize:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

#amavi-chat-minimize svg {
    width: 16px;
    height: 16px;
}

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

#amavi-chat-messages::-webkit-scrollbar {
    width: 4px;
}

#amavi-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(200,169,110,0.25);
    border-radius: 4px;
}

/* Message Bubbles */
.amavi-message {
    display: flex;
    gap: 8px;
    animation: amavi-msg-in 0.25s ease forwards;
    max-width: 88%;
}

@keyframes amavi-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.amavi-message.amavi-bot {
    align-self: flex-start;
    align-items: flex-end;
}

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

.amavi-bubble {
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--amavi-text);
}

.amavi-bot .amavi-bubble {
    background: var(--amavi-gray);
    border-bottom-left-radius: 4px;
    color: var(--amavi-text);
}

.amavi-user .amavi-bubble {
    background: var(--amavi-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.amavi-bubble a {
    color: inherit;
    text-decoration: underline;
    opacity: 0.85;
}

.amavi-message-time {
    font-size: 10px;
    color: var(--amavi-muted);
    margin-top: 3px;
    padding: 0 4px;
    align-self: flex-end;
}

/* Typing Indicator */
#amavi-chat-typing {
    padding: 4px 20px 12px;
    display: flex;
    gap: 5px;
    align-items: center;
}

#amavi-chat-typing span {
    width: 7px;
    height: 7px;
    background: var(--amavi-color);
    border-radius: 50%;
    opacity: 0.4;
    animation: amavi-bounce 1.2s ease infinite;
}

#amavi-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
#amavi-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes amavi-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* Input Area */
#amavi-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid rgba(200,169,110,0.12);
    background: #fff;
    flex-shrink: 0;
}

#amavi-chat-input {
    flex: 1;
    border: 1.5px solid #e8e2d8;
    border-radius: 12px;
    padding: 10px 14px;
    font-family: var(--amavi-font-body);
    font-size: 16px; /* 16px prevents iOS auto-zoom on tap */
    line-height: 1.4;
    resize: none;
    outline: none;
    color: var(--amavi-text);
    background: var(--amavi-gray);
    transition: border-color 0.2s;
    height: 44px;
    max-height: 44px;
    overflow-y: hidden;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
}

#amavi-chat-input:focus {
    border-color: var(--amavi-color);
    background: #fff;
}

#amavi-chat-input::placeholder {
    color: #b5a898;
    font-size: 16px; /* Must match input font-size to prevent iOS zoom */
}

#amavi-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--amavi-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
}

#amavi-chat-send:hover {
    background: #b8966a;
    transform: scale(1.05);
}

#amavi-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

#amavi-chat-send svg {
    width: 18px;
    height: 18px;
}

/* Footer */
#amavi-chat-footer {
    text-align: center;
    font-size: 10px;
    color: var(--amavi-muted);
    padding: 6px;
    background: #fff;
    letter-spacing: 0.03em;
}

#amavi-chat-footer a {
    color: var(--amavi-color);
    text-decoration: none;
}

/* Mobile */
@media (max-width: 480px) {
    #amavi-chat-container {
        bottom: 12px;
        right: 12px;
        left: auto;
    }

    #amavi-chat-window {
        position: fixed !important;
        bottom: 76px !important;
        right: 0 !important;
        left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        height: 70vh !important;
        max-height: 70vh !important;
        border-radius: 16px 16px 0 0 !important;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.15) !important;
        box-sizing: border-box !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    #amavi-chat-messages {
        flex: 1 !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        min-height: 0 !important;
    }

    #amavi-chat-input-area {
        flex-shrink: 0 !important;
        box-sizing: border-box !important;
        width: 100% !important;
    }

    #amavi-chat-input-row {
        box-sizing: border-box !important;
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
    }

    #amavi-chat-input {
        font-size: 16px !important;
        flex: 1 !important;
        min-width: 0 !important;
        max-width: calc(100% - 60px) !important;
        box-sizing: border-box !important;
    }

    #amavi-chat-send {
        flex-shrink: 0 !important;
    }

    .amavi-bubble {
        max-width: 82% !important;
        word-break: break-word !important;
    }
}

/* WhatsApp button */
.amavi-wa-row {
    display: flex;
    justify-content: flex-start;
    padding: 4px 12px;
}
.amavi-wa-btn {
    display: inline-flex;
    align-items: center;
    background: #25D366;
    color: #fff !important;
    text-decoration: none !important;
    padding: 11px 20px;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    box-shadow: 0 2px 8px rgba(37,211,102,0.3);
}
.amavi-wa-btn:hover {
    background: #1da851;
}
