/* =====================================================================
   Friendsware Solutions — FAQ Assistant
   ---------------------------------------------------------------------
   A floating, WhatsApp-style launcher (bottom-left so it never collides
   with the existing WhatsApp button at bottom-right). Clicking it opens
   a popup chat panel driven by a simple rule-based assistant
   (see /js/faq-chatbot.js).

   Brand: orange #e2660a / #f4761f  |  navy #172054 / #09335c
   ===================================================================== */

.fw-faq {
    --faq-orange: #e2660a;
    --faq-orange-light: #f4761f;
    --faq-navy: #172054;
    --faq-navy-deep: #09335c;
    --faq-radius: 18px;
    --faq-ease: cubic-bezier(0.16, 1, 0.3, 1);
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9998;
    font-family: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------------------------------------------------------------------
   Floating launcher button
   --------------------------------------------------------------------- */
.fw-faq-launcher {
    position: relative;
    width: 62px;
    height: 62px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background: linear-gradient(135deg, var(--faq-orange-light), var(--faq-orange));
    color: #fff;
    box-shadow: 0 10px 28px rgba(226, 102, 10, 0.40);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s var(--faq-ease), box-shadow 0.3s var(--faq-ease);
}

.fw-faq-launcher:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 14px 34px rgba(226, 102, 10, 0.50);
}

.fw-faq-launcher:focus-visible {
    outline: 3px solid rgba(244, 118, 31, 0.6);
    outline-offset: 3px;
}

/* Gentle attention pulse on the launcher */
.fw-faq-launcher::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--faq-orange-light);
    animation: fw-faq-pulse 2.2s ease-out infinite;
}

@keyframes fw-faq-pulse {
    0%   { transform: scale(1);   opacity: 0.6; }
    70%  { transform: scale(1.5); opacity: 0; }
    100% { transform: scale(1.5); opacity: 0; }
}

.fw-faq-launcher i {
    font-size: 26px;
    line-height: 1;
    transition: opacity 0.2s ease, transform 0.3s var(--faq-ease);
}

/* Swap the icon when the panel is open */
.fw-faq-launcher .fw-faq-icon-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(0.5); }
.fw-faq.is-open .fw-faq-launcher .fw-faq-icon-open  { opacity: 0; transform: rotate(90deg) scale(0.5); }
.fw-faq.is-open .fw-faq-launcher .fw-faq-icon-close { opacity: 1; transform: rotate(0) scale(1); }
.fw-faq.is-open .fw-faq-launcher::after { animation: none; }

/* Unread badge */
.fw-faq-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #25D366;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}
.fw-faq.is-open .fw-faq-badge { display: none; }

/* ---------------------------------------------------------------------
   Chat panel
   --------------------------------------------------------------------- */
.fw-faq-panel {
    position: absolute;
    bottom: 78px;
    left: 0;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: var(--faq-radius);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom left;
    transform: translateY(16px) scale(0.92);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.32s var(--faq-ease), opacity 0.25s ease;
}

.fw-faq.is-open .fw-faq-panel {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header */
.fw-faq-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--faq-navy), var(--faq-navy-deep));
    color: #fff;
}

.fw-faq-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.fw-faq-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--faq-orange-light), var(--faq-orange));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.fw-faq-title {
    display: block;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.fw-faq-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    opacity: 0.85;
}

.fw-faq-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #25D366;
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.7);
    animation: fw-faq-blink 2s infinite;
}

@keyframes fw-faq-blink {
    0%   { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.6); }
    70%  { box-shadow: 0 0 0 6px rgba(37, 211, 102, 0); }
    100% { box-shadow: 0 0 0 0 rgba(37, 211, 102, 0); }
}

.fw-faq-close {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}
.fw-faq-close:hover { background: rgba(255, 255, 255, 0.25); transform: rotate(90deg); }

/* Message area */
.fw-faq-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f3f5f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.fw-faq-body::-webkit-scrollbar { width: 7px; }
.fw-faq-body::-webkit-scrollbar-thumb { background: rgba(226, 102, 10, 0.45); border-radius: 4px; }

.fw-faq-msg {
    max-width: 82%;
    padding: 10px 14px;
    font-size: 13.5px;
    line-height: 1.5;
    border-radius: 16px;
    word-wrap: break-word;
    animation: fw-faq-msg-in 0.25s var(--faq-ease);
}

@keyframes fw-faq-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fw-faq-msg.bot {
    align-self: flex-start;
    background: #fff;
    color: #1f2733;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.fw-faq-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--faq-orange-light), var(--faq-orange));
    color: #fff;
    border-bottom-right-radius: 4px;
}

.fw-faq-msg a {
    color: var(--faq-orange);
    font-weight: 600;
    text-decoration: underline;
}
.fw-faq-msg.user a { color: #fff; }

.fw-faq-msg strong { font-weight: 700; }
.fw-faq-msg ul { margin: 6px 0 0; padding-left: 18px; }
.fw-faq-msg li { margin-bottom: 3px; }

/* Typing indicator */
.fw-faq-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.fw-faq-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b9c0cc;
    animation: fw-faq-bounce 1.3s infinite ease-in-out;
}
.fw-faq-typing span:nth-child(2) { animation-delay: 0.18s; }
.fw-faq-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes fw-faq-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

/* Quick-reply chips */
.fw-faq-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 10px 12px 0;
    background: #f3f5f9;
}

.fw-faq-chip {
    border: 1px solid rgba(226, 102, 10, 0.45);
    background: #fff;
    color: var(--faq-orange);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, transform 0.15s ease;
    font-family: inherit;
}
.fw-faq-chip:hover {
    background: var(--faq-orange);
    color: #fff;
    transform: translateY(-1px);
}

/* Input row */
.fw-faq-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #f3f5f9;
    border-top: 1px solid #e4e8ef;
}

.fw-faq-input input {
    flex: 1;
    border: 1px solid #d8deea;
    border-radius: 22px;
    padding: 11px 16px;
    font-size: 13.5px;
    outline: none;
    background: #fff;
    color: #1f2733;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.fw-faq-input input:focus {
    border-color: var(--faq-orange-light);
    box-shadow: 0 0 0 3px rgba(244, 118, 31, 0.15);
}

.fw-faq-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--faq-orange-light), var(--faq-orange));
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.fw-faq-send:hover { transform: scale(1.08); box-shadow: 0 6px 16px rgba(226, 102, 10, 0.4); }
.fw-faq-send:disabled { opacity: 0.5; cursor: default; transform: none; box-shadow: none; }

/* ---------------------------------------------------------------------
   Mobile
   --------------------------------------------------------------------- */
@media (max-width: 480px) {
    .fw-faq { bottom: 16px; left: 16px; }
    .fw-faq-panel {
        width: calc(100vw - 24px);
        height: calc(100vh - 110px);
        bottom: 74px;
    }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    .fw-faq-launcher::after,
    .fw-faq-status-dot { animation: none; }
    .fw-faq-panel,
    .fw-faq-msg { transition: none; animation: none; }
}
