:root {
    --chatbot-color: #0073aa;
    --chatbot-size: 60px;
    --chatbot-window-width: 400px;
    --chatbot-window-height: 600px;
}

.chatbot-widget-container {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    z-index: 9999;
}

.chatbot-fixed {
    position: fixed;
    bottom: 20px;
}

.chatbot-fixed.desktop-right {
    right: 20px;
}

.chatbot-fixed.desktop-left {
    left: 20px;
}

@media (max-width: 768px) {
    .chatbot-fixed.mobile-right {
        right: 20px;
        left: auto;
    }

    .chatbot-fixed.mobile-left {
        left: 20px;
        right: auto;
    }

    .chatbot-window {
        width: 90vw !important;
        height: 70vh !important;
        bottom: 80px !important;
    }
}

/* Tooltip */
.chatbot-tooltip {
    position: absolute;
    bottom: calc(var(--chatbot-size) + 15px);
    background-color: var(--chatbot-color);
    color: #fff;
    padding: 10px 16px;
    border-radius: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    z-index: 10000;
    transform: translateY(10px);
}

.chatbot-fixed.desktop-right .chatbot-tooltip {
    right: 0;
    transform-origin: bottom right;
}

.chatbot-fixed.desktop-left .chatbot-tooltip {
    left: 0;
    transform-origin: bottom left;
}

.chatbot-widget-container:not(.chatbot-open):hover .chatbot-tooltip,
.chatbot-tooltip.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    animation: tooltip-bounce 2s infinite;
}

@keyframes tooltip-bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-6px);
    }

    60% {
        transform: translateY(-3px);
    }
}

/* Arrow */
.chatbot-tooltip::after {
    content: '';
    position: absolute;
    bottom: -6px;
    width: 12px;
    height: 12px;
    background: var(--chatbot-color);
    transform: rotate(45deg);
}

.chatbot-fixed.desktop-right .chatbot-tooltip::after {
    right: 24px;
}

.chatbot-fixed.desktop-left .chatbot-tooltip::after {
    left: 24px;
}

@media (max-width: 768px) {
    .chatbot-tooltip {
        display: none;
    }
}

/* Bubble */
.chatbot-bubble {
    width: var(--chatbot-size);
    height: var(--chatbot-size);
    background-color: var(--chatbot-color);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.chatbot-bubble:hover {
    transform: scale(1.05);
}

.chatbot-bubble svg {
    width: 50%;
    height: 50%;
}

/* Window */
.chatbot-window {
    position: absolute;
    bottom: calc(var(--chatbot-size) + 20px);
    width: var(--chatbot-window-width);
    height: var(--chatbot-window-height);
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

/* Positioning fix for window */
.chatbot-fixed.desktop-right .chatbot-window {
    right: 0;
    transform-origin: bottom right;
}

.chatbot-fixed.desktop-left .chatbot-window {
    left: 0;
    transform-origin: bottom left;
}

@media (max-width: 768px) {
    .chatbot-fixed.mobile-right .chatbot-window {
        right: 0;
        left: auto;
        transform-origin: bottom right;
    }

    .chatbot-fixed.mobile-left .chatbot-window {
        left: 0;
        right: auto;
        transform-origin: bottom left;
    }
}

.chatbot-inline .chatbot-window {
    position: relative;
    bottom: auto;
    width: 100%;
    max-width: 100%;
    height: 600px;
    opacity: 1;
    pointer-events: all;
    transform: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #eee;
}

.chatbot-window.open {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

/* Header */
.chatbot-header {
    background-color: var(--chatbot-color);
    color: white;
    padding: 0 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    height: 27px;
    min-height: 27px;
}

#chatbot-close,
#chatbot-clear {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    margin: 0;
    padding: 0;
    height: 20px;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

#chatbot-close:hover,
#chatbot-clear:hover {
    opacity: 0.8;
}

#chatbot-close {
    font-size: 20px;
    line-height: 1;
}

/* Messages */
.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.bot {
    background-color: #e9e9eb;
    color: #000;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.message.user {
    background-color: var(--chatbot-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.message p {
    margin: 0 0 8px 0;
}

.message p:last-child {
    margin: 0;
}

.message ul,
.message ol {
    margin: 0 0 10px 20px;
    padding: 0;
}

.message li {
    margin-bottom: 5px;
}

/* Input Area */
.chatbot-input-area {
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    background: white;
}

#chatbot-input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
}

#chatbot-send {
    background-color: var(--chatbot-color);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

#chatbot-send:hover {
    filter: brightness(0.9);
}

#chatbot-send:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    filter: none;
}

#chatbot-send svg {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px;
    min-height: 18px;
    fill: white;
    flex-shrink: 0;
}

/* Product Card Styles */
.chatbot-product-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    gap: 12px;
    margin-top: 8px;
    max-width: 100%;
    box-sizing: border-box;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-product-image {
    flex-shrink: 0;
}

.chatbot-product-image img {
    width: 70px;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

.chatbot-product-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    /* Fix for flexbox text overflow */
}

.chatbot-product-title {
    margin: 0 0 6px 0;
    font-size: 14px;
    line-height: 1.3;
    font-weight: 600;
    /* Multi-line truncation */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-wrap: break-word;
}

.chatbot-product-title a {
    text-decoration: none;
    color: #333;
    transition: color 0.2s;
}

.chatbot-product-title a:hover {
    color: var(--chatbot-color);
}

.chatbot-product-price {
    font-weight: bold;
    color: var(--chatbot-color);
    font-size: 14px;
    margin-bottom: 8px;
}

.chatbot-product-variants {
    margin-bottom: 8px;
    width: 100%;
    /* Ensure variants container doesn't overflow */
}

.chatbot-variant-option {
    margin-bottom: 6px;
}

.chatbot-variant-option label {
    display: block;
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.chatbot-variant-select {
    width: 100%;
    max-width: 100%;
    /* Prevent overflow */
    padding: 4px;
    font-size: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    box-sizing: border-box;
    /* Include padding in width */
}

.chatbot-product-actions {
    margin-top: auto;
}

.chatbot-add-to-cart {
    display: inline-block;
    font-size: 13px !important;
    padding: 8px 12px !important;
    line-height: 1.2 !important;
    min-height: auto !important;
    background-color: var(--chatbot-color) !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    text-decoration: none !important;
    text-align: center;
    transition: background-color 0.2s, opacity 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.chatbot-add-to-cart:hover {
    background-color: var(--chatbot-color) !important;
    filter: brightness(0.9);
    color: white !important;
}

.chatbot-add-to-cart.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #ccc !important;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px;
    background: #e9e9eb;
    border-radius: 12px;
    align-self: flex-start;
    width: fit-content;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Progress Bar */
.chatbot-progress-container {
    width: 100%;
    height: 4px;
    background-color: #f0f0f0;
    margin-top: 5px;
    border-radius: 2px;
    overflow: hidden;
}

.chatbot-progress-bar {
    height: 100%;
    background-color: var(--chatbot-color);
    width: 0%;
    transition: width 0.1s linear;
}

/* Resize Handle */
.chatbot-resize-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    z-index: 100;
    transition: background-color 0.2s;
}

.chatbot-resize-handle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Visual Indicator for Resize */
.chatbot-resize-handle::before,
.chatbot-resize-handle::after {
    content: '';
    position: absolute;
    border-style: solid;
    border-color: #bbb;
    transition: border-color 0.2s;
    pointer-events: none;
}

.chatbot-resize-handle:hover::before,
.chatbot-resize-handle:hover::after {
    border-color: #888;
}

/* Right aligned chat -> Handle on Top-Left */
.chatbot-fixed.desktop-right .chatbot-resize-handle {
    top: 0;
    left: 0;
    cursor: nwse-resize;
    /* Diagonal resize */
    border-top-left-radius: 12px;
}

.chatbot-fixed.desktop-right .chatbot-resize-handle::before {
    top: 5px;
    left: 5px;
    width: 10px;
    height: 10px;
    border-width: 2px 0 0 2px;
}

.chatbot-fixed.desktop-right .chatbot-resize-handle::after {
    top: 9px;
    left: 9px;
    width: 6px;
    height: 6px;
    border-width: 2px 0 0 2px;
}

/* Left aligned chat -> Handle on Top-Right */
.chatbot-fixed.desktop-left .chatbot-resize-handle {
    top: 0;
    right: 0;
    cursor: nesw-resize;
    /* Diagonal resize */
    border-top-right-radius: 12px;
}

.chatbot-fixed.desktop-left .chatbot-resize-handle::before {
    top: 5px;
    right: 5px;
    width: 10px;
    height: 10px;
    border-width: 2px 2px 0 0;
}

.chatbot-fixed.desktop-left .chatbot-resize-handle::after {
    top: 9px;
    right: 9px;
    width: 6px;
    height: 6px;
    border-width: 2px 2px 0 0;
}

@media (max-width: 768px) {
    .chatbot-resize-handle {
        display: none;
    }
}

@keyframes wobble {
    0% {
        transform: translateX(0);
    }

    15% {
        transform: translateX(-5px) rotate(-5deg);
    }

    30% {
        transform: translateX(4px) rotate(3deg);
    }

    45% {
        transform: translateX(-3px) rotate(-3deg);
    }

    60% {
        transform: translateX(2px) rotate(2deg);
    }

    75% {
        transform: translateX(-1px) rotate(-1deg);
    }

    100% {
        transform: translateX(0);
    }
}

.wobble {
    animation: wobble 0.5s ease-in-out;
    color: red;
}

.chatbot-suggested-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 5px;
    background: #f9f9f9;
    border-top: 1px solid #eee;
}

.chatbot-suggestion-chip {
    background: #fff;
    border: 1px solid var(--chatbot-color);
    color: var(--chatbot-color);
    padding: 6px;
    border-radius: 16px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-suggestion-chip:hover {
    background: var(--chatbot-color);
    color: #fff;
}

.chatbot-instrument-btn {
    background: #fff;
    border: 1px solid var(--chatbot-color);
    color: #333;
    padding: 6px;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1 0 auto;
    text-align: center;
    min-width: 60px;
}

.chatbot-instrument-btn:hover {
    background: #f0f0f1;
}

.chatbot-instrument-btn.active {
    background: var(--chatbot-color);
    color: #fff;
    border-color: var(--chatbot-color);
}


.chatbot-instrument-selector {
    padding: 5px 10px;
    border-bottom: 1px solid #eee;
    background: #f9f9f9;
}

.chatbot-instrument-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-start;
    /* Align left to look more like a list */
}