:root {
    --gpi-primary: #0f2b46;
    --gpi-primary-dark: #0a1c2e;
    --gpi-primary-light: #18426b;
    --gpi-accent: #a3191e;
    --gpi-accent-hover: #b89628;
    --gpi-gold-gradient: linear-gradient(135deg, #d4af37 0%, #f3e5ab 50%, #b89628 100%);
    --gpi-bg-dark: #0c1622;
    --gpi-surface: #ffffff;
    --gpi-surface-alt: #f4f7fa;
    --gpi-text-main: #1e293b;
    --gpi-text-muted: #64748b;
    --gpi-border: #e2e8f0;
    --gpi-shadow-lg: 0 20px 40px -15px rgba(15, 43, 70, 0.25), 0 0 15px rgba(0, 0, 0, 0.05);
    --gpi-shadow-sm: 0 4px 12px rgba(15, 43, 70, 0.08);
    --gpi-radius: 16px;
    --gpi-font: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

/* ==========================================================================
   Widget Container & Trigger Button
   ========================================================================== */
#gpi-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: var(--gpi-font);
    font-size: 14px;
    line-height: 1.5;
    box-sizing: border-box;
}

    #gpi-chat-widget * {
        box-sizing: border-box;
    }

/* ==========================================================================
   GPI Bot Floating Widget & Animated Launcher
   ========================================================================== */
#gpi-bot-widget {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    user-select: none;
}

.gpi-circle,
.gpi-launcher-btn {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #18426b 0%, #0c2033 70%, #051321 100%);
    border: 2.5px solid #a3191e;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(15, 43, 70, 0.4), 0 0 12px rgba(212, 175, 55, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    outline: none;
    padding: 0;
}

    .gpi-circle:hover,
    .gpi-launcher-btn:hover {
        transform: scale(1.08) translateY(-3px);
        box-shadow: 0 14px 30px rgba(15, 43, 70, 0.5), 0 0 20px rgba(212, 175, 55, 0.45);
    }

    .gpi-circle svg.gpi-bot-svg {
        width: 52px;
        height: 52px;
        display: block;
        transition: transform 0.3s ease, opacity 0.3s ease;
    }

    .gpi-circle svg.icon-close,
    .gpi-launcher-btn svg.icon-close {
        display: none;
        width: 26px;
        height: 26px;
        color: #ffffff;
        transition: transform 0.3s ease;
    }

    .gpi-circle.active,
    .gpi-launcher-btn.active {
        background: #a3191e;
        border-color: #ffffff;
    }

        .gpi-circle.active svg.gpi-bot-svg {
            display: none;
        }

        .gpi-circle.active svg.icon-close,
        .gpi-launcher-btn.active svg.icon-close {
            display: block;
        }

/* Robot Floating Animation */
@keyframes botFloat {
    0%, 100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.bot-float {
    animation: botFloat 3s ease-in-out infinite;
    transform-origin: center;
}

/* Waving Right Arm Animation */
@keyframes rightArmWave {
    0%, 100% {
        transform: rotate(0deg);
    }

    20% {
        transform: rotate(-18deg);
    }

    40% {
        transform: rotate(10deg);
    }

    60% {
        transform: rotate(-14deg);
    }

    80% {
        transform: rotate(6deg);
    }
}

.right-arm-wave {
    animation: rightArmWave 2.2s ease-in-out infinite;
    transform-origin: 138px 145px;
}

/* Antenna Cyan Glow Pulse */
@keyframes antennaPulse {
    0%, 100% {
        opacity: 0.85;
        filter: drop-shadow(0 0 2px #00e5ff);
    }

    50% {
        opacity: 1;
        filter: drop-shadow(0 0 8px #00e5ff) drop-shadow(0 0 14px #00e5ff);
    }
}

.antenna-pulse {
    animation: antennaPulse 1.8s infinite ease-in-out;
}

/* Robot Blinking Eyes Animation */
@keyframes botBlink {
    0%, 94%, 98%, 100% {
        transform: scaleY(1);
    }

    96% {
        transform: scaleY(0.12);
    }
}

.bot-eyes {
    animation: botBlink 4.5s infinite;
    transform-origin: 100px 80px;
}

/* Pulse animation on launcher */
.gpi-pulse-ring {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid #a3191e;
    animation: gpi-pulse 2.5s infinite;
    pointer-events: none;
    opacity: 0.6;
}

@keyframes gpi-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    70% {
        transform: scale(1.25);
        opacity: 0;
    }

    100% {
        transform: scale(1.25);
        opacity: 0;
    }
}

/* ==========================================================================
   Floating Welcome Message / Tooltip
   ========================================================================== */
.gpi-tooltip {
    position: absolute;
    right: 80px;
    bottom: 10px;
    background: #ffffff;
    color: #0f2b46;
    border: 1.5px solid #a3191e;
    border-radius: 16px;
    padding: 10px 14px;
    box-shadow: 0 10px 28px rgba(15, 43, 70, 0.22);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    cursor: pointer;
    z-index: 999998;
    opacity: 0;
    transform: translateX(14px) scale(0.92);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    animation: gpi-tooltip-intro 0.6s 1.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes gpi-tooltip-intro {
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
        pointer-events: auto;
    }
}

.gpi-tooltip:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(15, 43, 70, 0.3);
}

.gpi-tooltip.hidden {
    opacity: 0 !important;
    transform: translateX(15px) scale(0.85) !important;
    pointer-events: none !important;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Tooltip Arrow pointing to robot */
.gpi-tooltip::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 7px solid transparent;
    border-bottom: 7px solid transparent;
    border-left: 8px solid #ffffff;
}

.gpi-tooltip::before {
    content: '';
    position: absolute;
    right: -10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 9px solid #a3191e;
}

.gpi-tooltip-content {
    display: flex;
    align-items: center;
    gap: 9px;
}

.gpi-tooltip-wave {
    font-size: 20px;
    animation: gpi-hand-wave 2s infinite ease-in-out;
    transform-origin: 70% 70%;
    display: inline-block;
}

@keyframes gpi-hand-wave {
    0%, 100% {
        transform: rotate(0deg);
    }

    20%, 60% {
        transform: rotate(14deg);
    }

    40%, 80% {
        transform: rotate(-10deg);
    }
}

.gpi-tooltip-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.gpi-tooltip-title {
    font-size: 11px;
    font-weight: 800;
    color: #a3191e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gpi-tooltip-msg {
    font-size: 13px;
    font-weight: 600;
    color: #0f2b46;
}

.gpi-tooltip-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    padding: 2px 5px;
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.15s, background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 2px;
}

    .gpi-tooltip-close:hover {
        color: #0f2b46;
        background: #f1f5f9;
    }

#gpi-bot-widget.active .gpi-tooltip {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ==========================================================================
   Chat Window
   ========================================================================== */
.gpi-chat-window {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 410px;
    height: 630px;
    max-width: calc(100vw - 32px);
    max-height: calc(100vh - 110px);
    background: var(--gpi-surface);
    border-radius: var(--gpi-radius);
    box-shadow: var(--gpi-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(15, 43, 70, 0.12);
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

    .gpi-chat-window.open {
        opacity: 1;
        transform: translateY(0) scale(1);
        pointer-events: auto;
    }

/* Header */
.gpi-header {
    background: #052437;
    color: #ffffff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--gpi-accent);
}

.gpi-header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.gpi-header-logo {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #ffffff;
    padding: 4px;
    object-fit: contain;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.gpi-header-titles {
    display: flex;
    flex-direction: column;
}

.gpi-header-title {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: #ffffff;
}

.gpi-header-subtitle {
    font-size: 11.5px;
    color: #cbd5e1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gpi-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
}

.gpi-header-actions {
    display: flex;
    gap: 8px;
}

.gpi-btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #ffffff;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

    .gpi-btn-icon:hover {
        background: rgba(255, 255, 255, 0.22);
    }

/* Messages Body */
.gpi-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--gpi-surface-alt);
    scroll-behavior: smooth;
}

.gpi-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    word-break: break-word;
    animation: gpi-fade-in 0.25s ease-out;
}

@keyframes gpi-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gpi-msg.user {
    align-self: flex-end;
}

.gpi-msg.bot {
    align-self: flex-start;
}

.gpi-bubble {
    padding: 12px 15px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    box-shadow: var(--gpi-shadow-sm);
}

.gpi-msg.user .gpi-bubble {
    background: linear-gradient(135deg, var(--gpi-primary) 0%, var(--gpi-primary-light) 100%);
    color: #ffffff;
    border-bottom-right-radius: 3px;
}

.gpi-msg.bot .gpi-bubble {
    background: #ffffff;
    color: var(--gpi-text-main);
    border: 1px solid var(--gpi-border);
    border-bottom-left-radius: 3px;
}

.gpi-bubble a {
    color: var(--gpi-primary-light);
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: color 0.2s;
}

    .gpi-bubble a:hover {
        color: var(--gpi-accent);
    }

.gpi-bubble ul {
    padding-left: 18px;
    margin: 8px 0;
}

.gpi-bubble li {
    margin-bottom: 4px;
}

.gpi-msg.bot.rtl .gpi-bubble {
    direction: rtl;
    text-align: right;
    border-bottom-left-radius: 14px;
    border-bottom-right-radius: 3px;
}

.gpi-img-wrap {
    margin: 10px 0;
    display: block;
}

    .gpi-bubble img,
    .gpi-msg-img,
    .gpi-img-wrap img {
        max-width: 100% !important;
        width: 100% !important;
        height: auto !important;
        max-height: 220px !important;
        border-radius: 8px;
        border: 1px solid var(--gpi-border);
        object-fit: contain !important;
        background: #f1f5f9;
        display: block;
        margin: 10px 0;
        box-sizing: border-box;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        cursor: pointer;
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

        .gpi-bubble img:hover,
        .gpi-msg-img:hover,
        .gpi-img-wrap img:hover {
            transform: scale(1.02);
            box-shadow: 0 4px 14px rgba(0, 0, 0, 0.15);
        }

.gpi-msg.user.rtl .gpi-bubble {
    direction: rtl;
    text-align: right;
}

/* Typing Indicator */
.gpi-typing {
    display: flex;
    gap: 5px;
    padding: 10px 14px;
    background: #ffffff;
    border-radius: 14px;
    width: fit-content;
    border: 1px solid var(--gpi-border);
    box-shadow: var(--gpi-shadow-sm);
}

    .gpi-typing span {
        width: 7px;
        height: 7px;
        background: var(--gpi-primary-light);
        border-radius: 50%;
        animation: gpi-typing-bounce 1.4s infinite ease-in-out both;
    }

        .gpi-typing span:nth-child(1) {
            animation-delay: -0.32s;
        }

        .gpi-typing span:nth-child(2) {
            animation-delay: -0.16s;
        }

@keyframes gpi-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   Product Cards in Chat
   ========================================================================== */
.gpi-products-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
    width: 100%;
}

.gpi-product-card {
    background: #ffffff;
    border-radius: 12px;
    border: 1px solid var(--gpi-border);
    padding: 12px;
    display: flex;
    gap: 12px;
    align-items: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}

    .gpi-product-card:hover {
        border-color: var(--gpi-accent);
        box-shadow: 0 4px 12px rgba(15, 43, 70, 0.08);
        transform: translateY(-1px);
    }

.gpi-prod-thumb {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    background: #f8fafc;
    object-fit: contain;
    padding: 4px;
    border: 1px solid #edf2f7;
    flex-shrink: 0;
}

.gpi-prod-info {
    flex: 1;
    min-width: 0;
}

.gpi-prod-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--gpi-primary);
    margin-bottom: 4px;
    line-height: 1.35;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.gpi-prod-specs {
    font-size: 11.5px;
    color: var(--gpi-text-muted);
    margin-bottom: 6px;
    line-height: 1.3;
}

.gpi-prod-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.gpi-btn-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--gpi-primary);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 5px;
    background: #f1f5f9;
    transition: all 0.15s;
}

    .gpi-btn-link:hover {
        background: var(--gpi-primary);
        color: #ffffff;
    }

.gpi-btn-pdf {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: #991b1b;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 5px;
    background: #fef2f2;
    border: 1px solid #fee2e2;
    transition: all 0.15s;
}

    .gpi-btn-pdf:hover {
        background: #dc2626;
        color: #ffffff;
    }

/* ==========================================================================
   Suggestion Chips
   ========================================================================== */
.gpi-suggestions {
    display: flex;
    flex-wrap: nowrap;
    flex-shrink: 0;
    gap: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 14px 8px;
    background: var(--gpi-surface);
    border-top: 1px solid var(--gpi-border);
    cursor: grab;
    touch-action: pan-x;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: auto;
    /* Thin scrollbar on desktop so users can see it scrolls */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

    .gpi-suggestions.is-dragging {
        cursor: grabbing;
        user-select: none;
    }

    .gpi-suggestions::-webkit-scrollbar {
        height: 4px;
    }

    .gpi-suggestions::-webkit-scrollbar-track {
        background: transparent;
    }

    .gpi-suggestions::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }

        .gpi-suggestions::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }

.gpi-chip {
    flex: 0 0 auto; /* never shrink or wrap: keeps chips in one scrollable row */
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: var(--gpi-primary);
    font-size: 11.5px;
    font-weight: 500;
    padding: 5px 11px;
    border-radius: 100px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

    .gpi-chip:hover {
        background: var(--gpi-primary);
        color: #ffffff;
        border-color: var(--gpi-primary);
    }

/* ==========================================================================
   Input Area
   ========================================================================== */
.gpi-input-area {
    padding: 12px 14px;
    background: var(--gpi-surface);
    border-top: 1px solid var(--gpi-border);
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.gpi-textarea {
    flex: 1;
    border: 1px solid var(--gpi-border);
    border-radius: 10px;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 13.5px;
    line-height: 1.4;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
    color: var(--gpi-text-main);
    background: #ffffff;
}

    .gpi-textarea:focus {
        border-color: var(--gpi-primary-light);
        box-shadow: 0 0 0 3px rgba(15, 43, 70, 0.08);
    }

.gpi-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #052437;
    border: none;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}

    .gpi-send-btn:hover {
        background: var(--gpi-primary-dark);
        transform: translateY(-1px);
    }

    .gpi-send-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        transform: none;
    }

/* ==========================================================================
   Responsive & Mobile Design System
   ========================================================================== */

/* Prevent background page scrolling when widget is open on mobile */
body.gpi-widget-open {
    overflow: hidden !important;
    touch-action: none;
}

/* Tablets Portrait & Small Laptops (769px to 960px) */
@media (max-width: 960px) and (min-width: 769px) {
    .gpi-chat-window {
        width: 380px;
        height: 580px;
        max-height: calc(100dvh - 96px);
    }
}

/* Mobile Devices & Tablets (max-width: 768px), or Landscape Phones (max-height: 520px) */
@media (max-width: 768px), (max-height: 520px) {
    #gpi-chat-widget {
        bottom: 16px;
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        right: calc(16px + env(safe-area-inset-right, 0px));
    }

        /* When open on mobile, container spans entire viewport */
        #gpi-chat-widget:has(.gpi-chat-window.open),
        body.gpi-widget-open #gpi-chat-widget {
            top: 0 !important;
            left: 0 !important;
            right: 0 !important;
            bottom: 0 !important;
            width: 100vw !important;
            height: 100% !important;
            pointer-events: none;
        }

    .gpi-circle,
    .gpi-launcher-btn {
        width: 60px;
        height: 60px;
        box-shadow: 0 6px 18px rgba(15, 43, 70, 0.35);
    }

        .gpi-circle svg.gpi-bot-svg {
            width: 46px;
            height: 46px;
        }

        .gpi-circle svg.icon-close,
        .gpi-launcher-btn svg.icon-close {
            width: 24px;
            height: 24px;
        }

        /* When open on mobile, hide floating launcher button so full screen belongs to chat */
        .gpi-circle.active,
        .gpi-launcher-btn.active,
        #gpi-bot-widget.active {
            display: none !important;
        }

    .gpi-tooltip {
        right: 70px;
        bottom: 6px;
        padding: 8px 11px;
/*        max-width: calc(100vw - 92px);*/
        width:350%;
        border-radius: 14px;
    }

    .gpi-tooltip-msg {
        font-size: 12px;
        white-space: normal;
    }

    /* Full screen modal takeover with native app slide-up */
    .gpi-chat-window {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        width: 100vw !important;
        height: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-width: 100vw !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        transform: translateY(100%) !important;
        opacity: 0;
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease !important;
        z-index: 1000000;
    }

        .gpi-chat-window.open {
            transform: translateY(0) !important;
            opacity: 1 !important;
            pointer-events: auto !important;
        }

    /* Safe-area insets & mobile header */
    .gpi-header {
        padding: max(14px, env(safe-area-inset-top, 0px)) 16px 14px 16px;
        min-height: calc(56px + env(safe-area-inset-top, 0px));
    }

    .gpi-header-logo {
        width: 32px;
        height: 32px;
    }

    .gpi-header-title {
        font-size: 14.5px;
    }

    .gpi-header-subtitle {
        font-size: 11px;
    }

    .gpi-btn-icon {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }

    /* Messages Area on Mobile */
    .gpi-messages {
        padding: 14px 12px;
        gap: 12px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .gpi-msg {
        max-width: 90%;
    }

    .gpi-bubble {
        padding: 10px 13px;
        font-size: 14px;
        line-height: 1.5;
    }

    .gpi-img-wrap {
        margin: 6px 0;
    }

    .gpi-msg-img,
    .gpi-bubble img {
        max-height: 180px !important;
    }

    /* Mobile Suggestions Strip */
    .gpi-suggestions {
        padding: 8px 12px;
        gap: 7px;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scroll-padding-left: 12px;
        scrollbar-width: none; /* hide scrollbar on touch devices */
        cursor: default;
    }

        .gpi-suggestions::-webkit-scrollbar {
            display: none;
        }

    .gpi-chip {
        flex: 0 0 auto;
        font-size: 12px;
        padding: 8px 14px; /* larger tap target */
        min-height: 34px;
    }

    /* Mobile Input Area with Safe Area Padding */
    .gpi-input-area {
        padding: 10px 12px max(12px, env(safe-area-inset-bottom, 0px)) 12px;
        gap: 8px;
    }

    .gpi-textarea {
        font-size: 16px !important; /* CRITICAL: prevents iOS Safari from automatically zooming into the page on focus */
        padding: 9px 12px;
        min-height: 56px;
        max-height: 85px;
        border-radius: 10px;
    }

    .gpi-send-btn {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }

    /* Product cards compact mobile layout */
    .gpi-product-card {
        padding: 10px;
        gap: 10px;
    }

    .gpi-prod-thumb {
        width: 52px;
        height: 52px;
    }

    .gpi-prod-title {
        font-size: 13px;
    }

    .gpi-prod-specs {
        font-size: 11.5px;
    }

    .gpi-prod-actions {
        flex-wrap: wrap;
        gap: 6px;
    }

    .gpi-btn-link, .gpi-btn-pdf {
        font-size: 11px;
        padding: 5px 9px;
    }
}

/* Extra small devices (iPhone SE, Galaxy A series, narrow phones <= 360px) */
@media (max-width: 360px) {
    .gpi-msg {
        max-width: 94%;
    }

    .gpi-header-titles {
        max-width: 170px;
    }

    .gpi-header-title {
        font-size: 13.5px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ==========================================================================
   Bubble spacing normalization (removes extra gaps in bot responses)
   Keep this block LAST in the file.
   ========================================================================== */
#gpi-chat-widget .gpi-bubble {
    white-space: normal;
}

    #gpi-chat-widget .gpi-bubble > *:first-child {
        margin-top: 0 !important;
    }

    #gpi-chat-widget .gpi-bubble > *:last-child {
        margin-bottom: 0 !important;
    }

    #gpi-chat-widget .gpi-bubble p {
        margin: 0 0 8px;
    }

    #gpi-chat-widget .gpi-bubble h1,
    #gpi-chat-widget .gpi-bubble h2,
    #gpi-chat-widget .gpi-bubble h3,
    #gpi-chat-widget .gpi-bubble h4,
    #gpi-chat-widget .gpi-bubble h5,
    #gpi-chat-widget .gpi-bubble h6 {
        margin: 10px 0 4px;
        font-size: 14.5px;
        line-height: 1.35;
        color: var(--gpi-primary);
    }

    #gpi-chat-widget .gpi-bubble ul,
    #gpi-chat-widget .gpi-bubble ol {
        margin: 4px 0 8px;
        padding-left: 18px;
        padding-right: 0;
    }

    #gpi-chat-widget .gpi-bubble li {
        margin: 0 0 2px;
    }

        #gpi-chat-widget .gpi-bubble li > p {
            margin: 0;
        }

        #gpi-chat-widget .gpi-bubble li > ul,
        #gpi-chat-widget .gpi-bubble li > ol {
            margin: 2px 0;
        }

    #gpi-chat-widget .gpi-bubble hr {
        border: none;
        border-top: 1px solid var(--gpi-border);
        margin: 8px 0;
    }

    #gpi-chat-widget .gpi-bubble blockquote,
    #gpi-chat-widget .gpi-bubble pre,
    #gpi-chat-widget .gpi-bubble table {
        margin: 6px 0;
    }

/* RTL lists */
#gpi-chat-widget .gpi-msg.rtl .gpi-bubble ul,
#gpi-chat-widget .gpi-msg.rtl .gpi-bubble ol {
    padding-left: 0;
    padding-right: 18px;
}

/* Images: stop double margins (wrapper + img) */
#gpi-chat-widget .gpi-img-wrap {
    margin: 6px 0;
}

    #gpi-chat-widget .gpi-img-wrap img,
    #gpi-chat-widget .gpi-bubble img {
        margin: 6px 0 !important;
    }

    #gpi-chat-widget .gpi-img-wrap > img {
        margin: 0 !important;
    }

#gpi-chat-widget .gpi-bubble p > img:only-child {
    margin: 4px 0 !important;
}

/* Stray <br> right after/before blocks */
#gpi-chat-widget .gpi-bubble br:first-child,
#gpi-chat-widget .gpi-bubble br:last-child {
    display: none;
}

/* ==========================================================================
   Touch devices: native swipe scrolling for suggestion chips
   ========================================================================== */
.gpi-suggestions::after {
    content: '';
    flex: 0 0 1px; /* keeps right padding visible at the end of the scroll */
}

@media (hover: none), (pointer: coarse) {
    .gpi-suggestions {
        cursor: default;
        scrollbar-width: none;
        touch-action: pan-x;
    }

        .gpi-suggestions::-webkit-scrollbar {
            display: none;
        }

    .gpi-messages {
        touch-action: pan-y;
    }

    .gpi-chip:hover {
        background: #f1f5f9;
        color: var(--gpi-primary);
        border-color: #e2e8f0;
    }

    .gpi-chip:active {
        background: var(--gpi-primary);
        color: #ffffff;
        border-color: var(--gpi-primary);
    }
}

/* ==========================================================================
   Chat content: mobile responsiveness (messages, bubbles, cards, tables)
   Keep this block LAST in the file.
   ========================================================================== */

/* Flex children must be allowed to shrink, otherwise the messages area
   pushes the input off-screen and long content causes horizontal overflow */
#gpi-chat-widget .gpi-chat-window,
#gpi-chat-widget .gpi-messages,
#gpi-chat-widget .gpi-msg,
#gpi-chat-widget .gpi-bubble {
    min-width: 0;
}

#gpi-chat-widget .gpi-messages {
    min-height: 0;
    overflow-x: hidden;
}

/* Long words, URLs and emails must wrap instead of stretching the bubble */
#gpi-chat-widget .gpi-bubble {
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}

    #gpi-chat-widget .gpi-bubble a {
        overflow-wrap: anywhere;
    }

    /* Wide content scrolls inside the bubble instead of breaking the layout */
    #gpi-chat-widget .gpi-bubble pre {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        background: #f1f5f9;
        padding: 8px 10px;
        border-radius: 8px;
        font-size: 12.5px;
    }

    #gpi-chat-widget .gpi-bubble code {
        font-size: 12.5px;
        overflow-wrap: anywhere;
    }

    #gpi-chat-widget .gpi-bubble pre code {
        overflow-wrap: normal;
        white-space: pre;
    }

    #gpi-chat-widget .gpi-bubble table {
        display: block;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border-collapse: collapse;
        font-size: 12.5px;
    }

    #gpi-chat-widget .gpi-bubble th,
    #gpi-chat-widget .gpi-bubble td {
        border: 1px solid var(--gpi-border);
        padding: 5px 8px;
        white-space: nowrap;
        text-align: start;
    }

    #gpi-chat-widget .gpi-bubble th {
        background: #f1f5f9;
        color: var(--gpi-primary);
    }

/* Product cards: keep inside the bubble width */
#gpi-chat-widget .gpi-products-grid,
#gpi-chat-widget .gpi-product-card {
    max-width: 100%;
    min-width: 0;
}

#gpi-chat-widget .gpi-msg.bot {
    min-width: 0;
}

    /* Arabic (RTL) bot messages: cards and actions follow reading direction */
    #gpi-chat-widget .gpi-msg.bot.rtl .gpi-product-card {
        direction: rtl;
    }

@media (max-width: 768px), (max-height: 520px) {
    /* Use the real visible height (handles mobile browser toolbars / keyboard) */
    #gpi-chat-widget .gpi-chat-window {
        height: var(--gpi-vh, 100dvh) !important;
        max-height: var(--gpi-vh, 100dvh) !important;
    }

    /* Messages use more of the screen width on phones */
    #gpi-chat-widget .gpi-msg {
        max-width: 92%;
    }

        #gpi-chat-widget .gpi-msg.bot:has(.gpi-products-grid) {
            width: 92%;
        }

    #gpi-chat-widget .gpi-bubble {
        font-size: 14px;
        line-height: 1.5;
    }

        /* Images fit the bubble */
        #gpi-chat-widget .gpi-img-wrap img,
        #gpi-chat-widget .gpi-bubble img {
            max-height: 200px !important;
        }

    /* Product cards: allow the title to wrap, shrink thumbnail */
    #gpi-chat-widget .gpi-prod-title {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    #gpi-chat-widget .gpi-prod-actions {
        gap: 6px;
    }

    #gpi-chat-widget .gpi-btn-link,
    #gpi-chat-widget .gpi-btn-pdf {
        min-height: 32px;
    }

    /* Tooltip should never overflow the viewport */
    #gpi-chat-widget .gpi-tooltip {
        white-space: normal;
        max-width: calc(100vw - 100px);
    }
}

/* Very narrow phones: stack the product card vertically */
@media (max-width: 400px) {
    #gpi-chat-widget .gpi-product-card {
        flex-direction: column;
        align-items: stretch;
        text-align: start;
    }

    #gpi-chat-widget .gpi-prod-thumb {
        width: 100%;
        height: 110px;
    }

    #gpi-chat-widget .gpi-prod-actions {
        flex-direction: column;
    }

    #gpi-chat-widget .gpi-btn-link,
    #gpi-chat-widget .gpi-btn-pdf {
        justify-content: center;
        width: 100%;
    }

    #gpi-chat-widget .gpi-header-subtitle {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 190px;
    }
}
