/* ---------- CHATBOT WIDGET ---------- */
#chatFab {
    position: fixed;
    right: 20px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 10px 26px rgba(var(--accent-rgb), 0.4);
    z-index: 96;
    transition: transform .2s cubic-bezier(.34,1.56,.64,1), box-shadow .2s ease, opacity .2s ease;
    animation: chatFabPulse 3s ease-in-out infinite;
}

#chatFab:hover {
    transform: scale(1.08);
    box-shadow: 0 14px 32px rgba(var(--accent-rgb), 0.5);
}

#chatFab:active {
    transform: scale(0.92);
}

#chatFab.chat__fab--active {
    transform: scale(0.9) rotate(90deg);
}

.chat__fab-icon {
    width: 26px;
    height: 26px;
}

.chat__fab-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--success);
    border: 2px solid var(--bg);
    animation: chatDotBlink 1.6s ease-in-out infinite;
}

@keyframes chatFabPulse {
    0%, 100% { box-shadow: 0 10px 26px rgba(var(--accent-rgb), 0.4); }
    50% { box-shadow: 0 10px 34px rgba(var(--accent-rgb), 0.65), 0 0 0 8px rgba(var(--accent-rgb), 0.08); }
}

@keyframes chatDotBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

@media (max-width:900px) {
    /* MUHIM TUZATISH: avval bu qoida "max-width:640px" edi, lekin pastki
       navigatsiya paneli (.command-nav) "max-width:900px" da paydo
       bo'ladi. Bu ikki chegaraviy qiymat MOS KELMAGANI sabab, 641-899px
       oralig'idagi ekranlarda (masalan planshetlar) #chatFab hali ham
       "desktop" holatida (bottom:24px) qolib, PASTKI NAVIGATSIYA
       PANELINING USTIGA tushib qolardi. Endi ikkalasi bir xil
       chegarada moslashadi. */
    #chatFab {
        bottom: calc(78px + env(safe-area-inset-bottom, 0px));
        right: 14px;
        width: 50px;
        height: 50px;
    }
}

.chat__panel {
    position: fixed;
    right: 20px;
    bottom: 92px;
    width: 360px;
    max-width: calc(100vw - 28px);
    height: 500px;
    max-height: calc(100vh - 140px);
    background: var(--bg2);
    border: 1px solid rgba(var(--overlay-rgb), 0.12);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    z-index: 97;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transition: opacity .22s ease, transform .22s cubic-bezier(.34,1.56,.64,1);
}

.chat__panel.state--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

@media (max-width:900px) {
    .chat__panel {
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        bottom: calc(136px + env(safe-area-inset-bottom, 0px));
        height: min(480px, calc(100vh - 220px));
    }
}

.chat__panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(90deg, var(--accent), var(--purple));
    color: #fff;
    flex: none;
}

.chat__panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    line-height: 1.3;
}

.chat__avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex: none;
}

.chat__close-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    transition: background .15s ease, transform .15s ease;
}

.chat__close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: none;
}

.chat__messages::-webkit-scrollbar {
    display: none;
}

.chat__msg {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    max-width: 84%;
    animation: fadeInUp .25s ease backwards;
}

.chat__msg-bot {
    align-self: flex-start;
}

.chat__msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat__msg-avatar {
    font-size: 15px;
    flex: none;
}

.chat__bubble {
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: normal;
    overflow-wrap: anywhere;
}

.chat__msg-bot .chat__bubble {
    background: rgba(var(--overlay-rgb), 0.08);
    color: var(--fg);
    border-bottom-left-radius: 4px;
}

.chat__msg-user .chat__bubble {
    background: linear-gradient(90deg, var(--accent), var(--purple));
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat__typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
}

.chat__typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: chatTypingBounce 1.1s ease-in-out infinite;
}

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

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

.chat__input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid rgba(var(--overlay-rgb), 0.1);
    flex: none;
}

.chat__input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 999px;
    border: 1px solid rgba(var(--overlay-rgb), 0.14);
    background: rgba(var(--overlay-rgb), 0.05);
    color: var(--fg);
    font-size: 13.5px;
    outline: none;
    transition: border-color .15s ease;
}

.chat__input:focus {
    border-color: var(--accent);
}

.chat__send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(90deg, var(--accent), var(--purple));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: none;
    transition: transform .15s ease;
}

.chat__send-btn .utility-chip__glyph {
    width: 16px;
    height: 16px;
}

.chat__send-btn:hover {
    transform: scale(1.1);
}

.chat__send-btn:active {
    transform: scale(0.88);
}

