/********** EMIS Chatbot — Modern UI **********/

:root {
    --emis-chat-primary: #06bbcc;
    --emis-chat-primary-dark: #0796a5;
    --emis-chat-blue: #12345a;
    --emis-chat-blue-dark: #081f38;
    --emis-chat-green: #16833d;
    --emis-chat-gold: #f5b400;
    --emis-chat-ink: #172033;
    --emis-chat-muted: #667085;
    --emis-chat-soft: #f6fbfd;
    --emis-chat-border: rgba(18, 52, 90, 0.10);
    --emis-chat-shadow: 0 28px 80px rgba(8, 26, 51, 0.24);
}

/********** Floating Button **********/
.emis-chatbot-float {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 68px;
    height: 68px;
    border: none;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 1060;
    padding: 0;
    cursor: pointer;
}

.emis-chatbot-icon {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 28% 20%, rgba(255,255,255,0.18), transparent 26%),
        linear-gradient(135deg, var(--emis-chat-blue), var(--emis-chat-blue-dark));
    color: #ffffff;
    font-size: 1.45rem;
    box-shadow: 0 18px 42px rgba(6, 18, 35, 0.32);
    border: 4px solid rgba(255, 255, 255, 0.18);
    position: relative;
    z-index: 3;
    transition: transform 0.35s ease, background 0.35s ease, box-shadow 0.35s ease;
}

.emis-chatbot-float:hover .emis-chatbot-icon {
    transform: scale(1.06) rotate(-4deg);
    background:
        radial-gradient(circle at 28% 20%, rgba(255,255,255,0.20), transparent 26%),
        linear-gradient(135deg, var(--emis-chat-primary), var(--emis-chat-primary-dark));
    box-shadow: 0 22px 48px rgba(6, 187, 204, 0.32);
}

.emis-chatbot-ripple {
    position: absolute;
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(6, 187, 204, 0.20);
    z-index: 1;
    animation: emisPulse 2.2s infinite;
}

.emis-chatbot-ripple.ripple-delay {
    animation-delay: 1.1s;
}

.emis-chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    z-index: 5;
    min-width: 24px;
    height: 24px;
    padding: 0 7px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--emis-chat-blue-dark);
    background: var(--emis-chat-gold);
    border: 3px solid #ffffff;
    font-size: 0.72rem;
    font-weight: 950;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.18);
}

.emis-chatbot-badge.is-hidden {
    display: none;
}

@keyframes emisPulse {
    0% {
        transform: scale(1);
        opacity: 0.55;
    }

    70% {
        transform: scale(1.62);
        opacity: 0;
    }

    100% {
        transform: scale(1.62);
        opacity: 0;
    }
}

/********** Panel **********/
.emis-chatbot-panel {
    position: fixed;
    right: 18px;
    bottom: 18px;
    width: min(430px, calc(100vw - 36px));
    height: min(690px, calc(100vh - 52px));
    z-index: 1080;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(18px) scale(0.975);
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0.28s;
}

.emis-chatbot-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0s linear 0s;
}

.emis-chatbot-window {
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at top left, rgba(6, 187, 204, 0.10), transparent 34%),
        linear-gradient(180deg, #ffffff 0%, #f5f9fc 100%);
    border-radius: 30px;
    overflow: hidden;
    box-shadow: var(--emis-chat-shadow);
    border: 1px solid rgba(255, 255, 255, 0.78);
    display: flex;
    flex-direction: column;
    position: relative;
}

.emis-chatbot-window::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 5px;
    background: linear-gradient(90deg, var(--emis-chat-primary), var(--emis-chat-gold), var(--emis-chat-green));
    z-index: 3;
}

/********** Header **********/
.emis-chatbot-header {
    min-height: 74px;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--emis-chat-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 16px;
    backdrop-filter: blur(16px);
    position: relative;
    z-index: 2;
}

.emis-chatbot-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.emis-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.emis-chat-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(18, 52, 90, 0.055);
    color: #667085;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background 0.3s ease, color 0.3s ease;
    padding: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.emis-chat-icon-btn:hover,
.emis-chat-icon-btn:focus {
    background: rgba(6, 187, 204, 0.12);
    color: var(--emis-chat-blue);
    transform: translateY(-1px);
    outline: none;
}

.emis-chatbot-single-avatar-wrap {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.emis-chatbot-single-avatar-wrap::after {
    content: "";
    position: absolute;
    right: 1px;
    bottom: 2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #ffffff;
}

.emis-chatbot-single-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: contain;
    display: block;
    background: #ffffff;
    border: 2px solid #ffffff;
    box-shadow: 0 10px 22px rgba(15, 39, 71, 0.12);
    padding: 3px;
}

.emis-chatbot-header-meta {
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.emis-chatbot-title {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.2;
    color: var(--emis-chat-ink);
    font-weight: 950;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.emis-chatbot-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--emis-chat-muted);
    font-size: 0.84rem;
    line-height: 1.2;
    margin-top: 3px;
    white-space: nowrap;
    font-weight: 700;
}

.emis-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12);
}

/********** Body **********/
.emis-chatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 12px;
    background:
        radial-gradient(circle at top left, rgba(6, 187, 204, 0.08), transparent 30%),
        radial-gradient(circle at bottom right, rgba(245, 180, 0, 0.10), transparent 34%),
        linear-gradient(180deg, #f8fbfe 0%, #eef5f8 100%);
    scroll-behavior: smooth;
}

/********** Intro Card **********/
.emis-chat-system-intro {
    max-width: 100%;
    margin: 0 auto 18px;
    padding: 18px;
    border-radius: 26px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.82);
    box-shadow: 0 18px 40px rgba(15, 39, 71, 0.08);
    backdrop-filter: blur(14px);
    text-align: left;
    position: relative;
    overflow: hidden;
}

.emis-chat-system-intro::after {
    content: "";
    position: absolute;
    width: 110px;
    height: 110px;
    right: -54px;
    top: -54px;
    border-radius: 50%;
    background: rgba(6, 187, 204, 0.12);
}

.emis-chat-intro-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 11px;
    border-radius: 999px;
    color: var(--emis-chat-blue-dark);
    background: rgba(245, 180, 0, 0.22);
    font-size: 0.72rem;
    font-weight: 950;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 12px;
    position: relative;
    z-index: 2;
}

.emis-chat-intro-tag i {
    color: var(--emis-chat-gold);
}

.emis-chat-system-intro h4 {
    margin: 0 0 8px;
    color: var(--emis-chat-ink);
    font-size: 1.22rem;
    font-weight: 950;
    letter-spacing: -0.035em;
    position: relative;
    z-index: 2;
}

.emis-chat-system-intro p {
    margin: 0;
    color: var(--emis-chat-muted);
    font-size: 0.92rem;
    line-height: 1.62;
    font-weight: 700;
    position: relative;
    z-index: 2;
}

.emis-chat-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 15px;
    position: relative;
    z-index: 2;
}

.emis-chat-chip {
    border: 1px solid rgba(6, 187, 204, 0.18);
    background: #ffffff;
    color: var(--emis-chat-blue);
    border-radius: 999px;
    padding: 9px 12px;
    font-size: 0.8rem;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    box-shadow: 0 10px 22px rgba(15, 39, 71, 0.06);
    cursor: pointer;
    transition: transform 0.3s ease, background 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.emis-chat-chip i {
    color: var(--emis-chat-primary);
}

.emis-chat-chip:hover {
    transform: translateY(-2px);
    background: var(--emis-chat-blue);
    color: #ffffff;
    box-shadow: 0 14px 28px rgba(15, 39, 71, 0.13);
}

.emis-chat-chip:hover i {
    color: var(--emis-chat-gold);
}

/********** Messages **********/
.emis-chat-message {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 15px;
    animation: emisMessageFade 0.28s ease;
}

@keyframes emisMessageFade {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.emis-chat-message-user {
    justify-content: flex-end;
}

.emis-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 8px 18px rgba(15, 39, 71, 0.10);
    background: #ffffff;
    border: 2px solid #ffffff;
}

.emis-chat-bubble-wrap {
    max-width: 78%;
    display: flex;
    flex-direction: column;
}

.emis-chat-message-user .emis-chat-bubble-wrap {
    align-items: flex-end;
}

.emis-chat-bubble {
    padding: 12px 15px;
    border-radius: 20px;
    font-size: 0.94rem;
    line-height: 1.62;
    word-break: break-word;
    overflow-wrap: anywhere;
    box-shadow: 0 10px 24px rgba(15, 39, 71, 0.07);
    white-space: normal;
}

.emis-chat-message-bot .emis-chat-bubble {
    background: rgba(255, 255, 255, 0.96);
    color: #455468;
    border-top-left-radius: 8px;
    border: 1px solid rgba(18, 52, 90, 0.06);
}

.emis-chat-message-user .emis-chat-bubble {
    background: linear-gradient(135deg, var(--emis-chat-primary), var(--emis-chat-primary-dark));
    color: #ffffff;
    border-top-right-radius: 8px;
}

.emis-chat-bubble strong,
.emis-chat-bubble b {
    font-weight: 900;
}

.emis-chat-bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.emis-chat-message-bot .emis-chat-bubble a {
    color: #0f6bdc;
}

.emis-chat-bubble ul,
.emis-chat-bubble ol {
    margin: 8px 0 0 18px;
    padding: 0;
}

.emis-chat-bubble li + li {
    margin-top: 4px;
}

.emis-chat-bubble br + br {
    content: "";
    display: block;
    margin-top: 6px;
}

.emis-chat-time {
    font-size: 0.73rem;
    color: #8a94a6;
    margin-top: 5px;
    padding: 0 6px;
    font-weight: 700;
}

/********** Composer **********/
.emis-chatbot-composer {
    padding: 13px 15px 15px;
    background: rgba(245, 249, 252, 0.96);
    border-top: 1px solid rgba(18, 52, 90, 0.06);
}

.emis-chatbot-composer-box {
    background: rgba(255, 255, 255, 0.96);
    border: 2px solid rgba(6, 187, 204, 0.50);
    border-radius: 24px;
    min-height: 98px;
    padding: 13px 13px 9px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: 0 12px 28px rgba(15, 39, 71, 0.07);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
}

.emis-chatbot-composer-box:focus-within {
    border-color: var(--emis-chat-primary);
    box-shadow: 0 16px 34px rgba(6, 187, 204, 0.15);
}

.emis-chatbot-input-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.emis-chatbot-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    min-height: 32px;
    max-height: 118px;
    padding: 2px 0;
    font-size: 0.98rem;
    line-height: 1.5;
    color: #344054;
    font-family: inherit;
}

.emis-chatbot-input::placeholder {
    color: #7b8190;
}

.emis-chatbot-input[aria-busy="true"] {
    opacity: 0.82;
}

.emis-chat-send-btn {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background: #d7d9de;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
    padding: 0;
    cursor: pointer;
}

.emis-chat-send-btn:hover,
.emis-chat-send-btn:focus {
    outline: none;
    transform: scale(1.04);
}

.emis-chat-send-btn.is-active {
    background: linear-gradient(135deg, var(--emis-chat-primary), var(--emis-chat-primary-dark));
    box-shadow: 0 12px 24px rgba(6, 187, 204, 0.28);
}

.emis-chat-send-btn.is-active:hover {
    transform: translateY(-2px);
}

.emis-chat-send-btn:disabled {
    cursor: not-allowed;
    opacity: 0.78;
    transform: none;
    box-shadow: none;
}

.emis-chatbot-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 9px;
}

.emis-chat-tool-btn {
    border: none;
    background: transparent;
    color: #7b8190;
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    transition: transform 0.3s ease, background 0.3s ease, color 0.3s ease;
    padding: 0;
    cursor: pointer;
}

.emis-chat-tool-btn:hover,
.emis-chat-tool-btn:focus {
    background: rgba(6, 187, 204, 0.10);
    color: var(--emis-chat-blue);
    outline: none;
    transform: translateY(-1px);
}

.emis-chat-gif-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.64rem;
    font-weight: 900;
    border: 1px solid currentColor;
    border-radius: 4px;
    padding: 1px 4px;
    line-height: 1;
}

/********** Typing Indicator **********/
.emis-chat-bubble-typing {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    min-width: 112px;
    color: #5f6c80;
}

.emis-chat-bubble-typing span:first-child {
    margin-right: 4px;
    font-size: 0.9rem;
    font-weight: 800;
}

.emis-dot {
    display: inline-block;
    font-weight: 900;
    animation: emisTypingBlink 1.2s infinite;
    opacity: 0.28;
}

.emis-dot:nth-child(2) {
    animation-delay: 0s;
}

.emis-dot:nth-child(3) {
    animation-delay: 0.2s;
}

.emis-dot:nth-child(4) {
    animation-delay: 0.4s;
}

@keyframes emisTypingBlink {
    0%, 80%, 100% {
        opacity: 0.22;
        transform: translateY(0);
    }

    40% {
        opacity: 1;
        transform: translateY(-1px);
    }
}

/********** Scrollbar **********/
.emis-chatbot-body::-webkit-scrollbar {
    width: 8px;
}

.emis-chatbot-body::-webkit-scrollbar-thumb {
    background: rgba(15, 39, 71, 0.16);
    border-radius: 999px;
}

.emis-chatbot-body::-webkit-scrollbar-track {
    background: transparent;
}

body.chatbot-open {
    overflow: hidden;
}

/********** Tablet **********/
@media (max-width: 991.98px) {
    .emis-chatbot-panel {
        width: min(390px, calc(100vw - 28px));
        height: min(610px, calc(100vh - 96px));
        right: 12px;
        bottom: 12px;
    }

    .emis-chat-system-intro {
        padding: 16px;
    }
}

/********** Mobile **********/
@media (max-width: 767.98px) {
    .emis-chatbot-float {
        right: 18px;
        bottom: 82px;
        width: 58px;
        height: 58px;
    }

    .emis-chatbot-icon,
    .emis-chatbot-ripple {
        width: 58px;
        height: 58px;
    }

    .emis-chatbot-icon {
        font-size: 1.15rem;
    }

    .emis-chatbot-badge {
        min-width: 22px;
        height: 22px;
        font-size: 0.68rem;
    }

    .emis-chatbot-panel {
        right: 12px;
        bottom: 12px;
        width: calc(100vw - 24px);
        max-width: 360px;
        height: min(560px, calc(100vh - 112px));
    }

    .emis-chatbot-window {
        border-radius: 24px;
    }

    .emis-chatbot-header {
        padding: 11px 12px;
        min-height: 62px;
    }

    .emis-chatbot-single-avatar-wrap,
    .emis-chatbot-single-avatar {
        width: 34px;
        height: 34px;
    }

    .emis-chatbot-single-avatar {
        padding: 2px;
    }

    .emis-chatbot-title {
        font-size: 0.94rem;
    }

    .emis-chatbot-status {
        font-size: 0.78rem;
    }

    .emis-chat-icon-btn {
        width: 32px;
        height: 32px;
    }

    .emis-chatbot-body {
        padding: 13px 12px 10px;
    }

    .emis-chat-system-intro {
        padding: 15px;
        border-radius: 22px;
        margin-bottom: 15px;
    }

    .emis-chat-system-intro h4 {
        font-size: 1.05rem;
    }

    .emis-chat-system-intro p {
        font-size: 0.86rem;
        line-height: 1.55;
    }

    .emis-chat-quick-actions {
        gap: 7px;
    }

    .emis-chat-chip {
        padding: 8px 10px;
        font-size: 0.76rem;
    }

    .emis-chat-bubble-wrap {
        max-width: 84%;
    }

    .emis-chat-bubble {
        font-size: 0.88rem;
        line-height: 1.55;
        padding: 11px 13px;
    }

    .emis-chat-avatar {
        width: 34px;
        height: 34px;
    }

    .emis-chatbot-composer {
        padding: 10px 12px 12px;
    }

    .emis-chatbot-composer-box {
        min-height: 88px;
        border-radius: 18px;
        padding: 10px 10px 8px;
    }

    .emis-chatbot-input {
        font-size: 0.92rem;
    }

    .emis-chatbot-tools {
        gap: 8px;
        flex-wrap: wrap;
    }

    .emis-chat-send-btn {
        width: 40px;
        height: 40px;
    }
}

/********** Small Mobile **********/
@media (max-width: 479.98px) {
    .emis-chatbot-panel {
        width: calc(100vw - 20px);
        max-width: none;
        height: min(530px, calc(100vh - 118px));
        right: 10px;
        bottom: 10px;
    }

    .emis-chatbot-header-left {
        gap: 8px;
    }

    .emis-chatbot-single-avatar-wrap,
    .emis-chatbot-single-avatar {
        width: 31px;
        height: 31px;
    }

    .emis-chatbot-title {
        font-size: 0.88rem;
    }

    .emis-chatbot-status {
        font-size: 0.73rem;
    }

    .emis-chatbot-body {
        padding: 11px 10px 8px;
    }

    .emis-chat-system-intro {
        padding: 13px;
        border-radius: 20px;
    }

    .emis-chat-system-intro h4 {
        font-size: 1rem;
    }

    .emis-chat-system-intro p {
        font-size: 0.82rem;
    }

    .emis-chat-chip {
        flex: 1 1 calc(50% - 7px);
        justify-content: center;
        padding: 8px 9px;
        font-size: 0.72rem;
    }

    .emis-chat-message {
        gap: 8px;
        margin-bottom: 13px;
    }

    .emis-chat-avatar {
        width: 31px;
        height: 31px;
    }

    .emis-chat-bubble-wrap {
        max-width: 87%;
    }

    .emis-chat-bubble {
        font-size: 0.84rem;
        padding: 10px 12px;
    }

    .emis-chatbot-composer-box {
        min-height: 84px;
        border-radius: 16px;
        padding: 9px 9px 7px;
    }

    .emis-chat-tool-btn {
        width: 28px;
        height: 28px;
    }

    .emis-chat-send-btn {
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 380px) {
    .emis-chatbot-panel {
        height: min(500px, calc(100vh - 112px));
    }

    .emis-chat-chip {
        font-size: 0.69rem;
        padding: 8px 7px;
    }
}

/********** Touch and Reduced Motion **********/
@media (hover: none) {
    .emis-chatbot-float:hover .emis-chatbot-icon,
    .emis-chat-chip:hover,
    .emis-chat-send-btn.is-active:hover,
    .emis-chat-tool-btn:hover,
    .emis-chat-icon-btn:hover {
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}