/* Tessora chat widget — bronze-themed floating panel, left-bottom anchored. */

.tess-chat-root {
    position: fixed;
    left: 24px;
    bottom: 24px;
    z-index: 9998;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.4;
}

.tess-chat-fab {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(138.54deg, #A8683D 0%, #C7875D 94.53%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
    transition: transform .25s ease, box-shadow .25s ease;
    padding: 0;
}
.tess-chat-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .32);
}
.tess-chat-fab:focus-visible {
    outline: 2px solid #C7875D;
    outline-offset: 3px;
}
.tess-chat-fab__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #C7875D;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #1d1a17;
}

.tess-chat-panel {
    position: absolute;
    left: 0;
    bottom: 72px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #1d1a17;
    color: #ececec;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 16px 48px rgba(0, 0, 0, .45);
    border: 1px solid rgba(168, 104, 61, .35);
    transform-origin: bottom left;
    transform: scale(.92) translateY(8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
}
.tess-chat-panel[hidden] { display: flex; }
.tess-chat-root[data-state="open"] .tess-chat-panel {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}
.tess-chat-root[data-state="closed"] .tess-chat-panel { visibility: hidden; }
.tess-chat-root[data-state="open"] .tess-chat-panel { visibility: visible; }

.tess-chat-panel__header {
    padding: 16px;
    background: linear-gradient(138.54deg, #A8683D 0%, #C7875D 94.53%);
    color: #fff;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex: 0 0 auto;
}
.tess-chat-panel__heading { min-width: 0; }
.tess-chat-panel__title {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}
.tess-chat-panel__subtitle {
    font-size: 12px;
    opacity: .85;
    margin-top: 3px;
}
.tess-chat-panel__close {
    background: rgba(0, 0, 0, .18);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0;
    transition: background .2s ease;
}
.tess-chat-panel__close:hover { background: rgba(0, 0, 0, .32); }

.tess-chat-panel__messages {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #1d1a17;
}
.tess-chat-panel__messages::-webkit-scrollbar { width: 6px; }
.tess-chat-panel__messages::-webkit-scrollbar-thumb { background: rgba(168, 104, 61, .4); border-radius: 3px; }

.tess-chat-msg {
    max-width: 84%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 12px;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.tess-chat-msg--visitor[data-status]::after {
    display: block;
    font-size: 9px;
    text-align: right;
    margin-top: 3px;
    opacity: .8;
    letter-spacing: .2px;
    color: rgba(255, 255, 255, .95);
}
.tess-chat-msg--visitor[data-status="sent"]::after { content: 'Wysłano'; }
.tess-chat-msg--visitor[data-status="read"]::after { content: 'Odczytano ✓'; }
.tess-chat-msg--visitor {
    align-self: flex-end;
    background: linear-gradient(138.54deg, #A8683D 0%, #C7875D 94.53%);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.tess-chat-msg--manager {
    align-self: flex-start;
    background: #2c2724;
    color: #ececec;
    border-bottom-left-radius: 4px;
}
.tess-chat-msg--system {
    align-self: center;
    background: transparent;
    color: #9d9690;
    font-size: 12px;
    text-align: center;
    padding: 4px 8px;
    max-width: 100%;
}

.tess-chat-panel__form {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    background: #16130f;
    align-items: flex-end;
    flex: 0 0 auto;
}
.tess-chat-panel__form textarea {
    flex: 1 1 auto;
    background: #2c2724;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 10px;
    color: #ececec;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    min-height: 40px;
    outline: none;
    line-height: 1.4;
    transition: border-color .2s ease;
}
.tess-chat-panel__form textarea:focus { border-color: #A8683D; }
.tess-chat-panel__form textarea::placeholder { color: #6f6862; }

.tess-chat-panel__send {
    background: linear-gradient(138.54deg, #A8683D 0%, #C7875D 94.53%);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0;
    transition: opacity .2s ease;
}
.tess-chat-panel__send:disabled { opacity: .4; cursor: not-allowed; }

.tess-chat-panel__gdpr {
    font-size: 11px;
    color: #9d9690;
    padding: 8px 14px 12px;
    line-height: 1.45;
    background: #16130f;
}
.tess-chat-panel__gdpr a { color: #C7875D; text-decoration: underline; }
.tess-chat-panel__gdpr a:hover { color: #d99e7a; }

/* Optional name prompt — injected dynamically inside panel above messages. */
.tess-chat-name-prompt {
    padding: 12px 14px;
    background: rgba(168, 104, 61, .12);
    border-bottom: 1px solid rgba(168, 104, 61, .2);
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
}
.tess-chat-name-prompt label {
    font-size: 12px;
    color: #d6cec5;
}
.tess-chat-name-prompt input {
    background: #2c2724;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 8px;
    color: #ececec;
    padding: 8px 10px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color .2s ease;
}
.tess-chat-name-prompt input:focus { border-color: #A8683D; }
.tess-chat-name-prompt__row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
.tess-chat-name-prompt__btn {
    background: transparent;
    border: 1px solid rgba(168, 104, 61, .5);
    color: #C7875D;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: background .2s ease, color .2s ease;
}
.tess-chat-name-prompt__btn:hover { background: rgba(168, 104, 61, .15); }
.tess-chat-name-prompt__btn--primary {
    background: linear-gradient(138.54deg, #A8683D 0%, #C7875D 94.53%);
    border-color: transparent;
    color: #fff;
}
.tess-chat-name-prompt__btn--primary:hover { opacity: .92; background: linear-gradient(138.54deg, #A8683D 0%, #C7875D 94.53%); }

@media (max-width: 480px) {
    .tess-chat-root { left: 16px; bottom: 16px; }
    .tess-chat-fab { width: 52px; height: 52px; }
    /* Hide FAB while panel is open — panel is fullscreen, FAB would just hover over it. */
    .tess-chat-root[data-state="open"] .tess-chat-fab { display: none; }

    /* Fullscreen panel: pinned to viewport edges, sized via 100dvh so iOS Safari
     * keyboard show/hide reflows the panel (not the body) without jumping.
     * Max z-index so site sticky header / logo can never overlap our header. */
    .tess-chat-panel {
        position: fixed;
        top: var(--tess-chat-top-offset, 0px);
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: none;
        height: auto;
        max-height: none;
        border-radius: 0;
        border: none;
        z-index: 2147483647;
        transform: translateY(20px);
        transform-origin: center;
    }
    .tess-chat-root[data-state="open"] .tess-chat-panel {
        transform: translateY(0);
    }
    .tess-chat-panel__form {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    .tess-chat-panel__gdpr {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}

/* Body scroll lock — applied by JS only on mobile when panel is open.
 * position:fixed prevents iOS rubber-band scrolling; JS preserves scrollY. */
body.tess-chat-locked {
    position: fixed;
    width: 100%;
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .tess-chat-fab,
    .tess-chat-panel { transition: none; }
}

/* ===== Light theme overrides — match site Bootstrap data-bs-theme="light" ===== */
[data-bs-theme="light"] .tess-chat-fab__badge {
    box-shadow: 0 0 0 2px #fff;
}
[data-bs-theme="light"] .tess-chat-panel {
    background: #ffffff;
    color: #1d1a17;
    border-color: rgba(168, 104, 61, .25);
    box-shadow: 0 16px 48px rgba(0, 0, 0, .18);
}
[data-bs-theme="light"] .tess-chat-panel__messages {
    background: #ffffff;
}
[data-bs-theme="light"] .tess-chat-panel__messages::-webkit-scrollbar-thumb {
    background: rgba(168, 104, 61, .3);
}
[data-bs-theme="light"] .tess-chat-msg--manager {
    background: #f9f0e7;
    color: #000000;
}
[data-bs-theme="light"] .tess-chat-msg--system {
    color: #888;
}
[data-bs-theme="light"] .tess-chat-panel__form {
    background: #faf6f1;
    border-top-color: rgba(0, 0, 0, .06);
}
[data-bs-theme="light"] .tess-chat-panel__form textarea {
    background: #ffffff;
    border-color: rgba(0, 0, 0, .12);
    color: #1d1a17;
}
[data-bs-theme="light"] .tess-chat-panel__form textarea::placeholder {
    color: #aaa;
}
[data-bs-theme="light"] .tess-chat-panel__gdpr {
    background: #faf6f1;
    color: #777;
}
[data-bs-theme="light"] .tess-chat-panel__gdpr a {
    color: #A8683D;
}
[data-bs-theme="light"] .tess-chat-name-prompt {
    background: rgba(168, 104, 61, .06);
    border-bottom-color: rgba(168, 104, 61, .15);
}
[data-bs-theme="light"] .tess-chat-name-prompt label {
    color: #555;
}
[data-bs-theme="light"] .tess-chat-name-prompt input {
    background: #ffffff;
    border-color: rgba(0, 0, 0, .12);
    color: #1d1a17;
}
