/* ????????????????????????????????????????????????????????
   Ishant 3D Prints ? Chatbot Widget Styles
   Adapted from RoboKidsAcademy chatbot.css
   ???????????????????????????????????????????????????????? */

.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    font-family: var(--font-body, 'Inter', sans-serif);
}

/* ??? Toggle button ???????????????????????????????????? */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary, #f97316) 0%, var(--primary-dark, #ea580c) 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(249, 115, 22, 0.5);
    transition: all 0.3s ease;
    position: relative;
}

.chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(249, 115, 22, 0.6);
}

.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid white;
}

/* ??? Chat window ?????????????????????????????????????? */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chatbot-window.active {
    display: flex;
}

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

/* ??? Header ??????????????????????????????????????????? */
.chatbot-header {
    background: linear-gradient(135deg, var(--primary, #f97316) 0%, var(--primary-dark, #ea580c) 100%);
    color: white;
    padding: 1.1rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.chatbot-avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.chatbot-header-info h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: white;
}

.chatbot-header-info p {
    margin: 0;
    font-size: 0.8rem;
    opacity: 0.85;
    color: white;
}

.chatbot-status-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #86efac;
    margin-right: 4px;
    vertical-align: middle;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 26px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
    opacity: 0.75;
    line-height: 1;
}
.chatbot-close:hover { background: rgba(0,0,0,0.15); opacity: 1; }

/* ??? Messages area ???????????????????????????????????? */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

.chatbot-message {
    display: flex;
    gap: 0.65rem;
    animation: fadeIn 0.3s ease;
}

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

.chatbot-message-bot  { align-self: flex-start; }
.chatbot-message-user { align-self: flex-end; flex-direction: row-reverse; }

.chatbot-avatar-small {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--primary, #f97316) 0%, var(--primary-dark, #ea580c) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.chatbot-message-user .chatbot-avatar-small {
    background: #e5e7eb;
}

.chatbot-message-content {
    max-width: 78%;
    padding: 0.65rem 0.9rem;
    border-radius: 16px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.07);
}

.chatbot-message-bot .chatbot-message-content {
    border-bottom-left-radius: 4px;
}

.chatbot-message-user .chatbot-message-content {
    background: linear-gradient(135deg, var(--primary, #f97316) 0%, var(--primary-dark, #ea580c) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message-bot .chatbot-message-content p {
    white-space: pre-line;
}

.chatbot-message-content p {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.6;
    color: #1e293b;
}

.chatbot-message-user .chatbot-message-content p {
    color: white;
}

/* Product result cards inside bot messages */
.chatbot-product-result {
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.4rem;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.chatbot-product-result:hover { background: #ffedd5; }
.chatbot-product-name { font-weight: 600; color: #1e293b; }
.chatbot-product-cat  { color: #ea580c; font-size: 0.78rem; }

/* ??? Typing indicator ????????????????????????????????? */
.chatbot-typing {
    display: flex;
    gap: 0.65rem;
    align-self: flex-start;
    animation: fadeIn 0.2s ease;
}

.chatbot-typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0.65rem 0.9rem;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.07);
}

.chatbot-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    display: inline-block;
    animation: typingBounce 1.2s infinite;
}

.chatbot-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chatbot-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30%            { transform: translateY(-5px); opacity: 1; }
}

/* ??? Chips ???????????????????????????????????????????? */
.chatbot-message-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.55rem;
}

.chatbot-chip {
    padding: 0.28rem 0.7rem;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 16px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #1e293b;
    font-weight: 500;
    font-family: var(--font-body, 'Inter', sans-serif);
}
.chatbot-chip:hover {
    background: var(--primary, #f97316);
    border-color: var(--primary-dark, #ea580c);
    color: white;
}

/* ??? Input area ??????????????????????????????????????? */
.chatbot-input-container {
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem 1rem;
    background: white;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    padding: 0.65rem 0.9rem;
    border: 1px solid #e5e7eb;
    border-radius: 22px;
    font-size: 0.875rem;
    outline: none;
    font-family: var(--font-body, 'Inter', sans-serif);
    transition: border-color 0.2s, box-shadow 0.2s;
    color: #1e293b;
}
.chatbot-input:focus {
    border-color: var(--primary, #f97316);
    box-shadow: 0 0 0 3px rgba(249,115,22,0.12);
}
.chatbot-input::placeholder { color: #9ca3af; }

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary, #f97316) 0%, var(--primary-dark, #ea580c) 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}
.chatbot-send:hover   { transform: scale(1.1); }
.chatbot-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ??? Quick replies strip ?????????????????????????????? */
.chatbot-quick-replies {
    display: flex;
    gap: 0.4rem;
    padding: 0 1rem 0.85rem;
    flex-wrap: wrap;
    flex-shrink: 0;
    background: white;
}

.quick-reply-btn {
    padding: 0.35rem 0.8rem;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 18px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
    color: #374151;
    font-family: var(--font-body, 'Inter', sans-serif);
}
.quick-reply-btn:hover {
    background: #fff7ed;
    border-color: var(--primary, #f97316);
    color: #ea580c;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: calc(12px + env(safe-area-inset-bottom, 0));
        right: calc(12px + env(safe-area-inset-right, 0));
    }

    .chatbot-window {
        width: 100vw;
        max-width: 100vw;
        height: calc(100dvh - 72px);
        max-height: calc(100dvh - 72px);
        bottom: calc(68px + env(safe-area-inset-bottom, 0));
        right: 0;
        border-radius: 20px 20px 0 0;
    }

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

    .chatbot-input {
        font-size: 16px;
    }

    .quick-reply-btn,
    .chatbot-chip {
        min-height: 36px;
        padding: 0.45rem 0.85rem;
    }
}
