/* ------------------------------------------------------------------
   Czat na stronie (przegrody.pl -> Telegram)
   Styl trzyma się zieleni serwisu (#2ecc71) i nie zależy od Bootstrapa.
   Wszystko pod #pchat, żeby nie wchodzić w drogę motywowi.
   ------------------------------------------------------------------ */

#pchat,
#pchat * {
    box-sizing: border-box;
}

#pchat {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 10000;
    font-family: 'Open Sans', 'Lato', Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    /* iOS potrafi samo rozdmuchac tekst w waskich blokach */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Odsuniecie od paska cookies ustawia JS inline (syncCookieOffset),
   bo wysokosc paska zmienia sie z szerokoscia ekranu. */

/* Otwarty panel jest w praktyce okienkiem modalnym i musi przebic dwie rzeczy
   ze strony: pasek cookies (z-index 10001) oraz przyklejony naglowek serwisu
   #modernHeader (position: sticky, z-index 99999). Bez tego na telefonie, gdzie
   panel idzie na caly ekran, pasek zaslania pole pisania, a naglowek serwisu
   zaslania naglowek czatu. Zostajemy pod globalnym powiadomieniem z ustawien
   (#global-notice-overlay, 100050) - to okienko modalne i ma byc na wierzchu.
   Zamkniety babel wraca do 10000, zeby nie zakrywac zgody na cookies. */
#pchat.pchat-open {
    z-index: 100000;
}

/* --- Przycisk otwierający --- */

#pchat-launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 22px 0 18px;
    border: none;
    border-radius: 28px;
    background: #2ecc71;
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}

#pchat-launcher:hover {
    background: #27ae60;
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

#pchat-launcher:focus-visible {
    outline: 3px solid #145a32;
    outline-offset: 2px;
}

#pchat-launcher .pchat-icon {
    font-size: 20px;
    line-height: 1;
}

#pchat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: #e74c3c;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 22px;
    text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

/* --- Panel --- */

#pchat-panel {
    display: flex;
    flex-direction: column;
    width: 370px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

#pchat[hidden],
#pchat-panel[hidden],
#pchat-launcher[hidden],
#pchat-badge[hidden],
#pchat-intro[hidden],
#pchat-thread[hidden],
#pchat-emailbox[hidden],
#pchat-error[hidden] {
    display: none !important;
}

.pchat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: #2ecc71;
    color: #fff;
}

.pchat-header strong {
    display: block;
    font-size: 15px;
    font-weight: 700;
}

.pchat-header .pchat-sub {
    font-size: 12px;
    opacity: 0.9;
}

#pchat-close {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

#pchat-close:hover {
    background: rgba(255, 255, 255, 0.32);
}

.pchat-body {
    flex: 1 1 auto;
    padding: 16px;
    overflow-y: auto;
    background: #f7f8f9;
    -webkit-overflow-scrolling: touch;
}

/* --- Ekran startowy --- */

#pchat-intro p {
    margin: 0 0 12px;
    color: #555;
}

#pchat-intro label {
    display: block;
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 600;
    color: #666;
}

/* WAZNE: kazde pole w widgecie ma min. 16px.
   iOS (Safari i Chrome, bo to ten sam WebKit) sam przybliza strone przy
   kliknieciu w pole z czcionka < 16px, a po takim przyblizeniu strona
   ZOSTAJE powiekszona - i panel przestaje sie miescic w widocznym obszarze.
   To byla pierwotna przyczyna "za szerokiego czatu" na telefonie. */
#pchat input,
#pchat textarea {
    font-size: 16px;
}

#pchat-intro input {
    width: 100%;
    margin: 0 0 10px;
    padding: 9px 12px;
    border: 1px solid #dcdfe2;
    border-radius: 6px;
    font-family: inherit;
    background: #fff;
}

#pchat-intro input:focus,
#pchat-input:focus,
#pchat-email:focus {
    border-color: #2ecc71;
    outline: none;
}

#pchat-intro textarea {
    width: 100%;
    margin: 0 0 12px;
    padding: 9px 12px;
    border: 1px solid #dcdfe2;
    border-radius: 6px;
    font-family: inherit;
    line-height: 1.4;
    background: #fff;
    resize: vertical;
}

.pchat-hint {
    font-size: 12px;
    color: #8a9098;
}

/* --- Wątek rozmowy --- */

.pchat-msg {
    max-width: 85%;
    margin: 0 0 10px;
    padding: 9px 13px;
    border-radius: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

.pchat-msg-in {
    margin-left: auto;
    border-bottom-right-radius: 4px;
    background: #2ecc71;
    color: #fff;
}

.pchat-msg-out {
    margin-right: auto;
    border-bottom-left-radius: 4px;
    background: #fff;
    border: 1px solid #e6e8ea;
}

.pchat-meta {
    margin: -4px 0 12px;
    font-size: 11px;
    color: #9aa0a6;
}

.pchat-meta-in {
    text-align: right;
}

.pchat-system {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fdf6e3;
    border: 1px solid #f2e2b8;
    font-size: 13px;
    color: #7a6321;
}

/* --- Prośba o e-mail --- */

#pchat-emailbox {
    margin: 0 0 12px;
    padding: 12px;
    border: 1px solid #e6e8ea;
    border-radius: 8px;
    background: #fff;
}

#pchat-emailbox p {
    margin: 0 0 8px;
    font-size: 13px;
    color: #555;
}

#pchat-emailbox .pchat-email-row {
    display: flex;
    gap: 8px;
}

#pchat-email {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #dcdfe2;
    border-radius: 6px;
    font-family: inherit;
}

/* --- Stopka z polem wpisywania --- */

.pchat-footer {
    flex: 0 0 auto;
    padding: 12px;
    border-top: 1px solid #e6e8ea;
    background: #fff;
}

.pchat-inputrow {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

#pchat-input {
    flex: 1 1 auto;
    min-width: 0;
    max-height: 120px;
    padding: 10px 12px;
    border: 1px solid #dcdfe2;
    border-radius: 8px;
    font-family: inherit;
    /* 16px to prog, ponizej ktorego iOS sam przybliza strone przy fokusie */
    font-size: 16px;
    line-height: 1.4;
    resize: none;
}

.pchat-btn {
    flex: 0 0 auto;
    padding: 10px 18px;
    border: none;
    border-radius: 8px;
    background: #2ecc71;
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.pchat-btn:hover:not(:disabled) {
    background: #27ae60;
}

/* Na szerokim ekranie wystarczy slowo, ikona dubluje przekaz */
#pchat-send .fa-paper-plane {
    display: none;
}

.pchat-btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.pchat-btn-block {
    display: block;
    width: 100%;
}

#pchat-error {
    margin: 8px 0 0;
    font-size: 12px;
    color: #c0392b;
}

.pchat-privacy {
    margin: 8px 0 0;
    font-size: 11px;
    color: #9aa0a6;
    text-align: center;
}

.pchat-privacy a {
    color: #2ecc71;
}

/* Honeypot - dla ludzi niewidoczne, dla botów zachęta */
.pchat-hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
}

/* --- Telefon: panel na cały ekran --- */

@media (max-width: 600px) {
    #pchat {
        right: 16px;
        bottom: 16px;
    }

    /* Panel na caly ekran. Rozmiar bierze sie z krawedzi kontenera, NIE z
       jednostek vw - przy powiekszonej stronie w Safari 100vw jest szersze
       niz to, co widac, i panel wychodzil za prawa krawedz. Dokladny obszar
       widoczny nadpisuje JS przez VisualViewport (syncVisualViewport). */
    #pchat.pchat-open {
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
    }

    #pchat.pchat-open #pchat-panel {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    /* Na waskim ekranie kazdy piksel na tekst sie liczy */
    .pchat-msg {
        max-width: 92%;
    }

    .pchat-body {
        padding: 12px;
    }

    /* Slowo "Wyslij" zjadalo pol wiersza - zostaje sama ikona */
    #pchat-send .pchat-send-label {
        display: none;
    }

    #pchat-send .fa-paper-plane {
        display: inline;
        font-size: 16px;
    }

    #pchat-send {
        padding: 12px 16px;
    }

    .pchat-privacy {
        font-size: 10px;
    }

    #pchat-launcher span.pchat-label {
        display: none;
    }

    #pchat-launcher {
        width: 56px;
        padding: 0;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    #pchat-launcher {
        transition: none;
    }

    #pchat-launcher:hover {
        transform: none;
    }
}
