/* Keyframes for fade-in animation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Fade-in class for dynamic messages */
.fade-in {
    opacity: 0;
    animation: fadeIn 0.5s forwards;
}

/* Chat Icon styling */
#chatbot-icon {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 50px;
    height: 50px;
    overflow: hidden;
    z-index: 9999;
    cursor: pointer;
    background-color: #212121;
    border-radius: 50%;
}

/* Container for the two icons */
#chatbot-icon .icon-mask {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Open icon (the image) and close icon share similar absolute positioning */
#chatbot-icon .open-icon,
#chatbot-icon .close-icon {
    position: absolute;
    width: 24px;
    height: 24px;
    top: 50%;
    left: 50%;
    transition: transform 0.5s cubic-bezier(.65, .05, 0, 1);
}

/* Open icon initial state: centered */
#chatbot-icon .open-icon {
    transform: translate(-50%, -50%);
}

/* Close icon initial state: positioned below the view */
#chatbot-icon .close-icon {
    transform: translate(-50%, calc(-50% + 37px));
}

/* When the #chatbot-icon has the class "open", swap the positions */
#chatbot-icon.open .open-icon {
    transform: translate(-50%, -200%) scale(1);
}
#chatbot-icon.open .close-icon {
    transform: translate(-50%, -50%);
}

/* Close icon styling (the lines) */
#chatbot-icon .close-icon .line1,
#chatbot-icon .close-icon .line2 {
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: #f2f3f8;
    top: 50%;
    left: 0;
    transform-origin: center;
    transition: transform 0.5s cubic-bezier(.65, .05, 0, 1);
}
#chatbot-icon .close-icon .line1 {
    transform: rotate(45deg);
}
#chatbot-icon .close-icon .line2 {
    transform: rotate(-45deg);
}

/* Keyframes for rotating the close icon lines on hover */
@keyframes rotateLine1 {
    from { transform: rotate(45deg); }
    to { transform: rotate(-45deg); }
}
@keyframes rotateLine2 {
    from { transform: rotate(-45deg); }
    to { transform: rotate(45deg); }
}

/* When the .rotate-animation class is applied, run the animations (and retain final state) */
#chatbot-icon .close-icon.rotate-animation .line1 {
    animation: rotateLine1 0.5s cubic-bezier(.65, .05, 0, 1) forwards;
}
#chatbot-icon .close-icon.rotate-animation .line2 {
    animation: rotateLine2 0.5s cubic-bezier(.65, .05, 0, 1) forwards;
}

/* Chat Mask Container (invisible mask for sliding animation) */
#chatbot-mask {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 400px;
    overflow: hidden;
    z-index: 9999;
    display: none;
}
@media(max-width:767px) {
  #chatbot-mask {
    right: 16px;
    width: calc(100% - 32px);
  }
}

/* Chat Popup Container inside the mask */
#chatbot-container {
    display: block;
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: #f2f3f8;
    z-index: 2;
    transform: translateY(100%);
    transition: 0.7s cubic-bezier(.65, .05, 0, 1);
}
#chatbot-container.open {
    transform: translateY(0);
}

/* Header styling */
#chatbot-header {
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #111111;
}
#chatbot-header h3 {
    margin: 0;
}

/* Chatbot body wrapper */
#chatbot-body-wrapper {
    position: relative;
}

/* The chatbot body styling */
#chatbot-body {
    padding: 10px;
    height: 400px;
    overflow-y: auto;
    background-color: #fff;
}

@media(max-width:767px) {
  #chatbot-body {
    height: 300px;
  }
}

/* Overlay element that covers the visible portion of the chatbot body */
#chatbot-body-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(rgba(0,0,0,0.15), transparent 1%);
    pointer-events: none;
    z-index: 2;
}

/* Chat form styling */
#chatbot-form {
    display: flex;
    border-top: 1px solid #111111;
    background-color: #fff;
}
#chatbot-form textarea {
    flex: 1;
    padding: 10px;
    border: none;
    background-color: #f2f3f8;
    resize: none;
}
#chatbot-form textarea:focus { 
    outline: none; 
}
#chatbot-form button {
    padding: 6px 12px;
    border: none;
    background-color: #111111;
    color: #f2f3f8;
    cursor: pointer;
}

/* Shared message wrapper for both user and bot */
.message-wrapper {
    clear: both;
    margin-bottom: 10px;
    max-width: 80%;
    text-align: left;
}

/* Right-align user messages */
.message-wrapper.user-message {
    float: right;
}
/* Left-align bot messages */
.message-wrapper.bot-message {
    float: left;
}

/* Label above the bubble */
.message-label {
    font-weight: bold;
    margin-bottom: 2px;
    display: block;
    padding: 0 8px;
}

/* Bubble container */
.bubble {
    background-color: #f1f0f0;
    color: #000;
    border-radius: 12px;
    padding: 10px;
    font-size: 14px;
    position: relative;
    display: block;
  	white-space: normal;  
}

.bubble a {
    color: #0066cc;
    text-decoration: underline!important;
    word-wrap: break-word;
    word-break: break-all;
}
.bubble a:hover {
  color: #0066cc!important;
}

/* User bubble styling (blue) */
.message-wrapper.user-message .bubble {
    background-color: #0084ff;
    color: #fff;
    margin-left: auto;
}
.message-wrapper.user-message .message-label {
    text-align: right;
}

/* Loading dots animation */
.dot {
    display: inline-block;
    vertical-align: middle;
    width: 6px;
    height: 6px;
    background-color: currentColor;
    border-radius: 50%;
    margin-right: 3px;
    animation: blink 1s infinite;
    opacity: 0.2;
}
.dot:nth-child(1) {
    animation-delay: 0s;
}
.dot:nth-child(2) {
    animation-delay: 0.2s;
}
.dot:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes blink {
    0%, 80%, 100% { opacity: 0.2; }
    40% { opacity: 1; }
}

/* Shrink the loading bubble around the 3 dots */
.message-wrapper.bot-loading {
    max-width: none;
}
.message-wrapper.bot-loading .bubble {
    display: inline-block;
    max-width: 50px;
    max-height: 41px;
    white-space: nowrap;
    width: auto;
}

/* FAQ container for suggestions */
#chatbot-faq-container {
    position: absolute;
    bottom: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 0 10px 10px 10px;
    z-index: 3;
}
.faq-title {
    font-weight: bold;
    margin-bottom: 2px;
    display: block;
    padding: 0 8px;
    text-align: left;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
    animation-delay: 0.5s;
}

/* SUGGESTIONS STYLING */
#chatbot-suggestions {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}
.suggestion-bubble {
    border: 1px solid #ccc;
    border-radius: 12px;
    padding: 8px 12px;
    background-color: #fff;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
    opacity: 0;
    animation: fadeIn 0.5s forwards;
}
#chatbot-suggestions .suggestion-bubble:nth-child(1) {
    animation-delay: 0.5s;
}
#chatbot-suggestions .suggestion-bubble:nth-child(2) {
    animation-delay: 0.6s;
}
#chatbot-suggestions .suggestion-bubble:nth-child(3) {
    animation-delay: 0.7s;
}
.suggestion-bubble:hover {
    background-color: #f2f3f8;
}

/* Chat Bubble styling */
#chatbot-bubble {
    position: fixed;
    bottom: 78px;
    right: 16px;
    background-color: #f2f3f8;
    color: #212121;
    padding: 6px 10px;
    border: 1px solid #212121;
    border-radius: 20px;
    font-size: 14px;
    z-index: 9998;
    white-space: nowrap;
}

/* Outer tail (dark border) */
#chatbot-bubble::before {
    content: "";
    position: absolute;
    bottom: -7px;
    right: 17px;
    border-width: 7px 7px 0 7px;
    border-style: solid;
    border-color: #212121 transparent transparent transparent;
}

/* Inner tail (light fill) */
#chatbot-bubble::after {
    content: "";
    position: absolute;
    bottom: -6px;
    right: 18px;
    border-width: 6px 6px 0 6px;
    border-style: solid;
    border-color: #f2f3f8 transparent transparent transparent;
}

/* Hide bubble when chatbot is open */
#chatbot-icon.open + #chatbot-bubble {
    display: none;
}

/* NEW CLASS: forcibly hide bubble for 700ms after closing */
.hide-bubble {
    display: none !important;
}