/* Agent AI — style widżetu czatu (tryb floating + inline).
   Akcent: --agent-accent (ustawiany per instalacja z panelu; fallback: token theme
   --c-primary, ostatecznie niebieski). Zero zależności od frameworków CSS. */

.agent-chat { --agent-accent-final: var(--agent-accent, var(--c-primary, #2563eb)); }

/* ---------- Floating: kontener + dymek ---------- */
.agent-chat--floating {
    position: fixed;
    bottom: 20px;
    z-index: 99990;
    font-family: var(--font-base, system-ui, sans-serif);
}
.agent-chat--br { right: 20px; }
.agent-chat--bl { left: 20px; }

.agent-chat-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border: 0;
    border-radius: 50%;
    background: var(--agent-accent-final);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
    transition: transform .15s ease;
}
.agent-chat-toggle:hover { transform: scale(1.06); }

/* ---------- Panel ---------- */
.agent-chat--floating .agent-chat-panel {
    display: none;
    position: absolute;
    bottom: 68px;
    width: min(360px, calc(100vw - 32px));
    height: min(520px, calc(100vh - 120px));
    box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
}
.agent-chat--br .agent-chat-panel { right: 0; }
.agent-chat--bl .agent-chat-panel { left: 0; }
.agent-chat--floating.agent-chat--open .agent-chat-panel { display: flex; }

.agent-chat-panel {
    flex-direction: column;
    background: #fff;
    color: #1e293b;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 12px;
    overflow: hidden;
}

/* Inline (element buildera): panel zawsze widoczny, w nurcie dokumentu. */
.agent-chat--inline .agent-chat-panel { display: flex; width: 100%; }
.agent-chat--inline.agent-chat--h-sm .agent-chat-panel { height: 320px; }
.agent-chat--inline.agent-chat--h-md .agent-chat-panel { height: 440px; }
.agent-chat--inline.agent-chat--h-lg .agent-chat-panel { height: 600px; }

.agent-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding: .65rem .9rem;
    background: var(--agent-accent-final);
    color: #fff;
}
.agent-chat-title { font-weight: 600; }
.agent-chat-close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 .2rem;
}

.agent-chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ---------- Bramka e-mail (wymagana przed rozmową — lead) ---------- */
.agent-chat-gate {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .6rem;
    padding: 1.1rem;
    background: #f8fafc;
}
.agent-chat-gate-title { margin: 0; font-weight: 600; font-size: 1rem; color: #1e293b; }
.agent-chat-gate-text { margin: 0; font-size: .88rem; color: #475569; }
.agent-chat-gate-error { margin: 0; font-size: .85rem; color: #dc2626; }
.agent-chat-gate-row { display: flex; gap: .5rem; }
.agent-chat-gate-row .agent-chat-input { flex: 1; background: #fff; }
.agent-chat-input--error { border-color: #dc2626 !important; }
.agent-chat-gate .agent-chat-note { padding: 0; background: transparent; }
.agent-chat-gate .agent-chat-note a { color: inherit; text-decoration: underline; }

.agent-chat-msgs {
    flex: 1;
    overflow-y: auto;
    padding: .9rem;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    background: #f8fafc;
}
.agent-chat-msg {
    max-width: 85%;
    padding: .5rem .75rem;
    border-radius: 12px;
    font-size: .92rem;
    line-height: 1.45;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}
.agent-chat-msg--bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, .08);
    border-bottom-left-radius: 4px;
}
.agent-chat-msg--user {
    align-self: flex-end;
    background: var(--agent-accent-final);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.agent-chat-msg--typing { color: #64748b; letter-spacing: 2px; }

.agent-chat-form {
    display: flex;
    gap: .5rem;
    padding: .6rem;
    border-top: 1px solid rgba(0, 0, 0, .08);
    background: #fff;
}
.agent-chat-input {
    flex: 1;
    border: 1px solid rgba(0, 0, 0, .15);
    border-radius: 8px;
    padding: .5rem .7rem;
    font: inherit;
    font-size: .92rem;
}
.agent-chat-input:focus { outline: 2px solid var(--agent-accent-final); outline-offset: 1px; }
.agent-chat-send {
    border: 0;
    border-radius: 8px;
    padding: .5rem .9rem;
    background: var(--agent-accent-final);
    color: #fff;
    font: inherit;
    font-size: .92rem;
    cursor: pointer;
}
.agent-chat-send:disabled { opacity: .55; cursor: default; }

.agent-chat-note {
    margin: 0;
    padding: .35rem .9rem .55rem;
    background: #fff;
    color: #94a3b8;
    font-size: .72rem;
    line-height: 1.35;
}

/* Ciemne sekcje (ton pb-dark) — panel inline zachowuje własne, jasne tło (czytelność). */

@media (max-width: 480px) {
    .agent-chat--floating .agent-chat-panel {
        position: fixed;
        inset: auto 8px 76px 8px;
        width: auto;
        height: min(70vh, 520px);
    }
}
