/* ===== FAN AI Franchise Advisor - Floating Chatbot ===== */
/* Urbanist font, lime (#dafe8e) and black (#0d0f0a) palette */
/* No emojis, clean professional styling */

:root {
    --fan-lime:       #dafe8e;
    --fan-lime-deep:  #c6f560;
    --fan-lime-tint:  #f4fbe7;
    --fan-ink:        #0d0f0a;
    --fan-slate:      #54584b;
    --fan-line:       #e7e9df;
    --fan-line-dark:  #23261c;
    --fan-r:          18px;
    --fan-shadow:     0 24px 64px -12px rgba(13,15,10,.28), 0 8px 24px -4px rgba(13,15,10,.14);
}

/* ── Launcher Button ───────────────────────────────────────────────────────── */
.fan-launcher-wrap {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 99990;
}

.fan-launcher {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--fan-ink);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 28px -4px rgba(13,15,10,.4);
    transition: transform .3s cubic-bezier(.34,1.4,.5,1), box-shadow .3s;
    font-family: 'Urbanist', sans-serif;
}

.fan-launcher:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 14px 40px -4px rgba(13,15,10,.5);
}

.fan-launcher:active {
    transform: scale(.96);
}

.fan-launcher .icon-chat {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    opacity: 1;
    transform: scale(1);
    transition: opacity .25s, transform .3s;
}
.fan-launcher .icon-chat img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    display: block;
}
.fan-launcher .icon-close {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(.6) rotate(90deg);
    transition: opacity .25s, transform .3s;
}
.fan-launcher .icon-close svg {
    width: 24px;
    height: 24px;
    color: var(--fan-lime);
}
.fan-launcher.is-open .icon-chat  { opacity: 0;  transform: scale(.6) rotate(-90deg); }
.fan-launcher.is-open .icon-close { opacity: 1;  transform: scale(1) rotate(0deg); }

/* Pulse ring */
.fan-launcher-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--fan-lime);
    animation: fanPulse 2.4s ease-out infinite;
    pointer-events: none;
}

@keyframes fanPulse {
    0%   { transform: scale(1);   opacity: .7; }
    70%  { transform: scale(1.55); opacity: 0; }
    100% { transform: scale(1.55); opacity: 0; }
}

/* Unread badge */
.fan-unread-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--fan-lime);
    color: var(--fan-ink);
    font-size: 11px;
    font-weight: 800;
    font-family: 'Urbanist', sans-serif;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: fanBadgePop .4s cubic-bezier(.34,1.4,.5,1);
}

@keyframes fanBadgePop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* ── Chat Widget ───────────────────────────────────────────────────────────── */
.fan-chat-widget {
    position: fixed;
    right: 24px;
    bottom: 100px;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100dvh - 120px);
    background: #fff;
    border-radius: var(--fan-r);
    border: 1px solid var(--fan-line);
    box-shadow: var(--fan-shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 99991;
    font-family: 'Urbanist', sans-serif;
    transform-origin: bottom right;
}

.fan-chat-widget.is-open {
    display: flex;
    animation: fanWidgetOpen .32s cubic-bezier(.22,1,.36,1);
}

@keyframes fanWidgetOpen {
    from { opacity: 0; transform: scale(.92) translateY(16px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Header ────────────────────────────────────────────────────────────────── */
.fan-chat-header {
    background: var(--fan-ink);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.fan-chat-logo-wrap {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--fan-lime);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    overflow: hidden;
    border: 2px solid rgba(218,254,142,.3);
}

.fan-chat-logo-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    filter: none;
}

.fan-chat-logo-wrap .fan-chat-initials {
    font-size: 15px;
    font-weight: 900;
    color: var(--fan-ink);
    letter-spacing: -.02em;
}

.fan-chat-title-wrap {
    flex: 1;
    min-width: 0;
}

.fan-chat-title {
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fan-chat-status {
    font-size: 12px;
    color: #9aa088;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.fan-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--fan-lime);
    flex-shrink: 0;
}

.fan-chat-actions {
    display: flex;
    gap: 4px;
}

.fan-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255,255,255,.08);
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: #9aa088;
    transition: background .2s, color .2s;
}

.fan-action-btn:hover {
    background: rgba(218,254,142,.15);
    color: var(--fan-lime);
}

.fan-action-btn svg { width: 16px; height: 16px; }

/* ── Messages body ─────────────────────────────────────────────────────────── */
.fan-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.fan-chat-body::-webkit-scrollbar { width: 4px; }
.fan-chat-body::-webkit-scrollbar-track { background: transparent; }
.fan-chat-body::-webkit-scrollbar-thumb { background: var(--fan-line); border-radius: 4px; }

.fan-msg {
    display: flex;
    gap: 8px;
    animation: fanMsgIn .28s cubic-bezier(.22,1,.36,1);
}

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

.fan-msg-bot  { align-items: flex-end; justify-content: flex-start; }
.fan-msg-user { justify-content: flex-end; }

.fan-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: var(--fan-lime);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 900;
    color: var(--fan-ink);
}

.fan-msg-avatar svg { width: 16px; height: 16px; color: var(--fan-ink); }

.fan-bubble {
    max-width: 80%;
    padding: 12px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.65;
    word-wrap: break-word;
}

.fan-msg-bot .fan-bubble {
    background: var(--fan-lime-tint);
    color: var(--fan-ink);
    border: 1px solid var(--fan-line);
    border-bottom-left-radius: 4px;
}

.fan-msg-user .fan-bubble {
    background: var(--fan-ink);
    color: #e8ecdf;
    border-bottom-right-radius: 4px;
}

/* Typing indicator */
.fan-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 14px 16px;
}

.fan-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9aa088;
    animation: fanDot 1.3s infinite;
}

.fan-typing-dots span:nth-child(2) { animation-delay: .18s; }
.fan-typing-dots span:nth-child(3) { animation-delay: .36s; }

@keyframes fanDot {
    0%, 80%, 100% { transform: translateY(0); opacity: .4; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

/* Quick prompts */
.fan-quick-prompts {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 4px;
}

.fan-quick-btn {
    background: #fff;
    border: 1.5px solid var(--fan-line);
    border-radius: 100px;
    padding: 8px 14px;
    font-family: 'Urbanist', sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: var(--fan-slate);
    cursor: pointer;
    text-align: left;
    transition: border-color .2s, background .2s, color .2s;
}

.fan-quick-btn:hover {
    border-color: var(--fan-lime-deep);
    background: var(--fan-lime-tint);
    color: var(--fan-ink);
}

/* Lead capture form inside chat */
.fan-lead-panel {
    background: var(--fan-lime-tint);
    border: 1.5px solid var(--fan-lime-deep);
    border-radius: 14px;
    padding: 16px;
    margin-top: 4px;
    font-size: 13px;
}

.fan-lead-panel h4 {
    font-size: 14px;
    font-weight: 800;
    color: var(--fan-ink);
    margin: 0 0 4px;
}

.fan-lead-panel p {
    color: var(--fan-slate);
    margin: 0 0 12px;
    font-size: 13px;
}

.fan-lead-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.fan-lead-field label {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--fan-slate);
}

.fan-lead-field input,
.fan-lead-field select {
    font-family: 'Urbanist', sans-serif;
    font-size: 13px;
    font-weight: 500;
    background: #fff;
    border: 1.5px solid var(--fan-line);
    border-radius: 9px;
    padding: 9px 12px;
    color: var(--fan-ink);
    outline: none;
    transition: border-color .2s;
    -webkit-appearance: none;
}

.fan-lead-field input:focus,
.fan-lead-field select:focus {
    border-color: var(--fan-lime-deep);
}

.fan-lead-submit {
    width: 100%;
    padding: 11px;
    background: var(--fan-ink);
    color: #fff;
    border: none;
    border-radius: 100px;
    font-family: 'Urbanist', sans-serif;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 6px;
    transition: background .2s, transform .2s;
}

.fan-lead-submit:hover {
    background: #23261c;
    transform: translateY(-1px);
}

.fan-lead-success {
    padding: 12px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    color: #166534;
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
    display: none;
}

/* ── Input area ────────────────────────────────────────────────────────────── */
.fan-chat-input-wrap {
    flex-shrink: 0;
    border-top: 1px solid var(--fan-line);
    padding: 12px 14px;
    background: #fff;
}

.fan-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.fan-chat-textarea {
    flex: 1;
    font-family: 'Urbanist', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--fan-ink);
    background: var(--fan-lime-tint);
    border: 1.5px solid var(--fan-line);
    border-radius: 12px;
    padding: 11px 14px;
    resize: none;
    outline: none;
    height: 44px;
    max-height: 110px;
    overflow-y: auto;
    line-height: 1.5;
    transition: border-color .2s;
}

.fan-chat-textarea:focus {
    border-color: var(--fan-lime-deep);
    background: #fff;
}

.fan-chat-textarea::placeholder { color: #9aa088; }

.fan-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--fan-ink);
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    transition: transform .25s cubic-bezier(.34,1.4,.5,1), background .2s;
}

.fan-send-btn:hover:not(:disabled) {
    transform: scale(1.1) rotate(-8deg);
    background: #23261c;
}

.fan-send-btn:disabled {
    opacity: .38;
    cursor: not-allowed;
}

.fan-send-btn svg { width: 18px; height: 18px; color: var(--fan-lime); }

.fan-chat-footer {
    text-align: center;
    font-size: 11px;
    color: #b0b7a4;
    margin-top: 8px;
    font-weight: 500;
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .fan-chat-widget {
        right: 12px;
        bottom: 88px;
        width: calc(100vw - 24px);
        height: calc(100dvh - 106px);
        max-height: none;
        border-radius: 16px;
    }
    .fan-launcher-wrap { right: 16px; bottom: 16px; }
}

/* ── Force chatbot visible on all devices including mobile ── */
.fan-launcher-wrap {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 999999 !important;
}
.fan-launcher {
    display: flex !important;
    visibility: visible !important;
}
