#wpfibot-toggle {
    position: fixed;
    width: 56px;
    height: 56px;
    background-color: var(--wpfibot-button, #2D4C74);
    background-repeat: no-repeat;
    background-size: 70%;
    background-position: center;
    border-radius: var(--wpfibot-radius, 50%);
    cursor: pointer;
    z-index: 9999;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visable;
  }

  .exit-flow-btn {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.8em;
    color: #888;
    text-decoration: underline;
    cursor: pointer;
  }
  .exit-flow-btn:hover {
    color: #555;
  }
  
  
  #wpfibot-toggle .wpfibot-toggle-inner {
    width: 100%;
    height: 100%;
    border-radius: var(--wpfibot-radius, 50%);
    background-color: var(--wpfibot-button, #2D4C74);
    color: var(--wpfibot-button-text, #ffffff);
    font-family: Arial, sans-serif;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  
  #wpfibot-box.active + #wpfibot-toggle .wpfibot-toggle-inner,
  #wpfibot-toggle.open .wpfibot-toggle-inner {
    opacity: 1;
    pointer-events: auto;
  }
  
  

#wpfibot-box {
    position: fixed;

    max-height: 70vh;
    background: var(--wpfibot-bg, #ffffff);
    border: 1px solid #ddd;

    display: flex;
    flex-direction: column;
    font-size: 14px;
    box-shadow: 0 6px 16px rgba(0,0,0,.2);
    z-index: 99999;
}

/* Box position is also controlled via JS for alignment and offset */
#wpfibot-box.hidden {
    display: none;
}

#wpfibot-box .header {
    background: var(--ff-primary, #4ec8ff);
    padding: 12px;
    font-weight: bold;
    text-align: center;
}

#wpfibot-log {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    background: #fafafa;
    min-height: 30vh;
}

#wpfibot-form {
    display: flex;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid #eee;
}

#wpfibot-form textarea {
    flex: 1;
    padding: 6px;
    border: 1px solid #ccc;
    resize: none;
}

#wpfibot-form button {
    padding: 6px 12px;
    background: var(--wpfibot-button, #2D4C74);
    color: var(--wpfibot-button-text, #ffffff);
    border: none;

    cursor: pointer;
}

#wpfibot-form button:hover {
    background: var(--wpfibot-hover, #000000);
    color: var(--wpfibot-button-text-hover, #ffffff);
}


.wpfibot-email-btn {
    padding: 6px 12px;
    background: var(--wpfibot-button, #2D4C74);
    color: var(--wpfibot-button-text, #ffffff);
    border: none;
    cursor: pointer;
}

.wpfibot-email-btn:hover {
    background: var(--wpfibot-hover, #000000);
    color: var(--wpfibot-button-text-hover, #ffffff);
}

.msg {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
  }
  
  /* Flip user direction */
  .msg.user {
    flex-direction: row-reverse;
  }
  
  /* Assistant stays left-to-right */
  .msg.assistant {
    flex-direction: row;
  }
  
  .msg .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
  }
  
  /* Ensure bubble spacing behaves */
  .msg .bubble {
    width: 78%;
    padding: 10px 14px;
    border-radius: 14px;
    line-height: 1.4;
    display: inline-block;
    word-wrap: break-word;
  }
  
  /* Bubble color styles */
  .msg.user .bubble {
    text-align: right;
    background: var(--wpfibot-user-bg, #ffffff);
    color: var(--wpfibot-user-color, #2D4C74);
  }
  
  .msg.assistant .bubble {
    background: var(--wpfibot-bot-bg, #f5f5f5);
    color: var(--wpfibot-bot-color, #111);
  }

  .delay-message {
    margin-bottom: 6px;
  }
  

  

.msg.assistant a {
    color: var(--wpfibot-bot-link, #0073aa);
    text-decoration: underline;
}
.msg.assistant a:hover {
    color: var(--wpfibot-bot-link-hover, #005177);
}


#wpfibot-log {
    background: var(--wpfibot-chat-bg, #ffffff);
}

#wpfibot-form textarea {
    color: var(--wpfibot-textarea-color, #000000);
    background: var(--wpfibot-textarea-bg, #ffffff);
}

#wpfibot-log::-webkit-scrollbar {
    width: 8px;
}
#wpfibot-log::-webkit-scrollbar-thumb {
    background-color: var(--wpfibot-scroll-thumb, rgba(0,0,0,0.2));
    border-radius: 4px;
}
#wpfibot-log::-webkit-scrollbar-track {
    background-color: var(--wpfibot-scroll-track, transparent);
    padding:1px;
}



.quick-btn {
    display: inline-block;
    margin: 6px 4px;
    background: #eee;
    border: none;
    padding: 6px 10px;
    border-radius: 16px;
    font-size: 13px;
    cursor: pointer;
}

.quick-btn:hover {
    background: #ddd;
}

/* Update header class to avoid conflicts */


.wpfibot-spinner {
    text-align: center;
    font-size: 13px;
    background: var(--wpfibot-bg, #2D4C74);
    color: var(--wpfibot-header-text, #ffffff);
    padding: 12px;
}

.hidden {
    display: none;
}

/* Assistant is thinking (bubble) */
.msg.thinking {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 12px;
  }
  
  .msg.thinking .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
  }
  
  .msg.thinking .bubble {
    background: var(--wpfibot-bot-bg, #f5f5f5);
    color: var(--wpfibot-bot-color, #333);
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 15px;
    max-width: 80%;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  


  .msg.bot.thinking .bubble {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }
  
  .typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  
  .typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--wpfibot-bot-color, #333);
    border-radius: 50%;
    animation: bounce 1.2s infinite ease-in-out;
  }
  
  .typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
  }
  .typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
  }
  
  @keyframes scalePulse {
    0%, 80%, 100% {
      transform: scale(1);
      opacity: 0.3;
    }
    40% {
      transform: scale(1.2);
      opacity: 1;
    }
  }
  .typing-indicator span {
    animation: scalePulse 1.4s infinite ease-in-out;
  }
  
  
  



#wpfibot-box {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

#wpfibot-box.active {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}



.wpfibot-intro {
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: #f0f0f0;
    border-radius: 8px;
}



@media (max-width: 800px) {
    #wpfibot-box {
        width: 93vw  !important;
        right: auto !important;
        left: 2.5vw !important;
        bottom: calc(var(--wpfibot-margin-bottom, 20px) + 70px);
    }

    #wpfibot-log {
        max-height: 50vh;
    }

    #wpfibot-form textarea,
    #wpfibot-form input {
      font-size: 16px !important; /* ✅ prevents zoom on iOS */
    }
}




#wpfibot-powered {
    text-align: center;
    font-size: 10px;
    padding-bottom: 5px;
    color: var(--wpfibot-header-text, #ffffff);
    width: 100%;
  }
  
  #wpfibot-powered a {
    color: var(--wpfibot-header-text, #ffffff);
    text-decoration: none;
    font-weight: 500;
  }
  
  #wpfibot-powered a:hover {
    text-decoration: underline;
  }
  





.wpfibot-email-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--wpfibot-bot-color, #111);
    background: var(--wpfibot-bot-bg, #f5f5f5);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    z-index: 999999;
    width: 100%;
    max-width: 600px;
    font-family: system-ui, sans-serif;
}

.wpfibot-email-modal input,
.wpfibot-email-modal textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    color: var(--wpfibot-textarea-color, #000000);
    background: var(--wpfibot-textarea-bg, #ffffff);
    font-size: 14px;
}

.wpfibot-email-modal button {
    padding: 10px;
    font-size: 14px;
    cursor: pointer;
}





#wpfibot-send-email {
    background: var(--wpfibot-button, #2D4C74);
    color: var(--wpfibot-button-text, #ffffff);
    border: none;
    flex: 1;
}


#wpfibot-send-email:hover {
    background: var(--wpfibot-hover, #000000);
    color: var(--wpfibot-button-text-hover, #ffffff);
}


#wpfibot-cancel-email {
    background: #ddd;
    color: #333;
    border: none;
    flex: 1;
}



.bubble-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
  }
  


  @keyframes wpfibot-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
  }
  
  .wpfibot-spin {
    animation: wpfibot-spin 1.2s linear infinite;
  }
  


  .bubble-name {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .msg-time {
    font-size: 11px;
    font-weight: normal;
    margin-left: 8px;
  }
  



  .wpfibot-pulse {
    animation: wpfibot-pulse 1.4s infinite;
  }
  
  @keyframes wpfibot-pulse {
    0%   { transform: scale(1); opacity: 1; }
    50%  { transform: scale(1.08); opacity: 0.85; }
    100% { transform: scale(1); opacity: 1; }
  }
  


  .wpfibot-toggle-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: red;
    color: #fff;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    padding: 4px 8px;
    line-height: 1;
    z-index: 999;
    pointer-events: none;
  }
  .wpfibot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
  }
  
  .wpfibot-title {
    flex: 1;                     /* 🔥 allow it to take up space */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color:var(--wpfibot-header-text,#FFFFFF);
  }
  
  .wpfibot-header-icons {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;           /* ✅ push icons to the right */
  }
  
  .wpfibot-icon-wrapper {
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    position: relative;
  }
  
  .wpfibot-icon-wrapper.visible {
    display: inline-flex;
    opacity: 1;
  }
  


  .wpfibot-icon {
    cursor: pointer;
    font-size: 18px;
    color: var(--wpfibot-icon-button, #ffffff);
    line-height: 1;
    opacity: 0.85;
    transition: opacity 0.2s ease;
  }
  
  .wpfibot-icon:hover {
    color: var(--wpfibot-icon-hover, #ffffff);
    opacity: 1;
  }
  
  /* Tooltip */
  .wpfibot-icon-wrapper::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px); /* above the icon, with spacing */
    left: 100%;
    transform: translateX(-100%);
    background: #333;
    color: #fff;
    padding: 6px 10px;
    font-size: 11px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 9999;
  }
  
  
  .wpfibot-icon-wrapper:hover::after,
  .wpfibot-icon-wrapper.show-tooltip::after {
    opacity: 1;
  }
  
/* ✨ Tooltip arrow (down-pointing triangle) */
.wpfibot-icon-wrapper::before {
    content: "";
    position: absolute;
    bottom: 100%; /* place above the icon */
    left: 100%;
    transform: translateX(-120%);
    border: 6px solid transparent;
    border-top: 6px solid #333; /* ✅ properly sets the triangle */
    border-bottom: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 9998;
  }
  
  
  .wpfibot-icon-wrapper:hover::before,
  .wpfibot-icon-wrapper.show-tooltip::before {
    opacity: 1;
  }
  


  #wpfibot-human-icon.disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
  }


  .resuming-fade-out {
    opacity: 0;
    transition: opacity 0.4s ease;
  }
  

  .flatpickr-calendar {
    font-family: inherit;
    border-radius: 12px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--wpfibot-scroll-thumb, #ccc);
  }
  
  .flatpickr-day.selected,
  .flatpickr-day:hover {
    background: var(--wpfibot-button, #e91e63);
    color: var(--wpfibot-button-text, #fff);
    border-color: var(--wpfibot-button, #e91e63);
  }
  
  .flatpickr-months,
  .flatpickr-weekdays {
    background: var(--wpfibot-button, #e91e63);
    color: var(--wpfibot-button-text, #fff);
  }
  