/* ============================================
   NEXA CHATBOT — Premium Design System
   ============================================ */

/* --- Toggle Button --- */
.chatbot-toggler {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(30, 58, 138, 0.4);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    outline: none;
}

.chatbot-toggler:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(30, 58, 138, 0.5);
}

.chatbot-toggler:active {
    transform: scale(0.95);
}

.chatbot-toggler .toggler-open,
.chatbot-toggler .toggler-close {
    position: absolute;
    font-size: 1.5rem;
    transition: opacity 0.25s, transform 0.3s;
}

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

body.show-chatbot .chatbot-toggler .toggler-open {
    opacity: 0;
    transform: rotate(90deg);
}

body.show-chatbot .chatbot-toggler .toggler-close {
    opacity: 1;
    transform: rotate(0deg);
}

/* Notification badge */
.toggler-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid white;
    display: none;
}

.toggler-badge.visible {
    display: block;
    animation: badge-pulse 1.5s infinite;
}

@keyframes badge-pulse {

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

    50% {
        transform: scale(1.3);
    }
}

/* --- Chat Window --- */
.chatbot {
    position: fixed;
    bottom: 96px;
    right: 28px;
    width: 380px;
    max-height: 580px;
    background: #ffffff;
    border-radius: 20px;
    overflow: hidden;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.04);

    /* Hidden state */
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* --- Header --- */
.chatbot-header {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar-sm {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chatbot-avatar-sm .material-symbols-outlined {
    font-size: 1.25rem;
    color: white;
}

.chatbot-header-title {
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.chatbot-header-status {
    font-size: 0.7rem;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: status-glow 2s infinite;
}

@keyframes status-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.5);
    }

    50% {
        box-shadow: 0 0 0 4px rgba(74, 222, 128, 0);
    }
}

.chatbot-header-actions {
    display: flex;
    gap: 4px;
}

.chatbot-header-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chatbot-header-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chatbot-header-btn .material-symbols-outlined {
    font-size: 1.15rem;
}

/* --- Messages Area --- */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 320px;
    max-height: 360px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

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

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* --- Message Bubbles --- */
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: msg-appear 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes msg-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Incoming (bot) */
.chat-msg.incoming {
    align-self: flex-start;
}

.chat-msg.incoming .msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: auto;
}

.chat-msg.incoming .msg-avatar .material-symbols-outlined {
    font-size: 0.9rem;
    color: white;
}

.chat-msg.incoming .msg-bubble {
    background: white;
    color: #1e293b;
    border-radius: 4px 16px 16px 16px;
    padding: 10px 14px;
    font-size: 0.875rem;
    line-height: 1.55;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    border: 1px solid #e2e8f0;
}

/* Outgoing (user) */
.chat-msg.outgoing {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg.outgoing .msg-bubble {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: white;
    border-radius: 16px 4px 16px 16px;
    padding: 10px 14px;
    font-size: 0.875rem;
    line-height: 1.55;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.2);
}

/* Error state */
.chat-msg.incoming .msg-bubble.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

/* Message timestamp */
.msg-time {
    font-size: 0.65rem;
    color: #94a3b8;
    margin-top: 4px;
    display: block;
}

.chat-msg.outgoing .msg-time {
    text-align: right;
}

/* --- Typing Indicator --- */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing-bounce 1.2s infinite;
}

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

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

@keyframes typing-bounce {

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

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

/* --- Quick Replies --- */
.chatbot-quick-replies {
    padding: 0 16px 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
    background: #f8fafc;
}

.quick-reply-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: white;
    color: #1e3a8a;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}

.quick-reply-btn:hover {
    background: #1e3a8a;
    color: white;
    border-color: #1e3a8a;
    transform: translateY(-1px);
}

.quick-reply-btn:active {
    transform: translateY(0);
}

/* --- Input Area --- */
.chatbot-input-area {
    padding: 12px 14px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
    background: white;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    background: #f8fafc;
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow-y: auto;
}

#chatbot-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: white;
}

#chatbot-input::placeholder {
    color: #94a3b8;
}

.chatbot-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
    opacity: 0.4;
}

.chatbot-send-btn:not(:disabled) {
    opacity: 1;
}

.chatbot-send-btn:not(:disabled):hover {
    transform: scale(1.05);
}

.chatbot-send-btn:not(:disabled):active {
    transform: scale(0.95);
}

.chatbot-send-btn .material-symbols-outlined {
    font-size: 1.15rem;
}

/* --- Mobile Responsive --- */
@media (max-width: 490px) {
    .chatbot-toggler {
        bottom: 16px;
        right: 16px;
        width: 50px;
        height: 50px;
    }

    .chatbot {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 100%;
        height: 100%;
        border-radius: 0;
    }

    .chatbot-messages {
        min-height: 0;
        max-height: none;
        flex: 1;
    }

    .chatbot-header {
        border-radius: 0;
    }
}