/* ============================================================
   AI Chatbot Widget - MurliGanj Local Store Theme
   Designed to match: framework.css green-primary/orange-accent
   ============================================================ */

#mls-chat-widget * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* ─── Floating Button ─── */
#mls-chat-widget .chat-fab {
    position: fixed;
    bottom: 100px;
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    pointer-events: auto;
}

#mls-chat-widget .chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
}

#mls-chat-widget .chat-fab:active {
    transform: scale(0.95);
}

#mls-chat-widget .chat-fab .notification-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border: 2px solid white;
    border-radius: 50%;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* ─── Chat Panel ─── */
#mls-chat-widget .chat-panel {
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    z-index: 9989;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: mls-chat-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

#mls-chat-widget .chat-panel.open {
    display: flex;
}

@keyframes mls-chat-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ─── Header ─── */
#mls-chat-widget .chat-header {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    position: relative;
}

#mls-chat-widget .chat-header::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 0;
    right: 0;
    height: 8px;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    filter: blur(4px);
    opacity: 0.3;
}

#mls-chat-widget .chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

#mls-chat-widget .chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#mls-chat-widget .chat-avatar svg {
    width: 20px;
    height: 20px;
}

#mls-chat-widget .chat-header-info {
    min-width: 0;
}

#mls-chat-widget .chat-header-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#mls-chat-widget .chat-header-status {
    font-size: 11px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

#mls-chat-widget .status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}

#mls-chat-widget .status-dot.online {
    background: #4ade80;
    box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}

#mls-chat-widget .status-dot.offline {
    background: #9ca3af;
}

#mls-chat-widget .chat-header-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

#mls-chat-widget .chat-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
    touch-action: manipulation;
}

#mls-chat-widget .chat-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ─── Messages Area ─── */
#mls-chat-widget .chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

#mls-chat-widget .chat-messages::-webkit-scrollbar {
    width: 4px;
}

#mls-chat-widget .chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#mls-chat-widget .chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

#mls-chat-widget .chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ─── Message Bubbles ─── */
#mls-chat-widget .message-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    animation: mls-chat-fade-in 0.3s ease;
}

@keyframes mls-chat-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

#mls-chat-widget .message-wrapper.bot {
    justify-content: flex-start;
}

#mls-chat-widget .message-wrapper.user {
    justify-content: flex-end;
}

#mls-chat-widget .message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

#mls-chat-widget .message-avatar.bot {
    background: #6366f1;
}

#mls-chat-widget .message-avatar.user {
    background: #16a34a;
}

#mls-chat-widget .message-avatar svg {
    width: 14px;
    height: 14px;
}

#mls-chat-widget .message-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.5;
    word-break: break-word;
    position: relative;
}

#mls-chat-widget .message-bubble.bot {
    background: white;
    color: #111827;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

#mls-chat-widget .message-bubble.user {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

#mls-chat-widget .message-bubble.agent {
    background: #fef3c7;
    color: #92400e;
    border-bottom-left-radius: 4px;
}

#mls-chat-widget .message-time {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 3px;
    text-align: right;
}

#mls-chat-widget .message-wrapper.user .message-time {
    color: rgba(255, 255, 255, 0.7);
}

#mls-chat-widget .message-bubble.bot .message-time {
    color: #9ca3af;
}

/* ─── Quick Replies ─── */
#mls-chat-widget .quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 0 4px;
}

#mls-chat-widget .quick-reply-btn {
    padding: 7px 14px;
    border-radius: 20px;
    border: 1.5px solid #6366f1;
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    touch-action: manipulation;
}

#mls-chat-widget .quick-reply-btn:hover {
    background: #6366f1;
    color: white;
}

/* ─── Typing Indicator ─── */
#mls-chat-widget .typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    width: fit-content;
}

#mls-chat-widget .typing-dot {
    width: 7px;
    height: 7px;
    background: #d1d5db;
    border-radius: 50%;
    animation: mls-chat-typing 1.4s infinite;
}

#mls-chat-widget .typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

#mls-chat-widget .typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes mls-chat-typing {
    0%, 60%, 100% { transform: translateY(0); background: #d1d5db; }
    30% { transform: translateY(-6px); background: #6366f1; }
}

/* ─── Input Area ─── */
#mls-chat-widget .chat-input-area {
    padding: 12px 14px;
    border-top: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
}

#mls-chat-widget .chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f3f4f6;
    border-radius: 12px;
    padding: 4px;
}

#mls-chat-widget .chat-input-wrapper:focus-within {
    outline: 2px solid rgba(99, 102, 241, 0.3);
    outline-offset: 1px;
}

#mls-chat-widget .chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 10px;
    font-size: 13.5px;
    outline: none;
    color: #111827;
    font-family: 'Inter', system-ui, sans-serif;
    min-width: 0;
}

#mls-chat-widget .chat-input::placeholder {
    color: #9ca3af;
}

#mls-chat-widget .chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
    touch-action: manipulation;
}

#mls-chat-widget .chat-send-btn:hover {
    transform: scale(1.05);
}

#mls-chat-widget .chat-send-btn:active {
    transform: scale(0.95);
}

#mls-chat-widget .chat-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    transform: none;
}

/* ─── Welcome / Initial State ─── */
#mls-chat-widget .welcome-message {
    text-align: center;
    padding: 30px 20px;
}

#mls-chat-widget .welcome-icon {
    font-size: 48px;
    margin-bottom: 12px;
    display: block;
}

#mls-chat-widget .welcome-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 6px;
}

#mls-chat-widget .welcome-text {
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
    margin-bottom: 16px;
}

/* ─── Login Required Banner ─── */
#mls-chat-widget .login-banner {
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 10px;
    padding: 10px 14px;
    margin-top: 8px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

#mls-chat-widget .login-banner i {
    color: #f59e0b;
    font-size: 16px;
    margin-top: 1px;
}

#mls-chat-widget .login-banner-content {
    flex: 1;
}

#mls-chat-widget .login-banner-content p {
    font-size: 12px;
    color: #92400e;
    line-height: 1.4;
}

#mls-chat-widget .login-banner-content a {
    color: #6366f1;
    font-weight: 600;
    text-decoration: underline;
}

/* ─── Scroll to Bottom Button ─── */
#mls-chat-widget .scroll-bottom-btn {
    position: absolute;
    bottom: 80px;
    right: 20px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: white;
    border: 1px solid #e5e7eb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    font-size: 14px;
    transition: all 0.2s;
    touch-action: manipulation;
}

#mls-chat-widget .scroll-bottom-btn.show {
    display: flex;
}

#mls-chat-widget .scroll-bottom-btn:hover {
    transform: translateY(-2px);
    color: #6366f1;
}

/* ─── Branding ─── */
#mls-chat-widget .chat-footer-branding {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #9ca3af;
    background: white;
    border-top: 1px solid #f3f4f6;
    flex-shrink: 0;
}

/* ─── Mobile Responsive ─── */
@media (max-width: 640px) {
    #mls-chat-widget .chat-fab {
        bottom: 76px;
        right: 12px;
        width: 48px;
        height: 48px;
        font-size: 18px;
    }

    #mls-chat-widget .chat-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    #mls-chat-widget .chat-header {
        padding: 14px 16px;
        padding-top: calc(14px + env(safe-area-inset-top, 0px));
    }

    #mls-chat-widget .chat-messages {
        padding: 12px;
    }

    #mls-chat-widget .message-bubble {
        max-width: 88%;
        font-size: 14px;
    }

    #mls-chat-widget .quick-reply-btn {
        font-size: 13px;
        padding: 8px 16px;
    }
}
