/* Petka ChatBot – messenger style widget */
.pcb-root {
    --pcb-primary: #2563eb;
    --pcb-on-primary: #fff;
    --pcb-bg: #ffffff;
    --pcb-surface: #f3f4f6;
    --pcb-text: #111827;
    --pcb-muted: #6b7280;
    --pcb-border: #e5e7eb;
    --pcb-radius: 20px;
    --pcb-shadow: 0 24px 60px -12px rgba(17, 24, 39, .35), 0 8px 20px -8px rgba(17, 24, 39, .18);
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2147483000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.45;
    color: var(--pcb-text);
    display: none;
    -webkit-font-smoothing: antialiased;
}
.pcb-root.pcb-ready { display: block; }
.pcb-root.pcb-pos-left { right: auto; left: 20px; }
.pcb-root *, .pcb-root *::before, .pcb-root *::after { box-sizing: border-box; }
.pcb-root svg { width: 100%; height: 100%; display: block; }
.pcb-root button { font: inherit; cursor: pointer; margin: 0; }
.pcb-root [hidden] { display: none !important; }

/* ── Launcher ─────────────────────────────── */
.pcb-launcher {
    position: relative;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    border: 0;
    padding: 0;
    background: var(--pcb-primary);
    color: var(--pcb-on-primary);
    box-shadow: 0 10px 28px -6px rgba(0, 0, 0, .35);
    display: grid;
    place-items: center;
    transition: transform .2s ease, box-shadow .2s ease;
    margin-left: auto;
}
.pcb-pos-left .pcb-launcher { margin-left: 0; }
.pcb-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 34px -6px rgba(0, 0, 0, .4); }
.pcb-launcher:focus-visible { outline: 3px solid color-mix(in srgb, var(--pcb-primary) 45%, transparent); outline-offset: 3px; }
.pcb-launcher::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--pcb-primary);
    opacity: .5;
    z-index: -1;
    animation: pcb-pulse 2.8s ease-out 1.5s 3;
}
.pcb-launcher-icon {
    position: absolute;
    width: 30px;
    height: 30px;
    transition: transform .25s ease, opacity .2s ease;
}
.pcb-icon-close { opacity: 0; transform: rotate(-90deg) scale(.6); }
.pcb-open .pcb-icon-chat { opacity: 0; transform: rotate(90deg) scale(.6); }
.pcb-open .pcb-icon-close { opacity: 1; transform: none; }
.pcb-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ef4444;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    border: 2px solid #fff;
}

/* ── Teaser ─────────────────────────────── */
.pcb-teaser {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: max-content;
    max-width: 260px;
    padding: 12px 34px 12px 14px;
    background: var(--pcb-bg);
    border-radius: 16px 16px 4px 16px;
    box-shadow: var(--pcb-shadow);
    cursor: pointer;
    animation: pcb-pop .35s cubic-bezier(.2, .9, .3, 1.3);
    font-size: 14px;
}
.pcb-pos-left .pcb-teaser { right: auto; left: 0; border-radius: 16px 16px 16px 4px; }
.pcb-teaser-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 20px;
    height: 20px;
    padding: 3px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--pcb-muted);
}
.pcb-teaser-close:hover { background: var(--pcb-surface); }

/* ── Panel ─────────────────────────────── */
.pcb-panel {
    position: absolute;
    bottom: 78px;
    right: 0;
    width: 390px;
    height: min(640px, calc(100vh - 120px));
    background: var(--pcb-bg);
    border-radius: var(--pcb-radius);
    box-shadow: var(--pcb-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(.97);
    transform-origin: bottom right;
    transition: opacity .2s ease, transform .22s ease;
    pointer-events: none;
}
.pcb-pos-left .pcb-panel { right: auto; left: 0; transform-origin: bottom left; }
.pcb-open .pcb-panel { opacity: 1; transform: none; pointer-events: auto; }

.pcb-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 14px 16px 16px;
    background: linear-gradient(135deg, var(--pcb-primary), color-mix(in srgb, var(--pcb-primary) 70%, #000));
    color: var(--pcb-on-primary);
    flex-shrink: 0;
}
.pcb-heading { flex: 1; min-width: 0; }
.pcb-title { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcb-subtitle { font-size: 12.5px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcb-hbtn {
    width: 34px;
    height: 34px;
    padding: 7px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    opacity: .85;
    transition: background .15s, opacity .15s;
}
.pcb-hbtn:hover { background: rgba(255, 255, 255, .18); opacity: 1; }

.pcb-avatar {
    position: relative;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    color: var(--pcb-primary);
    background: var(--pcb-bg);
}
.pcb-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.pcb-avatar-lg { width: 42px; height: 42px; box-shadow: 0 0 0 2px rgba(255, 255, 255, .35); }
.pcb-online {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
}

/* ── Messages ─────────────────────────────── */
.pcb-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 14px 8px;
    background:
        radial-gradient(circle at 100% 0, color-mix(in srgb, var(--pcb-primary) 6%, transparent), transparent 45%),
        var(--pcb-bg);
    scrollbar-width: thin;
}
.pcb-messages { display: flex; flex-direction: column; gap: 12px; }
.pcb-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.pcb-row-user { justify-content: flex-end; }
.pcb-stack { display: flex; flex-direction: column; min-width: 0; max-width: 82%; }
.pcb-row-user .pcb-stack { align-items: flex-end; }
.pcb-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}
.pcb-row-bot .pcb-bubble { background: var(--pcb-surface); border-bottom-left-radius: 6px; }
.pcb-row-user .pcb-bubble {
    background: var(--pcb-primary);
    color: var(--pcb-on-primary);
    border-bottom-right-radius: 6px;
}
.pcb-status-rate_limited .pcb-bubble { background: #fef3c7; }
.pcb-status-quota .pcb-bubble, .pcb-status-budget .pcb-bubble,
.pcb-status-error .pcb-bubble { background: #fee2e2; }
.pcb-bubble p { margin: 0; }
.pcb-bubble p + p, .pcb-bubble p + ul, .pcb-bubble p + ol, .pcb-bubble ul + p, .pcb-bubble ol + p { margin-top: 8px; }
.pcb-bubble ul, .pcb-bubble ol { margin: 6px 0 0; padding-left: 20px; }
.pcb-bubble li + li { margin-top: 4px; }
.pcb-bubble a { color: var(--pcb-primary); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.pcb-row-user .pcb-bubble a { color: inherit; }
.pcb-time { font-size: 11px; color: var(--pcb-muted); margin: 4px 6px 0; }
.pcb-in { animation: pcb-slide .28s ease both; }

.pcb-typing { display: flex; gap: 4px; padding: 14px 16px; }
.pcb-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--pcb-muted);
    animation: pcb-dot 1.2s infinite ease-in-out;
}
.pcb-typing i:nth-child(2) { animation-delay: .15s; }
.pcb-typing i:nth-child(3) { animation-delay: .3s; }

/* ── Product cards ─────────────────────────────── */
.pcb-cards {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 10px 2px 6px;
    margin-right: -40px;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
}
.pcb-card {
    flex: 0 0 158px;
    display: flex;
    flex-direction: column;
    background: var(--pcb-bg);
    border: 1px solid var(--pcb-border);
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none !important;
    color: var(--pcb-text) !important;
    scroll-snap-align: start;
    transition: transform .15s ease, box-shadow .15s ease;
}
.pcb-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px -8px rgba(0, 0, 0, .25); }
.pcb-card-img { display: block; height: 118px; background: #fff; border-bottom: 1px solid var(--pcb-border); }
.pcb-card-img img { width: 100%; height: 100%; object-fit: contain; padding: 8px; display: block; }
.pcb-card-body { display: flex; flex-direction: column; gap: 3px; padding: 9px 10px 10px; flex: 1; }
.pcb-card-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.pcb-card-price { font-size: 14px; font-weight: 700; }
.pcb-card-price s { color: var(--pcb-muted); font-weight: 400; font-size: 12px; }
.pcb-card-stock { font-size: 11.5px; font-weight: 600; }
.pcb-card-stock.is-in { color: #16a34a; }
.pcb-card-stock.is-out { color: #dc2626; }
.pcb-card-cta { margin-top: auto; padding-top: 4px; font-size: 12.5px; font-weight: 700; color: var(--pcb-primary); }

/* ── Suggestions ─────────────────────────────── */
.pcb-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 8px; justify-content: flex-end; }
.pcb-chip {
    border: 1.5px solid var(--pcb-primary);
    color: var(--pcb-primary);
    background: var(--pcb-bg);
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    transition: background .15s, color .15s;
}
.pcb-chip:hover { background: var(--pcb-primary); color: var(--pcb-on-primary); }

/* ── Composer ─────────────────────────────── */
.pcb-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0 12px;
    padding: 6px 6px 6px 14px;
    border: 1.5px solid var(--pcb-border);
    border-radius: 24px;
    background: var(--pcb-bg);
    transition: border-color .15s, box-shadow .15s;
}
.pcb-composer:focus-within {
    border-color: var(--pcb-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--pcb-primary) 18%, transparent);
}
.pcb-root .pcb-input {
    flex: 1;
    border: 0 !important;
    outline: 0 !important;
    box-shadow: none !important;
    resize: none;
    background: transparent;
    font: inherit;
    font-size: 15px;
    color: var(--pcb-text);
    padding: 7px 0;
    margin: 0;
    max-height: 120px;
    min-height: 0;
    height: auto;
    line-height: 1.4;
}
.pcb-send {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 0;
    border-radius: 50%;
    padding: 9px;
    background: var(--pcb-primary);
    color: var(--pcb-on-primary);
    transition: transform .15s, opacity .15s;
}
.pcb-send:disabled { opacity: .35; cursor: default; }
.pcb-send:not(:disabled):hover { transform: scale(1.07); }
.pcb-busy .pcb-send { opacity: .35; }
.pcb-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 16px 10px;
    font-size: 11px;
    color: var(--pcb-muted);
    line-height: 1.35;
}
.pcb-footer a { color: inherit; text-decoration: underline; }
.pcb-counter { white-space: nowrap; order: 2; }

/* ── Mobile: full screen ─────────────────────────────── */
@media (max-width: 640px) {
    .pcb-root { bottom: 14px; right: 14px; }
    .pcb-root.pcb-pos-left { left: 14px; }
    .pcb-root.pcb-hide-mobile { display: none !important; }
    .pcb-panel {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        transform: translateY(24px);
    }
    .pcb-open .pcb-launcher { display: none; }
    .pcb-root .pcb-input { font-size: 16px; } /* no iOS zoom */
    .pcb-teaser { max-width: calc(100vw - 100px); }
}

/* ── Animations ─────────────────────────────── */
@keyframes pcb-pulse { 0% { transform: scale(1); opacity: .5; } 100% { transform: scale(1.7); opacity: 0; } }
@keyframes pcb-pop { from { opacity: 0; transform: translateY(8px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes pcb-slide { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes pcb-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-5px); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
    .pcb-root *, .pcb-root *::before { animation: none !important; transition: none !important; }
}
@media print { .pcb-root { display: none !important; } }
