/*
 * Produktový chatbot – moderný plávajúci widget vpravo dole.
 * Desktop default: 30 % šírky, 66 % výšky (plávajúci panel so zaoblenými rohmi).
 */

#pcb-root {
    position: relative;
    z-index: 9999;
    --pcb-primary: #2d7ff9;
    --pcb-primary-2: #5b6cff;
    --pcb-grad: linear-gradient(135deg, #2d7ff9 0%, #5b6cff 100%);
    --pcb-ink: #1f2430;
    --pcb-muted: #6b7280;
    --pcb-bg: #f5f7fb;
    --pcb-line: #e7eaf0;
    --pcb-radius: 18px;
    --pcb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ============================ Plávajúca bublina ============================ */
.pcb-bubble {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 0;
    background: var(--pcb-grad);
    color: #fff;
    box-shadow: 0 10px 28px rgba(45, 127, 249, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.pcb-bubble:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 34px rgba(45, 127, 249, 0.55); }
.pcb-bubble:active { transform: scale(0.98); }
.pcb-bubble-icon { font-size: 27px; line-height: 1; }

/* ============================ Panel ============================ */
.pcb-panel {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 30vw;
    min-width: 340px;
    max-width: 600px;
    height: 66vh;
    min-height: 420px;
    max-height: calc(100vh - 44px);
    background: var(--pcb-bg);
    border: 1px solid var(--pcb-line);
    border-radius: var(--pcb-radius);
    box-shadow: 0 24px 60px rgba(17, 24, 39, 0.28);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    font-family: var(--pcb-font);
    -webkit-font-smoothing: antialiased;
    animation: pcb-pop 0.18s ease;
}
@keyframes pcb-pop {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.pcb-resize {
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 3;
    background:
        linear-gradient(135deg, transparent 0 7px, rgba(255, 255, 255, 0.85) 7px 9px, transparent 9px 11px, rgba(255, 255, 255, 0.85) 11px 13px, transparent 13px);
    border-top-left-radius: var(--pcb-radius);
    touch-action: none;
}

/* ============================ Hlavička ============================ */
.pcb-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 14px 13px 18px;
    background: var(--pcb-grad);
    color: #fff;
    flex: 0 0 auto;
}
.pcb-head-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pcb-avatar {
    width: 34px; height: 34px;
    flex: 0 0 auto;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 50%;
}
.pcb-head-txt { display: flex; flex-direction: column; min-width: 0; }
.pcb-title { font-weight: 700; font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcb-status { display: flex; align-items: center; gap: 5px; font-size: 11.5px; opacity: 0.92; }
.pcb-dot { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3); }

.pcb-head-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.pcb-reset, .pcb-close {
    background: transparent; border: 0; color: #fff;
    line-height: 1; cursor: pointer; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.15s ease;
}
.pcb-reset { font-size: 18px; width: 32px; height: 32px; }
.pcb-close { font-size: 22px; width: 32px; height: 32px; }
.pcb-reset:hover, .pcb-close:hover { background: rgba(255, 255, 255, 0.22); }

/* ============================ Správy ============================ */
.pcb-msgs {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
}
.pcb-msgs::-webkit-scrollbar { width: 8px; }
.pcb-msgs::-webkit-scrollbar-thumb { background: rgba(31, 36, 48, 0.18); border-radius: 8px; }
.pcb-msgs::-webkit-scrollbar-track { background: transparent; }

.pcb-msg {
    max-width: 86%;
    padding: 10px 13px;
    border-radius: 16px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 1px 2px rgba(17, 24, 39, 0.05);
}
.pcb-user {
    margin-left: auto;
    background: var(--pcb-grad);
    color: #fff;
    border-bottom-right-radius: 5px;
}
.pcb-bot {
    margin-right: auto;
    background: #fff;
    color: var(--pcb-ink);
    border: 1px solid var(--pcb-line);
    border-bottom-left-radius: 5px;
}
.pcb-typing { color: var(--pcb-muted); font-style: italic; }

/* Formátovanie dlhších odpovedí bota (odseky, zoznamy, nadpisy) */
.pcb-bot .pcb-p { margin: 0 0 9px; }
.pcb-bot .pcb-p:last-child { margin-bottom: 0; }
.pcb-bot .pcb-list { margin: 5px 0 9px; padding-left: 20px; }
.pcb-bot .pcb-list:last-child { margin-bottom: 0; }
.pcb-bot .pcb-list li { margin: 3px 0; }
.pcb-bot strong { font-weight: 700; }

/* ============================ Karty produktov ============================ */
.pcb-products { display: flex; flex-direction: column; gap: 9px; margin: 2px 0 10px; }
.pcb-pitem { display: flex; flex-direction: column; gap: 2px; }
.pcb-fb { display: flex; gap: 1px; align-items: center; padding-left: 2px; }
.pcb-fb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #b4bac2;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.15s ease, background 0.15s ease;
}
.pcb-fb-btn svg { width: 14px; height: 14px; display: block; }
.pcb-fb-down svg { transform: rotate(180deg); }
.pcb-fb-up:hover { color: #2f8a2f; background: rgba(47, 138, 47, 0.1); }
.pcb-fb-down:hover { color: #c0392b; background: rgba(192, 57, 43, 0.1); }
.pcb-fb-done .pcb-fb-btn { cursor: default; }
.pcb-fb-done .pcb-fb-btn:hover { background: transparent; }
.pcb-fb-btn.pcb-sel.pcb-fb-up { color: #2f8a2f; }
.pcb-fb-btn.pcb-sel.pcb-fb-down { color: #c0392b; }
.pcb-fb-btn.pcb-dim { opacity: 0.25; }
.pcb-fb-ok { font-size: 11px; color: #9aa0a6; margin-left: 5px; }
.pcb-card {
    display: flex;
    gap: 11px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--pcb-line);
    border-radius: 14px;
    padding: 10px;
    text-decoration: none;
    color: var(--pcb-ink);
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.pcb-card:hover { border-color: var(--pcb-primary); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(45, 127, 249, 0.16); }
.pcb-card-img { width: 54px; height: 54px; object-fit: cover; border-radius: 10px; flex: 0 0 auto; background: #eef1f6; }
.pcb-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pcb-card-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.pcb-card-price { color: var(--pcb-primary); font-weight: 700; font-size: 14px; }
.pcb-oos {
    display: inline-block;
    margin-top: 2px;
    font-size: 11px;
    color: #a31515;
    background: #fdecea;
    border: 1px solid #f0c2bc;
    border-radius: 6px;
    padding: 1px 7px;
    width: fit-content;
}

/* ============================ Návrhy (chipy) ============================ */
.pcb-suggest-wrap { border-top: 1px solid var(--pcb-line); background: #fff; flex: 0 0 auto; }
.pcb-suggest {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    max-height: 32vh;
    overflow-y: auto;
}
.pcb-suggest::-webkit-scrollbar { width: 8px; }
.pcb-suggest::-webkit-scrollbar-thumb { background: rgba(31, 36, 48, 0.15); border-radius: 8px; }
.pcb-suggest .pcb-chip {
    white-space: normal;      /* celý text, žiadne orezanie */
    text-align: left;
    flex: 0 1 auto;
    max-width: 100%;
    word-break: break-word;
}

.pcb-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.pcb-chip {
    border: 1px solid rgba(45, 127, 249, 0.35);
    background: rgba(45, 127, 249, 0.08);
    color: #1f5fbf;
    border-radius: 18px;
    padding: 7px 13px;
    font-size: 13px;
    cursor: pointer;
    line-height: 1.25;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.pcb-chip:hover { background: var(--pcb-grad); color: #fff; border-color: transparent; }

/* ============================ Vstup ============================ */
.pcb-form { display: flex; gap: 9px; padding: 12px; border-top: 1px solid var(--pcb-line); background: #fff; flex: 0 0 auto; }
.pcb-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 1px solid var(--pcb-line);
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--pcb-font);
    outline: none;
    background: var(--pcb-bg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.pcb-input:focus { border-color: var(--pcb-primary); background: #fff; box-shadow: 0 0 0 3px rgba(45, 127, 249, 0.14); }
.pcb-send {
    border: 0;
    background: var(--pcb-grad);
    color: #fff;
    border-radius: 22px;
    padding: 9px 18px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    flex: 0 0 auto;
    transition: filter 0.15s ease, transform 0.1s ease;
}
.pcb-send:hover { filter: brightness(1.06); }
.pcb-send:active { transform: scale(0.97); }
.pcb-input:disabled, .pcb-send:disabled { opacity: 0.55; cursor: not-allowed; }

.pcb-legal { padding: 7px 12px 11px; font-size: 11px; color: #9aa0a6; background: #fff; text-align: center; flex: 0 0 auto; }

/* ============================ Responzívne ============================ */
@media (max-width: 1280px) {
    .pcb-panel { width: 40vw; }
}
@media (max-width: 900px) {
    .pcb-panel { width: 66vw; height: 72vh; }
}
@media (max-width: 640px) {
    .pcb-bubble { right: 16px; bottom: 16px; }
    .pcb-panel {
        right: 0; bottom: 0;
        width: 100vw; max-width: 100vw;
        height: 100vh; height: 100dvh; max-height: 100vh; min-width: 0;
        border-radius: 0;
    }
    .pcb-resize { display: none; } /* na mobile bez ručného resize – je fullscreen */
}

/* ============================ Spojenie s operátorom (WhatsApp) ============================ */
.pcb-op-wrap {
    padding: 6px 12px;
    text-align: center;
}
.pcb-op-btn {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    border: 1px solid var(--pcb-line);
    border-radius: 999px;
    background: #fff;
    color: var(--pcb-ink);
    font: 600 13px/1.2 var(--pcb-font);
    text-align: center;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.pcb-op-btn::before {
    content: "🎧";
    font-size: 14px;
}
.pcb-op-btn:hover { border-color: #25d366; color: #128c4b; }
.pcb-op-btn.pcb-op-active {
    background: #fdecea;
    border-color: #e57373;
    color: #b0281c;
}
.pcb-op-btn.pcb-op-active::before { content: "✕"; }

/* Systémové (stavové) hlásenie v konverzácii */
.pcb-msg.pcb-sys {
    align-self: center;
    max-width: 92%;
    background: #eef1f6;
    color: var(--pcb-muted);
    border: 1px dashed var(--pcb-line);
    font-size: 12.5px;
    text-align: center;
    border-radius: 12px;
}

/* Správa operátora (zelený WhatsApp odtieň, vľavo ako bot) */
.pcb-msg.pcb-op {
    align-self: flex-start;
    background: #e7fbe9;
    color: #14351d;
    border: 1px solid #bfead0;
}
.pcb-op-tag {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #128c4b;
    margin-bottom: 2px;
}
