/* ── biila Toppik Smart Chatbot CSS ── */
#tpkRoot {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: 'Cairo', 'Segoe UI', sans-serif;
    direction: rtl;
}

/* زر الفتح */
.tpk-btn {
    position: relative;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff0050, #b000ff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 28px rgba(255, 0, 80, 0.5);
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1), box-shadow .3s;
}

.tpk-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 10px 36px rgba(255, 0, 80, 0.7);
}

.tpk-ico {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .25s, transform .25s;
}

.tpk-ico svg {
    width: 24px;
    height: 24px;
}

.tpk-ico.cls {
    opacity: 0;
    transform: rotate(-90deg) scale(.8);
}

.tpk-win.open~.tpk-btn .tpk-ico.open,
#tpkRoot:has(.tpk-win.open) .tpk-ico.open {
    opacity: 0;
    transform: rotate(90deg) scale(.8);
}

#tpkRoot:has(.tpk-win.open) .tpk-ico.cls {
    opacity: 1;
    transform: rotate(0) scale(1);
}

#tpkRoot:has(.tpk-win.open) .tpk-ring,
#tpkRoot:has(.tpk-win.open) .tpk-badge {
    display: none;
}

.tpk-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 0, 80, .3);
    animation: tpkPulse 2.4s ease-out infinite;
}

@keyframes tpkPulse {
    0% {
        transform: scale(1);
        opacity: .6
    }

    100% {
        transform: scale(1.9);
        opacity: 0
    }
}

.tpk-badge {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #00e676;
    color: #000;
    font-size: .65rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #0a0a0a;
}

/* نافذة البوت */
.tpk-win {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    height: 520px;
    background: #111;
    border-radius: 20px;
    border: 1px solid rgba(255, 0, 80, .2);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .65);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(18px) scale(.95);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity .3s cubic-bezier(.34, 1.56, .64, 1), transform .3s cubic-bezier(.34, 1.56, .64, 1);
}

.tpk-win.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* رأس */
.tpk-hd {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 15px;
    background: linear-gradient(135deg, rgba(255, 0, 80, .12), rgba(176, 0, 255, .1));
    border-bottom: 1px solid rgba(255, 0, 80, .15);
    flex-shrink: 0;
}

.tpk-hd-l {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tpk-av {
    position: relative;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
}

.tpk-av svg {
    width: 38px;
    height: 38px;
    border-radius: 50%;
}

.tpk-online {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #00e676;
    border: 2px solid #111;
    animation: tpkPulse 2s ease-in-out infinite;
}

.tpk-nm {
    font-size: .88rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2px;
}

.tpk-st {
    font-size: .7rem;
    color: #777;
    display: flex;
    align-items: center;
    gap: 5px;
}

.tpk-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #00e676;
    animation: tpkPulse 1.8s ease-in-out infinite;
}

.tpk-xbtn {
    background: rgba(255, 255, 255, .06);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    color: #777;
    font-size: .75rem;
    transition: background .2s, color .2s;
}

.tpk-xbtn:hover {
    background: rgba(255, 0, 80, .15);
    color: #ff0050;
}

/* أسئلة سريعة */
.tpk-quick {
    display: flex;
    gap: 6px;
    padding: 9px 12px;
    overflow-x: auto;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255, 255, 255, .05);
    scrollbar-width: none;
    overflow: hidden;
    max-height: 50px;
    transition: max-height .4s ease;
}

.tpk-quick::-webkit-scrollbar {
    display: none;
}

.tpk-quick button {
    white-space: nowrap;
    padding: 4px 11px;
    background: rgba(255, 0, 80, .08);
    border: 1px solid rgba(255, 0, 80, .2);
    border-radius: 20px;
    color: #ff3366;
    font-size: .7rem;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    flex-shrink: 0;
    transition: all .2s;
}

.tpk-quick button:hover {
    background: rgba(255, 0, 80, .18);
    border-color: #ff0050;
    transform: translateY(-1px);
}

/* جسم المحادثة */
.tpk-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 11px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 0, 80, .2) transparent;
}

.tpk-body::-webkit-scrollbar {
    width: 3px;
}

.tpk-body::-webkit-scrollbar-thumb {
    background: rgba(255, 0, 80, .25);
    border-radius: 4px;
}

/* فقاعات */
.tpk-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .28s ease, transform .28s ease;
}

.tpk-row.vis {
    opacity: 1;
    transform: translateY(0);
}

.tpk-row.user {
    align-items: flex-start;
}

.tpk-row.bot {
    align-items: flex-end;
}

.tpk-bub {
    max-width: 86%;
    padding: 9px 13px;
    border-radius: 15px;
    font-size: .83rem;
    line-height: 1.65;
    word-break: break-word;
}

.tpk-bub.user {
    background: linear-gradient(135deg, #ff0050, #b000ff);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-start;
}

.tpk-bub.bot {
    background: #222;
    color: #f0f0f0;
    border: 1px solid rgba(255, 255, 255, .06);
    border-bottom-left-radius: 4px;
    align-self: flex-end;
}

/* مؤشر الكتابة */
.tpk-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 11px 14px;
    min-width: 52px;
}

.tpk-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 0, 80, .6);
    animation: tpkBounce 1.2s ease-in-out infinite;
}

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

.tpk-typing span:nth-child(3) {
    animation-delay: .30s;
}

@keyframes tpkBounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
        opacity: .5;
    }

    40% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* زر واتساب */
.tpk-wa {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 15px;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    border-radius: 50px;
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
    align-self: flex-end;
    transition: all .25s;
    box-shadow: 0 4px 14px rgba(37, 211, 102, .35);
}

.tpk-wa:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 22px rgba(37, 211, 102, .55);
    color: #fff;
}

.tpk-wa svg {
    width: 14px;
    height: 14px;
    fill: #fff;
    flex-shrink: 0;
}

/* حقل الإدخال */
.tpk-ft {
    padding: 9px 11px 11px;
    border-top: 1px solid rgba(255, 255, 255, .05);
    background: #1a1a1a;
    flex-shrink: 0;
}

.tpk-row-inp {
    display: flex;
    align-items: flex-end;
    gap: 7px;
    background: #222;
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 13px;
    padding: 7px 7px 7px 11px;
    transition: border-color .2s;
}

.tpk-row-inp:focus-within {
    border-color: rgba(255, 0, 80, .4);
    box-shadow: 0 0 0 3px rgba(255, 0, 80, .08);
}

.tpk-row-inp textarea {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    color: #f0f0f0;
    font-family: inherit;
    font-size: .83rem;
    line-height: 1.5;
    min-height: 18px;
    max-height: 90px;
    direction: rtl;
    scrollbar-width: none;
}

.tpk-row-inp textarea::placeholder {
    color: #555;
}

.tpk-row-inp textarea::-webkit-scrollbar {
    display: none;
}

.tpk-snd {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    flex-shrink: 0;
    background: linear-gradient(135deg, #ff0050, #b000ff);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(255, 0, 80, .4);
    transition: all .2s;
}

.tpk-snd:hover {
    transform: scale(1.08);
    box-shadow: 0 5px 18px rgba(255, 0, 80, .6);
}

.tpk-snd svg {
    transform: scaleX(-1);
}

.tpk-walink {
    display: flex;
    align-items: center;
    gap: 5px;
    justify-content: center;
    margin-top: 7px;
    font-size: .68rem;
    color: #25D366;
    text-decoration: none;
    font-weight: 600;
    transition: color .2s;
}

.tpk-walink:hover {
    color: #40e080;
}

/* موبايل */
@media (max-width: 480px) {
    #tpkRoot {
        bottom: 16px;
        right: 14px;
    }

    .tpk-win {
        width: calc(100vw - 28px);
        right: 0;
        height: 470px;
    }
}