/* ==========================================================================
   NohiAI — Nohitatu AI Support widget (v20260820icons)
   Self-contained: loads Plus Jakarta Sans here so any page linking only
   chatbot.css still gets the brand UI font (not Georgia / system serif).
   Direction: soft white panel + site violet accents — unlike cream/serif
   and unlike navy/orange ui2.
   Panel starts closed: #chatbot-window.chatbot-window.hidden must beat the
   open-state #chatbot-window.chatbot-window rule (ID+class specificity).
   Open/close uses opacity + visibility only (no display:none / transform
   slide) so composited white layers cannot ghost-flash behind the panel.
   ========================================================================== */

@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap");

#chatbot-container.chatbot-container,
.chatbot-container {
    --cb-navy: #1a2332;
    --cb-ink: #1a2332;
    --cb-muted: #6b7280;
    --cb-line: #e5e7eb;
    --cb-soft: #f5f6f8;
    --cb-paper: #ffffff;
    --cb-live: #22c55e;
    --cb-violet: #726cf4;
    --cb-violet-deep: #5f58dc;
    --cb-user: #ebe9fe;
    --cb-user-ink: #2e2a6b;
    --cb-radius: 14px;
    --cb-radius-sm: 10px;
    --cb-shadow: 0 18px 48px rgba(26, 35, 50, 0.14);

    position: fixed;
    bottom: 35px;
    right: 90px;
    z-index: 2147483000;
    /* Let page content receive clicks outside the FAB / open panel */
    pointer-events: none;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif !important;
    -webkit-font-smoothing: antialiased;
    color: var(--cb-ink);
}

/* Trigger — site violet (not navy / not orange) */
#chatbot-toggle.chatbot-toggle,
.chatbot-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cb-violet) !important;
    border: none !important;
    color: #ffffff !important;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(114, 108, 244, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    position: relative;
    outline: none !important;
    pointer-events: auto;
}

.chatbot-toggle:hover {
    background: var(--cb-violet-deep) !important;
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(95, 88, 220, 0.36);
}

.chatbot-toggle:active {
    transform: scale(0.96);
}

.toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.toggle-icon.hidden {
    display: none !important;
}

/* Panel — white / soft light
   Keep display:flex always. Toggling display:none↔flex with opacity/transform
   transitions paints a full solid-white layer for a frame (or leaves a
   semi-transparent “ghost” twin offset during compositing) — the white flicker
   users see behind the open widget on GPU-heavy heroes (Spline robot). */
#chatbot-window.chatbot-window,
.chatbot-window {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 370px;
    height: 500px;
    max-height: calc(100vh - 120px);
    background: #ffffff !important;
    border: 1px solid var(--cb-line);
    border-radius: var(--cb-radius);
    box-shadow: 0 16px 48px rgba(15, 23, 42, 0.22), 0 0 1px rgba(15, 23, 42, 0.15) !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: auto;
    /* Stable composite without permanent will-change (avoids layer thrash/flicker) */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Closed by default — match #chatbot-window.chatbot-window specificity.
   No display:none, no translate/scale open animation (those cause white ghosts). */
#chatbot-window.chatbot-window.hidden,
.chatbot-window.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transform: none;
}

/* Header — white/light with dark navy text */
.chatbot-header {
    background: var(--cb-paper) !important;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chatbot-avatar-box {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #726cf4, #00f2fe) !important;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(114, 108, 244, 0.35);
}

.chatbot-avatar-box svg {
    stroke: #ffffff !important;
}

.chatbot-avatar-box svg circle,
.chatbot-avatar-box svg path[fill] {
    fill: #ffffff !important;
}

.chatbot-header-text h4 {
    margin: 0 !important;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    letter-spacing: -0.02em !important;
    line-height: 1.2 !important;
    color: #0f172a !important;
    font-style: normal !important;
}

.chatbot-header-text small {
    font-family: "Plus Jakarta Sans", system-ui, sans-serif !important;
    font-size: 11px !important;
    color: #16a34a !important;
    font-weight: 700 !important;
    letter-spacing: 0.03em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    text-transform: uppercase;
}

.chatbot-header {
    background: #ffffff !important;
    padding: 12px 16px !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    border-bottom: 1px solid #e2e8f0 !important;
    flex-shrink: 0 !important;
}

.status-dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

/* Messages — soft light area */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #f8fafc !important;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.chatbot-message {
    display: flex;
    animation: msgFade 0.22s ease;
}

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

.bot-message {
    justify-content: flex-start;
}

.user-message {
    justify-content: flex-end;
}

.message-content {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 14px;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif !important;
    font-size: 13.5px;
    font-weight: 450;
    line-height: 1.6;
    letter-spacing: -0.01em;
    overflow-wrap: break-word;
    word-break: normal;
}

.cb-cta {
    white-space: nowrap !important;
    font-weight: 600 !important;
    display: inline-block;
}

.bot-message .message-content {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.bot-message .message-content p {
    margin: 0 0 8px 0;
}

.bot-message .message-content p:last-child {
    margin-bottom: 0;
}

.user-message .message-content {
    background: linear-gradient(135deg, #726cf4, #6366f1) !important;
    color: #ffffff !important;
    border: none;
    border-bottom-right-radius: 4px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(114, 108, 244, 0.28);
}

/* Quick replies */
.quick-chips {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.quick-chips-label {
    font-family: "Plus Jakarta Sans", system-ui, sans-serif !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #64748b !important;
    margin: 4px 0 2px;
}

.quick-chips--row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: stretch;
}

.quick-chips--row .quick-chips-label {
    flex: 1 0 100%;
}

.quick-chips--row .chip-btn {
    flex: 1 1 auto;
    text-align: center;
    min-width: 120px;
}

.chip-btn {
    background: #ffffff !important;
    border: 1.5px solid #e2e8f0 !important;
    color: #334155 !important;
    padding: 10px 14px;
    border-radius: 10px !important;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: -0.01em;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none !important;
    text-align: left;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03) !important;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chip-btn .chip-icon-svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: block;
    overflow: visible;
}

.chip-btn .chip-label {
    flex: 1;
    min-width: 0;
    line-height: 1.3;
}

.chip-btn:hover {
    background: #f5f3ff !important;
    color: #6366f1 !important;
    border-color: rgba(99, 102, 241, 0.45) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.12) !important;
}

.chip-btn:hover .chip-icon-svg {
    transform: scale(1.06);
    transition: transform 0.2s ease;
}

.chip-btn--cta {
    border-color: rgba(114, 108, 244, 0.4) !important;
    color: var(--cb-violet-deep) !important;
    background: #f7f6ff !important;
}

.chip-btn--cta:hover {
    background: #efedff !important;
    border-color: rgba(114, 108, 244, 0.55) !important;
}

.chip-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(114, 108, 244, 0.22);
}

/* In-message CTAs */
.bot-message .message-content a.cb-cta,
.message-content a.cb-cta {
    color: #6366f1 !important;
    font-weight: 700 !important;
    text-decoration: underline !important;
    text-underline-offset: 3px;
}

.bot-message .message-content a.cb-cta:hover,
.message-content a.cb-cta:hover {
    color: #4f46e5 !important;
}

/* Input Area */
.chatbot-input-area {
    padding: 14px 16px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    background: #f8fafc !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 11px 16px;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif !important;
    font-size: 13.5px;
    font-weight: 500;
    color: #0f172a;
    outline: none;
    transition: all 0.2s ease;
    min-width: 0;
}

.chatbot-input::placeholder {
    color: #94a3b8;
    font-weight: 500;
}

.chatbot-input:focus {
    border-color: #6366f1 !important;
    background: #ffffff !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15) !important;
}

.chatbot-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px !important;
    background: linear-gradient(135deg, #726cf4, #6366f1) !important;
    border: none !important;
    color: #ffffff !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    outline: none !important;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(114, 108, 244, 0.32);
}

.chatbot-send-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(114, 108, 244, 0.42);
}

.chatbot-send-btn:active {
    transform: scale(0.96);
}

.chatbot-send-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(114, 108, 244, 0.28);
}

/* Typing */
.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
}

.typing-dots span {
    width: 5px;
    height: 5px;
    background: var(--cb-violet);
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: 0s; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.15); opacity: 1; }
}

/* Mobile + tablets — keep FAB on-screen and panel within the viewport */
@media (max-width: 991px) {
    .chatbot-container {
        bottom: 20px;
        right: 16px;
    }

    .chatbot-window {
        width: min(370px, calc(100vw - 32px));
        height: min(500px, calc(100vh - 100px));
        max-height: calc(100vh - 100px);
        right: 0;
        left: auto;
        bottom: 66px;
    }

    .chatbot-toggle {
        width: 52px;
        height: 52px;
    }
}

/* CTA Link formatting in bot messages */
.message-content a.cb-cta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(114, 108, 244, 0.1);
    color: #5f58dc !important;
    font-weight: 700;
    font-size: 13px;
    text-decoration: none !important;
    transition: background 0.2s ease, transform 0.2s ease;
}

.message-content a.cb-cta:hover {
    background: rgba(114, 108, 244, 0.2);
    transform: translateY(-1px);
}

