/* ═══════════════════════════════════════════════════
   MITR AI & WEB — AI Chatbot Widget
   Glassmorphism + Aurora style
   ═══════════════════════════════════════════════════ */

/* ── Floating Button ── */
.chatbot-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    font-size: 1.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow:
        0 6px 24px rgba(45, 106, 223, .35),
        0 0 0 0 rgba(45, 106, 223, .3);
    transition: transform .3s cubic-bezier(.4, 0, .2, 1), box-shadow .3s ease;
    animation: fabPulse 2.5s ease-in-out infinite;
}

.chatbot-fab:hover {
    transform: scale(1.08);
    box-shadow:
        0 8px 32px rgba(45, 106, 223, .45),
        0 0 0 8px rgba(45, 106, 223, .08);
}

.chatbot-fab.open {
    animation: none;
    transform: rotate(90deg) scale(1);
}

.chatbot-fab .fab-icon,
.chatbot-fab .fab-close {
    position: absolute;
    transition: opacity .25s, transform .25s;
}

.chatbot-fab .fab-close {
    opacity: 0;
    transform: scale(.6) rotate(-90deg);
}

.chatbot-fab.open .fab-icon {
    opacity: 0;
    transform: scale(.6) rotate(90deg);
}

.chatbot-fab.open .fab-close {
    opacity: 1;
    transform: scale(1) rotate(0);
}

@keyframes fabPulse {

    0%,
    100% {
        box-shadow: 0 6px 24px rgba(45, 106, 223, .35), 0 0 0 0 rgba(45, 106, 223, .3);
    }

    50% {
        box-shadow: 0 6px 24px rgba(45, 106, 223, .35), 0 0 0 12px rgba(45, 106, 223, 0);
    }
}

/* ── Notification Badge ── */
.chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #FF4757;
    border-radius: 50%;
    border: 2.5px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .6rem;
    font-weight: 700;
    color: #fff;
    animation: badgeBounce .5s cubic-bezier(.4, 0, .2, 1);
}

@keyframes badgeBounce {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
    }
}

/* ── Chat Window ── */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 28px;
    z-index: 9999;
    width: 380px;
    max-height: 560px;
    border-radius: 20px;
    overflow: hidden;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(24px) saturate(1.6);
    -webkit-backdrop-filter: blur(24px) saturate(1.6);
    border: 1px solid rgba(255, 255, 255, .6);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, .12),
        0 0 0 1px rgba(45, 106, 223, .06);
    display: flex;
    flex-direction: column;
    transform: scale(.88) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: transform .35s cubic-bezier(.4, 0, .2, 1),
        opacity .3s ease;
    transform-origin: bottom right;
}

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

/* ── Header ── */
.chatbot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: #fff;
    position: relative;
}

.chatbot-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, .15);
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, .2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.chatbot-header-info {
    flex: 1;
    min-width: 0;
}

.chatbot-header-name {
    font-weight: 600;
    font-size: .95rem;
    letter-spacing: -.01em;
}

.chatbot-header-status {
    font-size: .72rem;
    opacity: .85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.chatbot-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2ECC71;
    display: inline-block;
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: .5;
    }
}

/* ── Messages Area ── */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 300px;
    max-height: 360px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Scrollbar */
.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .12);
    border-radius: 4px;
}

/* ── Message Bubbles ── */
.cb-msg {
    border-radius: 16px;
    padding: 10px 16px;
    font-size: .88rem;
    line-height: 1.6;
    max-width: 82%;
    word-break: break-word;
    animation: cbFadeIn .35s cubic-bezier(.4, 0, .2, 1);
    position: relative;
}

.cb-msg.bot {
    align-self: flex-start;
    background: var(--bg-alt);
    color: var(--text);
    border-bottom-left-radius: 5px;
}

.cb-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border-bottom-right-radius: 5px;
}

.cb-msg.error {
    align-self: center;
    background: rgba(255, 71, 87, .08);
    color: #E55343;
    font-size: .8rem;
    text-align: center;
    border-radius: 10px;
    max-width: 90%;
}

@keyframes cbFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px) scale(.97);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* ── Typing Indicator ── */
.cb-typing {
    display: none;
    align-self: flex-start;
    align-items: center;
    gap: 4px;
    padding: 12px 18px;
    background: var(--bg-alt);
    border-radius: 16px;
    border-bottom-left-radius: 5px;
}

.cb-typing.show {
    display: flex;
}

.cb-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    opacity: .4;
    animation: cbBlink 1.2s infinite;
    display: block;
}

.cb-typing i:nth-child(2) {
    animation-delay: .2s;
}

.cb-typing i:nth-child(3) {
    animation-delay: .4s;
}

@keyframes cbBlink {

    0%,
    100% {
        opacity: .3;
        transform: scale(.75);
    }

    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ── Input Area ── */
.chatbot-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--border);
    background: rgba(255, 255, 255, .5);
}

.chatbot-input {
    flex: 1;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, .6);
    border-radius: 12px;
    padding: 10px 16px;
    font-size: .88rem;
    font-family: var(--font);
    color: var(--text);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    resize: none;
    max-height: 80px;
    line-height: 1.5;
}

.chatbot-input::placeholder {
    color: var(--text-3);
}

.chatbot-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 106, 223, .08);
}

.chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .2s, opacity .2s;
    flex-shrink: 0;
}

.chatbot-send:hover {
    transform: scale(1.06);
}

.chatbot-send:disabled {
    opacity: .4;
    cursor: not-allowed;
    transform: none;
}

/* ── Rate Limit Warning ── */
.chatbot-rate-warn {
    padding: 8px 16px;
    background: rgba(255, 190, 47, .1);
    color: #B8860B;
    font-size: .75rem;
    text-align: center;
    display: none;
    border-top: 1px solid rgba(255, 190, 47, .15);
}

.chatbot-rate-warn.show {
    display: block;
}

/* ── Quick Actions ── */
.cb-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-self: flex-start;
    margin-top: 4px;
    animation: cbFadeIn .4s cubic-bezier(.4, 0, .2, 1);
}

.cb-quick-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: rgba(255, 255, 255, .7);
    color: var(--primary);
    font-size: .78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all .2s;
    font-family: var(--font);
}

.cb-quick-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ── Powered-by ── */
.chatbot-powered {
    text-align: center;
    padding: 6px;
    font-size: .62rem;
    color: var(--text-3);
    background: rgba(255, 255, 255, .3);
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        max-height: calc(100vh - 120px);
        border-radius: 16px;
    }

    .chatbot-fab {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
        font-size: 1.4rem;
    }

    .chatbot-messages {
        min-height: 250px;
        max-height: calc(100vh - 280px);
    }
}

@media (max-width: 360px) {
    .chatbot-window {
        width: calc(100vw - 8px);
        right: 4px;
    }
}