/* ============================================================
   Back Acres Farm AI Assistant - Chat Widget Styles
   ============================================================ */

/* ---- Floating button ---- */
.baf-ai-btn {
    position: fixed;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    color: #fff;
    border: 3px solid rgba(255,255,255,0.3);
    cursor: pointer;
    z-index: 999999999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.baf-ai-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(0,0,0,0.38);
}
.baf-ai-btn.open { background: #c0392b !important; }
.baf-ai-btn svg {
    width: 26px;
    height: 26px;
    fill: #fff;
}

/* Pulse ring */
.baf-ai-btn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid currentColor;
    animation: bafAiPulse 2.5s ease-out infinite;
    opacity: 0;
}
@keyframes bafAiPulse {
    0%   { transform: scale(1);   opacity: 0.6; }
    100% { transform: scale(1.6); opacity: 0; }
}
.baf-ai-btn.open::before { display: none; }

/* ---- Tooltip ---- */
.baf-ai-tooltip {
    position: fixed;
    bottom: 34px;
    background: #2ea3f2;
    color: #fff;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    white-space: nowrap;
    z-index: 999999998;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.baf-ai-tooltip.hidden { opacity: 0; }

/* ---- Chat window ---- */
.baf-ai-window {
    position: fixed;
    bottom: 92px;
    width: 360px;
    height: 500px;
    max-height: 75vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.25);
    z-index: 999999997;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95) translateY(10px);
    transform-origin: bottom right;
    transition: opacity 0.22s ease, transform 0.22s ease;
    overflow: hidden;
    isolation: isolate;
}
.baf-ai-window.open {
    opacity: 1;
    pointer-events: all;
    transform: scale(1) translateY(0);
}

/* ---- Header ---- */
.baf-ai-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.baf-ai-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.baf-ai-avatar {
    font-size: 26px;
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.baf-ai-header-name {
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    font-family: Georgia, serif;
}
.baf-ai-header-status {
    color: rgba(255,255,255,0.85);
    font-size: 0.75rem;
    font-family: -apple-system, sans-serif;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}
.baf-ai-status-dot {
    width: 7px;
    height: 7px;
    background: #7dff7d;
    border-radius: 50%;
    display: inline-block;
}
.baf-ai-header-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}
.baf-ai-header-close:hover { background: rgba(255,255,255,0.25); }

/* ---- Messages area ---- */
.baf-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.baf-ai-messages::-webkit-scrollbar { width: 4px; }
.baf-ai-messages::-webkit-scrollbar-track { background: transparent; }
.baf-ai-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

/* Message bubbles */
.baf-ai-msg {
    display: flex;
    gap: 8px;
    max-width: 100%;
}
.baf-ai-msg.user { flex-direction: row-reverse; }

.baf-ai-bubble {
    padding: 10px 13px;
    border-radius: 16px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.875rem;
    line-height: 1.55;
    max-width: 80%;
    word-wrap: break-word;
}
.baf-ai-msg.assistant .baf-ai-bubble {
    background: #f3f4f6;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}
.baf-ai-msg.user .baf-ai-bubble {
    background: #3a5a3a;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.baf-ai-typing .baf-ai-bubble {
    background: #f3f4f6;
    padding: 12px 16px;
}

/* ---- Formatted content inside assistant bubbles ---- */
.baf-ai-msg.assistant .baf-ai-bubble strong {
    font-weight: 700;
    color: #111;
}
.baf-ai-msg.assistant .baf-ai-bubble em {
    font-style: italic;
}
.baf-ai-msg.assistant .baf-ai-bubble ul,
.baf-ai-msg.assistant .baf-ai-bubble ol {
    margin: 8px 0 8px 6px;
    padding-left: 18px;
}
.baf-ai-msg.assistant .baf-ai-bubble li {
    margin-bottom: 4px;
    line-height: 1.5;
}
.baf-ai-msg.assistant .baf-ai-bubble br + br {
    display: block;
    content: '';
    margin-top: 6px;
}
.baf-ai-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}
.baf-ai-dots span {
    width: 7px;
    height: 7px;
    background: #aaa;
    border-radius: 50%;
    animation: bafAiDot 1.2s ease-in-out infinite;
}
.baf-ai-dots span:nth-child(2) { animation-delay: 0.2s; }
.baf-ai-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bafAiDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* ---- Suggested questions ---- */
.baf-ai-suggestions {
    padding: 4px 12px 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}
.baf-ai-suggestion {
    background: #f0f6f0;
    border: 1px solid #c8dfc8;
    color: #3a5a3a;
    border-radius: 20px;
    padding: 5px 11px;
    font-size: 0.75rem;
    font-family: -apple-system, sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.baf-ai-suggestion:hover {
    background: #d8ecd8;
    border-color: #3a5a3a;
}
.baf-ai-suggestions.hidden { display: none; }

/* ---- Input area ---- */
.baf-ai-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    background: #fafafa;
    flex-shrink: 0;
}
.baf-ai-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 9px 14px;
    font-size: 0.875rem;
    font-family: -apple-system, sans-serif;
    resize: none;
    outline: none;
    line-height: 1.4;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color 0.15s;
    background: #fff;
}
.baf-ai-input:focus { border-color: #3a5a3a; }
.baf-ai-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.1s;
}
.baf-ai-send:hover { opacity: 0.88; transform: scale(1.05); }
.baf-ai-send:disabled { opacity: 0.4; cursor: default; transform: none; }
.baf-ai-send svg { width: 18px; height: 18px; fill: #fff; }

/* ---- Mobile ---- */
@media (max-width: 600px) {
    .baf-ai-window {
        width: calc(100vw - 16px);
        right: 8px !important;
        left: 8px !important;
        bottom: 88px;
        height: 70vh;
    }
    .baf-ai-btn { bottom: 16px; }
    .baf-ai-tooltip { display: none; }
    .baf-ai-suggestion { font-size: 0.7rem; padding: 4px 9px; }
}
