﻿/* Online chat — widget (launcher + okno). Brand barva přes --pkchat-barva. */
.pkchat { position: fixed; bottom: 20px; z-index: 2147482000; --pkchat-barva: #1565c0; }
.pkchat-vpravo { right: 20px; }
.pkchat-vlevo { left: 20px; }

.pkchat-launcher {
    width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--pkchat-barva); color: #fff; box-shadow: 0 4px 16px rgba(0,0,0,.25);
    position: relative; display: flex; align-items: center; justify-content: center;
    font-size: 26px; transition: transform .15s ease;
}
.pkchat-launcher:hover { transform: scale(1.06); }
.pkchat-launcher-ikona { line-height: 1; }
.pkchat-launcher-badge {
    position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px;
    background: #e53935; color: #fff; border-radius: 10px; font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center; box-sizing: border-box;
}

.pkchat-okno {
    position: absolute; bottom: 74px; width: 360px; max-width: calc(100vw - 40px);
    height: 520px; max-height: calc(100vh - 120px);
    background: #fff; color: #1a1a1a; border-radius: 14px; overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,.28); display: flex; flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; font-size: 14px;
}
.pkchat-vpravo .pkchat-okno { right: 0; }
.pkchat-vlevo .pkchat-okno { left: 0; }

.pkchat-hlavicka {
    background: var(--pkchat-barva); color: #fff; padding: 12px 14px;
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.pkchat-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; background: rgba(255,255,255,.25); }
.pkchat-hlavicka-text { flex: 1; min-width: 0; }
.pkchat-hlavicka-jmeno { font-weight: 700; }
.pkchat-hlavicka-stav { font-size: 12px; opacity: .9; }
.pkchat-stavovka.pkchat-on::before { content: "● "; color: #8affb0; }
.pkchat-stavovka.pkchat-off::before { content: "● "; color: #ffd0d0; }
.pkchat-zavrit { background: none; border: none; color: #fff; font-size: 24px; line-height: 1; cursor: pointer; padding: 0 4px; }

.pkchat-telo { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.pkchat-zpravy { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }

.pkchat-zprava { max-width: 82%; padding: 8px 11px; border-radius: 12px; line-height: 1.4; word-wrap: break-word; white-space: pre-wrap; }
.pkchat-zprava-text { }
.pkchat-zprava-cas { font-size: 10px; opacity: .55; margin-top: 3px; }
.pkchat-zprava-ja { align-self: flex-end; background: var(--pkchat-barva); color: #fff; border-bottom-right-radius: 3px; }
.pkchat-zprava-operator { align-self: flex-start; background: #eef1f5; color: #1a1a1a; border-bottom-left-radius: 3px; }
.pkchat-zprava-system { align-self: center; background: transparent; color: #888; font-size: 12px; text-align: center; max-width: 100%; }
.pkchat-typing { padding: 2px 14px 6px; font-size: 12px; color: #888; font-style: italic; }

.pkchat-paticka { border-top: 1px solid #e6e6e6; padding: 10px; }
.pkchat-psani { display: flex; gap: 8px; align-items: flex-end; }
.pkchat-psani-input { flex: 1; resize: none; border: 1px solid #ccc; border-radius: 18px; padding: 9px 12px; font: inherit; max-height: 100px; }
.pkchat-psani-input:focus { outline: 2px solid var(--pkchat-barva); outline-offset: -1px; }
.pkchat-psani-btn { background: var(--pkchat-barva); color: #fff; border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 16px; flex: 0 0 auto; }
.pkchat-psani-priloha { background: none; border: 1px solid #ccc; color: #555; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 16px; flex: 0 0 auto; }
.pkchat-psani-priloha:hover { background: #f0f0f0; }

/* Přílohy ve zprávě (obrázky náhled, PDF odkaz). */
.pkchat-prilohy { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.pkchat-priloha-obr { display: inline-block; max-width: 100%; }
.pkchat-priloha-obr img { max-width: 200px; max-height: 200px; border-radius: 8px; display: block; }
.pkchat-priloha-soubor { display: inline-flex; align-items: center; gap: 4px; background: rgba(0,0,0,.06); border-radius: 8px; padding: 6px 10px; font-size: 13px; text-decoration: none; color: inherit; word-break: break-all; }
.pkchat-priloha-soubor:hover { background: rgba(0,0,0,.12); }

.pkchat-form { display: flex; flex-direction: column; gap: 8px; }
.pkchat-pole input, .pkchat-pole textarea { width: 100%; box-sizing: border-box; border: 1px solid #ccc; border-radius: 8px; padding: 9px 11px; font: inherit; resize: vertical; }
.pkchat-pole input:focus, .pkchat-pole textarea:focus { outline: 2px solid var(--pkchat-barva); outline-offset: -1px; }
.pkchat-btn { background: var(--pkchat-barva); color: #fff; border: none; border-radius: 8px; padding: 10px; cursor: pointer; font: inherit; font-weight: 600; }
.pkchat-souhlas { display: flex; gap: 7px; align-items: flex-start; font-size: 12px; color: #555; }
.pkchat-souhlas + .pkchat-souhlas { margin-top: 4px; }
.pkchat-souhlas a { color: var(--pkchat-barva); text-decoration: underline; }
.pkchat-offline-uvod { font-size: 13px; color: #555; margin-bottom: 8px; }
.pkchat-offline-diky, .pkchat-csat-otazka { text-align: center; color: #2e7d32; padding: 8px; }
.pkchat-chyba { background: #fdecea; color: #b71c1c; border-radius: 6px; padding: 7px 9px; font-size: 12px; margin-bottom: 8px; }
.pkchat-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }

.pkchat-csat { text-align: center; padding: 6px; }
.pkchat-csat-btn { background: none; border: 1px solid #ccc; border-radius: 8px; font-size: 20px; padding: 4px 12px; margin: 4px; cursor: pointer; }

.pkchat-ukonceno { text-align: center; color: #888; font-size: 13px; padding: 2px 0 8px; }

/* Proaktivní teaser (nabídka pomoci nad launcherem). */
.pkchat-teaser { position: absolute; bottom: 74px; max-width: 260px; background: #fff; color: #1a1a1a; border-radius: 12px; padding: 12px 30px 12px 14px; box-shadow: 0 6px 24px rgba(0,0,0,.22); font-size: 14px; line-height: 1.35; cursor: pointer; }
.pkchat-vpravo .pkchat-teaser { right: 0; }
.pkchat-vlevo .pkchat-teaser { left: 0; }
.pkchat-teaser-zavrit { position: absolute; top: 3px; right: 6px; background: none; border: none; font-size: 18px; line-height: 1; color: #999; cursor: pointer; padding: 0 2px; }

/* Mobil: fullscreen okno. */
@media (max-width: 480px) {
    .pkchat { bottom: 12px; }
    .pkchat-vpravo { right: 12px; }
    .pkchat-vlevo { left: 12px; }
    .pkchat-okno {
        position: fixed; inset: 0; width: 100vw; max-width: 100vw; height: 100vh; max-height: 100vh;
        /* iOS Safari: 100vh je „velký" viewport (se sbaleným toolbarem) — patička by byla pod
           toolbarem/klávesnicí. Dynamická jednotka drží vstup viditelný; starší prohlížeče
           spadnou na 100vh výše. */
        height: 100dvh; max-height: 100dvh;
        border-radius: 0; bottom: 0;
        /* Vstupy ≥ 16 px (font: inherit), jinak iOS při fokusu zazoomuje celou stránku. */
        font-size: 16px;
    }
    /* Home indicator (safe area) nesmí ležet přes vstupní řádek. */
    .pkchat-paticka { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
    /* Gumování fullscreen chatu nesmí scrollovat stránku pod ním. */
    .pkchat-zpravy { overscroll-behavior: contain; }
}

/* Tmavý režim (respektuje systémové nastavení). */
@media (prefers-color-scheme: dark) {
    .pkchat-okno { background: #1f2229; color: #e8e8e8; }
    .pkchat-zprava-operator { background: #2c313a; color: #e8e8e8; }
    .pkchat-paticka { border-top-color: #333; }
    .pkchat-pole input, .pkchat-pole textarea, .pkchat-psani-input { background: #2c313a; color: #e8e8e8; border-color: #444; }
    .pkchat-chyba { background: #3a1f1f; color: #ff9a9a; }
    /* Šedé doprovodné texty (#555/#888) mají na tmavém podkladu kontrast ~2:1 — zesvětlit. */
    .pkchat-souhlas, .pkchat-offline-uvod, .pkchat-typing, .pkchat-ukonceno, .pkchat-zprava-system { color: #b7bcc5; }
    .pkchat-psani-priloha { color: #b7bcc5; border-color: #444; }
    .pkchat-psani-priloha:hover { background: #2c313a; }
    .pkchat-priloha-soubor { background: rgba(255,255,255,.08); }
    .pkchat-csat-btn { border-color: #444; }
    .pkchat-teaser { background: #2c313a; color: #e8e8e8; }
}
