/* Premium ChatGPT-Style Chatbot CSS */

/* Color system & variables */
:root {
    --chat-primary: #0F172A; /* Slate 900 for modern elegant look */
    --chat-primary-hover: #1E293B;
    --chat-accent: #6366F1; /* Indigo accent */
    --chat-accent-hover: #4F46E5;
    --chat-bg: #F8FAFC;
    --chat-bubble-user: #6366F1;
    --chat-bubble-bot: #F1F5F9;
    --chat-text-dark: #0F172A;
    --chat-text-light: #FFFFFF;
    --chat-text-muted: #64748B;
    --chat-border: #E2E8F0;
    --chat-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --chat-font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Floating widget container */
.chatbot-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 99999;
    font-family: var(--chat-font);
}
@media(max-width:768px){
  .chatbot-widget {
    bottom: calc(var(--bot-h, 70px) + env(safe-area-inset-bottom, 0px) + 12px) !important;
    right: 14px !important;
  }
}

/* Floating Action Button (Toggle) */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chat-primary);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.chatbot-toggle:hover {
    transform: scale(1.08) rotate(5deg);
    background: var(--chat-primary-hover);
    box-shadow: 0 15px 30px rgba(15, 23, 42, 0.35);
}
.chatbot-toggle svg {
    width: 26px;
    height: 26px;
    transition: transform 0.3s ease;
}
.chatbot-toggle.open svg {
    transform: rotate(90deg);
}

/* Chat Window */
.chatbot-window {
    display: none;
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 580px;
    max-width: calc(100vw - 28px);
    max-height: calc(100dvh - var(--bot-h, 70px) - env(safe-area-inset-bottom, 0px) - 100px);
    background: white;
    border-radius: 20px;
    box-shadow: var(--chat-shadow);
    overflow: hidden;
    flex-direction: column;
    border: 1px solid var(--chat-border);
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.chatbot-window.open {
    display: flex;
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

/* Chat Header */
.chatbot-header {
    background: var(--chat-primary);
    color: white;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chatbot-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}
.chatbot-avatar svg {
    color: white;
    width: 22px;
    height: 22px;
}
.chatbot-title-container {
    display: flex;
    flex-direction: column;
}
.chatbot-title {
    font-weight: 700;
    font-size: 15px;
    margin: 0;
    line-height: 1.2;
    color: white;
}
.chatbot-status {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}
.chatbot-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10B981; /* pulsing green online indicator */
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.4);
    animation: pulse-dot 2s infinite;
}

/* Reset and Close Buttons */
.chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}
.chatbot-header-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.2s ease;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chatbot-header-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}
.chatbot-header-btn svg {
    width: 18px;
    height: 18px;
}

/* Chat Messages Container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--chat-bg);
    scroll-behavior: smooth;
}

/* Scrollbar styles */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}
.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chatbot-messages::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}
.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Individual Chat Messages */
.chat-msg {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: message-appear 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.chat-msg.bot {
    align-self: flex-start;
}
.chat-msg.user {
    align-self: flex-end;
}

/* Chat Bubbles */
.chat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.chat-msg.bot .chat-bubble {
    background: var(--chat-bubble-bot);
    color: var(--chat-text-dark);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chat-border);
}
.chat-msg.user .chat-bubble {
    background: var(--chat-bubble-user);
    color: var(--chat-text-light);
    border-bottom-right-radius: 4px;
}

/* Message Meta (Timestamp) */
.chat-meta {
    font-size: 10px;
    color: var(--chat-text-muted);
}
.chat-msg.bot .chat-meta {
    margin-left: 4px;
}
.chat-msg.user .chat-meta {
    align-self: flex-end;
    margin-right: 4px;
}

/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
}
.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--chat-text-muted);
    border-radius: 50%;
    display: inline-block;
    animation: typing-bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

/* Chat Input Area */
.chatbot-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--chat-border);
    display: flex;
    gap: 12px;
    align-items: center;
}
.chatbot-input-area input {
    flex: 1;
    border: 1px solid var(--chat-border);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 14px;
    outline: none;
    background: #F8FAFC;
    transition: all 0.2s ease;
    color: var(--chat-text-dark);
}
.chatbot-input-area input:focus {
    border-color: var(--chat-accent);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.chatbot-input-area button {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--chat-accent);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
}
.chatbot-input-area button:hover {
    background: var(--chat-accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(99, 102, 241, 0.3);
}
.chatbot-input-area button:active {
    transform: translateY(0);
}
.chatbot-input-area button svg {
    width: 18px;
    height: 18px;
    margin-left: 2px;
}

/* Animations */
@keyframes pulse-dot {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes typing-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

@keyframes message-appear {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive design */
@media (max-width: 480px) {
    .chatbot-widget {
        right: 15px;
        bottom: 15px;
    }
    .chatbot-window {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        border: none;
        bottom: 0;
    }
    .chatbot-toggle {
        width: 54px;
        height: 54px;
    }
}

/* Premium E-commerce Product Cards System */
.chat-products-container {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    overflow-x: auto;
    padding: 4px 4px 10px 4px;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    flex-shrink: 0;
}

.chat-products-container::-webkit-scrollbar {
    height: 4px;
}
.chat-products-container::-webkit-scrollbar-track {
    background: transparent;
}
.chat-products-container::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 2px;
}

.chat-product-card {
    flex: 0 0 210px;
    scroll-snap-align: start;
    background: white;
    border: 1px solid var(--chat-border);
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    text-decoration: none;
}

.chat-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.12);
    border-color: var(--chat-accent);
}

.chat-product-img-wrapper {
    width: 100%;
    height: 110px;
    background: #F1F5F9;
    position: relative;
    overflow: hidden;
}

.chat-product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.chat-product-card:hover .chat-product-img {
    transform: scale(1.05);
}

.chat-product-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}

.chat-product-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--chat-text-dark);
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    height: 34px;
}

.chat-product-price-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 2px;
}

.chat-product-price {
    font-weight: 700;
    font-size: 14px;
    color: var(--chat-accent);
}

.chat-product-price-old {
    font-size: 11px;
    text-decoration: line-through;
    color: var(--chat-text-muted);
}

.chat-product-desc {
    font-size: 11px;
    color: var(--chat-text-muted);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-top: 2px;
    height: 28px;
}

.chat-product-btn {
    margin-top: 10px;
    display: block;
    text-align: center;
    background: var(--chat-accent);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
}

.chat-product-card:hover .chat-product-btn {
    background: var(--chat-accent-hover);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.25);
}

