
/* When chat is open → show X */
#chat-bubble[data-x="1"]::after {
    content: "✖";          /* The X */
    font-size: 26px;
    color: white !important;
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;  /* ensures clicks still toggle */
}

/* Hide the IMG while chat is open */
#chat-bubble[data-x="1"] img {
    display: none !important;
}


/* Floating Bubble */
#chat-bubble,
#chat-bubble-facade {
    position: fixed;
    bottom: 25px;
    width: 60px;
    height: 60px;
    background: #e65727;
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 999999;
    transition: 0.3s;
}

#chat-bubble.chat-position-left,
#chat-bubble-facade.chat-position-left {
    left: 25px;
    right: auto;
}

#chat-bubble.chat-position-right,
#chat-bubble-facade.chat-position-right {
    right: 25px;
    left: auto;
}

#chat-bubble:hover,
#chat-bubble-facade:hover {
    transform: scale(1.1);
    background: #c9451f;
}

/* Chat Window */
#chat-window {
    position: fixed;
    min-height: 0;
    bottom: 100px;
    width: 340px;
    height: 440px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.25);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    font-family: 'Inter', sans-serif;
}

#chat-window.chat-position-left { left: 25px; right: auto; }
#chat-window.chat-position-right { right: 25px; left: auto; }

#chat-messages {
    flex: 1;
    padding: 12px;
    overflow-y: auto !important;
    min-height: 0;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.msg-user {
    background: #ffe7e1;
    padding: 10px;
    border-radius: 10px;
    align-self: flex-end;
    max-width: 80%;
}

.msg-user p {
    font-size: 14px;
    line-height: 24px;
    margin: 0 0 10px 0 !important;
    text-align: left !important;
}

.msg-user p:last-of-type {
    margin-bottom: 0;
}

.msg-bot-container {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    max-width: 100%;      /* ⭐ Change from 90% → 100% */
}


.msg-bot-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.msg-bot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msg-bot {
    background: #f7f7f7;
    padding: 10px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.4;
    max-width: 80%;        /* ⭐ Add this */
    word-wrap: break-word; /* ⭐ Force wrap */
    overflow-wrap: break-word;
}

.msg-bot p {
    font-size: 14px;
    line-height: 24px;
    margin: 0 0 10px 0 !important;
    text-align: left !important;
}

.msg-bot p:last-of-type {
    margin-bottom: 0;
}

.quick-replies {
    display: flex;
    flex-wrap: wrap;        /* allow multiple per row */
    gap: 8px;
    margin-top: 12px;
}


.quick-reply-btn {
    display: inline-block;     /* shrink to fit content */
    width: auto;               /* no full width */
    padding: 8px 12px;
    border-radius: 18px;
    cursor: pointer;
    background: #f1f1f1;
    border: 1px solid #ddd;
    font-size: 12px;
    white-space: nowrap;       /* prevent forced wrapping */
    max-width: 100%;           /* but still responsive */
    transition: 0.2s;
}


.quick-reply-btn:hover {
    background: #e65727;
    color: white;
    border-color: #e65727;
}



/* Product Cards */
.product-cards {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.product-card {
    width: 150px;
    background: white;
    border: 1px solid #eee;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: black;
    display: block;
}
.product-title {
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
}
.typing-dot {
    width: 6px;
    height: 6px;
    background: #ccc;
    border-radius: 50%;
    animation: blink 1.4s infinite both;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
    0%,100% { opacity: 0.2; }
    20% { opacity: 1; }
}

/* Input Box */
#chat-input-box {
    display: flex;
    flex-wrap: wrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
#chat-input {
    flex: 1;
    padding: 2px 10px;
    margin: auto;
    border: none;
    outline: none;
    resize: none;
    overflow-y: auto;
    height: 30px;      /* starting small */
    max-height: 160px;     /* stop expanding here */
    font-size: 14px;
    line-height: 20px;
    box-sizing: border-box;
}

#chat-send {
    width: 80px;
    height: 48px;      /* fixed height */
    background: #e65727;
    color: white;
    border: none;
    cursor: pointer;
    flex-shrink: 0;    /* do not grow with input area */
    align-self: flex-end;
    white-space: nowrap;
    text-align: center;
}
#chat-send:hover { background: #c9451f; }

@media (max-width: 480px) {
    #chat-window {
        width: auto !important;
        left: 20px !important;
        right: 20px !important;
    }

    #chat-bubble.chat-position-left,
    #chat-bubble-facade.chat-position-left {
        left: 30px !important;
    }

    #chat-bubble.chat-position-right,
    #chat-bubble-facade.chat-position-right {
        right: 30px !important;
    }
}

/* Chat bubble label */
.chat-bubble-label {
    position: absolute;
    top: -25px;
    transform: translateY(-50%);
    
    background: #ffffff;
    color: #333;
    padding: 4px 8px;
    border-radius: 16px;
    font-size: 13px;
    white-space: nowrap;
    
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    pointer-events: auto;        /* clicks still hit bubble */
}


/* Hide bubble label when chat is open */
body.chat-open .chat-bubble-label {
    display: none;
}

/* Text links inside bot messages only */
#chat-messages .msg-bot p a:not(.chat-source-card) {
    color: #e65727;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

#chat-messages .msg-bot p a:not(.chat-source-card):hover {
    color: #c9451f;
    text-decoration: none;
}

.chat-source-card {
    text-decoration: none !important;
    color: inherit !important;
    background: #fff;
}

.feedback-thumbs {
    display: flex;
    gap: 8px;
    margin-left: 48px;  /* match avatar width + gap */
    padding: 4px 0 8px;
}

.feedback-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 0.5;
    padding: 2px 4px;
    transition: opacity 0.2s;
}

.feedback-btn:hover {
    opacity: 1;
}

.feedback-btn.feedback-active {
    opacity: 1;
}

.feedback-disabled .feedback-btn {
    cursor: default;
}

.feedback-disabled .feedback-btn:not(.feedback-active) {
    opacity: 0.2;
}

.chat-sources ul {
  margin: 0;
  padding-left: 18px;
}
.chat-sources li {
  margin: 4px 0;
}

.chat-sources {
    font-size: 13px;
    margin-top: 10px;
}

.chat-sources-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
}

.chat-source-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 2 cards per row */
    gap: 10px;
}

.chat-source-card {
    width: 100%;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
    transition: transform 0.2s;
}

.chat-source-card:hover {
    transform: translateY(-2px);
}

.source-image {
    width: 100%;
    height: 100px;
    background: #f4f4f4;
    display: flex;
    align-items: center;
    justify-content: center;
}

.source-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.source-image-fallback {
    font-size: 24px;
    color: #999;
}

.source-title {
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
}

/* Analytics charts grid */
.sgcb-analytics-page .sgcb-analytics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    max-width: 1100px;
}

/* Full-width cards still span both columns */
.sgcb-analytics-page .sgcb-analytics-card--full {
    grid-column: 1 / -1;
}

/* Responsive fallback */
@media (max-width: 900px) {
    .sgcb-analytics-page .sgcb-analytics-grid {
        grid-template-columns: 1fr;
    }
}

#chat-attach {
    background: #f2f2f2;
    border: none;
    cursor: pointer;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    flex-shrink: 0;
}

#chat-attach:hover {
    color: #333;
    background: #e6e6e6;
}

#chat-attach:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

#chat-image-preview {
    border-top: 1px solid #eee;
}

#chat-image-preview {
    width: 100%;
}

.chat-bubble-label-close {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px;
    height: 16px;
    background: #e65727;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 1;
}

