/* ==========================================================================
   Jerry Pet Hub — AI Sales Assistant Chat Widget
   Version: 5.0.0
   Design: "Premium Digital Concierge" — Glassmorphism + Feline Personality
   Direction: RTL (Hebrew)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS
   -------------------------------------------------------------------------- */

:root {
    --jerry-primary: #7c3aed;
    --jerry-primary-light: #a78bfa;
    --jerry-primary-dark: #5b21b6;
    --jerry-gradient: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
    --jerry-gradient-header: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    --jerry-accent: #10b981;
    --jerry-bg-glass: rgba(255, 255, 255, 0.88);
    --jerry-surface: #f8f7fc;
    --jerry-text: #1f2937;
    --jerry-text-muted: #6b7280;
    --jerry-font: 'Assistant', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --jerry-z-fab: 10000001;
    --jerry-z-backdrop: 10000000;
    --jerry-z-panel: 10000002;
    --jerry-mobile-bottom: calc(85px + env(safe-area-inset-bottom, 0px));
    --jerry-desktop-bottom: 24px;
    --jerry-shadow-premium: 0 10px 40px -10px rgba(124, 58, 237, 0.25), 0 0 2px rgba(0, 0, 0, 0.08);
    --jerry-shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.03);
    --jerry-radius-panel: 24px;
    --jerry-radius-bubble: 20px;
    --jerry-radius-card: 16px;
    --jerry-radius-pill: 24px;
    --jerry-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
    --jerry-ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   2. ANIMATIONS
   -------------------------------------------------------------------------- */

@keyframes jerry-slide-up {
    0% {
        transform: translateY(100%);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes jerry-pop-in {
    0% {
        transform: scale(0.85) translateY(20px);
    }
    100% {
        transform: scale(1) translateY(0);
    }
}

@keyframes jerry-pulse-ring {
    0% {
        box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.5);
    }
    70% {
        box-shadow: 0 0 0 12px rgba(124, 58, 237, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(124, 58, 237, 0);
    }
}

@keyframes jerry-shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@keyframes jerry-bounce-dots {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-6px);
    }
}

@keyframes jerry-fade-in {
    0% {
        opacity: 0;
        transform: translateY(8px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes jerry-pounce {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(0.85);
    }
    60% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes jerry-avatar-think {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(124, 58, 237, 0);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(124, 58, 237, 0.35);
    }
}

@keyframes jerry-status-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.4;
    }
}

@keyframes jerry-fade-backdrop {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@keyframes jerry-callout-in {
    0% {
        opacity: 0;
        transform: translateY(8px) scale(0.92);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --------------------------------------------------------------------------
   3. WIDGET ROOT & BODY LOCK
   -------------------------------------------------------------------------- */

body.jerry-chat-active {
    overflow: hidden !important;
    overscroll-behavior: none;
    position: fixed;
    width: 100%;
}

.jph-chat-widget {
    font-family: var(--jerry-font);
    direction: rtl;
    text-align: right;
    line-height: 1.5;
    color: var(--jerry-text);
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.jph-chat-widget *,
.jph-chat-widget *::before,
.jph-chat-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* --------------------------------------------------------------------------
   4. FAB (Floating Action Button) — Toggle
   -------------------------------------------------------------------------- */

.jph-chat-toggle {
    position: fixed;
    bottom: var(--jerry-desktop-bottom);
    right: 24px;
    z-index: var(--jerry-z-fab);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--jerry-gradient);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--jerry-shadow-premium);
    transition: transform 0.3s var(--jerry-spring), box-shadow 0.3s ease;
    animation: jerry-pulse-ring 3s ease-out infinite;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.jph-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 14px 48px -8px rgba(124, 58, 237, 0.35), 0 0 2px rgba(0, 0, 0, 0.1);
}

.jph-chat-toggle:active {
    transform: scale(0.95);
}

.jph-chat-toggle:focus-visible {
    outline: 3px solid var(--jerry-primary-light);
    outline-offset: 3px;
}

.jph-chat-toggle-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    line-height: 0;
    transition: transform 0.3s var(--jerry-spring), opacity 0.25s ease;
}

.jph-chat-icon-open svg {
    width: 32px;
    height: 32px;
}

.jph-chat-icon-close svg {
    width: 24px;
    height: 24px;
}

.jph-chat-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.jph-chat-icon-open {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* When panel is open */
.jph-chat-open .jph-chat-toggle .jph-chat-icon-open {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.jph-chat-open .jph-chat-toggle .jph-chat-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Open state: stop pulse */
.jph-chat-open .jph-chat-toggle {
    animation: none;
}

/* --------------------------------------------------------------------------
   5. CALLOUT TOOLTIP
   -------------------------------------------------------------------------- */

.jph-chat-callout {
    position: fixed;
    bottom: calc(var(--jerry-desktop-bottom) + 70px);
    right: 24px;
    z-index: var(--jerry-z-fab);
    background: #fff;
    color: var(--jerry-text);
    padding: 10px 16px;
    border-radius: 14px;
    font-size: 0.88em;
    font-weight: 600;
    box-shadow: var(--jerry-shadow-card);
    max-width: 220px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px) scale(0.92);
    transition: opacity 0.3s ease, transform 0.3s var(--jerry-spring);
    white-space: nowrap;
}

.jph-chat-callout::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 22px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.04);
}

.jph-callout-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    animation: jerry-callout-in 0.4s var(--jerry-spring) forwards;
}

/* Hide callout when panel is open */
.jph-chat-open .jph-chat-callout {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* --------------------------------------------------------------------------
   6. BACKDROP (Mobile)
   -------------------------------------------------------------------------- */

.jph-chat-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--jerry-z-backdrop);
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}

.jph-backdrop-visible {
    opacity: 1;
    pointer-events: auto;
    animation: jerry-fade-backdrop 0.35s ease forwards;
}

/* --------------------------------------------------------------------------
   7. CHAT PANEL — Desktop (default)
   -------------------------------------------------------------------------- */

.jph-chat-panel {
    position: fixed;
    bottom: var(--jerry-desktop-bottom);
    right: 24px;
    z-index: var(--jerry-z-panel);
    width: min(400px, calc(100vw - 48px));
    max-height: calc(100vh - 100px);
    min-height: min(600px, calc(100vh - 100px));
    background: var(--jerry-bg-glass);
    backdrop-filter: blur(16px) saturate(1.6);
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    border-radius: var(--jerry-radius-panel);
    box-shadow: var(--jerry-shadow-premium);
    border: 1px solid rgba(255, 255, 255, 0.5);
    display: none;
    flex-direction: column;
    overflow: hidden;
    direction: rtl;
    transform-origin: bottom right;
}

.jph-chat-open .jph-chat-panel {
    display: flex;
    opacity: 1;
    animation: jerry-pop-in 0.4s var(--jerry-spring) both;
}

/* Safety net: if body lock is active, panel MUST be visible */
body.jerry-chat-active .jph-chat-panel {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* --------------------------------------------------------------------------
   8. HEADER
   -------------------------------------------------------------------------- */

.jph-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--jerry-gradient-header);
    color: #fff;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
}

.jph-chat-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: box-shadow 0.4s ease;
}

/* Green online status dot on avatar */
.jph-chat-header-info {
    position: relative;
    flex: 1;
    min-width: 0;
}

.jph-chat-header-info::before {
    content: '';
    position: absolute;
    top: 4px;
    right: -30px;
    width: 10px;
    height: 10px;
    background: var(--jerry-accent);
    border-radius: 50%;
    border: 2px solid rgba(91, 33, 182, 0.8);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
    animation: jerry-status-pulse 2.5s ease-in-out infinite;
}

.jph-chat-header-name-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.jph-chat-header-name {
    font-size: 1.05em;
    font-weight: 800;
    letter-spacing: 0.01em;
    line-height: 1.3;
}

.jph-chat-ai-badge,
.jph-chat-ai-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.95);
    font-size: 9px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    letter-spacing: 0.03em;
    line-height: 1;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.jph-chat-header-status {
    font-size: 0.78em;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 1px;
}

.jph-chat-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--jerry-accent);
    display: inline-block;
    flex-shrink: 0;
}

/* Header buttons — unified size for +, X, back */
.jph-chat-header-btn,
.jph-chat-back {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

#jph-chat-new-conv {
    margin-inline-start: auto;
}

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

.jph-chat-header-btn:active,
.jph-chat-back:active {
    transform: scale(0.92);
}

.jph-chat-header-btn:focus-visible,
.jph-chat-back:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 2px;
}

/* Back button (RTL arrow) */
.jph-chat-back {
    margin-inline-end: 4px;
}

/* Avatar thinking state */
.jph-chat-header.thinking .jph-chat-header-avatar {
    animation: jerry-avatar-think 1.5s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   8b. CONVERSATION LIST VIEW
   -------------------------------------------------------------------------- */

.jph-chat-list-view {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px;
    -webkit-overflow-scrolling: touch;
}

.jph-chat-list-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.jph-chat-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #fff;
    border-radius: 14px;
    cursor: pointer;
    border: 1px solid rgba(0, 0, 0, 0.06);
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.jph-chat-list-item:hover {
    background: var(--jerry-surface);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.jph-chat-list-item:active {
    transform: scale(0.99);
}

.jph-chat-list-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--jerry-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #fff;
}

.jph-chat-list-content {
    flex: 1;
    min-width: 0;
    direction: rtl;
}

.jph-chat-list-preview {
    font-size: 0.88em;
    color: var(--jerry-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.jph-chat-list-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.76em;
    color: var(--jerry-text-muted);
    margin-top: 2px;
}

.jph-chat-list-arrow {
    color: var(--jerry-text-muted);
    flex-shrink: 0;
    opacity: 0.5;
}

.jph-chat-list-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--jerry-text-muted);
    font-size: 0.9em;
}

/* Active view wrapper */
.jph-chat-active-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* --------------------------------------------------------------------------
   9. MESSAGES AREA
   -------------------------------------------------------------------------- */

.jph-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: var(--jerry-surface);
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    min-height: 0;
}

/* Custom scrollbar */
.jph-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.jph-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.jph-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(124, 58, 237, 0.2);
    border-radius: 10px;
}

.jph-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(124, 58, 237, 0.35);
}

/* Firefox scrollbar */
.jph-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 58, 237, 0.2) transparent;
}

/* --------------------------------------------------------------------------
   10. MESSAGE ROWS
   -------------------------------------------------------------------------- */

#jph-chat-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.jph-chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
    animation: jerry-fade-in 0.35s var(--jerry-ease-out) forwards;
}

.jph-chat-msg-user {
    justify-content: flex-start; /* RTL: user messages align to the right (start) */
}

.jph-chat-msg-assistant {
    justify-content: flex-end; /* RTL: assistant messages align to the left (end) */
    flex-direction: row-reverse;
}

/* Small avatar next to assistant messages */
.jph-chat-msg-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    opacity: 0.9;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --------------------------------------------------------------------------
   11. MESSAGE BUBBLES
   -------------------------------------------------------------------------- */

.jph-chat-bubble {
    max-width: 82%;
    padding: 14px 16px;
    font-size: 0.93em;
    line-height: 1.8;
    word-break: break-word;
    overflow-wrap: break-word;
    position: relative;
}

/* User bubble */
.jph-chat-msg-user .jph-chat-bubble {
    background: var(--jerry-gradient);
    color: #fff;
    border-radius: 20px 20px 4px 20px;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.2);
}

.jph-chat-msg-user .jph-chat-bubble a {
    color: rgba(255, 255, 255, 0.95);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Assistant bubble */
.jph-chat-msg-assistant .jph-chat-bubble {
    background: #fff;
    color: var(--jerry-text);
    border-radius: 20px 20px 20px 4px;
    box-shadow: var(--jerry-shadow-card);
    border: 1px solid rgba(0, 0, 0, 0.04);
    white-space: pre-line;
    word-wrap: break-word;
}

.jph-chat-msg-assistant .jph-chat-bubble a {
    color: var(--jerry-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.jph-chat-msg-assistant .jph-chat-bubble a:hover {
    color: var(--jerry-primary-dark);
    text-decoration: underline;
    text-underline-offset: 2px;
}

/* Streaming cursor */
.jph-chat-streaming .jph-chat-bubble::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--jerry-primary);
    margin-inline-start: 3px;
    vertical-align: text-bottom;
    animation: jerry-status-pulse 0.8s ease-in-out infinite;
}

/* Lists in assistant bubbles */
.jph-chat-msg-assistant .jph-chat-bubble ul,
.jph-chat-msg-assistant .jph-chat-bubble ol {
    padding-inline-start: 20px;
    margin: 8px 0;
}

.jph-chat-msg-assistant .jph-chat-bubble li {
    margin-bottom: 6px;
}

.jph-chat-msg-assistant .jph-chat-bubble strong {
    font-weight: 700;
    color: var(--jerry-text);
}

/* --------------------------------------------------------------------------
   12. USER IMAGE IN CHAT
   -------------------------------------------------------------------------- */

.jph-chat-user-image {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--jerry-radius-card);
    object-fit: cover;
    display: block;
    margin-bottom: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* --------------------------------------------------------------------------
   13. QUICK ACTION CHIPS
   -------------------------------------------------------------------------- */

.jph-chat-quick-actions {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    padding: 4px 20px 12px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.jph-chat-quick-actions::-webkit-scrollbar {
    display: none;
}

.jph-chat-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    background: #fff;
    color: var(--jerry-primary);
    border: 1.5px solid var(--jerry-primary-light);
    border-radius: var(--jerry-radius-pill);
    font-family: var(--jerry-font);
    font-size: 0.82em;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.25s var(--jerry-spring);
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.jph-chat-chip:hover {
    background: var(--jerry-primary);
    color: #fff;
    border-color: var(--jerry-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.25);
}

.jph-chat-chip:active {
    transform: translateY(0) scale(0.96);
}

.jph-chat-chip:focus-visible {
    outline: 2px solid var(--jerry-primary);
    outline-offset: 2px;
}

/* Chip icons via pseudo-elements */
.jph-chat-chip:nth-child(1)::before {
    content: '\1F50D'; /* magnifying glass */
    font-size: 0.9em;
}

.jph-chat-chip:nth-child(2)::before {
    content: '\1F381'; /* gift */
    font-size: 0.9em;
}

.jph-chat-chip:nth-child(3)::before {
    content: '\1F431'; /* cat */
    font-size: 0.9em;
}

.jph-chat-chip:nth-child(4)::before {
    content: '\1F436'; /* dog */
    font-size: 0.9em;
}

/* --------------------------------------------------------------------------
   14. PRODUCT CARDS CAROUSEL
   -------------------------------------------------------------------------- */

.jph-chat-products {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 20px 14px;
    scroll-snap-type: x mandatory;
    scroll-padding-inline-start: 20px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.jph-chat-products::-webkit-scrollbar {
    display: none;
}

.jph-chat-product-card {
    flex-shrink: 0;
    width: 160px;
    background: #fff;
    border-radius: var(--jerry-radius-card);
    box-shadow: var(--jerry-shadow-card);
    overflow: hidden;
    scroll-snap-align: start;
    transition: transform 0.3s var(--jerry-spring), box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

.jph-chat-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.1), 0 0 0 1px rgba(124, 58, 237, 0.08);
}

.jph-chat-product-link {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    flex: 1;
}

/* Product image */
.jph-chat-product-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: var(--jerry-surface);
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    padding: 8px;
}

/* No-image placeholder */
.jph-chat-product-noimg {
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--jerry-surface) 0%, #eee 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--jerry-text-muted);
    font-size: 2em;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.jph-chat-product-noimg::after {
    content: '\1F4E6'; /* package emoji */
}

/* Sale badge */
.jph-chat-sale-badge {
    position: absolute;
    top: 8px;
    left: 8px; /* Left for RTL = visual top-right */
    background: #ef4444;
    color: #fff;
    font-size: 0.7em;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 20px;
    line-height: 1.2;
    z-index: 1;
    letter-spacing: 0.02em;
}

/* Product info */
.jph-chat-product-name {
    padding: 10px 12px 4px;
    font-size: 0.8em;
    font-weight: 700;
    line-height: 1.4;
    color: var(--jerry-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.8em;
}

.jph-chat-product-price {
    padding: 0 12px 4px;
    font-size: 0.92em;
    font-weight: 800;
    color: var(--jerry-primary);
    line-height: 1.3;
}

.jph-chat-price-sale {
    color: #ef4444;
    font-weight: 800;
    margin-left: 6px;
}

.jph-chat-price-regular {
    text-decoration: line-through;
    color: var(--jerry-text-muted);
    font-weight: 400;
    font-size: 0.85em;
}

.jph-chat-price-current {
    color: var(--jerry-primary);
    font-weight: 800;
}

/* Star rating */
.jph-chat-product-rating {
    padding: 0 12px 8px;
    font-size: 0.72em;
    color: #f59e0b;
    letter-spacing: 1px;
    line-height: 1;
}

/* Add to Cart button */
.jph-chat-product-atc {
    margin: auto 10px 10px;
    padding: 8px 12px;
    background: transparent;
    color: var(--jerry-primary);
    border: 1.5px solid var(--jerry-primary);
    border-radius: var(--jerry-radius-pill);
    font-family: var(--jerry-font);
    font-size: 0.78em;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    transition: all 0.25s var(--jerry-spring);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.jph-chat-product-atc:hover {
    background: var(--jerry-primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.25);
}

.jph-chat-product-atc:active {
    transform: scale(0.95);
}

.jph-chat-product-atc:focus-visible {
    outline: 2px solid var(--jerry-primary);
    outline-offset: 2px;
}

/* ATC states */
.jph-chat-atc-loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}

.jph-chat-atc-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid var(--jerry-primary-light);
    border-top-color: var(--jerry-primary);
    border-radius: 50%;
    animation: jerry-spin 0.6s linear infinite;
}

@keyframes jerry-spin {
    to {
        transform: rotate(360deg);
    }
}

.jph-chat-atc-added {
    background: var(--jerry-accent) !important;
    border-color: var(--jerry-accent) !important;
    color: #fff !important;
}

/* --------------------------------------------------------------------------
   15. SKELETON LOADING CARDS
   -------------------------------------------------------------------------- */

.jph-chat-skeleton-card {
    flex-shrink: 0;
    width: 160px;
    background: #fff;
    border-radius: var(--jerry-radius-card);
    box-shadow: var(--jerry-shadow-card);
    overflow: hidden;
    scroll-snap-align: start;
}

.jph-chat-skeleton-card::before {
    content: '';
    display: block;
    width: 100%;
    aspect-ratio: 1;
    background: linear-gradient(
        90deg,
        #f0eef5 25%,
        #e8e5f0 37%,
        #f0eef5 63%
    );
    background-size: 200% 100%;
    animation: jerry-shimmer 1.8s ease-in-out infinite;
}

.jph-chat-skeleton-card::after {
    content: '';
    display: block;
    margin: 12px;
    height: 14px;
    border-radius: 7px;
    background: linear-gradient(
        90deg,
        #f0eef5 25%,
        #e8e5f0 37%,
        #f0eef5 63%
    );
    background-size: 200% 100%;
    animation: jerry-shimmer 1.8s ease-in-out 0.15s infinite;
}

/* --------------------------------------------------------------------------
   16. TYPING INDICATOR
   -------------------------------------------------------------------------- */

.jph-chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background: #fff;
    border-radius: 20px 20px 20px 4px;
    box-shadow: var(--jerry-shadow-card);
    width: fit-content;
    animation: jerry-fade-in 0.3s ease forwards;
}

.jph-chat-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--jerry-primary-light);
    animation: jerry-bounce-dots 1.2s ease-in-out infinite;
}

.jph-chat-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.jph-chat-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

/* Tool execution status */
.jph-chat-tool-status {
    font-size: 0.82em;
    color: var(--jerry-primary);
    font-weight: 600;
    padding: 8px 16px;
    background: rgba(124, 58, 237, 0.06);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    animation: jerry-fade-in 0.3s ease forwards;
}

.jph-chat-tool-status::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--jerry-primary);
    animation: jerry-status-pulse 1s ease-in-out infinite;
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   17. FEEDBACK BUTTONS
   -------------------------------------------------------------------------- */

.jph-chat-feedback {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    padding-inline-start: 32px; /* offset for avatar */
}

.jph-chat-fb-btn {
    background: transparent;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 0.78em;
    cursor: pointer;
    opacity: 0.45;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 3px;
    -webkit-tap-highlight-color: transparent;
}

.jph-chat-fb-btn:hover {
    opacity: 1;
    transform: scale(1.08);
}

.jph-chat-fb-btn:focus-visible {
    outline: 2px solid var(--jerry-primary);
    outline-offset: 1px;
    opacity: 1;
}

.jph-fb-up:hover,
.jph-fb-up.jph-fb-active {
    background: rgba(16, 185, 129, 0.12);
    border-color: var(--jerry-accent);
    color: var(--jerry-accent);
    opacity: 1;
}

.jph-fb-down:hover,
.jph-fb-down.jph-fb-active {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
    opacity: 1;
}

.jph-fb-active {
    opacity: 1 !important;
    transform: scale(1);
}

/* --------------------------------------------------------------------------
   17b. MESSAGE TIMESTAMPS
   -------------------------------------------------------------------------- */

.jph-chat-time {
    display: block;
    font-size: 0.65em;
    color: var(--jerry-text-muted);
    opacity: 0.6;
    margin-top: 4px;
    text-align: left;
}

.jph-chat-msg-user .jph-chat-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.6);
}

/* --------------------------------------------------------------------------
   17c. STOP GENERATION BUTTON
   -------------------------------------------------------------------------- */

.jph-chat-stop-btn {
    display: block;
    margin: 0 auto 8px;
    padding: 6px 18px;
    background: var(--jerry-surface);
    color: var(--jerry-text-muted);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--jerry-radius-pill);
    font-family: var(--jerry-font);
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.jph-chat-stop-btn:hover {
    background: #fee2e2;
    color: #ef4444;
    border-color: #ef4444;
}

/* --------------------------------------------------------------------------
   18. INPUT AREA — Floating Island
   -------------------------------------------------------------------------- */

.jph-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin: 12px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.04);
    flex-shrink: 0;
    position: relative;
    transition: box-shadow 0.3s ease;
}

.jph-chat-input-area:focus-within {
    box-shadow: 0 2px 20px rgba(124, 58, 237, 0.15), 0 0 0 2px rgba(124, 58, 237, 0.2);
}

/* Screen reader only */
.jph-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Image upload button */
.jph-chat-image-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--jerry-surface);
    border: none;
    color: var(--jerry-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.jph-chat-image-btn:hover {
    background: rgba(124, 58, 237, 0.08);
    color: var(--jerry-primary);
}

.jph-chat-image-btn:focus-visible {
    outline: 2px solid var(--jerry-primary);
    outline-offset: 1px;
}

/* Text input */
.jph-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--jerry-font);
    font-size: 0.93em;
    color: var(--jerry-text);
    outline: none;
    direction: rtl;
    min-width: 0;
    padding: 6px 6px;
    line-height: 1.4;
    resize: none;
}

.jph-chat-input::placeholder {
    color: var(--jerry-text-muted);
    opacity: 0.7;
    line-height: 1.4;
}

/* Send button */
.jph-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--jerry-gradient);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
    -webkit-tap-highlight-color: transparent;
}

/* RTL flip for arrow icon */
.jph-chat-send svg,
.jph-chat-send img {
    transform: scaleX(-1);
}

.jph-chat-send:hover {
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
    transform: scale(1.06);
}

.jph-chat-send:active {
    animation: jerry-pounce 0.4s var(--jerry-spring);
}

.jph-chat-send:focus-visible {
    outline: 3px solid var(--jerry-primary-light);
    outline-offset: 2px;
}

.jph-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    box-shadow: none;
}

.jph-chat-send:disabled:hover {
    transform: none;
}

/* Image preview */
.jph-chat-image-preview {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 14px;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--jerry-shadow-card);
    padding: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: jerry-fade-in 0.25s ease forwards;
}

.jph-chat-image-preview img {
    width: 56px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
}

.jph-chat-image-remove {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    border: none;
    color: #ef4444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.jph-chat-image-remove:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* --------------------------------------------------------------------------
   19. FOOTER
   -------------------------------------------------------------------------- */

.jph-chat-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 16px 10px;
    font-size: 10px;
    color: var(--jerry-text-muted);
    flex-shrink: 0;
    background: transparent;
}

.jph-chat-footer-sep {
    opacity: 0.35;
}

.jph-chat-human-link,
.jph-chat-footer-link,
.jph-chat-email-link {
    color: var(--jerry-text-muted);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
    white-space: nowrap;
}

.jph-chat-human-link:hover,
.jph-chat-footer-link:hover,
.jph-chat-email-link:hover {
    color: var(--jerry-primary);
}

.jph-chat-human-link:focus-visible,
.jph-chat-footer-link:focus-visible,
.jph-chat-email-link:focus-visible {
    outline: 1px solid var(--jerry-primary);
    outline-offset: 2px;
    border-radius: 2px;
}


.jph-chat-footer-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.jph-chat-footer-link svg {
    flex-shrink: 0;
    vertical-align: middle;
}

.jph-chat-footer-branding {
    color: var(--jerry-text-muted);
    font-weight: 600;
    white-space: nowrap;
    font-size: 10px;
}

.jph-chat-footer-sep::before {
    content: "\00b7";
}

/* --------------------------------------------------------------------------
   20. HANDOFF CHIP (WhatsApp)
   -------------------------------------------------------------------------- */

.jph-handoff-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: #fff;
    color: #25d366;
    border: 2px solid #25d366;
    border-radius: var(--jerry-radius-card);
    font-family: var(--jerry-font);
    font-size: 0.88em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s var(--jerry-spring);
    text-decoration: none;
    margin-top: 6px;
    -webkit-tap-highlight-color: transparent;
}

.jph-handoff-chip:hover {
    background: #25d366;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.3);
}

.jph-handoff-chip:active {
    transform: translateY(0) scale(0.97);
}

.jph-handoff-chip:focus-visible {
    outline: 3px solid rgba(37, 211, 102, 0.5);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   21. TABLES IN CHAT
   -------------------------------------------------------------------------- */

.jph-chat-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.82em;
    margin: 8px 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(124, 58, 237, 0.12);
}

.jph-chat-table thead th {
    background: var(--jerry-gradient);
    color: #fff;
    font-weight: 700;
    padding: 8px 12px;
    text-align: right;
    font-size: 0.92em;
    white-space: nowrap;
}

.jph-chat-table tbody td {
    padding: 7px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    text-align: right;
}

.jph-chat-table tbody tr:last-child td {
    border-bottom: none;
}

.jph-chat-table tbody tr:nth-child(even) {
    background: rgba(124, 58, 237, 0.03);
}

.jph-chat-table tbody tr:hover {
    background: rgba(124, 58, 237, 0.06);
}

/* --------------------------------------------------------------------------
   22. DESKTOP-SPECIFIC STYLES (min-width: 769px)
   -------------------------------------------------------------------------- */

@media (min-width: 769px) {
    /* Panel sizing already handled in base styles */

    .jph-chat-backdrop {
        display: none !important;
    }

    /* Callout visible on desktop */
    .jph-chat-callout {
        display: block;
    }
}

/* --------------------------------------------------------------------------
   23. MOBILE FULL-SCREEN (max-width: 768px)
   -------------------------------------------------------------------------- */

@media (max-width: 768px) {
    /* Hide FAB on mobile — navbar button triggers the chat */
    .jph-chat-toggle {
        display: none !important;
    }

    /* Hide callout on mobile */
    .jph-chat-callout {
        display: none !important;
    }

    /* Full-screen panel */
    .jph-chat-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        height: var(--jph-app-height, 100dvh);
        max-height: none;
        min-height: 0;
        border-radius: 0;
        background: #fff;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border: none;
        box-shadow: none;
        overflow: hidden;
    }

    .jph-chat-open .jph-chat-panel {
        animation: none !important;
        z-index: 99999999 !important;
        display: flex !important;
        opacity: 1 !important;
        transform: translateY(0) !important;
        visibility: visible !important;
    }

    /* Sticky header */
    .jph-chat-header {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 12px 16px;
        padding-top: calc(12px + env(safe-area-inset-top, 0px));
    }

    /* Messages fill remaining space */
    .jph-chat-messages {
        flex: 1;
        padding: 16px;
        gap: 12px;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        position: relative;
    }

    /* Sticky input at bottom */
    .jph-chat-input-area {
        margin: 8px;
        margin-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        padding: 8px 12px;
    }

    .jph-chat-send {
        width: 42px;
        height: 42px;
    }

    .jph-chat-image-btn {
        width: 34px;
        height: 34px;
    }

    /* Product cards: responsive width */
    .jph-chat-product-card {
        width: min(160px, 42vw);
    }

    .jph-chat-skeleton-card {
        width: min(160px, 42vw);
    }

    /* Quick actions padding */
    .jph-chat-quick-actions {
        padding: 4px 16px 10px;
    }

    /* Products padding */
    .jph-chat-products {
        padding: 8px 16px 12px;
        scroll-padding-inline-start: 16px;
    }

    .jph-chat-bubble {
        max-width: 88%;
    }

    /* Footer */
    .jph-chat-footer {
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
    }
}
    /* Hide mobile navbar when chat is open */
    body.jerry-chat-active .cmn-mobile-navbar {
        display: none !important;
    }


/* --------------------------------------------------------------------------
   24. SMALL MOBILE (max-width: 360px)
   -------------------------------------------------------------------------- */

@media (max-width: 360px) {
    .jph-chat-product-card,
    .jph-chat-skeleton-card {
        width: 130px;
    }

    .jph-chat-messages {
        padding: 12px;
        gap: 10px;
    }

    .jph-chat-quick-actions {
        padding: 4px 12px 8px;
        gap: 6px;
    }

    .jph-chat-products {
        padding: 6px 12px 10px;
        gap: 8px;
    }

    .jph-chat-chip {
        padding: 6px 12px;
        font-size: 0.78em;
    }

    .jph-chat-input-area {
        margin: 6px;
        padding: 6px 10px;
        gap: 6px;
    }

    .jph-chat-send {
        width: 40px;
        height: 40px;
    }

    .jph-chat-header {
        padding: 10px 12px;
        gap: 10px;
    }

    .jph-chat-header-avatar {
        width: 36px;
        height: 36px;
    }

    .jph-chat-header-name {
        font-size: 0.95em;
    }

    .jph-chat-bubble {
        padding: 10px 13px;
        font-size: 0.88em;
        max-width: 90%;
    }

    .jph-chat-product-name {
        font-size: 0.75em;
        padding: 8px 8px 3px;
    }

    .jph-chat-product-price {
        padding: 0 8px 3px;
        font-size: 0.85em;
    }

    .jph-chat-product-atc {
        margin: auto 6px 6px;
        padding: 6px 8px;
        font-size: 0.72em;
    }
}

/* --------------------------------------------------------------------------
   25. TINY MOBILE — iPhone SE (max-width: 320px)
   -------------------------------------------------------------------------- */

@media (max-width: 320px) {
    .jph-chat-product-card,
    .jph-chat-skeleton-card {
        width: 120px;
    }

    .jph-chat-messages {
        padding: 10px;
        gap: 8px;
    }

    .jph-chat-header-avatar {
        width: 32px;
        height: 32px;
    }

    .jph-chat-ai-badge,
    .jph-chat-ai-pill {
        font-size: 8px;
        padding: 2px 6px;
    }

    .jph-chat-bubble {
        font-size: 0.85em;
        padding: 9px 11px;
    }

    .jph-chat-chip {
        font-size: 0.75em;
        padding: 5px 10px;
    }

    .jph-chat-chip::before {
        display: none; /* hide emoji icons on tiny screens */
    }

    .jph-chat-send {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .jph-chat-image-btn {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
}

/* --------------------------------------------------------------------------
   26. ACCESSIBILITY — Reduced Motion
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }

    .jph-chat-toggle {
        animation: none !important;
    }

    .jph-chat-open .jph-chat-panel {
        animation: none !important;
        opacity: 1;
        transform: none;
    }

    .jph-chat-typing-dot {
        animation: none !important;
        opacity: 0.5;
    }

    .jph-chat-skeleton-card::before,
    .jph-chat-skeleton-card::after {
        animation: none !important;
        opacity: 0.6;
    }

    .jph-chat-tool-status::before {
        animation: none !important;
    }
}

/* --------------------------------------------------------------------------
   27. FOCUS-VISIBLE GLOBAL
   -------------------------------------------------------------------------- */

.jph-chat-widget :focus:not(:focus-visible) {
    outline: none;
}

.jph-chat-widget :focus-visible {
    outline: 2px solid var(--jerry-primary);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   28. HIGH CONTRAST MODE
   -------------------------------------------------------------------------- */

@media (forced-colors: active) {
    .jph-chat-bubble {
        border: 1px solid ButtonText;
    }

    .jph-chat-send,
    .jph-chat-header-btn,
    .jph-chat-back,
    .jph-chat-toggle {
        border: 2px solid ButtonText;
    }

    .jph-chat-chip {
        border: 1px solid ButtonText;
    }

    .jph-chat-product-card {
        border: 1px solid ButtonText;
    }
}

/* --------------------------------------------------------------------------
   29. PRINT — Hide Widget
   -------------------------------------------------------------------------- */

@media print {
    .jph-chat-widget {
        display: none !important;
    }
}


/* --------------------------------------------------------------------------
   ENHANCEMENT: Auto-grow textarea
   -------------------------------------------------------------------------- */

.jph-chat-input {
    resize: none;
    overflow-y: auto;
    min-height: 40px;
    max-height: calc(1.6em * 4 + 16px);
    line-height: 1.6;
    transition: height 0.1s ease;
}

/* --------------------------------------------------------------------------
   ENHANCEMENT: Scroll-to-bottom button
   -------------------------------------------------------------------------- */

.jph-scroll-bottom {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--jerry-primary, #7c3aed);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 5;
}

.jph-scroll-bottom.jph-scroll-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.jph-scroll-bottom:active {
    transform: translateX(-50%) scale(0.92);
}

.jph-unread-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

.jph-unread-count:empty {
    display: none;
}

/* --------------------------------------------------------------------------
   ENHANCEMENT: Follow-up chips
   -------------------------------------------------------------------------- */

.jph-chat-follow-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 8px;
    justify-content: flex-end;
}

.jph-chat-follow-chip {
    font-size: 0.82em;
    padding: 6px 14px;
    border-radius: 16px;
    background: rgba(124, 58, 237, 0.08);
    color: var(--jerry-primary, #7c3aed);
    border: 1px solid rgba(124, 58, 237, 0.2);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
    white-space: nowrap;
}

.jph-chat-follow-chip:hover {
    background: rgba(124, 58, 237, 0.15);
}

.jph-chat-follow-chip:active {
    transform: scale(0.95);
}

/* --------------------------------------------------------------------------
   ENHANCEMENT: Retry button
   -------------------------------------------------------------------------- */

.jph-chat-retry-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
    padding: 5px 12px;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    font-size: 0.82em;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.jph-chat-retry-btn:hover {
    background: rgba(239, 68, 68, 0.15);
}

.jph-chat-retry-btn:active {
    transform: scale(0.95);
}

/* Cache source badge (admin only) */
.jph-chat-source-badge {
    display: inline-block;
    font-size: 0.7em;
    color: #059669;
    background: rgba(5, 150, 105, 0.1);
    padding: 1px 6px;
    border-radius: 8px;
    margin-inline-end: 4px;
    font-weight: 600;
    vertical-align: middle;
}
