/* =========================================
   The Navigator: 3D Bot Widget & Chat Window
   ========================================= */

/* Only show on desktop by default, mobile adjustments below */
.navigator-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
    /* Let clicks pass through area around bot */
    font-family: 'Inter', sans-serif;
}

/* -----------------------------------------------------
   1. The Floating Bot Avatar
   ----------------------------------------------------- */
.bot-container {
    width: 60px;
    height: 60px;
    cursor: pointer;
    pointer-events: auto;
    /* Re-enable clicks on the bot itself */
    position: relative;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: floatBot 6s ease-in-out infinite;
}

.bot-container:hover {
    transform: scale(1.1) rotate(-5deg);
}

.bot-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px rgba(37, 99, 235, 0.25));
}

/* Status Dot (Online Indicator) */
.bot-status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background-color: #10b981;
    /* Green */
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
    }

    70% {
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes floatBot {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-10px);
    }
}


/* -----------------------------------------------------
   2. Chat Window (The Glass Panel)
   ----------------------------------------------------- */
/* HIDE LEGACY SPEECH BUBBLE */
.speech-bubble {
    display: none !important;
}

/* -----------------------------------------------------
   2. Chat Window (The Glass Panel)
   ----------------------------------------------------- */
.chat-window {
    position: absolute;
    bottom: 80px;
    /* Above the bot */
    right: 0;
    width: 300px;
    /* Compact width */
    height: 400px;
    /* Compact height */
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    z-index: 10000;
    /* Ensure it's on top */

    font-family: 'Inter', sans-serif;
    /* Ensure font consistency */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
    z-index: 10000;
    /* Ensure it's on top */

    /* Animation State: Hidden */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    visibility: hidden;
}

.chat-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    visibility: visible;
}

/* Header */
.chat-header {
    background: linear-gradient(to right, #ffffff, #f8fafc);
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-title {
    display: flex;
    flex-direction: column;
    /* Stack name and status */
    gap: 2px;
}

.chat-title h3 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.chat-title span {
    font-size: 0.7rem;
    color: #10b981;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-title span::before {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
}

.chat-close-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
    font-size: 1.2rem;
}

.chat-close-btn:hover {
    color: #ef4444;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background-color: #f8fafc;
    /* Very light cool gray */
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}


/* Message Bubbles */
.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.5;
    position: relative;
    animation: messagePop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes messagePop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message.bot {
    align-self: flex-start;
    background: white;
    color: #334155;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.message.user {
    align-self: flex-end;
    background: #2563eb;
    /* Primary Blue */
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.2);
}

/* Loading Dots */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    width: fit-content;
    border-bottom-left-radius: 4px;
    animation: messagePop 0.3s ease;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}


/* Input Area */
.chat-input-area {
    padding: 12px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: center;
}

.chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s;
    color: #334155;
}

.chat-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.chat-send-btn {
    background: #2563eb;
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
    padding: 0;
    flex-shrink: 0; /* Prevent distortion in flex containers */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    box-sizing: border-box;
}

.chat-send-btn:hover {
    background: #1d4ed8;
}

.chat-send-btn:disabled {
    background: #94a3b8;
    cursor: not-allowed;
}

.chat-send-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
    margin-left: 2px;
}

/* -----------------------------------------------------
   Responsive Adjustments (Up to Tablets)
   ----------------------------------------------------- */
@media (max-width: 991px) {
    .navigator-widget {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        pointer-events: none;
        display: block;
        z-index: 9999;
    }

    .bot-container {
        position: absolute;
        bottom: 20px;
        right: 20px;
        pointer-events: auto; /* Ensure bot is clickable */
        z-index: 10001;
    }

    .chat-window {
        bottom: 100px;
        right: 20px;
        width: 300px; /* Match desktop width for better spacing */
        max-height: calc(100vh - 200px); /* Leave room for top navbar and bottom cushion */
        max-width: calc(100vw - 40px);
        height: auto;
        border-radius: 16px;
        pointer-events: auto; /* Ensure chat is interactable */
        z-index: 10002;
    }

    .chat-input {
        min-width: 0; /* Allow input to shrink to accommodate button */
    }
}