.help-chat-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 150002 !important;
}

.help-chat-container .chat-header {
    padding: 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.help-chat-container .chat-header h3 {
    margin: 0;
    font-size: 16px;
}

.help-chat-container .chat-header .close-button {
    all: unset;
    cursor: pointer;
    font-family: Arial, sans-serif !important;
    font-size: 20px !important;
    min-width: 40px !important;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666 !important;
    background: none !important;
    border: none !important;
    padding: 0 !important;
    margin-right: -5px !important;
    line-height: 1 !important;
}

.help-chat-container .chat-header .close-button:hover {
    color: #333 !important;
}

.help-chat-container .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.help-chat-container .message {
    margin-bottom: 10px;
    max-width: 80%;
}

.help-chat-container .message.user {
    margin-left: auto;
    background: #007bff;
    color: white;
    padding: 8px 12px;
    border-radius: 15px 15px 0 15px;
}

/*
This selector may be obsolete.
CHECK.
*/
.help-chat-container .message.bot {
    margin-right: auto;
    background: #dbe3de;
    color: #2c3338;
    padding: 8px 12px;
    border-radius: 15px 15px 15px 0;
}

.help-chat-container .message.assistant {
    margin-right: auto;
    background-color: #f0f3e7;
    color: #252f27;
    padding: 8px 12px;
    border-radius: 15px 15px 15px 0;
    max-width: 95%;
}

.help-chat-container .message-time {
    font-size: 12px;
    color: #4a5056;
    margin-top: 4px;
}

.help-chat-container .chat-input {
    padding: 12px 15px;
    border-top: 1px solid #dee2e6;
    display: flex;
    gap: 10px;
    align-items: flex-end; /* align send button to baseline of textarea */
    background: #f9fafb;
}

.help-chat-container .chat-input textarea {
    flex: 1;
    width: 100%;
    display: block;
    margin: 0 !important;               /* defeat global margins */
    padding: 8px 12px;
    border: 1px solid #ddd !important;  /* defeat theme overrides */
    border-radius: 8px !important;
    color: #2c3338;
    font-family: inherit;
    font-size: 15px !important;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;            /* break very long tokens */
    white-space: pre-wrap;              /* wrap and keep newlines */
    outline: none;
    background: #fff !important;
    box-sizing: border-box;
    resize: none;                       /* user cannot manually resize */
    overflow-y: auto;                   /* will scroll once it hits max-height */
    overflow-x: hidden;                 /* never show horizontal scroll */
    height: auto;                       /* let JS set explicit height inline */
    min-height: 39px !important;        /* consistent single-line baseline */
    max-height: 100px;                  /* reduced cap (~about 2.5-3 lines) */
    -webkit-appearance: none;           /* safari reset */
    appearance: none;                   /* generic reset */
}

.help-chat-container .chat-input button {
    /* padding: 8px 15px; */
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    flex-shrink: 0; /* don't compress the button as textarea grows */
    height: 39px !important; /* match textarea base height */
    padding: 0 15px !important; /* horizontal spacing only */
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.help-chat-container .loading {
    padding: 10px;
    color: #666;
    font-style: italic;
}

/* #faq-app .chat-trigger-button {
    display: none !important;
} */

.help-chat-container .chat-input textarea:disabled,
.help-chat-container .chat-input button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.help-chat-container .connection-status {
    position: absolute;
    top: 16px;
    right: 50px;
    font-size: 12px;
    color: #dc3545;
    transition: color 0.3s ease;
}

.help-chat-container .connection-status.connected {
    color: #719500;
}

.help-chat-container .product-selector {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    color: #2c3338;
}

.help-chat-container .product-selector h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
}

.help-chat-container .product-list {
    margin: 15px 0;
}

.help-chat-container .product-item {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.help-chat-container .product-item:last-child {
    border-bottom: none;
}

.help-chat-container .product-item label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.help-chat-container .product-item input[type="checkbox"] {
    margin: 0;
}

.help-chat-container .submit-selection {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
}

.help-chat-container .submit-selection:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.help-chat-container .submit-selection:hover:not(:disabled) {
    background: #0056b3;
}

.help-chat-container .message.product-selector {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    margin-right: auto;
    border-radius: 15px 15px 15px 0;
}

.help-chat-container .refund-reason-selector {
    margin: 15px 0;
}

.help-chat-container .refund-reason-selector select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    margin-top: 5px;
}

.help-chat-container .refund-comment {
    margin: 15px 0;
}

.help-chat-container .refund-comment textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    margin-top: 5px;
}

.help-chat-container .product-item {
    display: flex;
    padding: 10px;
    border-bottom: 1px solid #eee;
}

.help-chat-container .product-item label {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.help-chat-container .product-price {
    font-size: 12px;
    color: #666;
    margin-top: 3px;
}

/* Updated Product Selector Styling to match basket item */
.help-chat-container .chat-product-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 15px;
    width: 100%;
}

.help-chat-container .chat-product-item {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    background-color: #fff;
}

.help-chat-container .chat-product-item.refrigerated {
    background-color: #f5f9ff;
}

.help-chat-container .chat-product-item.gift {
    background-color: #fff5f5;
}

.help-chat-container .chat-product-item:last-child {
    border-bottom: none;
}

.help-chat-container .order-top {
    display: flex;
    align-items: flex-start;
}

.help-chat-container .chat-product-checkbox {
    margin-right: 10px;
    display: flex;
    align-items: flex-start;
    padding-top: 15px;
}

.help-chat-container .chat-product-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.help-chat-container .chat-product-image {
    width: 90px;
    height: 70px;
    margin-right: 15px;
    overflow: hidden;
    border-radius: 4px;
}

.help-chat-container .chat-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.help-chat-container .chat-product-details {
    flex: 1;
    min-width: 0;
    padding-right: 5px;
}

.help-chat-container .chat-product-name {
    font-weight: 500;
    font-size: 15px;
    margin-bottom: 6px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.help-chat-container .chat-product-supplier {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}

.help-chat-container .chat-product-price {
    font-size: 14px;
    color: #333;
    margin-top: 3px;
}

.help-chat-container .chat-product-status {
    margin-top: 5px;
    font-size: 12px;
}

.help-chat-container .short-message {
    color: red;
    font-style: italic;
}

.help-chat-container .refunded-message {
    color: #0066cc;
    font-style: italic;
}

.help-chat-container .submit-selection {
    background-color: #719500; /* Lufa green */
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px 15px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    margin-top: 10px;
}

.help-chat-container .submit-selection:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

/* Update the width of the help chat container */
.help-chat-container {
    width: 450px;
    max-width: 95vw;
}

/* Typing indicator styles */
.help-chat-container .typing-indicator {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background-color: #ffffff !important;
    border-radius: 16px;
    margin-bottom: 8px;
    max-width: 80%;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.help-chat-container .typing-indicator .message-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.help-chat-container .message-content {
    font-size: 16px !important;
    white-space: pre-wrap; /* preserve user-entered newlines */
    overflow-wrap: anywhere; /* wrap long unbroken strings */
    word-break: break-word;  /* fallback for older engines */
}

.help-chat-container .typing-indicator .typing-text {
    font-size: 13px;
    color: #777;
    white-space: nowrap;
}

.help-chat-container .typing-indicator .dot-container {
    display: flex;
    align-items: center;
    gap: 3px;
}

.help-chat-container .typing-indicator .dot {
    width: 4px;
    height: 4px;
    background: #777;
    border-radius: 50%;
    opacity: 0.3;
}

.help-chat-container .typing-indicator .dot:nth-child(1) {
    animation: dot-fade 1.4s infinite;
    animation-delay: 0s;
}

.help-chat-container .typing-indicator .dot:nth-child(2) {
    animation: dot-fade 1.4s infinite;
    animation-delay: 0.2s;
}

.help-chat-container .typing-indicator .dot:nth-child(3) {
    animation: dot-fade 1.4s infinite;
    animation-delay: 0.4s;
}

.help-chat-container strong, .help-chat-container h4 {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: black;
}

.help-chat-container strong {
    font-weight: 700;
}

@keyframes dot-fade {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 1;
    }
}

.help-chat-container .button-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.help-chat-container .submit-selection,
.help-chat-container .cancel-selection {
    width: 80%;
    padding: 10px 15px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    border-radius: 4px;
    margin-left: 30px;
    margin-bottom: 10px;
}

.help-chat-container .submit-selection {
    background-color: #719500;
    color: white;
}

.help-chat-container .cancel-selection {
    background-color: #dc3545 !important;
    color: white;
}

.help-chat-container .submit-selection:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}

.help-chat-container .cancel-selection:hover {
    background-color: #c82333 !important;
}

.help-chat-container .submit-selection:hover:not(:disabled) {
    background-color: #5a7a00 !important;
}

/* ---- New: make the trigger button visible outside FAQ pages ---- */
.chat-trigger-button {
    position: fixed;
    bottom: 100px;
    right: 20px;
    left: auto !important;
    padding: 6px 12px !important;
    background-color: #719500 !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 14px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2) !important;
    z-index: 150001 !important;
    transition: transform 0.2s ease;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: max-content;
    float: right;
    transform: none;
    min-width: 0;
}

.chat-trigger-button:hover {
    transform: scale(1.05);
}

/* ===================== Scoped reset & overrides ===================== */
.help-chat-container, .help-chat-container * {
    box-sizing: border-box !important;
    font-family: "Gibson", Arial, sans-serif !important;
}

/* .help-chat-container .chat-input input {
    margin-bottom: 0px !important;
} */

.help-chat-container .chat-input {
    font-size: 14px !important;
}

.help-chat-container p {
    margin: 0 0 0.75em !important;
}

.help-chat-container ul,
.help-chat-container ol {
    margin: 0 0 0 1.2em !important;
    padding: 0 !important;
}

.help-chat-container li {
    list-style: disc !important;
    margin-left: 0.5em !important;
}

/* Buttons */
.help-chat-container button,
.help-chat-container .chat-input button,
.help-chat-container .submit-selection,
.help-chat-container .cancel-selection {
    background: #719500 !important; /* Lufa green */
    color: #fff !important;
    font-size: 14px !important;
    border: none !important;
    border-radius: 4px !important;
    padding: 8px 15px !important;
    line-height: 1.2 !important;
    cursor: pointer !important;
}

/* Error / destructive button */
.help-chat-container .cancel-selection {
    background: #dc3545 !important;
}

/* Hover */
.help-chat-container button:hover:enabled,
.help-chat-container .chat-input button:hover:enabled,
.help-chat-container .submit-selection:hover:not(:disabled),
.help-chat-container .cancel-selection:hover:not(:disabled) {
    opacity: 0.9 !important;
}

/* Disable state */
.help-chat-container button:disabled,
.help-chat-container .chat-input button:disabled,
.help-chat-container .submit-selection:disabled,
.help-chat-container .cancel-selection:disabled {
    opacity: 0.6 !important;
    cursor: not-allowed !important;
}

/* Global Chat Trigger Button */
.chat-global-trigger-button {
    position: fixed;
    bottom: 40px;
    right: -105px;  /* Adjusted: further off-screen to ensure text is hidden initially */
    z-index: 150001;
    display: flex;
    align-items: center;
    padding: 12px 20px; /* Increased padding */
    background-color: #719500;
    color: white;
    border: none;
    border-radius: 22px 0 0 22px; /* Adjusted for new height/padding */
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: right 0.5s ease, background-color 0.3s ease, transform 0.2s ease;
    font-family: "Gibson", Arial, sans-serif;
    font-size: 16px; /* Increased font size */
    white-space: nowrap;
}

.chat-global-trigger-button:hover {
    background-color: #5a7a00;
    right: 0px;
}

/* Subtle highlight pulse to draw attention to chat trigger/container */
.highlight-pulse {
    /* Slower, gentler triple pulse */
    animation:
        chat-pulse 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0s 1,
        chat-pulse 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.30s 1,
        chat-pulse 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.60s 1;
}

/* Brief expansion/slide-in attention cue for the trigger */
.highlight-expand {
    right: 0px !important;
    transform: scale(1.04);
}

@keyframes chat-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(113, 149, 0, 0.35); transform: scale(1); }
    50%  { box-shadow: 0 0 0 24px rgba(113, 149, 0, 0); transform: scale(1.03); }
    100% { box-shadow: 0 0 0 0 rgba(113, 149, 0, 0); transform: scale(1.003); }
}

.chat-global-trigger-button img {
    width: 24px; /* Increased icon size */
    height: 24px; /* Increased icon size */
    margin-right: 10px; /* Adjusted icon margin */
    filter: brightness(0) invert(1);
}

/* No specific .fr right offset needed if "Help" and "Aide" (from userSettings.help.bookmark) are similar width */
/* .chat-global-trigger-button.fr {
    right: -XXXpx; 
} */

.chat-global-trigger-button.fr {
    right: -127px; /* Specific offset for French text if it's longer */
}

.chat-global-trigger-button:hover {
    background-color: #5a7a00;
    right: 0px;
}

/* Legacy trigger – normalise icon size */
.superlufa-profile-help-widget img {
    width: 24px !important;
    height: 24px !important;
}

@media (max-width: 768px) {
    #chat-widget {
      width: 90%;
      right: 5%;
      bottom: 10px;
    }
}

@media (max-width: 600px) {
    .help-chat-container {
        left: 10px;
        right: 10px;
        width: auto;
        max-width: none;
        min-width: 0;
        height: 60vh;
        bottom: 20px;
        border-radius: 8px;
        height: 500px;
    }
}

@media (max-width: 768px) {
    .chat-global-trigger-button,
    .chat-trigger-button {
        bottom: 5em !important;
    }
}

/* ===================== Disclaimer message ===================== */
.help-chat-container .message.disclaimer {
    max-width: 95% !important; /* wider than regular 80% */
    margin: 0 auto 10px auto !important; /* centered */
    background: transparent !important; /* let inner box control visuals */
    padding: 0 !important;
    border-radius: 0 !important;
}

/* Stand-alone disclaimer box (used inside both the widget and the ticket view) */
.help-chat-container .help-chat-disclaimer {
    display: block;
    font-size: 13px;
    color: #555;
    background: #fffceb; /* soft yellow */
    border-left: 4px solid #ffc107; /* Bootstrap warning colour */
    padding: 10px 16px;
    border-radius: 4px;
    line-height: 1.45;
    margin-bottom: 12px;
}