/* =========================================================
   evradar — dəstək çatı (evr-chat-)
   Rənglər evradar.css-dəki --evr-* dəyişənlərindən gəlir.
   ========================================================= */

.evr-chat {
    --evr-chat-gap: 24px;
    --evr-chat-fab: 58px;
    --evr-chat-line: rgba(13, 26, 28, .08);
    --evr-chat-muted: rgba(13, 26, 28, .5);
    --evr-chat-canvas: #F6F6F7;
    position: fixed;
    right: var(--evr-chat-gap);
    bottom: var(--evr-chat-gap);
    z-index: 1040;
    font-size: 14px;
    line-height: 1.5;
    color: var(--evr-ink, #0D1A1C);
}

.evr-chat [hidden] {
    display: none !important;
}

/* ---------- Düymə ---------- */
.evr-chat-fab {
    position: relative;
    width: var(--evr-chat-fab);
    height: var(--evr-chat-fab);
    border: 0;
    border-radius: 50%;
    background: var(--evr-accent, #FF6725);
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 28px rgba(var(--evr-accent-rgb, 255, 103, 37), .38), 0 2px 6px rgba(13, 26, 28, .12);
    transition: transform .25s cubic-bezier(.2, .8, .2, 1), background .2s ease;
}

.evr-chat-fab:hover {
    background: var(--evr-accent-hover, #F05A1A);
    transform: translateY(-2px);
}

.evr-chat-fab i {
    line-height: 1;
    transition: transform .25s ease, opacity .2s ease;
}

.evr-chat-fab-close,
.evr-chat.is-open .evr-chat-fab-open {
    display: none;
}

.evr-chat.is-open .evr-chat-fab-close {
    display: inline;
    font-size: 20px;
}

/* Oxunmamış mesaj varsa düymə ətrafında yumşaq dalğa */
.evr-chat.has-unread:not(.is-open) .evr-chat-fab::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--evr-accent, #FF6725);
    animation: evrChatPulse 1.8s ease-out infinite;
}

@keyframes evrChatPulse {
    from { transform: scale(1); opacity: .7; }
    to { transform: scale(1.5); opacity: 0; }
}

.evr-chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--evr-ink, #0D1A1C);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px #fff;
}

/* ---------- Pəncərə ---------- */
.evr-chat-win {
    position: absolute;
    right: 0;
    bottom: calc(var(--evr-chat-fab) + 16px);
    width: 380px;
    height: min(600px, calc(100vh - 130px));
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(13, 26, 28, .2), 0 4px 12px rgba(13, 26, 28, .06), 0 0 0 1px rgba(13, 26, 28, .04);
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(.97);
    transform-origin: bottom right;
    transition: opacity .22s ease, transform .3s cubic-bezier(.2, .8, .2, 1), visibility .22s;
}

.evr-chat.is-open .evr-chat-win {
    opacity: 1;
    visibility: visible;
    transform: none;
}

/* Başlıq: açıq fon */
.evr-chat-head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 12px 14px 16px;
    background: #fff;
    color: var(--evr-ink, #0D1A1C);
    border-bottom: 1px solid var(--evr-chat-line);
    flex-shrink: 0;
}

.evr-chat-avatar {
    position: relative;
    flex: 0 0 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--evr-chat-canvas);
    display: flex;
    align-items: center;
    justify-content: center;
}

.evr-chat-avatar img {
    width: 30px;
    height: 30px;
    display: block;
}

.evr-chat-avatar-dot {
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: var(--evr-success, #00B579);
    box-shadow: 0 0 0 2px #fff;
}

.evr-chat-head-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.evr-chat-head-text strong {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: var(--evr-ink, #0D1A1C);
}

.evr-chat-head-text span {
    font-size: 12px;
    line-height: 1.35;
    color: var(--evr-chat-muted);
}

.evr-chat-end,
.evr-chat-x {
    flex: 0 0 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: rgba(13, 26, 28, .55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    transition: background .2s ease, color .2s ease;
}

.evr-chat-end:hover,
.evr-chat-x:hover {
    background: var(--evr-chat-canvas);
    color: var(--evr-ink, #0D1A1C);
}

/* ---------- Mesajlar ---------- */
.evr-chat-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 12px;
    display: flex;
    flex-direction: column;
    background: var(--evr-chat-canvas);
    overscroll-behavior: contain;
    scrollbar-width: thin;
}

.evr-chat-msg {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 84%;
    margin-top: 12px;
    animation: evrChatIn .25s cubic-bezier(.2, .8, .2, 1);
}

.evr-chat-msg:first-child {
    margin-top: 0;
}

.evr-chat-msg.is-cont {
    margin-top: 3px;
}

.evr-chat-msg.is-admin {
    align-self: flex-start;
}

.evr-chat-msg.is-me {
    align-self: flex-end;
}

@keyframes evrChatIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* Admin mesajında kiçik avatar (qrupun birincisində) */
.evr-chat-mini {
    flex: 0 0 26px;
    height: 26px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(13, 26, 28, .08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.evr-chat-mini img {
    width: 20px;
    height: 20px;
    display: block;
}

.evr-chat-msg.is-cont .evr-chat-mini {
    visibility: hidden;
}

.evr-chat-bubble {
    padding: 8px 12px 6px;
    border-radius: 18px;
    word-break: break-word;
    min-width: 0;
}

.evr-chat-body {
    white-space: pre-wrap;
}

.evr-chat-msg.is-admin .evr-chat-bubble {
    background: #fff;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(13, 26, 28, .06);
}

.evr-chat-msg.is-admin.is-cont .evr-chat-bubble {
    border-top-left-radius: 6px;
}

.evr-chat-msg.is-me .evr-chat-bubble {
    background: var(--evr-accent, #FF6725);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.evr-chat-msg.is-me.is-cont .evr-chat-bubble {
    border-top-right-radius: 6px;
}

/* Vaxt və status — qabarcığın içində, sağ altda */
.evr-chat-meta {
    float: right;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    margin: 6px 0 -2px 10px;
    font-size: 10.5px;
    line-height: 1;
    color: var(--evr-chat-muted);
}

.evr-chat-meta:empty {
    display: none;
}

.evr-chat-msg.is-me .evr-chat-meta {
    color: rgba(255, 255, 255, .78);
}

.evr-chat-tick {
    font-size: 14px;
}

.evr-chat-msg.is-read .evr-chat-tick {
    color: #fff;
}

.evr-chat-msg.is-pending .evr-chat-bubble {
    opacity: .7;
}

.evr-chat-msg.is-failed .evr-chat-bubble {
    background: #FEF3F2;
    color: #B42318;
    box-shadow: inset 0 0 0 1px #FDA29B;
}

.evr-chat-msg.is-failed .evr-chat-meta {
    color: #B42318;
}

/* ---------- Qonaq forması ---------- */
.evr-chat-form {
    flex-shrink: 0;
    padding: 18px 16px 16px;
    border-top: 1px solid var(--evr-chat-line);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #fff;
    animation: evrChatIn .25s ease;
}

.evr-chat-form-lead {
    margin: 0 0 4px;
    font-size: 13px;
    line-height: 1.45;
    color: rgba(13, 26, 28, .7);
}

.evr-chat-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.evr-chat-input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1px solid transparent !important;
    border-radius: 12px;
    background: var(--evr-chat-canvas) !important;
    font-size: 14px;
    color: var(--evr-ink, #0D1A1C);
    outline: none !important;
    box-shadow: none !important;
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.evr-chat-input:focus {
    background: #fff !important;
    border-color: var(--evr-accent, #FF6725) !important;
    box-shadow: 0 0 0 3px rgba(var(--evr-accent-rgb, 255, 103, 37), .12) !important;
}

.evr-chat-hint {
    font-size: 12px;
    color: var(--evr-chat-muted);
}

.evr-chat-error {
    font-size: 13px;
    color: #B42318;
}

/* ---------- Düymələr ---------- */
.evr-chat-btn {
    height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: 12px;
    background: var(--evr-accent, #FF6725);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    transition: background .2s ease, transform .15s ease;
}

.evr-chat-btn:hover {
    background: var(--evr-accent-hover, #F05A1A);
}

.evr-chat-btn:active {
    transform: scale(.98);
}

.evr-chat-btn:disabled {
    opacity: .6;
}

.evr-chat-btn.is-ghost {
    background: var(--evr-chat-canvas);
    color: var(--evr-ink, #0D1A1C);
}

.evr-chat-btn.is-ghost:hover {
    background: #EDEDEF;
}

/* ---------- Söhbət bitdi ---------- */
.evr-chat-ended {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 28px;
    gap: 6px;
    background: var(--evr-chat-canvas);
}

.evr-chat-ended-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--evr-success-soft, #E6F8F1);
    color: var(--evr-success, #00B579);
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.evr-chat-ended strong {
    font-size: 17px;
}

.evr-chat-ended p {
    margin: 0 0 14px;
    color: rgba(13, 26, 28, .6);
}

/* ---------- Təsdiq ---------- */
.evr-chat-confirm {
    position: absolute;
    inset: 0;
    background: rgba(13, 26, 28, .4);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: flex-end;
    z-index: 2;
    animation: evrChatFade .2s ease;
}

@keyframes evrChatFade {
    from { opacity: 0; }
    to { opacity: 1; }
}

.evr-chat-confirm-box {
    width: 100%;
    background: #fff;
    border-radius: 22px 22px 0 0;
    padding: 22px 20px 20px;
    animation: evrChatIn .25s cubic-bezier(.2, .8, .2, 1);
}

.evr-chat-confirm-box strong {
    font-size: 16px;
}

.evr-chat-confirm-box p {
    margin: 6px 0 18px;
    color: rgba(13, 26, 28, .6);
}

.evr-chat-confirm-actions {
    display: flex;
    gap: 8px;
}

.evr-chat-confirm-actions .evr-chat-btn {
    flex: 1;
}

/* ---------- Yazma sahəsi ---------- */
.evr-chat-bar {
    flex-shrink: 0;
    padding: 12px;
    background: #fff;
    border-top: 1px solid var(--evr-chat-line);
}

.evr-chat-compose {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 5px 5px 5px 16px;
    border-radius: 24px;
    background: var(--evr-chat-canvas);
    border: 1px solid transparent;
    transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}

.evr-chat-compose:focus-within {
    background: #fff;
    border-color: var(--evr-accent-line, #FFD9C7);
    box-shadow: 0 0 0 3px rgba(var(--evr-accent-rgb, 255, 103, 37), .08);
}

/* Şablonun ümumi textarea stilləri burada işləməsin */
.evr-chat-text {
    flex: 1;
    min-height: 36px;
    max-height: 120px;
    padding: 8px 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    resize: none;
    font-size: 14px;
    line-height: 20px;
    color: var(--evr-ink, #0D1A1C);
}

.evr-chat-text::placeholder {
    color: rgba(13, 26, 28, .42);
}

.evr-chat-send {
    flex: 0 0 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--evr-accent, #FF6725);
    color: #fff;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s ease, transform .15s ease;
}

.evr-chat-send:hover:not(:disabled) {
    background: var(--evr-accent-hover, #F05A1A);
}

.evr-chat-send:active:not(:disabled) {
    transform: scale(.92);
}

.evr-chat-send:disabled {
    background: rgba(13, 26, 28, .12);
    color: rgba(13, 26, 28, .35);
}

/* ---------- Scroll-top: çat düyməsinin üstündə, mərkəzi eyni xətdə ---------- */
.scroll-top {
    right: 33px !important;
    bottom: 96px !important;
    width: 40px !important;
    height: 40px !important;
    line-height: 40px !important;
    z-index: 1030 !important;
}

/* Çat açıq olanda scroll-top pəncərənin arxasında qalmasın */
body.evr-chat-is-open .scroll-top {
    display: none !important;
}

/* ---------- Mobil: pəncərə tam ekran ---------- */
@media (max-width: 575px) {
    .evr-chat {
        --evr-chat-gap: 16px;
        --evr-chat-fab: 54px;
    }

    .scroll-top {
        right: 23px !important;
        bottom: 82px !important;
    }

    .evr-chat-win {
        position: fixed;
        inset: 0;
        width: auto;
        height: auto;
        border-radius: 0;
        transform: translateY(24px);
    }

    .evr-chat-head {
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .evr-chat-bar {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .evr-chat.is-open .evr-chat-fab {
        display: none;
    }

    body.evr-chat-is-open {
        overflow: hidden;
    }

    /* iOS: 16px-dən kiçik şriftdə sahəyə toxunanda səhifə böyüyür */
    .evr-chat-input,
    .evr-chat-text {
        font-size: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .evr-chat *,
    .evr-chat *::after {
        animation: none !important;
        transition: none !important;
    }
}
