/* Lebegő ügyfélszolgálati chat widget – includes/support_chat_widget.php, js/support-chat.js
   Saját, "pzc-" előtagú tokenek: a régi (modern-ui) és az új (pz-redesign) felületen is
   ugyanígy nézzen ki, és ne ütközzön az oldalak stílusaival. */

.pzc-root {
    --pzc-primary: #3d8a7c;
    --pzc-primary-2: #73bdaa;
    --pzc-on-primary: #ffffff;
    --pzc-bg: #ffffff;
    --pzc-surface: #f3f7f5;
    --pzc-text: #17221e;
    --pzc-muted: #5f6f69;
    --pzc-border: #dce6e2;
    --pzc-user-bg: #3d8a7c;
    --pzc-user-text: #ffffff;
    --pzc-shadow: 0 12px 40px rgba(16, 40, 33, 0.22);
    --pzc-offset: 0px;

    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: calc(max(16px, env(safe-area-inset-bottom)) + var(--pzc-offset));
    z-index: 2147483000;
    font-family: "Geist", "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--pzc-text);
    transition: bottom .2s ease;
}

[data-theme="dark"] .pzc-root {
    --pzc-bg: #121815;
    --pzc-surface: #1b2420;
    --pzc-text: #eef6f2;
    --pzc-muted: #9fb0a9;
    --pzc-border: #29362f;
    --pzc-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

.pzc-root *, .pzc-root *::before, .pzc-root *::after { box-sizing: border-box; }

/* Indító gomb (összecsukott állapot) */
.pzc-launcher {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 0;
    cursor: pointer;
    background: linear-gradient(160deg, var(--pzc-primary-2), var(--pzc-primary));
    color: var(--pzc-on-primary);
    box-shadow: var(--pzc-shadow);
    display: grid;
    place-items: center;
    transition: transform .15s ease, box-shadow .15s ease;
}
.pzc-launcher:hover { transform: translateY(-2px) scale(1.04); }
.pzc-launcher:focus-visible { outline: 3px solid var(--pzc-primary-2); outline-offset: 3px; }
.pzc-launcher svg { width: 28px; height: 28px; }
.pzc-root.is-open .pzc-launcher { display: none; }

/* Panel */
.pzc-panel {
    display: none;
    flex-direction: column;
    width: min(380px, calc(100vw - 32px));
    height: min(600px, calc(100vh - 32px - var(--pzc-offset)));
    height: min(600px, calc(100dvh - 32px - var(--pzc-offset)));
    background: var(--pzc-bg);
    border: 1px solid var(--pzc-border);
    border-radius: 18px;
    box-shadow: var(--pzc-shadow);
    overflow: hidden;
    animation: pzc-in .18s ease-out;
}
.pzc-root.is-open .pzc-panel { display: flex; }
@keyframes pzc-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .pzc-panel { animation: none; } .pzc-launcher { transition: none; } }

.pzc-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px 12px 16px;
    background: linear-gradient(160deg, var(--pzc-primary-2), var(--pzc-primary));
    color: var(--pzc-on-primary);
}
.pzc-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: grid; place-items: center; flex: none;
}
.pzc-avatar svg { width: 20px; height: 20px; }
.pzc-titles { flex: 1; min-width: 0; }
.pzc-title { font-weight: 700; font-size: 15px; margin: 0; }
.pzc-subtitle { font-size: 12px; opacity: .85; margin: 0; }
.pzc-icon-btn {
    background: transparent; border: 0; color: inherit; cursor: pointer;
    width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
}
.pzc-icon-btn:hover { background: rgba(255,255,255,.18); }
.pzc-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }
.pzc-icon-btn svg { width: 18px; height: 18px; }

.pzc-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--pzc-surface);
    overscroll-behavior: contain;
}

.pzc-msg {
    max-width: 88%;
    padding: 9px 12px;
    border-radius: 14px;
    white-space: normal;
    overflow-wrap: anywhere;
}
.pzc-msg p { margin: 0 0 6px; }
.pzc-msg p:last-child { margin-bottom: 0; }
.pzc-msg ul { margin: 4px 0 6px; padding-left: 18px; }
.pzc-msg li { margin: 2px 0; }
.pzc-msg a { color: inherit; text-decoration: underline; }
.pzc-msg--bot {
    align-self: flex-start;
    background: var(--pzc-bg);
    border: 1px solid var(--pzc-border);
    border-bottom-left-radius: 4px;
}
.pzc-msg--user {
    align-self: flex-end;
    background: var(--pzc-user-bg);
    color: var(--pzc-user-text);
    border-bottom-right-radius: 4px;
}
.pzc-msg--error {
    align-self: center;
    background: #fdecea;
    color: #8a1c13;
    font-size: 13px;
}
[data-theme="dark"] .pzc-msg--error { background: #3a1d1a; color: #ffb4a9; }

.pzc-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pzc-chip, .pzc-action {
    border: 1px solid var(--pzc-primary);
    background: transparent;
    color: var(--pzc-primary);
    border-radius: 999px;
    padding: 6px 12px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
}
[data-theme="dark"] .pzc-chip, [data-theme="dark"] .pzc-action { color: var(--pzc-primary-2); border-color: var(--pzc-primary-2); }
.pzc-chip:hover, .pzc-action:hover { background: var(--pzc-primary); color: #fff; }
.pzc-action[disabled] { opacity: .5; cursor: default; }
.pzc-chips { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; }

.pzc-typing { align-self: flex-start; color: var(--pzc-muted); font-size: 13px; display: flex; gap: 6px; align-items: center; }
.pzc-dots { display: inline-flex; gap: 3px; }
.pzc-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--pzc-muted); animation: pzc-blink 1.2s infinite; }
.pzc-dots i:nth-child(2) { animation-delay: .2s; }
.pzc-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes pzc-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.pzc-form {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--pzc-border);
    background: var(--pzc-bg);
}
.pzc-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--pzc-border);
    border-radius: 12px;
    padding: 9px 11px;
    font: inherit;
    font-size: 16px; /* iOS ne zoomoljon */
    max-height: 120px;
    background: var(--pzc-bg);
    color: var(--pzc-text);
}
.pzc-input:focus { outline: 2px solid var(--pzc-primary-2); outline-offset: 0; border-color: transparent; }
.pzc-send {
    width: 42px; flex: none; border: 0; border-radius: 12px; cursor: pointer;
    background: var(--pzc-primary); color: #fff; display: grid; place-items: center;
}
.pzc-send[disabled] { opacity: .5; cursor: default; }
.pzc-send svg { width: 18px; height: 18px; }
.pzc-disclaimer { margin: 0; padding: 0 12px 8px; font-size: 11px; color: var(--pzc-muted); background: var(--pzc-bg); text-align: center; }

.pzc-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Mobilon nyitva szinte teljes képernyő */
@media (max-width: 480px) {
    .pzc-root.is-open { right: 0; bottom: 0; left: 0; top: 0; }
    .pzc-root.is-open .pzc-panel { width: 100vw; height: 100%; border-radius: 0; border: 0; }
}

/* ── Térképoldal (/map/, MapLibre): a jobb alsó sarok egy oszlop, alulról felfelé:
      chat gomb → zoom/iránytű → saját gombok (pozíció, 3D, teljes képernyő);
      az attribúció a chat gomb mellé, balra kerül. Az osztályokat a js/support-chat.js
      teszi a <html>-re (pzc-map: van MapLibre térkép, pzc-map-v2: új megjelenés). ── */
html.pzc-map .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib { margin-right: 84px; }
html.pzc-map .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { margin-right: 16px; margin-bottom: 48px; }

@media (min-width: 1100px) {
    html.pzc-map-v2 .pz2m-mapctl { bottom: 196px; }
    /* A közeli állomások kártya a jobb sarok fölött van; a chat gomb a kártya
       bal szélére kerül, egy oszlopba a térkép ikonjaival (redesign.css). */
    html.pzc-map-v2.pz2-has-nearby .pzc-root:not(.is-open) { right: 456px; }
}

/* Telefon / táblagép álló: a chat gomb a kártyasáv fölött (JS: --pzc-offset = sáv magassága) */
@media (max-width: 1099px) and (min-height: 521px) {
    html.pzc-map-v2 .pzc-root:not(.is-open) { bottom: calc(12px + env(safe-area-inset-bottom) + var(--pzc-offset)); right: 12px; }
    html.pzc-map-v2 .pz2m-mapctl { bottom: calc(var(--pz2m-strip) + env(safe-area-inset-bottom) + 134px); }
    html.pzc-map-v2 .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { margin-right: 12px; margin-bottom: 44px; }
    html.pzc-map-v2 .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib { margin-right: 80px; }
    /* kiválasztott töltő: az alulról felcsúszó lap foglalja el az alját */
    html.pzc-map-v2.pz2-has-selection .pzc-root:not(.is-open) { display: none; }
}

/* Fekvő telefon: a jobb oldali állomáslista melletti keskeny szabad sávba, kisebb gombbal */
@media (max-width: 1099px) and (max-height: 520px) {
    html.pzc-map-v2 .pzc-root:not(.is-open) { right: 6px; bottom: calc(8px + env(safe-area-inset-bottom)); }
    html.pzc-map-v2 .pzc-root:not(.is-open) .pzc-launcher { width: 48px; height: 48px; }
    html.pzc-map-v2 .pzc-root:not(.is-open) .pzc-launcher svg { width: 24px; height: 24px; }
    html.pzc-map-v2 .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib,
    html.pzc-map-v2 .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group { margin-right: 10px; margin-bottom: 10px; }
}

@media print { .pzc-root { display: none !important; } }
