/* Premium AI Assistant Widget Styles for Divine Foods */
:root {
    --df-ivory: #fdf6e3;
    --df-paper: #fffdf7;
    --df-ink: #0f3d27;
    --df-ink-light: #165c3b;
    --df-gold: #f5a800;
    --df-gold-soft: #ffd873;
    --df-muted: #5b6b60;
    
    --ai-shadow: 0 12px 40px rgba(15, 61, 39, 0.16);
    --ai-shadow-sm: 0 4px 12px rgba(15, 61, 39, 0.08);
    --ai-radius: 20px;
    --ai-ease: cubic-bezier(0.22, 1, 0.36, 1);
}

#ai-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: "Avenir Next", "Century Gothic", Futura, sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

#ai-chat-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background-color: var(--df-ink);
    color: var(--df-paper);
    border: 2px solid var(--df-gold);
    box-shadow: var(--ai-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    transition: transform 300ms var(--ai-ease), background-color 300ms ease;
}

#ai-chat-btn:hover {
    transform: scale(1.06) translateY(-4px);
    background-color: var(--df-ink-light);
}

#ai-chat-btn.has-notification::after {
    content: '';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background-color: var(--df-gold);
    border-radius: 50%;
    border: 2px solid var(--df-ink);
    box-shadow: 0 0 0 2px var(--df-paper);
}

#ai-chat-window {
    position: absolute;
    bottom: 84px;
    right: 0;
    width: 340px;
    max-width: calc(100vw - 48px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: var(--df-ivory);
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-shadow);
    border: 1px solid rgba(15, 61, 39, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 350ms var(--ai-ease), transform 350ms var(--ai-ease);
}

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

#ai-chat-header {
    background: var(--df-ink);
    color: var(--df-paper);
    padding: 16px 18px;
    margin: 12px 12px 0 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(15, 61, 39, 0.15);
}

.ai-chat-header-info {
    display: flex;
    flex-direction: column;
}

.ai-chat-title {
    font-weight: 700;
    font-size: 16px;
    margin: 0;
    letter-spacing: 0.02em;
}

.ai-chat-subtitle {
    font-size: 12px;
    color: rgba(255,255,255,0.7);
    margin: 4px 0 0 0;
}

.ai-chat-subtitle a {
    color: var(--df-gold);
    text-decoration: none;
    font-weight: 600;
    transition: color 200ms;
}
.ai-chat-subtitle a:hover {
    color: var(--df-gold-soft);
}

#ai-chat-close {
    background: transparent;
    border: none;
    color: var(--df-paper);
    font-size: 22px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 200ms ease, transform 200ms ease;
    padding: 4px;
}

#ai-chat-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

#ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: transparent;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
#ai-chat-messages::-webkit-scrollbar {
    display: none;
}

.ai-msg {
    max-width: 88%;
    padding: 14px 18px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
    box-shadow: var(--ai-shadow-sm);
    position: relative;
}

.ai-msg-bot {
    align-self: flex-start;
    background: #ffffff;
    color: var(--df-ink);
    border-radius: 20px 20px 20px 4px;
    border: 1px solid rgba(15, 61, 39, 0.05);
}

.ai-msg-user {
    align-self: flex-end;
    background: var(--df-ink);
    color: var(--df-paper);
    border-radius: 20px 20px 4px 20px;
}

.ai-msg-error {
    align-self: center;
    background: #fff0f0;
    color: #d32f2f;
    font-size: 13px;
    text-align: center;
    border-radius: 12px;
    padding: 10px 16px;
    border: 1px solid #ffcdd2;
}

/* Enhanced Markdown/HTML Formatting inside messages */
.ai-msg p { margin: 0 0 10px 0; }
.ai-msg p:last-child { margin: 0; }
.ai-msg ul, .ai-msg ol { margin: 0 0 10px 0; padding-left: 22px; }
.ai-msg li { margin-bottom: 6px; }
.ai-msg strong { font-weight: 700; color: inherit; }
.ai-msg-bot strong { color: var(--df-ink); }

/* Structured Order Plan UI */
.ai-order-plan {
    background: var(--df-paper);
    border: 1px solid var(--df-gold);
    border-radius: 12px;
    padding: 14px;
    margin-top: 12px;
}
.ai-order-header {
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--df-muted);
    border-bottom: 1px solid rgba(15,61,39,0.1);
    padding-bottom: 8px;
    margin-bottom: 12px;
}
.ai-order-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 13.5px;
    border-bottom: 1px dashed rgba(15,61,39,0.1);
    padding-bottom: 8px;
}
.ai-order-item:last-child {
    border-bottom: none;
}
.ai-order-item-qty {
    color: var(--df-muted);
    font-size: 12px;
    display: block;
}
.ai-order-totals {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px solid rgba(15,61,39,0.1);
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    font-size: 15px;
}
.ai-order-meta {
    font-size: 12px;
    color: var(--df-muted);
    margin-top: 6px;
    text-align: right;
}

/* Actions */
.ai-chat-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.ai-action-btn {
    background: #25d366;
    color: #ffffff !important;
    border: none;
    padding: 10px 16px;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 200ms var(--ai-ease), box-shadow 200ms ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3);
}

.ai-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(37, 211, 102, 0.4);
}

/* Typing Indicator */
.ai-typing {
    display: flex;
    gap: 5px;
    padding: 8px 4px;
    align-items: center;
    height: 24px;
}
.ai-dot {
    width: 6px;
    height: 6px;
    background: var(--df-muted);
    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); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Composer Area */
#ai-chat-input-area {
    padding: 12px 14px;
    background: var(--df-paper);
    border: 1px solid rgba(15, 61, 39, 0.08);
    margin: 0 12px 12px 12px;
    border-radius: 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

#ai-chat-input {
    flex: 1;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 1px solid rgba(15, 61, 39, 0.15);
    border-radius: 22px;
    font-family: inherit;
    font-size: 14px;
    color: var(--df-ink);
    resize: none;
    outline: none;
    transition: border-color 200ms ease, box-shadow 200ms ease;
    background: #ffffff;
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
}
#ai-chat-input::-webkit-scrollbar {
    display: none;
}
#ai-chat-input::placeholder {
    color: var(--df-muted);
}

#ai-chat-input:focus {
    border-color: var(--df-gold);
    box-shadow: 0 0 0 3px rgba(245, 168, 0, 0.15);
}

#ai-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--df-gold);
    color: var(--df-ink);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 200ms var(--ai-ease), background 200ms ease;
    flex-shrink: 0;
}

#ai-chat-send:hover:not(:disabled) {
    background: var(--df-gold-soft);
    transform: scale(1.05);
}
#ai-chat-send:disabled {
    background: #e0e0e0;
    color: #a0a0a0;
    cursor: not-allowed;
    transform: none;
}

@media (max-width: 480px) {
    #ai-chat-window {
        position: fixed;
        bottom: 16px;
        right: 16px;
        width: calc(100vw - 32px);
        max-width: none;
        height: 65dvh;
        max-height: 500px;
        border-radius: var(--ai-radius);
        border: 1px solid rgba(15, 61, 39, 0.1);
        transform-origin: bottom right;
    }
    #ai-chat-window.is-open {
        transform: translateY(0) scale(1);
    }
    #ai-chat-widget {
        bottom: 16px;
        right: 16px;
    }
    #ai-chat-header {
        padding: 12px 14px;
        margin: 10px 10px 0 10px;
        border-radius: 14px;
    }
    #ai-chat-messages {
        padding: 12px;
        gap: 12px;
    }
    #ai-chat-input-area {
        padding: 10px 12px;
        margin: 0 10px 10px 10px;
        border-radius: 16px;
    }
    .ai-order-plan {
        padding: 10px;
    }
}

/* Hide launcher and global WhatsApp button when AI widget is open */
body.ai-chat-open #ai-chat-btn {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: scale(0.8) !important;
}

body.ai-chat-open .floating-whatsapp {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(20px) !important;
}
