/* fatihkovka.ru — виджет заявки (низкий левый угол, фирменный красный). */

#fatih-chat {
    --fk-red: #c60000;
    --fk-red-dark: #9c0000;
    --fk-ink: #1f2124;
    --fk-line: #e6e6e6;
    position: fixed;
    left: max(18px, env(safe-area-inset-left));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 2147483000;
    font-family: inherit;
    color: var(--fk-ink);
    -webkit-font-smoothing: antialiased;
}

#fatih-chat *,
#fatih-chat *::before,
#fatih-chat *::after {
    box-sizing: border-box;
}

/* --- launcher ---------------------------------------------------------- */

#fatih-chat .fk-launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 56px;
    padding: 9px 18px 9px 10px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(150deg, #e00000 0%, var(--fk-red-dark) 100%);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .01em;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(140, 0, 0, .26), 0 2px 6px rgba(0, 0, 0, .12);
    transition: transform .18s ease, box-shadow .18s ease;
}

#fatih-chat .fk-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(140, 0, 0, .3), 0 3px 8px rgba(0, 0, 0, .14);
}

#fatih-chat .fk-launcher-icon {
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
}

/* --- panel ------------------------------------------------------------- */

#fatih-chat .fk-panel {
    position: absolute;
    left: 0;
    bottom: 68px;
    display: flex;
    flex-direction: column;
    width: min(370px, calc(100vw - 24px));
    height: min(560px, calc(100vh - 110px));
    min-height: 320px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, .08);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 22px 60px rgba(0, 0, 0, .22), 0 4px 14px rgba(0, 0, 0, .08);
    transform-origin: bottom left;
    animation: fk-in .18s ease-out;
}

#fatih-chat .fk-panel[hidden] {
    display: none;
}

@keyframes fk-in {
    from { opacity: 0; transform: translateY(10px) scale(.985); }
    to   { opacity: 1; transform: none; }
}

#fatih-chat .fk-header {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 14px;
    background: linear-gradient(120deg, #a80000 0%, #d81111 100%);
    color: #fff;
}

#fatih-chat .fk-mark {
    display: grid;
    place-items: center;
    flex: 0 0 38px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #fff;
    color: var(--fk-red);
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.02em;
}

#fatih-chat .fk-heading {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

#fatih-chat .fk-heading strong {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

#fatih-chat .fk-heading span {
    font-size: 12px;
    line-height: 1.3;
    opacity: .86;
}

#fatih-chat .fk-close {
    display: grid;
    place-items: center;
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease;
}

#fatih-chat .fk-close:hover {
    background: rgba(255, 255, 255, .28);
}

/* --- conversation ------------------------------------------------------ */

#fatih-chat .fk-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
    background: #fafafa;
}

#fatih-chat .fk-messages {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    padding: 16px 14px 10px;
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

#fatih-chat .fk-message {
    max-width: 88%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

#fatih-chat .fk-message.bot {
    align-self: flex-start;
    border: 1px solid var(--fk-line);
    border-bottom-left-radius: 5px;
    background: #fff;
    color: #26282b;
}

#fatih-chat .fk-message.user {
    align-self: flex-end;
    border-bottom-right-radius: 5px;
    background: var(--fk-red);
    color: #fff;
}

#fatih-chat .fk-message.typing {
    align-self: flex-start;
    border: 1px dashed #dcdcdc;
    background: #fff;
    color: #7a7a7a;
    font-size: 13px;
}

#fatih-chat .fk-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 0 14px 12px;
}

#fatih-chat .fk-chip {
    padding: 7px 12px;
    border: 1px solid #dedede;
    border-radius: 999px;
    background: #fff;
    color: #333;
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.3;
    cursor: pointer;
    transition: border-color .15s ease, color .15s ease, background .15s ease;
}

#fatih-chat .fk-chip:hover {
    border-color: var(--fk-red);
    color: var(--fk-red);
    background: #fff6f6;
}

/* --- form -------------------------------------------------------------- */

#fatih-chat .fk-form {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--fk-line);
    background: #fff;
}

#fatih-chat .fk-form[hidden] {
    display: none;
}

#fatih-chat .fk-form textarea {
    flex: 1;
    min-width: 0;
    max-height: 108px;
    padding: 10px 12px;
    border: 1px solid #dcdcdc;
    border-radius: 12px;
    background: #fff;
    color: #222;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

#fatih-chat .fk-form textarea:focus {
    border-color: var(--fk-red);
    box-shadow: 0 0 0 3px rgba(198, 0, 0, .1);
}

#fatih-chat .fk-send {
    display: grid;
    place-items: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--fk-red);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease, opacity .15s ease;
}

#fatih-chat .fk-send:hover {
    background: var(--fk-red-dark);
}

#fatih-chat .fk-send:disabled {
    opacity: .5;
    cursor: wait;
}

#fatih-chat .fk-note {
    margin: 0;
    padding: 0 14px 10px;
    background: #fff;
    color: #8a8a8a;
    font-size: 11px;
    line-height: 1.4;
}

#fatih-chat .fk-note[hidden] {
    display: none;
}

/* --- success state ----------------------------------------------------- */

#fatih-chat .fk-done {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-top: 1px solid #e7f3e7;
    background: #f2fbf2;
}

#fatih-chat .fk-done[hidden] {
    display: none;
}

#fatih-chat .fk-done-text {
    margin: 0;
    color: #1f6b2b;
    font-size: 13px;
    font-weight: 600;
}

#fatih-chat .fk-restart {
    flex: 0 0 auto;
    padding: 7px 12px;
    border: 1px solid #bfdcbf;
    border-radius: 8px;
    background: #fff;
    color: #1f6b2b;
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
}

/* --- utilities --------------------------------------------------------- */

#fatih-chat .fk-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#fatih-chat button:focus-visible,
#fatih-chat textarea:focus-visible {
    outline: 3px solid #1f2124;
    outline-offset: 2px;
}

@media (max-width: 520px) {
    #fatih-chat {
        left: max(10px, env(safe-area-inset-left));
        bottom: max(10px, env(safe-area-inset-bottom));
    }

    #fatih-chat .fk-launcher {
        width: 56px;
        height: 56px;
        min-height: 56px;
        padding: 9px;
        justify-content: center;
    }

    #fatih-chat .fk-launcher-label {
        display: none;
    }

    #fatih-chat .fk-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: max(76px, calc(env(safe-area-inset-bottom) + 68px));
        width: auto;
        height: min(600px, calc(100vh - 100px));
        max-height: calc(100vh - 100px);
    }
}

@media (prefers-reduced-motion: reduce) {
    #fatih-chat *,
    #fatih-chat *::before,
    #fatih-chat *::after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important;
    }
}

/* --- confirmation card ------------------------------------------------- */

#fatih-chat .fk-confirm {
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 12px 14px 14px;
    border-top: 1px solid var(--fk-line);
    background: #fff;
}

#fatih-chat .fk-confirm[hidden] {
    display: none;
}

#fatih-chat .fk-confirm-title {
    margin: 0;
    color: #6b6b6b;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .02em;
    text-transform: uppercase;
}

#fatih-chat .fk-confirm-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: #26282b;
    font-size: 13px;
    line-height: 1.45;
}

#fatih-chat .fk-confirm-list li span {
    color: #7a7a7a;
    font-weight: 600;
}

#fatih-chat .fk-confirm-send {
    align-self: flex-start;
    padding: 10px 16px;
    border: 0;
    border-radius: 9px;
    background: var(--fk-red);
    color: #fff;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s ease;
}

#fatih-chat .fk-confirm-send:hover {
    background: var(--fk-red-dark);
}
