/* Nesfe Jahan AI chatbot — compact panel + composer */

.nj-chat-root {
    --nj-teal: #01A8A8;
    --nj-ink: #243838;
    position: fixed;
    right: 18px;
    bottom: 24px;
    z-index: 10050;
    font-family: Tahoma, 'BYekan', Arial, sans-serif;
}

.nj-chat-toggle {
    width: 62px;
    height: 62px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, 0.65);
    border-radius: 50%;
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.28), transparent 45%),
        linear-gradient(145deg, #2fc4bc, #01A8A8 48%, #016d6d);
    box-shadow:
        0 10px 24px rgba(1, 100, 100, 0.3),
        0 0 0 4px rgba(1, 168, 168, 0.12);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s ease, box-shadow .2s ease;
    overflow: hidden;
    animation: nj-chat-pulse 2.8s ease-in-out infinite;
}

.nj-chat-toggle:hover,
.nj-chat-toggle:focus {
    transform: translateY(-3px) scale(1.03);
    box-shadow:
        0 16px 30px rgba(1, 100, 100, 0.36),
        0 0 0 5px rgba(1, 168, 168, 0.16);
    outline: none;
    animation: none;
}

.nj-chat-toggle-icon {
    width: 42px;
    height: 42px;
    display: block;
    pointer-events: none;
}

.nj-chat-root.is-open .nj-chat-toggle {
    animation: none;
}

@keyframes nj-chat-pulse {
    0%, 100% { box-shadow: 0 10px 24px rgba(1, 100, 100, 0.3), 0 0 0 4px rgba(1, 168, 168, 0.10); }
    50% { box-shadow: 0 12px 28px rgba(1, 100, 100, 0.34), 0 0 0 8px rgba(1, 168, 168, 0.06); }
}

.nj-chat-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 76px;
    width: min(360px, calc(100vw - 24px));
    height: min(440px, calc(100vh - 120px));
    max-height: 440px;
    background: #fff;
    border: 1px solid #cfe9e9;
    border-radius: 18px;
    box-shadow: 0 22px 48px rgba(1, 60, 60, 0.2);
    overflow: hidden;
    flex-direction: column;
}

.nj-chat-root.is-open .nj-chat-panel {
    display: flex;
    animation: nj-chat-rise .22s ease-out;
}

@keyframes nj-chat-rise {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.nj-chat-header {
    position: relative;
    flex: 0 0 auto;
    background:
        linear-gradient(125deg, rgba(255, 255, 255, 0.12), transparent 40%),
        linear-gradient(120deg, #017f7f, #01A8A8 55%, #019696);
    color: #fff;
    padding: 12px 12px 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    overflow: hidden;
}

.nj-chat-header::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .16;
    background-image:
        linear-gradient(30deg, transparent 48%, rgba(255, 255, 255, .35) 49%, transparent 51%),
        linear-gradient(-30deg, transparent 48%, rgba(255, 255, 255, .25) 49%, transparent 51%);
    background-size: 16px 16px;
    pointer-events: none;
}

.nj-chat-header-main {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.nj-chat-header-badge {
    width: 38px;
    height: 38px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.nj-chat-header-badge img {
    width: 32px;
    height: 32px;
}

.nj-chat-header strong {
    display: block;
    font-size: 14px;
    line-height: 1.35;
}

.nj-chat-header span {
    display: block;
    font-size: 10.5px;
    opacity: .92;
    margin-top: 2px;
    line-height: 1.4;
}

.nj-chat-close {
    position: relative;
    z-index: 1;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    flex: 0 0 auto;
}

.nj-chat-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    background:
        radial-gradient(circle at top right, rgba(1, 168, 168, 0.07), transparent 42%),
        #f7fcfc;
}

.nj-chat-bubble {
    max-width: 92%;
    margin-bottom: 10px;
    padding: 10px 12px;
    border-radius: 13px;
    line-height: 1.65;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--nj-ink);
}

.nj-chat-bubble--bot {
    background: #fff;
    border: 1px solid #d5ecec;
    border-bottom-right-radius: 4px;
    box-shadow: 0 3px 10px rgba(1, 80, 80, 0.04);
}

html[dir="ltr"] .nj-chat-bubble--bot {
    border-bottom-right-radius: 13px;
    border-bottom-left-radius: 4px;
}

.nj-chat-bubble--user {
    margin-left: auto;
    background: linear-gradient(135deg, #01A8A8, #018787);
    color: #fff;
    border-bottom-left-radius: 4px;
}

html[dir="ltr"] .nj-chat-bubble--user {
    margin-left: 0;
    margin-right: auto;
    border-bottom-left-radius: 13px;
    border-bottom-right-radius: 4px;
}

.nj-chat-source {
    display: inline-block;
    margin-top: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: bold;
    background: #f3fbfb;
    border: 1px solid #bfe7e7;
    color: #017d7d;
}

.nj-chat-source[data-source="chatgpt"] {
    border-color: #b7d4ff;
    color: #1a5fb4;
    background: #f3f8ff;
}

.nj-chat-source[data-source="deepseek"] {
    border-color: #d7c8a0;
    color: #7a5a18;
    background: #fff9ec;
}

.nj-chat-source[data-source="wikipedia"] {
    border-color: #c9d4e0;
    color: #334;
    background: #f4f6f8;
}

.nj-chat-source[data-source="site"] {
    border-color: #bfe7e7;
    color: #017d7d;
    background: #f3fbfb;
}

.nj-chat-link {
    color: #017070;
    font-weight: bold;
    word-break: break-all;
    text-decoration: underline;
}

.nj-chat-bubble--user .nj-chat-link {
    color: #fff;
}

.nj-chat-suggest {
    flex: 0 0 auto;
    padding: 0 10px 8px;
    background: #f7fcfc;
    border-top: 1px solid #e6f2f2;
}

.nj-chat-suggest.is-hidden {
    display: none;
}

.nj-chat-suggest-label {
    font-size: 11px;
    color: #5a7777;
    margin: 8px 2px 6px;
}

.nj-chat-suggest-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.nj-chat-chip {
    border: 1px solid #bfe7e7;
    background: #fff;
    color: #017070;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 11.5px;
    line-height: 1.3;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.nj-chat-chip:hover,
.nj-chat-chip:focus {
    background: #01A8A8;
    border-color: #01A8A8;
    color: #fff;
    outline: none;
}

.nj-chat-typing {
    flex: 0 0 auto;
    font-size: 12px;
    color: #678;
    padding: 0 12px 6px;
    display: none;
    background: #f7fcfc;
}

.nj-chat-root.is-busy .nj-chat-typing {
    display: block;
}

/* Compact composer — never grow tall */
.nj-chat-composer {
    flex: 0 0 auto !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #dff0f0;
    background: #fff;
    min-height: 0 !important;
    height: auto !important;
    max-height: 64px !important;
}

.nj-chat-composer .nj-chat-input {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    height: 40px !important;
    max-height: 40px !important;
    min-height: 40px !important;
    margin: 0 !important;
    border: 1px solid #c5e6e6 !important;
    border-radius: 11px !important;
    padding: 0 12px !important;
    font-size: 13px !important;
    line-height: 40px !important;
    color: var(--nj-ink) !important;
    background: #fff !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    resize: none !important;
}

.nj-chat-composer .nj-chat-input:focus {
    border-color: #01A8A8 !important;
    box-shadow: 0 0 0 3px rgba(1, 168, 168, 0.14) !important;
    outline: none !important;
}

.nj-chat-composer .nj-chat-send {
    flex: 0 0 auto !important;
    height: 40px !important;
    min-width: 72px;
    margin: 0 !important;
    border: none !important;
    border-radius: 11px !important;
    background: linear-gradient(135deg, #01A8A8, #017d7d) !important;
    color: #fff !important;
    padding: 0 14px !important;
    font-size: 13px !important;
    font-weight: bold !important;
    cursor: pointer;
    box-shadow: 0 5px 12px rgba(1, 120, 120, 0.18);
}

.nj-chat-composer .nj-chat-send:disabled {
    opacity: .65;
    cursor: wait;
}

@media (max-width: 767px) {
    .nj-chat-root {
        right: 12px;
        bottom: 16px;
    }

    .nj-chat-panel {
        bottom: 70px;
        height: min(68vh, 460px);
        max-height: 460px;
    }

    #back-top.back-to-top {
        left: 12px;
        bottom: 88px;
    }
}
