/*
 * Kiwi Web Chat — CSP-safe public widget styles.
 *
 * Kept in a standalone stylesheet because the public website intentionally
 * blocks inline <style> elements with its Content-Security-Policy.
 * All selectors are scoped to the kwc- prefix so these rules do not leak into
 * the host website, and the host website's typography cannot distort the chat.
 */

.kwc-panel,
.kwc-panel * {
    box-sizing: border-box;
}

.kwc-panel[hidden] {
    display: none !important;
}

.kwc-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2147483000;
    display: none;
    width: 390px;
    max-width: calc(100vw - 32px);
    height: min(580px, calc(100vh - 40px));
    max-height: calc(100vh - 40px);
    overflow: hidden;
    flex-direction: column;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(20, 39, 28, .12);
    border-radius: 20px;
    background: #fff;
    color: #14271c;
    box-shadow: 0 24px 70px rgba(12, 41, 25, .24), 0 4px 18px rgba(12, 41, 25, .10);
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: normal;
    text-align: left;
}

.kwc-panel.is-open {
    display: flex;
}

.kwc-panel button,
.kwc-panel input,
.kwc-panel textarea {
    font: inherit;
    letter-spacing: normal;
}

.kwc-head {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 11px;
    min-height: 76px;
    padding: 14px 16px;
    background: #173f29;
    color: #fff;
}

.kwc-head-text {
    min-width: 0;
    flex: 1;
}

.kwc-head h2 {
    margin: 0;
    padding: 0;
    color: #fff;
    font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    font-weight: 750;
    line-height: 1.25;
    letter-spacing: -.01em;
}

.kwc-head p {
    margin: 3px 0 0;
    padding: 0;
    color: rgba(255, 255, 255, .78);
    font-size: 12px;
    line-height: 1.35;
}

.kwc-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #8aa79a;
}

.kwc-dot.is-on {
    background: #83e45b;
    box-shadow: 0 0 0 4px rgba(131, 228, 91, .18);
}

.kwc-x {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 11px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 25px;
    font-weight: 400;
    line-height: 1;
}

.kwc-x:hover {
    background: rgba(255, 255, 255, .12);
}

.kwc-x:focus-visible,
.kwc-send:focus-visible {
    outline: 3px solid #83e45b;
    outline-offset: 2px;
}

.kwc-body {
    display: flex;
    min-height: 0;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 9px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px;
    background: #f5f8f5;
}

.kwc-greet {
    max-width: 88%;
    align-self: flex-start;
    margin: 0;
    padding: 10px 13px;
    border: 1px solid #cfe5d8;
    border-radius: 15px 15px 15px 5px;
    background: #e8f3ec;
    color: #263a2f;
    font-size: 14px;
    line-height: 1.45;
}

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

.kwc-msg.them {
    align-self: flex-start;
    border: 1px solid #dce5de;
    border-bottom-left-radius: 5px;
    background: #fff;
    color: #14271c;
}

.kwc-msg.you {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    background: #087d3b;
    color: #fff;
}

.kwc-msg.sys {
    max-width: 100%;
    align-self: center;
    padding-block: 5px;
    background: transparent;
    color: #69766f;
    font-size: 12.5px;
    text-align: center;
}

.kwc-time {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.25;
    opacity: .65;
}

.kwc-typing {
    display: flex;
    align-self: flex-start;
    gap: 4px;
    padding: 10px 14px;
    border: 1px solid #dce5de;
    border-radius: 14px;
    background: #fff;
}

.kwc-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #8aa79a;
    animation: kwcBounce 1.2s infinite;
}

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

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

.kwc-foot {
    flex: 0 0 auto;
    margin: 0;
    padding: 11px;
    border-top: 1px solid #e2e9e4;
    background: #fff;
}

.kwc-err {
    margin: 0 0 9px;
    padding: 8px 10px;
    border: 1px solid #f0c2c2;
    border-radius: 9px;
    background: #fff3f3;
    color: #a32020;
    font-size: 13px;
    line-height: 1.4;
}

.kwc-err[hidden] {
    display: none !important;
}

.kwc-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    margin: 0 0 8px;
}

.kwc-foot input,
.kwc-foot textarea {
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 10px 12px;
    border: 1.5px solid #d5dfd8;
    border-radius: 10px;
    outline: 0;
    background: #fff;
    color: #14271c;
    box-shadow: none;
    font-size: 16px;
    line-height: 1.35;
}

.kwc-foot textarea {
    min-height: 46px;
    max-height: 110px;
    resize: none;
}

.kwc-foot input::placeholder,
.kwc-foot textarea::placeholder {
    color: #758078;
    opacity: 1;
}

.kwc-foot input:focus,
.kwc-foot textarea:focus {
    border-color: #087d3b;
    outline: none;
    box-shadow: 0 0 0 3px rgba(8, 125, 59, .12);
}

.kwc-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.kwc-row textarea {
    flex: 1 1 auto;
}

.kwc-send {
    display: grid;
    width: 46px;
    min-width: 46px;
    height: 46px;
    flex: 0 0 46px;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 12px;
    background: #087d3b;
    color: #fff;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
}

.kwc-send:hover:not(:disabled) {
    background: #173f29;
}

.kwc-send:disabled {
    cursor: not-allowed;
    opacity: .42;
}

.kwc-note {
    margin: 8px 2px 0;
    padding: 0;
    color: #69766f;
    font-size: 11.5px;
    line-height: 1.4;
    text-align: center;
}

@media (max-width: 520px) {
    .kwc-panel {
        right: 8px;
        bottom: 8px;
        width: calc(100vw - 16px);
        max-width: calc(100vw - 16px);
        height: min(620px, calc(100dvh - 16px));
        max-height: calc(100dvh - 16px);
        border-radius: 18px;
    }
}

@media (max-width: 420px) {
    .kwc-panel {
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-width: 0;
        border-radius: 0;
    }

    .kwc-fields {
        grid-template-columns: 1fr;
    }

    .kwc-head {
        min-height: 70px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .kwc-typing span {
        animation: none;
    }
}
