/* ==========================================================================
   PurnoBD Intelligent AI Product Guide & Moveable Widget Styling
   ========================================================================== */

#ai-assistant-widget-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #1e293b;
    pointer-events: none; /* children enable pointer events */
}

/* Floating Launcher Button */
.ai-widget-launcher {
    pointer-events: auto;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    box-shadow: 0 10px 25px -5px rgba(79, 70, 229, 0.5), 0 8px 10px -6px rgba(6, 182, 212, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    cursor: grab;
    user-select: none;
    touch-action: none;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
    position: relative;
}

.ai-widget-launcher:active {
    cursor: grabbing;
    transform: scale(0.94);
}

.ai-widget-launcher:hover {
    transform: scale(1.08);
    box-shadow: 0 14px 30px -4px rgba(79, 70, 229, 0.6), 0 10px 14px -5px rgba(6, 182, 212, 0.5);
}

.ai-widget-launcher i {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.ai-widget-launcher.open i.fa-wand-magic-sparkles,
.ai-widget-launcher.open i.fa-robot {
    display: none;
}
.ai-widget-launcher.open i.fa-xmark {
    display: block !important;
}

/* Online Pulse Beacon */
.ai-widget-beacon {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.8);
}

/* Tooltip hint */
.ai-widget-tooltip {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    background: #0f172a;
    color: #f8fafc;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.ai-widget-launcher:hover .ai-widget-tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(-4px);
}

/* Chat Drawer Window */
.ai-widget-window {
    pointer-events: auto;
    position: fixed;
    width: 385px;
    max-width: calc(100vw - 20px);
    height: 565px;
    max-height: calc(100vh - 20px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.25), 0 1px 3px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999998;
    border: 1px solid rgba(226, 232, 240, 0.9);
    transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1), transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    opacity: 0;
    transform: scale(0.92) translateY(20px);
    pointer-events: none;
}

.ai-widget-window.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Header */
.ai-widget-header {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    color: #ffffff;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    box-sizing: border-box;
}

.ai-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

.ai-header-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
}

.ai-header-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.ai-header-title {
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: -0.01em;
}

.ai-header-subrow {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.ai-header-role-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 1.5px 6px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #cbd5e1;
    white-space: nowrap;
    line-height: 1.2;
}

/* Connection Health Badge */
.ai-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1.5px 6px;
    border-radius: 6px;
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.35);
    font-size: 0.62rem;
    font-weight: 600;
    color: #6ee7b7;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
    line-height: 1.2;
}

.ai-status-badge.fallback {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.35);
    color: #fcd34d;
}

.ai-status-badge.offline {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

.ai-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 6px #10b981;
    display: inline-block;
    flex-shrink: 0;
}

.ai-status-badge.fallback .ai-status-dot {
    background: #f59e0b;
    box-shadow: 0 0 6px #f59e0b;
}

.ai-status-badge.offline .ai-status-dot {
    background: #ef4444;
    box-shadow: 0 0 6px #ef4444;
}

.ai-status-dot.pulse {
    animation: aiPulseAnim 1.8s infinite ease-in-out;
}

@keyframes aiPulseAnim {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.75); opacity: 0.4; }
}

/* Header Action Buttons (Reset, Language, Close) */
.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.ai-header-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    font-size: 0.72rem;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-header-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.08);
}

.ai-header-btn:active {
    transform: scale(0.92);
}

.ai-header-btn.rotate-btn:hover i {
    transform: rotate(180deg);
    transition: transform 0.3s ease;
}

.ai-lang-toggle-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    padding: 3px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s ease;
    user-select: none;
}

.ai-lang-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.04);
}

.ai-header-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
}

.ai-header-close-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* Quick Suggestion Pills with Smooth Horizontal Scrolling */
.ai-suggestions-wrapper {
    position: relative;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    overflow: hidden;
    padding: 2px 4px;
}

.ai-suggestions-container {
    padding: 6px 4px;
    overflow-x: auto;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    scroll-behavior: smooth;
    cursor: grab;
    user-select: none;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    flex: 1;
}

.ai-suggestions-container::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.ai-suggestions-container.grabbing {
    cursor: grabbing !important;
    scroll-behavior: auto !important;
}

.ai-suggestion-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ai-suggestion-chip:hover {
    background: #4f46e5;
    color: #ffffff;
    border-color: #4f46e5;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(79, 70, 229, 0.25);
}

.ai-scroll-arrow {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #64748b;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.68rem;
    z-index: 2;
    transition: all 0.15s ease;
    flex-shrink: 0;
    margin: 0 2px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.ai-scroll-arrow:hover {
    color: #4f46e5;
    background: #eef2ff;
    border-color: #c7d2fe;
}

/* Center Hero Welcome State (PayOnTask style) */
.ai-hero-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 14px 10px 8px 10px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
    animation: aiFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.ai-hero-icon-box {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12) 0%, rgba(6, 182, 212, 0.16) 100%);
    border: 1px solid rgba(79, 70, 229, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4f46e5;
    font-size: 1.25rem;
    margin-bottom: 8px;
    box-shadow: 0 4px 14px -2px rgba(79, 70, 229, 0.2);
}

.ai-hero-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 4px 0;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.ai-hero-subtitle {
    font-size: 0.73rem;
    color: #64748b;
    line-height: 1.45;
    margin: 0 0 10px 0;
    max-width: 290px;
}

/* Centered Question Pills */
.ai-center-pills-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 320px;
    margin-top: 2px;
}

.ai-center-pill {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #334155;
    padding: 7px 12px;
    border-radius: 9px;
    font-size: 0.73rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: left;
    line-height: 1.35;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ai-center-pill:hover {
    background: #f8fafc;
    border-color: #818cf8;
    color: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 3px 10px -2px rgba(79, 70, 229, 0.2);
}

.ai-center-pill-arrow {
    color: #94a3b8;
    font-size: 0.7rem;
    flex-shrink: 0;
    transition: transform 0.2s ease, color 0.2s ease;
}

.ai-center-pill:hover .ai-center-pill-arrow {
    color: #4f46e5;
    transform: translateX(2px);
}


/* Chat Messages Stream */
.ai-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f1f5f9;
}

/* Message Bubbles */
.ai-msg {
    max-width: 88%;
    font-size: 0.83rem;
    line-height: 1.45;
    position: relative;
    word-break: break-word;
}

.ai-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: #ffffff;
    padding: 10px 14px;
    border-radius: 16px 16px 2px 16px;
    box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25);
}

.ai-msg-assistant {
    align-self: flex-start;
    background: #ffffff;
    color: #1e293b;
    padding: 12px 14px;
    border-radius: 16px 16px 16px 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
}

.ai-msg-assistant h3, .ai-msg-assistant h4 {
    font-size: 0.88rem;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 6px;
    color: #0f172a;
}

.ai-msg-assistant p {
    margin-bottom: 6px;
}
.ai-msg-assistant p:last-child {
    margin-bottom: 0;
}

.ai-msg-assistant blockquote {
    margin: 8px 0;
    padding: 8px 12px;
    background: #fffbeb;
    border-left: 3px solid #f59e0b;
    border-radius: 4px;
    color: #92400e;
    font-size: 0.78rem;
}

/* Steps list card */
.ai-step-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px 10px;
    margin: 8px 0;
    font-size: 0.78rem;
}
.ai-step-item {
    display: flex;
    gap: 6px;
    margin-bottom: 4px;
}
.ai-step-item:last-child {
    margin-bottom: 0;
}
.ai-step-num {
    font-weight: 700;
    color: #4f46e5;
    min-width: 18px;
}

/* Action button inside message */
.ai-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
    color: #ffffff !important;
    text-decoration: none !important;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 8px;
    box-shadow: 0 2px 5px rgba(79, 70, 229, 0.3);
    transition: transform 0.15s, box-shadow 0.15s;
}
.ai-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.4);
}

.ai-provider-badge {
    display: inline-block;
    font-size: 0.62rem;
    color: #94a3b8;
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

/* Typing indicator */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 16px 16px 16px 2px;
    align-self: flex-start;
    border: 1px solid #e2e8f0;
    width: fit-content;
}
.ai-typing-dot {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aiPulse 1.2s infinite ease-in-out;
}
.ai-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiPulse {
    0%, 100% { transform: scale(0.8); opacity: 0.4; }
    50% { transform: scale(1.2); opacity: 1; }
}

/* Footer & Input Box */
.ai-widget-footer {
    padding: 8px 12px 10px 12px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
}

.ai-widget-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 6px;
    gap: 6px;
}

.ai-page-info-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    padding: 3px 9px;
    border-radius: 14px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.ai-page-info-btn:hover {
    background: #e0e7ff;
    border-color: #6366f1;
    color: #4338ca;
    transform: translateY(-1px);
}

.ai-page-info-btn i {
    font-size: 0.72rem;
    color: #4f46e5;
}

.ai-widget-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 24px;
    padding: 4px 6px 4px 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-widget-form:focus-within {
    border-color: #4f46e5;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
    background: #ffffff;
}

.ai-widget-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    background: transparent;
    font-size: 0.84rem;
    color: #1e293b;
    padding: 6px 0;
}

.ai-widget-send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: transform 0.15s;
}
.ai-widget-send-btn:hover {
    transform: scale(1.06);
}
