/* Okno rozmowy.
   buttons.css i widget.css są ładowane osobno przez WordPressa, z numerem wersji.
   Przy @import przeglądarka pobierała je BEZ wersji i trzymała starą kopię
   w nieskończoność — poprawki wyglądu nigdy nie docierały. */

:root {
    --pixelis-bot-primary-color: #4CAF50;
    --pixelis-bot-primary-dark: #2e7d32;
    --pixelis-bot-primary-soft: rgba(76, 175, 80, .14);
    --pixelis-bot-user-msg-bg: #DCF8C6;
    --pixelis-bot-bot-msg-bg: #f1f0f0;
    --pixelis-bot-text-color: #1f2933;
    --pixelis-bot-muted-color: #667085;
    --pixelis-bot-bg-color: #ffffff;
    --pixelis-bot-border-color: #e6e8ec;
    --pixelis-bot-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------------------------------------------------------------
   Kontener
   --------------------------------------------------------------- */

#pixelis-bot-chat-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 32px);
    /* Okno nigdy nie wychodzi nad górną krawędź ekranu. Stała wysokość 500 px
       przy niskim oknie przeglądarki (telefon w poziomie, laptop z paskami)
       wypychała nagłówek poza ekran i czatu nie dało się zamknąć. */
    height: 600px;
    max-height: calc(100vh - var(--pixelis-bot-bottom, 20px) - 24px);
    border: 1px solid rgba(15, 23, 42, .08);
    border-radius: 18px;
    box-shadow: 0 28px 64px -16px rgba(15, 23, 42, .38), 0 4px 14px rgba(15, 23, 42, .08);
    font-family: var(--pixelis-bot-font) !important;
    font-size: 15px;
    line-height: 1.5;
    color: var(--pixelis-bot-text-color);
    display: flex;
    flex-direction: column;
    background: var(--pixelis-bot-bg-color);
    overflow: hidden;
    z-index: 99990;
    visibility: visible;
    transition: transform .28s cubic-bezier(.2, .9, .3, 1), opacity .2s ease, visibility 0s linear 0s;
    transform-origin: bottom right;
}

/* visibility z opóźnieniem: zamknięte okno znika z czytnika ekranu
   i z kolejności Tab dopiero po skończonej animacji. */
#pixelis-bot-chat-container.minimized {
    transform: translateY(18px) scale(.96);
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: transform .22s ease-in, opacity .18s ease-in, visibility 0s linear .22s;
}

/* ---------------------------------------------------------------
   Nagłówek
   --------------------------------------------------------------- */

#pixelis-bot-chat-header {
    background: var(--pixelis-bot-primary-color);
    color: #fff;
    padding: 12px 8px 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 68px;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.pixelis-bot-header-text {
    flex: 1;
    min-width: 0;
}

.pixelis-bot-header-title {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

/* Kolor i krój jawnie: motyw (Elementor) nadaje nagłówkom h2 własny kolor,
   krój i WERSALIKI — nazwa bota wychodziła ciemna na niebieskim tle. */
#pixelis-bot-chat-header #pixelis-bot-title {
    margin: 0 !important;
    padding: 0;
    font-size: 16px !important;
    font-weight: 650;
    line-height: 1.25 !important;
    color: #fff !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#pixelis-bot-status {
    margin: 2px 0 0 !important;
    padding: 0;
    font-size: 12.5px;
    line-height: 1.3;
    color: rgba(255, 255, 255, .88);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#pixelis-bot-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-inline-start: auto;
    flex-shrink: 0;
}

/* 40 px to minimum na palec. Wcześniej zwijanie miało rozmiar samej ikony (20 px). */
#pixelis-bot-header-actions button {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: .92;
    transition: background-color .15s, opacity .15s;
    -webkit-tap-highlight-color: transparent;
}

#pixelis-bot-header-actions button:hover,
#pixelis-bot-header-actions button:focus-visible {
    background: rgba(255, 255, 255, .18);
    opacity: 1;
    outline: none;
}

/* ---------------------------------------------------------------
   Rozmowa
   --------------------------------------------------------------- */

#pixelis-bot-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    /* Przewijanie rozmowy do końca nie przewija strony pod spodem. */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--pixelis-bot-bg-color);
}

/* Informacja "to bot" jako pierwsza linijka rozmowy. */
#pixelis-bot-chat-messages #pixelis-bot-ai-note {
    align-self: center;
    max-width: 88%;
    margin: 0 0 2px !important;
    padding: 0 8px;
    color: var(--pixelis-bot-muted-color);
    font-size: 12px !important;
    line-height: 1.45 !important;
    text-align: center;
}

.pixelis-bot-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

.pixelis-bot-row--user {
    justify-content: flex-end;
}

.pixelis-bot-msg-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .18);
    line-height: 0;
}

.pixelis-bot-msg-avatar img,
.pixelis-bot-msg-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

/* Kilka odpowiedzi pod rząd: awatar tylko przy pierwszej, reszta trzyma wcięcie. */
.pixelis-bot-row--bot + .pixelis-bot-row--bot .pixelis-bot-msg-avatar {
    visibility: hidden;
}

.pixelis-bot-message {
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 85%;
    font-size: 15px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-wrap: break-word;
}

.pixelis-bot-row--bot .pixelis-bot-message {
    max-width: calc(100% - 36px);
}

.pixelis-bot-user-message {
    background: var(--pixelis-bot-user-msg-bg);
    color: var(--pixelis-bot-text-color);
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}

.pixelis-bot-bot-message {
    background: var(--pixelis-bot-bot-msg-bg);
    color: var(--pixelis-bot-text-color);
    align-self: flex-start;
    border-bottom-left-radius: 6px;
}

/* Markdown w odpowiedzi. Marginesy jawnie: motyw daje akapitom i listom
   własne odstępy — pod ostatnim akapitem zostawała pusta linijka w dymku. */
#pixelis-bot-chat-messages .pixelis-bot-message p,
#pixelis-bot-chat-messages .pixelis-bot-message ul,
#pixelis-bot-chat-messages .pixelis-bot-message ol {
    margin: 0 0 .6em;
    padding: 0;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

#pixelis-bot-chat-messages .pixelis-bot-message ul,
#pixelis-bot-chat-messages .pixelis-bot-message ol {
    padding-left: 1.2em;
}

#pixelis-bot-chat-messages .pixelis-bot-message li {
    margin: .2em 0;
    padding: 0;
    font-size: inherit;
    line-height: inherit;
}

#pixelis-bot-chat-messages .pixelis-bot-message > :last-child {
    margin-bottom: 0;
}

#pixelis-bot-chat-messages .pixelis-bot-message strong {
    font-weight: 650;
}

#pixelis-bot-chat-messages .pixelis-bot-message a {
    color: var(--pixelis-bot-primary-dark);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

/* Numer telefonu nie może się łamać w połowie. */
#pixelis-bot-chat-messages .pixelis-bot-message a[href^="tel:"] {
    white-space: nowrap;
}

/* ---------------------------------------------------------------
   Źródła pod odpowiedzią
   --------------------------------------------------------------- */

.pixelis-bot-sources {
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid rgba(15, 23, 42, .08);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pixelis-bot-sources-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--pixelis-bot-muted-color);
}

#pixelis-bot-chat-messages .pixelis-bot-sources a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .8);
    border: 1px solid rgba(15, 23, 42, .08);
    color: var(--pixelis-bot-text-color);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    text-decoration: none;
    transition: border-color .15s, background-color .15s;
}

#pixelis-bot-chat-messages .pixelis-bot-sources a:hover {
    border-color: var(--pixelis-bot-primary-color);
    background: #fff;
}

.pixelis-bot-sources a::before {
    content: "";
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    background: var(--pixelis-bot-primary-color);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='8' y1='13' x2='16' y2='13'/%3E%3Cline x1='8' y1='17' x2='13' y2='17'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3Cline x1='8' y1='13' x2='16' y2='13'/%3E%3Cline x1='8' y1='17' x2='13' y2='17'/%3E%3C/svg%3E") center / contain no-repeat;
}

.pixelis-bot-source-title {
    flex: 1;
    min-width: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------------------------------------------------------------
   Podpowiedzi w rozmowie (pod powitaniem, zanim padnie pierwsze pytanie)
   --------------------------------------------------------------- */

.pixelis-bot-suggestions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
    padding-left: 36px;
}

.pixelis-bot-suggestions-label {
    font-size: 12px;
    color: var(--pixelis-bot-muted-color);
    margin: 2px 0 0;
}

#pixelis-bot-chat-container .pixelis-bot-suggestions .pixelis-bot-chip {
    display: inline-block;
    width: auto;
    max-width: 100%;
    padding: 8px 14px !important;
    border: 1px solid var(--pixelis-bot-primary-color);
    border-radius: 18px;
    background: #fff;
    color: var(--pixelis-bot-primary-dark);
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    white-space: normal;
    cursor: pointer;
    transition: background-color .15s, color .15s;
    -webkit-tap-highlight-color: transparent;
}

#pixelis-bot-chat-container .pixelis-bot-suggestions .pixelis-bot-chip:hover,
#pixelis-bot-chat-container .pixelis-bot-suggestions .pixelis-bot-chip:focus-visible {
    background: var(--pixelis-bot-primary-color);
    color: #fff;
    outline: none;
}

/* ---------------------------------------------------------------
   Wskaźnik pisania
   --------------------------------------------------------------- */

.pixelis-bot-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
}

.pixelis-bot-typing-bubble {
    background: var(--pixelis-bot-bot-msg-bg);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    padding: 14px 16px;
}

.pixelis-bot-typing-bubble .pixelis-bot-typing-indicator {
    padding: 0;
}

.pixelis-bot-typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9aa3ae;
    animation: pixelis-bot-bounce 1.2s infinite ease-in-out;
}

.pixelis-bot-typing-indicator span:nth-child(2) { animation-delay: .15s; }
.pixelis-bot-typing-indicator span:nth-child(3) { animation-delay: .3s; }

@keyframes pixelis-bot-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ---------------------------------------------------------------
   Pole pisania
   --------------------------------------------------------------- */

#pixelis-bot-chat-input-container {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--pixelis-bot-border-color);
    background: var(--pixelis-bot-bg-color);
    flex-shrink: 0;
}

.pixelis-bot-field {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0 6px 0 4px;
    border: 1.5px solid transparent;
    border-radius: 24px;
    background: #f1f3f6;
    transition: border-color .15s, background-color .15s, box-shadow .15s;
}

.pixelis-bot-field:focus-within {
    background: #fff;
    border-color: var(--pixelis-bot-primary-color);
    box-shadow: 0 0 0 3px var(--pixelis-bot-primary-soft);
}

/* '!important' przy obramowaniu, tle i wysokości: motywy stylują input[type=text]
   globalnie (ramka, cień, wysokość 50 px), a pole ma wyglądać jak część kapsuły. */
#pixelis-bot-chat-container #pixelis-bot-chat-input {
    flex: 1;
    min-width: 0;
    width: auto;
    height: 44px !important;
    margin: 0;
    padding: 0 10px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none;
    font-size: 15px !important;
    line-height: 44px;
    color: var(--pixelis-bot-text-color);
    -webkit-appearance: none;
    appearance: none;
}

#pixelis-bot-chat-input::placeholder {
    color: #8a929c;
    opacity: 1;
}

#pixelis-bot-chat-input:disabled {
    background: transparent !important;
    opacity: .6;
}

#pixelis-bot-chat-send {
    background: var(--pixelis-bot-primary-color);
    border: none;
    color: #fff;
    border-radius: 50%;
    /* 46 px = wygodny cel dla palca i wyraźny sygnał "tu się wysyła" */
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 6px 14px -6px rgba(15, 23, 42, .45);
    transition: filter .15s, transform .15s;
    -webkit-tap-highlight-color: transparent;
}

#pixelis-bot-chat-send:active:not(:disabled) {
    transform: scale(.94);
}

/* Wyszarzany jest TYLKO w trakcie wysyłania. Przy pustym polu zostaje aktywny,
   żeby było widać, gdzie się klika, żeby wysłać wiadomość. */
#pixelis-bot-chat-send:disabled {
    background: #c3c9d0;
    box-shadow: none;
    cursor: default;
}

#pixelis-bot-chat-send:hover:not(:disabled) {
    filter: brightness(.93);
}

#pixelis-bot-chat-send:focus-visible {
    outline: 3px solid var(--pixelis-bot-primary-soft);
    outline-offset: 2px;
}

#pixelis-bot-chat-send svg {
    width: 21px;
    height: 21px;
    /* ikona samolotu jest optycznie przesunięta w prawo — korekta na oko środka */
    margin-right: 2px;
}

/* Zabezpieczenie: nawet gdyby przeglądarka trzymała starą kopię buttons.css,
   pływający przycisk nie może zasłaniać przycisku wysyłania. */
#pixelis-bot-open-icon.is-open {
    display: none !important;
}
