/**
 * Chat Hub — یک FAB برای انتخاب AI / پیام‌ها
 */

.hmj-chat-hub {
    --hub-fab: 3.4rem;
    --hub-z: 1410;
    position: relative;
    z-index: var(--hub-z);
    pointer-events: none;
    font-family: inherit;
}

.hmj-chat-hub > * {
    pointer-events: auto;
}

/* مخفی کردن لانچرهای جدا */
body.has-chat-hub .hmj-ai__launcher,
body.has-chat-hub .hmj-msg__launcher {
    display: none !important;
}

body.has-chat-hub .hmj-ai,
body.has-chat-hub .hmj-msg {
    /* panels هنوز کار می‌کنند */
}

.hmj-chat-hub__fab {
    position: fixed;
    inset-inline-end: 1.1rem;
    bottom: var(--hmj-fab-bottom, 1.15rem);
    width: var(--hub-fab);
    height: var(--hub-fab);
    border: 0;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--hmj-primary) 0%, var(--hmj-primary-dark) 100%);
    color: #fff;
    box-shadow:
        0 12px 28px rgba(15, 159, 138, 0.36),
        0 2px 8px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    display: grid;
    place-items: center;
    z-index: calc(var(--hub-z) + 2);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease, background 0.2s ease;
}

.hmj-chat-hub__fab:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 16px 34px rgba(15, 159, 138, 0.42),
        0 4px 12px rgba(15, 23, 42, 0.14);
}

.hmj-chat-hub__fab:active {
    transform: scale(0.96);
}

.hmj-chat-hub.is-open .hmj-chat-hub__fab {
    background: #0F172A;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
}

.hmj-chat-hub__fab-icon {
    position: absolute;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    transition: opacity 0.2s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

.hmj-chat-hub__fab-icon--close {
    opacity: 0;
    transform: rotate(-40deg) scale(0.6);
}

.hmj-chat-hub.is-open .hmj-chat-hub__fab-icon--open {
    opacity: 0;
    transform: rotate(40deg) scale(0.6);
}

.hmj-chat-hub.is-open .hmj-chat-hub__fab-icon--close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.hmj-chat-hub__fab-badge {
    position: absolute;
    top: -3px;
    inset-inline-start: -3px;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: #EF4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    display: grid;
    place-items: center;
    box-shadow: 0 0 0 2px #fff;
    line-height: 1;
}

.hmj-chat-hub__menu {
    position: fixed;
    inset-inline-end: 1.1rem;
    bottom: calc(var(--hmj-fab-bottom, 1.15rem) + var(--hub-fab) + 0.65rem);
    width: min(17.5rem, calc(100vw - 2rem));
    padding: 0.4rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(16px) saturate(1.2);
    -webkit-backdrop-filter: blur(16px) saturate(1.2);
    border: 1px solid rgba(15, 159, 138, 0.12);
    box-shadow:
        0 18px 40px rgba(15, 23, 42, 0.16),
        0 2px 8px rgba(15, 23, 42, 0.06);
    z-index: calc(var(--hub-z) + 1);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    transform-origin: bottom center;
    opacity: 0;
    transform: translateY(10px) scale(0.96);
    visibility: hidden;
    transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.22s;
}

.hmj-chat-hub.is-open .hmj-chat-hub__menu {
    opacity: 1;
    transform: none;
    visibility: visible;
}

.hmj-chat-hub__option {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    width: 100%;
    padding: 0.7rem 0.75rem;
    border: 0;
    border-radius: 14px;
    background: transparent;
    text-align: right;
    cursor: pointer;
    color: var(--hmj-text);
    font-family: inherit;
    transition: background 0.18s ease;
}

.hmj-chat-hub__option:hover,
.hmj-chat-hub__option:focus-visible {
    background: var(--hmj-primary-light);
    outline: none;
}

.hmj-chat-hub__option-icon {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 13px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    color: #fff;
    font-size: 0.95rem;
}

.hmj-chat-hub__option-icon--ai {
    background: linear-gradient(145deg, #14B8A6, #0F766E);
}

.hmj-chat-hub__option-icon--msg {
    background: linear-gradient(145deg, #0EA5E9, #0369A1);
}

.hmj-chat-hub__option-copy {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.hmj-chat-hub__option-copy strong {
    font-size: 0.88rem;
    font-weight: 800;
    line-height: 1.25;
}

.hmj-chat-hub__option-copy small {
    font-size: 0.7rem;
    color: var(--hmj-text-muted);
    font-weight: 500;
}

.hmj-chat-hub__option-badge {
    min-width: 1.3rem;
    height: 1.3rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: #EF4444;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 800;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

/* وقتی پنل چت باز است، هاب خلوت بماند */
body.hmj-chat-overlay-open .hmj-chat-hub {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.18s ease, visibility 0.18s;
}

@media (prefers-reduced-motion: reduce) {
    .hmj-chat-hub__fab,
    .hmj-chat-hub__menu,
    .hmj-chat-hub__fab-icon {
        transition: none;
    }
}

/* جلوگیری از تداخل دکمه بازگشت به بالا با دکمه چت شناور */
.site-scroll-top.scroll-top {
    position: fixed !important;
    inset-inline-end: 1.35rem !important;
    right: auto !important;
    left: auto !important;
    bottom: calc(var(--hmj-fab-bottom, 1.15rem) + 4.05rem) !important;
    width: 2.55rem;
    height: 2.55rem;
    padding: 0;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.94);
    color: var(--hmj-primary-dark, #06665A);
    border: 1px solid rgba(15, 159, 138, 0.22);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
    z-index: 1390;
}

.site-scroll-top.scroll-top:hover {
    background: var(--hmj-primary, #0F9F8A);
    color: #fff;
}
