/*
 * "Telegram bot" — yuqori paneldagi tugma va yon paneldagi taklif.
 *
 * Rang — Telegramning o'z ko'ki (#229ED9): odam uni birinchi
 * qarashdayoq Telegram deb taniydi. Ikkala temada ham oq yozuv bilan
 * yetarli kontrast beradi.
 */

/* ---------- Yuqori panel: ulanmagan — ko'k tugma ---------- */
.app-tgbtn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    height: 38px;
    min-width: 38px;
    flex: 0 0 auto;
    padding: 0 .85rem 0 .7rem;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #2aabee 0%, #1c8fc7 100%);
    color: #fff;
    font-size: .84rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
    box-shadow: 0 4px 12px -4px rgba(34, 158, 217, .6);
    transition: filter .15s ease, box-shadow .15s ease, transform .15s ease;
}

.app-tgbtn .fa-telegram {
    font-size: 1.15rem;
    line-height: 1;
}

.app-tgbtn:hover {
    color: #fff;
    filter: brightness(1.07);
    box-shadow: 0 6px 16px -4px rgba(34, 158, 217, .7);
}

.app-tgbtn:active {
    transform: translateY(1px);
}

.app-tgbtn:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(34, 158, 217, .45);
}

/*
 * Ulanmagan holatda e'tiborni tortish: atrofida yumshoq to'lqin.
 * Faqat 3 marta — doimiy miltillash ishlashga xalaqit berardi.
 */
.app-tgbtn:not(.is-linked)::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: inherit;
    border: 2px solid rgba(34, 158, 217, .55);
    opacity: 0;
    pointer-events: none;
    animation: app-tg-pulse 2.4s ease-out .6s 3;
}

@keyframes app-tg-pulse {
    0% {
        transform: scale(.94);
        opacity: .9;
    }

    70% {
        transform: scale(1.16);
        opacity: 0;
    }

    100% {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-tgbtn:not(.is-linked)::after {
        animation: none;
    }
}

/* ---------- Yuqori panel: ulangan — oddiy ikonka + yashil belgi ---------- */
.app-tgbtn.is-linked {
    width: 38px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: var(--app-radius-sm);
    background: transparent;
    color: #229ed9;
    box-shadow: none;
}

.app-tgbtn.is-linked:hover {
    filter: none;
    background: var(--app-surface-2);
    border-color: var(--app-border);
    color: #1c8fc7;
}

.app-tgbtn.is-linked .app-tgbtn__label {
    display: none;
}

.app-tgbtn__ok {
    position: absolute;
    right: 2px;
    bottom: 3px;
    width: 15px;
    height: 15px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #10b981;
    color: #fff;
    font-size: .5rem;
    border: 2px solid var(--app-surface);
}

/*
 * Telefon va planshetda — faqat ikonka (yozuv sarlavhaga joy
 * qoldirsin), lekin KO'K dumaloq bo'lib qoladi: panelning boshqa
 * kulrang ikonkalari orasida darhol ko'zga tashlanadi.
 * O'lcham — shu kenglikdagi boshqa ikonkalar bilan bir xil (42px).
 */
@media (max-width: 991.98px) {
    .app-tgbtn,
    .app-tgbtn.is-linked {
        width: 42px;
        height: 42px;
        padding: 0;
    }

    .app-tgbtn .app-tgbtn__label {
        display: none;
    }

    .app-tgbtn .fa-telegram {
        font-size: 1.3rem;
    }
}

/*
 * Telefonda panelga bitta ikonka qo'shilgani sarlavhani siqib
 * qo'ymasin: tugma BOR panelda ikonkalar orasidagi masofa biroz
 * qisqaradi — sarlavhaga oldingidek joy qoladi. Tugma yo'q
 * (sotuvchi) panelga tegilmaydi. `:has()` qo'llanmaydigan eski
 * brauzerda shunchaki oldingi masofa qoladi.
 */
@media (max-width: 575.98px) {
    .app-topbar:has(.app-tgbtn) {
        gap: .35rem;
        padding-left: .6rem;
        padding-right: .6rem;
    }
}

/* ---------- Yon panel: taklif kartochkasi ---------- */
.app-tgcard {
    display: flex;
    align-items: center;
    gap: .65rem;
    margin-bottom: .65rem;
    padding: .6rem .7rem;
    border-radius: var(--app-radius-sm);
    background: linear-gradient(135deg, rgba(42, 171, 238, .22) 0%, rgba(28, 143, 199, .12) 100%);
    border: 1px solid rgba(42, 171, 238, .35);
    color: var(--app-sb-text-strong);
    text-decoration: none;
    overflow: hidden;
    transition: background-color .15s ease, border-color .15s ease;
}

.app-tgcard:hover {
    color: var(--app-sb-text-strong);
    border-color: rgba(42, 171, 238, .6);
    background: linear-gradient(135deg, rgba(42, 171, 238, .3) 0%, rgba(28, 143, 199, .18) 100%);
}

.app-tgcard:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 3px rgba(34, 158, 217, .45);
}

.app-tgcard__icon {
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #2aabee 0%, #1c8fc7 100%);
    color: #fff;
    font-size: 1.15rem;
}

.app-tgcard__text {
    min-width: 0;
    flex: 1 1 auto;
    line-height: 1.2;
}

.app-tgcard__text strong {
    display: block;
    font-size: .86rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ikki qatorga tushishi mumkin — vaqtlar kesilib qolmasin */
.app-tgcard__text small {
    display: block;
    font-size: .72rem;
    line-height: 1.25;
    color: var(--app-sb-text);
}

.app-tgcard__go {
    flex: 0 0 auto;
    font-size: .72rem;
    color: var(--app-sb-text);
}

/* Yig'ilgan (mini) yon panel — faqat dumaloq ikonka qoladi */
@media (min-width: 992px) {
    body.sidebar-collapsed .app-tgcard {
        justify-content: center;
        padding: .45rem;
        background: transparent;
        border-color: transparent;
    }

    body.sidebar-collapsed .app-tgcard__text,
    body.sidebar-collapsed .app-tgcard__go {
        display: none;
    }
}

@media print {
    .app-tgbtn,
    .app-tgcard {
        display: none !important;
    }
}
