/* ============================================================
   Zefinx AI Chatbot Widget — chatbot.css
   Branding: Dark Navy (#011A41) + Gold (#cba557) + Red (#E93C05)
   ============================================================ */

#zfx-chatbot {
    /* Design tokens scoped to this widget */
    --zfx-primary:   #011A41;
    --zfx-gold:      #cba557;
    --zfx-red:       #E93C05;
    --zfx-white:     #ffffff;
    --zfx-bg:        #f5f7fc;
    --zfx-border:    #e8ecf4;
    --zfx-shadow:    0 8px 40px rgba(1, 26, 65, 0.18);
    --zfx-radius:    18px;
    --zfx-font:      'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

    font-family: var(--zfx-font);
    font-size: 14px;

    position: fixed;
    bottom: 16px;
    right: 16px;
    left: auto;
    z-index: 99999;

    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

#zfx-chatbot .zfx-chat-toggle {
    pointer-events: auto;
}

#zfx-chatbot .zfx-chat-window.zfx-open,
#zfx-chatbot .zfx-chat-window.zfx-open * {
    pointer-events: auto;
}

/* ─── Toggle Button ─────────────────────────────────────── */
.zfx-chat-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--zfx-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 4px 20px rgba(1, 26, 65, 0.40);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
    order: 2; /* sits below the chat window */
}

.zfx-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(1, 26, 65, 0.50);
}

.zfx-chat-toggle svg {
    fill: var(--zfx-gold);
    transition: opacity 0.22s ease, transform 0.22s ease;
    position: absolute;
}

/* Chat icon (visible by default) */
.zfx-icon-chat  { opacity: 1; transform: scale(1)       rotate(0deg);  width: 26px; }
/* Close icon (hidden by default) */
.zfx-icon-close { opacity: 0; transform: scale(0.5) rotate(90deg);  width: 22px; }

/* When chat is open, swap icons */
.zfx-chat-toggle.zfx-active .zfx-icon-chat  { opacity: 0; transform: scale(0.5) rotate(-90deg); }
.zfx-chat-toggle.zfx-active .zfx-icon-close { opacity: 1; transform: scale(1)    rotate(0deg);  }

/* Pulsing ring animation */
.zfx-chat-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--zfx-gold);
    animation: zfxPulse 2.5s ease-out infinite;
}

@keyframes zfxPulse {
    0%   { transform: scale(1);   opacity: 0.8; }
    100% { transform: scale(1.8); opacity: 0;   }
}

/* Unread notification badge */
.zfx-unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--zfx-red);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: zfxBounce 0.5s ease;
}

@keyframes zfxBounce {
    0%, 100% { transform: scale(1);   }
    50%       { transform: scale(1.3); }
}

/* ─── Chat Window ───────────────────────────────────────── */
.zfx-chat-window {
    width: 360px;
    height: 530px;
    background: var(--zfx-white);
    border-radius: var(--zfx-radius);
    box-shadow: var(--zfx-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 16px;
    order: 1;

    /* Hidden state by default */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    position: relative;
}

.zfx-chat-window.zfx-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ─── Header ────────────────────────────────────────────── */
.zfx-header {
    background: var(--zfx-primary);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.zfx-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zfx-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--zfx-gold), #e8c56a);
    color: var(--zfx-primary);
    font-weight: 700;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--zfx-font);
}

.zfx-header-name {
    color: var(--zfx-white);
    font-weight: 600;
    font-size: 15px;
}

.zfx-header-status {
    color: rgba(255, 255, 255, 0.65);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.zfx-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: zfxBlink 2s ease infinite;
}

@keyframes zfxBlink {
    0%, 100% { opacity: 1;   }
    50%       { opacity: 0.4; }
}

.zfx-close-btn {
    background: rgba(255, 255, 255, 0.10);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.zfx-close-btn:hover {
    background: rgba(255, 255, 255, 0.20);
}

.zfx-close-btn svg {
    fill: rgba(255, 255, 255, 0.80);
}

/* ─── Messages Area ─────────────────────────────────────── */
.zfx-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--zfx-bg);
    scroll-behavior: smooth;
}

.zfx-messages::-webkit-scrollbar       { width: 4px; }
.zfx-messages::-webkit-scrollbar-track { background: transparent; }
.zfx-messages::-webkit-scrollbar-thumb { background: var(--zfx-border); border-radius: 4px; }

/* ─── Individual Message ────────────────────────────────── */
.zfx-msg {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.zfx-msg.zfx-msg-visible { opacity: 1; transform: translateY(0); }

/* Welcome message shows immediately */
.zfx-msg:first-child { opacity: 1; transform: none; }

.zfx-msg-bot  { align-self: flex-start; align-items: flex-start; }
.zfx-msg-user { align-self: flex-end;   align-items: flex-end;   }

.zfx-msg-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.55;
    font-size: 13.5px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.zfx-msg-bot .zfx-msg-bubble {
    background: var(--zfx-white);
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.zfx-msg-user .zfx-msg-bubble {
    background: var(--zfx-primary);
    color: var(--zfx-white);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(1, 26, 65, 0.25);
}

.zfx-msg-time {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 3px;
    padding: 0 4px;
}

/* ─── Quick Action Chips ────────────────────────────────── */
.zfx-quick-actions {
    padding: 4px 0 8px;
}

.zfx-quick-label {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
}

.zfx-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.zfx-chip {
    background: var(--zfx-white);
    border: 1.5px solid var(--zfx-gold);
    color: var(--zfx-primary);
    border-radius: 20px;
    padding: 6px 13px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--zfx-font);
    line-height: 1.4;
}

.zfx-chip:hover {
    background: var(--zfx-gold);
    color: var(--zfx-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(203, 165, 87, 0.35);
}

/* ─── Meeting Panel ─────────────────────────────────────── */
.zfx-meeting-panel {
    position: absolute;
    top: 68px;
    left: 10px;
    right: 10px;
    bottom: 72px;
    z-index: 3;
    background: rgba(1, 26, 65, 0.16);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10px 0;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.zfx-meeting-panel.zfx-active {
    opacity: 1;
    transform: translateY(0);
}

.zfx-meeting-card {
    width: 100%;
    max-height: 100%;
    overflow: auto;
    background: #fff;
    border-radius: 16px;
    border: 1px solid #dbe4f0;
    box-shadow: 0 14px 30px rgba(1, 26, 65, 0.2);
    padding: 14px;
}

.zfx-meeting-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.zfx-meeting-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--zfx-primary);
}

.zfx-meeting-subtitle {
    font-size: 12px;
    color: #64748b;
    line-height: 1.5;
    margin-top: 4px;
}

.zfx-meeting-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #eef2ff;
    color: var(--zfx-primary);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.zfx-meeting-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.zfx-meeting-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.zfx-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.zfx-field span {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.zfx-field input,
.zfx-field select,
.zfx-field textarea {
    width: 100%;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
    padding: 10px 12px;
    font: inherit;
    color: #0f172a;
    background: #f8fafc;
    outline: none;
    box-sizing: border-box;
}

.zfx-field input:focus,
.zfx-field select:focus,
.zfx-field textarea:focus {
    border-color: var(--zfx-gold);
    background: #fff;
}

.zfx-field textarea {
    resize: vertical;
    min-height: 88px;
}

.zfx-field-full {
    grid-column: 1 / -1;
}

.zfx-meeting-feedback {
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 12.5px;
    line-height: 1.5;
}

.zfx-meeting-feedback.zfx-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.zfx-meeting-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.zfx-meeting-secondary,
.zfx-meeting-submit {
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.zfx-meeting-secondary {
    background: #e2e8f0;
    color: #0f172a;
}

.zfx-meeting-submit {
    background: var(--zfx-primary);
    color: var(--zfx-white);
}

.zfx-meeting-submit:disabled {
    opacity: 0.7;
    cursor: wait;
}

/* ─── Typing Indicator ──────────────────────────────────── */
.zfx-typing {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--zfx-bg);
    flex-shrink: 0;
}

.zfx-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--zfx-white);
    padding: 8px 12px;
    border-radius: 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);
}

.zfx-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--zfx-gold);
    display: inline-block;
    animation: zfxTypingDot 1.4s infinite ease-in-out;
}

.zfx-typing-dots span:nth-child(2) { animation-delay: 0.22s; }
.zfx-typing-dots span:nth-child(3) { animation-delay: 0.44s; }

@keyframes zfxTypingDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%            { transform: scale(1);   opacity: 1;   }
}

.zfx-typing-label {
    font-size: 11.5px;
    color: #9ca3af;
    font-style: italic;
}

/* ─── WhatsApp Prompt Bar ───────────────────────────────── */
.zfx-whatsapp-bar {
    padding: 10px 16px;
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border-top: 1px solid #bbf7d0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
}

.zfx-whatsapp-bar span {
    font-size: 12px;
    color: #166534;
    font-weight: 500;
}

.zfx-wa-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #25d366;
    color: #fff;
    text-decoration: none;
    padding: 6px 13px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.zfx-wa-btn:hover {
    background: #128c7e;
    color: #fff;
    text-decoration: none;
}

.zfx-wa-btn svg {
    fill: #fff;
    flex-shrink: 0;
}

/* ─── Input Area ────────────────────────────────────────── */
.zfx-input-area {
    padding: 12px;
    background: var(--zfx-white);
    border-top: 1px solid var(--zfx-border);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.zfx-input {
    flex: 1;
    border: 1.5px solid var(--zfx-border);
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 13.5px;
    font-family: var(--zfx-font);
    color: #1a1a2e;
    background: var(--zfx-bg);
    outline: none;
    transition: border-color 0.2s, background 0.2s;
}

.zfx-input:focus {
    border-color: var(--zfx-gold);
    background: #fff;
}

.zfx-input::placeholder {
    color: #9ca3af;
}

.zfx-send-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--zfx-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.12s;
    flex-shrink: 0;
}

.zfx-send-btn svg  { fill: var(--zfx-gold); }
.zfx-send-btn:hover  { background: #02245a; transform: scale(1.06); }
.zfx-send-btn:active { transform: scale(0.94); }

/* ─── Mobile Responsive ─────────────────────────────────── */
@media (max-width: 480px) {
    #zfx-chatbot {
        bottom: 16px;
        right: 16px;
        left: auto;
    }

    .zfx-chat-window {
        width: calc(100vw - 32px);
        height: 75dvh;
        max-height: 560px;
    }

    .zfx-chat-toggle {
        width: 56px;
        height: 56px;
    }

    .zfx-chat-toggle::before {
        display: none;
    }

    .zfx-meeting-panel {
        left: 8px;
        right: 8px;
        bottom: 78px;
    }

    .zfx-meeting-grid {
        grid-template-columns: 1fr;
    }

    .zfx-meeting-actions {
        flex-direction: column-reverse;
    }
}
