/* Chatbot Widget Styles */

#chatbot-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Position variants */
.chatbot-widget.chatbot-bottom-right {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.chatbot-widget.chatbot-bottom-left {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
}

/* Bubble button */
.chatbot-bubble {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #adff31 0%, #8a041f 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: white;
    transition: all 0.3s ease;
}

.chatbot-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chatbot-bubble svg {
    width: 28px;
    height: 28px;
}

/* Chat window */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.chatbot-window.chatbot-bottom-left {
    left: 0;
    right: auto;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, #adff31 0%, #8a041f 100%);
    color: white;
    padding: 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 25px;
    /* font-weight: 600; */
    font-family: Asiyah Script;
    color: white;
    text-decoration: none;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.chatbot-close:hover {
    opacity: 0.8;
}

/* Messages container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f5f7fa;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* Messages */
.chatbot-message {
    display: flex;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message-user {
    justify-content: flex-end;
}

.chatbot-message-bot {
    justify-content: flex-start;
}

.chatbot-text {
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 14px;
}

.chatbot-message-user .chatbot-text {
    background: #8a041f;
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message-bot .chatbot-text {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    border: 1px solid #e0e0e0;
}

.chatbot-text strong {
    font-weight: 600;
    color: inherit;
}

/* Product recommendation */
.chatbot-product {
    display: flex;
    gap: 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    max-width: 100%;
    margin-top: 8px;
}

.product-image {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f7fa;
}

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

.product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-info h4 {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.product-price {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #8a041f;
}

.product-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
    align-self: flex-start;
}

.product-btn:hover {
    background: #764ba2;
}

/* Loading indicator */
.chatbot-loading {
    display: flex;
    gap: 4px;
    align-items: flex-end;
}

.chatbot-loading span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: loading 1.4s infinite;
}

.chatbot-loading span:nth-child(2) {
    animation-delay: 0.2s;
}

.chatbot-loading span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes loading {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input area */
.chatbot-input-area {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-top: 1px solid #e0e0e0;
    background: white;
    border-radius: 0 0 12px 12px;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chatbot-input:focus {
    border-color: #8a041f;
}

#chatbot-input::placeholder {
    color: #999;
}

.chatbot-send {
    background: #8a041f;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    background: #764ba2;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 20px);
        height: 70vh;
        max-height: 500px;
        /* Use fixed positioning on small screens to avoid layout issues
           when the widget is appended to different containers */
        position: fixed;
        bottom: calc(env(safe-area-inset-bottom, 20px) + 10px);
        left: 10px;
        right: 10px;
        margin: 0 auto;
        border-radius: 10px;
    }

    .chatbot-bubble {
        width: 56px;
        height: 56px;
    }

    .chatbot-text {
        max-width: 90%;
    }

    .chatbot-product {
        max-width: 100%;
    }
}

/* Tablet responsive (small desktops / large phones in landscape) */
@media (min-width: 481px) and (max-width: 1024px) {
    .chatbot-window {
        /* Constrain width and use fixed positioning so the window remains
           visible while scrolling on touch devices */
        width: min(480px, calc(100vw - 40px));
        height: 64vh;
        max-height: 720px;
        position: fixed;
        bottom: calc(env(safe-area-inset-bottom, 20px) + 14px);
        left: 20px;
        right: 20px;
        margin: 0 auto;
        border-radius: 12px;
    }

    .chatbot-bubble {
        width: 52px;
        height: 52px;
    }

    .chatbot-header h3 {
        font-size: 18px;
    }

    .chatbot-input-area {
        padding: 12px;
    }

    .chatbot-text {
        font-size: 14px;
    }
}

/* Support Form Styles */
.chatbot-support-form {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    border-radius: 0 0 12px 12px;
    gap: 10px;
}

.chatbot-support-form form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chatbot-support-form input,
.chatbot-support-form textarea {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: Arial, sans-serif;
    font-size: 13px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-support-form input:focus,
.chatbot-support-form textarea:focus {
    border-color: #667eea;
}

.chatbot-support-form textarea {
    min-height: 80px;
}

.support-submit {
    background: #28a745;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
}

.support-submit:hover {
    background: #218838;
}

.support-cancel {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.support-cancel:hover {
    background: #5a6268;
}

/* Contact Support Action Button */
.chatbot-action {
    margin-top: 8px;
}

.support-contact-btn {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    width: 100%;
}

.support-contact-btn:hover {
    background: #ee5a52;
}
