/* AI Chatbot Styles */
.sticky-chatbot-btn {
    position: fixed;
    bottom: 120px;
    /* Aligned vertically above the cart button (which is bottom:40px) */
    right: 40px;
    /* Aligned horizontally with the cart button */
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    /* Indigo/Purple Gradient */
    color: white;
    border-radius: 50%;
    border: 3px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 9999;
    /* Higher than cart to ensure clickability if close */
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.sticky-chatbot-btn:hover {
    transform: scale(1.1) rotate(10deg);
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.6);
}

.chat-window {
    position: fixed;
    bottom: 100px;
    /* Positioned significantly higher to clear OS taskbars */
    right: 120px;
    /* Positioned to the left of the button stack to avoid overlap */
    width: 350px;
    height: 500px;
    max-height: calc(100vh - 140px);
    /* Ensure it fits on screen (100px bottom + 40px buffer) */
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 10000;
    overflow: hidden;
    animation: slideUp 0.3s ease-out forwards;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 10001;
    background: transparent;
}

.resize-handle::after {
    content: '';
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 10px;
    height: 10px;
    border-right: 2px solid #ccc;
    border-bottom: 2px solid #ccc;
}

.chat-header {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-header h5 {
    font-family: 'Nunito', sans-serif;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
}

.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
    word-wrap: break-word;
    /* Ensure long words break */
}

.chat-message.bot {
    background-color: white;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    margin-right: auto;
}

.chat-message.user {
    background-color: #4f46e5;
    color: white;
    border-bottom-right-radius: 4px;
    margin-left: auto;
    box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3);
}

.chat-footer {
    padding: 15px;
    background: white;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 10px;
}

.chat-footer input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 10px 15px;
    outline: none;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.chat-footer input:focus {
    border-color: #4f46e5;
}

.chat-footer button {
    background: #4f46e5;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-footer button:hover {
    background: #4338ca;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Responsive Logic */
@media (max-width: 768px) {
    .sticky-chatbot-btn {
        right: 20px;
        bottom: 90px;
        /* Above standard bottom nav */
        width: 50px;
        height: 50px;
        font-size: 20px;
    }

    .chat-window {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        /* Full screen on mobile */
        border-radius: 0;
        z-index: 2000;
    }
}