/* ============================================
   EdKey Chatbot Widget – chatbot.css
   Agent EdKey – Premium Floating Chat Widget
   ============================================ */

/* ---- Toggle Button ---- */
.chatbot-toggle-btn {
    position: fixed;
    bottom: 5.5rem;
    /* above back-to-top button */
    right: 1.5rem;
    z-index: 9998;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #09aff4 0%, #0d1857 100%);
    box-shadow: 0 4px 20px rgba(9, 175, 244, 0.45);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
}

.chatbot-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(9, 175, 244, 0.6);
}

.chatbot-toggle-btn .chat-icon,
.chatbot-toggle-btn .close-icon {
    position: absolute;
    font-size: 1.35rem;
    color: #fff;
    transition: all 0.3s ease;
}

.chatbot-toggle-btn .close-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0.5);
}

.chatbot-toggle-btn.is-open .chat-icon {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.chatbot-toggle-btn.is-open .close-icon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Pulse ring */
.chatbot-toggle-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(9, 175, 244, 0.5);
    animation: chatbot-pulse 2.5s ease-out infinite;
}

@keyframes chatbot-pulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }

    70% {
        transform: scale(1.4);
        opacity: 0;
    }

    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

/* Notification badge */
.chatbot-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 14px;
    height: 14px;
    background: #fb0205;
    border-radius: 50%;
    border: 2px solid #fff;
    animation: badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes badge-pop {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* ---- Widget Panel ---- */
.chatbot-widget {
    position: fixed;
    bottom: 9.5rem;
    right: 1.5rem;
    z-index: 9997;
    width: 370px;
    max-width: calc(100vw - 2rem);
    max-height: 560px;
    display: flex;
    flex-direction: column;
    border-radius: 1.25rem;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(9, 175, 244, 0.15);
    transform: translateY(20px) scale(0.92);
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Glassmorphism */
    background: rgba(6, 9, 34, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(9, 175, 244, 0.25);
}

.chatbot-widget.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* ---- Header ---- */
.chatbot-header {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, rgba(9, 175, 244, 0.2) 0%, rgba(13, 24, 87, 0.4) 100%);
    border-bottom: 1px solid rgba(9, 175, 244, 0.2);
    flex-shrink: 0;
}

.chatbot-avatar {
    position: relative;
    flex-shrink: 0;
}

.chatbot-avatar-img {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(9, 175, 244, 0.5);
}

.chatbot-avatar-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #09aff4 0%, #0d1857 100%);
    border: 2px solid rgba(9, 175, 244, 0.5);
    font-size: 1.2rem;
    color: #fff;
}

.chatbot-status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid rgba(6, 9, 34, 0.9);
    background: #22c55e;
    transition: background 0.3s ease;
}

.chatbot-status-dot.offline {
    background: #94a3b8;
}

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

.chatbot-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
    line-height: 1.2;
    letter-spacing: 0.3px;
}

.chatbot-status-text {
    font-size: 0.72rem;
    color: #22c55e;
    margin: 0;
    margin-top: 2px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.chatbot-status-text.offline {
    color: #94a3b8;
}

.chatbot-close-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    flex-shrink: 0;
    outline: none;
}

.chatbot-close-btn:hover {
    background: rgba(9, 175, 244, 0.25);
    color: #fff;
}

/* ---- Messages Area ---- */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(9, 175, 244, 0.3) transparent;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(9, 175, 244, 0.3);
    border-radius: 2px;
}

/* Welcome / date separator */
.chat-date-separator {
    text-align: center;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.35);
    margin: 0.25rem 0;
    position: relative;
}

.chat-date-separator::before,
.chat-date-separator::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.chat-date-separator::before {
    right: 52%;
}

.chat-date-separator::after {
    left: 52%;
}

/* Message row */
.chat-message {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    animation: message-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes message-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user-message {
    flex-direction: row-reverse;
}

/* Small avatar inside chat */
.msg-avatar {
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    background: linear-gradient(135deg, #09aff4 0%, #0d1857 100%);
    color: #fff;
}

.chat-message.user-message .msg-avatar {
    background: linear-gradient(135deg, #4820a7 0%, #0d1857 100%);
}

/* Bubble */
.msg-bubble {
    max-width: 78%;
    padding: 0.65rem 0.95rem;
    border-radius: 1.1rem;
    font-size: 0.875rem;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    position: relative;
}

/* Agent bubble */
.chat-message.agent-message .msg-bubble {
    background: rgba(9, 175, 244, 0.12);
    border: 1px solid rgba(9, 175, 244, 0.2);
    color: rgba(255, 255, 255, 0.92);
    border-bottom-left-radius: 0.25rem;
}

/* User bubble */
.chat-message.user-message .msg-bubble {
    background: linear-gradient(135deg, #09aff4 0%, #0d1857 100%);
    color: #fff;
    border-bottom-right-radius: 0.25rem;
}

.msg-time {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 3px;
    display: block;
    text-align: right;
}

.chat-message.agent-message .msg-time {
    text-align: left;
}

/* Markdown bold inside messages */
.msg-bubble strong {
    color: #09aff4;
    font-weight: 700;
}

/* ---- Typing indicator ---- */
.typing-indicator {
    display: flex;
    align-items: flex-end;
    gap: 0.6rem;
    animation: message-in 0.3s ease forwards;
}

.typing-indicator .typing-dots {
    background: rgba(9, 175, 244, 0.12);
    border: 1px solid rgba(9, 175, 244, 0.2);
    border-radius: 1.1rem;
    border-bottom-left-radius: 0.25rem;
    padding: 0.7rem 1rem;
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-indicator .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(9, 175, 244, 0.6);
    animation: typing-bounce 1.2s ease-in-out infinite;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.5;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ---- Input Footer ---- */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    border-top: 1px solid rgba(9, 175, 244, 0.15);
    background: rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(9, 175, 244, 0.2);
    border-radius: 2rem;
    padding: 0.6rem 1.1rem;
    color: #fff;
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.25s ease;
    min-width: 0;
}

.chat-input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.chat-input:focus {
    border-color: rgba(9, 175, 244, 0.55);
    background: rgba(9, 175, 244, 0.06);
}

.chat-send-btn {
    background: linear-gradient(135deg, #09aff4 0%, #0d1857 100%);
    border: none;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    font-size: 1rem;
    flex-shrink: 0;
    transition: all 0.25s ease;
    outline: none;
}

.chat-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(9, 175, 244, 0.4);
}

.chat-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ---- Light theme overrides ---- */
body.light-theme .chatbot-widget {
    background: rgba(255, 255, 255, 0.96);
    border-color: rgba(9, 175, 244, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 6px 20px rgba(9, 175, 244, 0.15);
}

body.light-theme .chatbot-header {
    background: linear-gradient(135deg, rgba(9, 175, 244, 0.12) 0%, rgba(13, 24, 87, 0.08) 100%);
}

body.light-theme .chatbot-name {
    color: #0d1857;
}

body.light-theme .chatbot-close-btn {
    color: rgba(13, 24, 87, 0.6);
    background: rgba(13, 24, 87, 0.06);
}

body.light-theme .chatbot-close-btn:hover {
    color: #0d1857;
    background: rgba(9, 175, 244, 0.15);
}

body.light-theme .chat-messages {
    scrollbar-color: rgba(9, 175, 244, 0.3) transparent;
}

body.light-theme .chat-message.agent-message .msg-bubble {
    background: rgba(9, 175, 244, 0.08);
    border-color: rgba(9, 175, 244, 0.25);
    color: #1a1a2e;
}

body.light-theme .chat-date-separator {
    color: rgba(0, 0, 0, 0.35);
}

body.light-theme .chat-input {
    background: rgba(13, 24, 87, 0.04);
    border-color: rgba(9, 175, 244, 0.3);
    color: #0d1857;
}

body.light-theme .chat-input::placeholder {
    color: rgba(13, 24, 87, 0.4);
}

body.light-theme .chat-input-area {
    background: rgba(13, 24, 87, 0.03);
    border-top-color: rgba(9, 175, 244, 0.15);
}

body.light-theme .typing-indicator .typing-dots {
    background: rgba(9, 175, 244, 0.08);
}

body.light-theme .msg-time {
    color: rgba(0, 0, 0, 0.3);
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
    .chatbot-widget {
        right: 0.75rem;
        bottom: 9rem;
        width: calc(100vw - 1.5rem);
        max-height: 480px;
        border-radius: 1rem;
    }

    .chatbot-toggle-btn {
        bottom: 5rem;
        right: 0.75rem;
    }
}