/* ============================================
   AI CHATBOT WIDGET — First Class
   3D Robot as background, messages overlaid on top
   ============================================ */

/* --- Floating Trigger Button --- */
.chatbot-trigger {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 1px solid rgba(212, 175, 55, 0.4);
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    cursor: pointer;
    z-index: 9990;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 40px rgba(212, 175, 55, 0.15);
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1);
    animation: chatbotPulse 3s ease-in-out infinite;
}

.chatbot-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 60px rgba(212, 175, 55, 0.3);
    border-color: rgba(212, 175, 55, 0.7);
}

.chatbot-trigger svg {
    width: 28px;
    height: 28px;
    color: #d4af37;
    transition: transform 0.3s ease;
}

.chatbot-trigger:hover svg {
    transform: scale(1.1);
}

.chatbot-trigger.active {
    animation: none;
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.6);
}

@keyframes chatbotPulse {

    0%,
    100% {
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 20px rgba(212, 175, 55, 0.1);
    }

    50% {
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 50px rgba(212, 175, 55, 0.25);
    }
}

/* --- Chat Panel — 3D Robot fills entire background --- */
.chatbot-panel {
    position: fixed;
    bottom: 6.5rem;
    right: 2rem;
    width: 420px;
    height: 600px;
    max-height: calc(100vh - 8rem);
    background: #0a0a0a;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    z-index: 9991;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7), 0 0 0 0.5px rgba(255, 255, 255, 0.05) inset;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

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

/* --- 3D Scene Layer (absolute, fills the panel) --- */
.chatbot-scene {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

.chatbot-scene spline-viewer {
    display: block;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

.chatbot-scene-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 6rem;
    opacity: 0.15;
}

/* HIDE Spline watermark */
.chatbot-scene spline-viewer {
    --spline-viewer-logo-display: none;
}

.chatbot-scene spline-viewer::part(logo) {
    display: none !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

/* --- Top bar — floats above the 3D scene --- */
.chatbot-topbar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    background: linear-gradient(to bottom, rgba(10, 10, 10, 0.85) 0%, rgba(10, 10, 10, 0.4) 70%, transparent 100%);
    flex-shrink: 0;
}

.chatbot-topbar-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chatbot-topbar-name {
    font-family: var(--font-display, 'Playfair Display', serif);
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: 0.02em;
}

.chatbot-topbar-status {
    font-size: 0.6rem;
    color: rgba(212, 175, 55, 0.7);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chatbot-topbar-status::before {
    content: '';
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

.chatbot-close-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chatbot-close-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

.chatbot-close-btn svg {
    width: 14px;
    height: 14px;
}

/* --- Messages overlay — at BOTTOM, above 3D --- */
.chatbot-messages {
    position: relative;
    z-index: 2;
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0.85rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.55rem;
    scroll-behavior: smooth;
    /* Let the 3D show through where there are no messages */
    pointer-events: none;
}

.chatbot-messages>* {
    pointer-events: auto;
}

.chatbot-messages::-webkit-scrollbar {
    width: 3px;
}

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

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

/* Message Bubbles — glassmorphism so 3D shows behind */
.chatbot-msg {
    max-width: 85%;
    padding: 0.6rem 0.85rem;
    border-radius: 14px;
    font-size: 0.82rem;
    line-height: 1.5;
    animation: msgFadeIn 0.3s ease;
    word-wrap: break-word;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.chatbot-msg.bot {
    align-self: flex-start;
    background: rgba(10, 10, 10, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
    border-bottom-left-radius: 4px;
}

.chatbot-msg.user {
    align-self: flex-end;
    background: rgba(212, 175, 55, 0.2);
    border: 1px solid rgba(212, 175, 55, 0.25);
    color: rgba(255, 255, 255, 0.95);
    border-bottom-right-radius: 4px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.chatbot-msg a {
    color: #d4af37;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chatbot-msg a:hover {
    color: #f0d060;
}

@keyframes msgFadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

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

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 4px;
    padding: 0.6rem 0.85rem;
    align-self: flex-start;
    background: rgba(10, 10, 10, 0.6);
    border-radius: 14px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.chatbot-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(212, 175, 55, 0.6);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.chatbot-typing span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.4;
    }

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

/* Quick Reply Chips */
.chatbot-quick-replies {
    position: relative;
    z-index: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.35rem 0.85rem 0.4rem;
}

.chatbot-chip {
    padding: 0.35rem 0.75rem;
    border-radius: 16px;
    border: 1px solid rgba(212, 175, 55, 0.3);
    background: rgba(10, 10, 10, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: rgba(212, 175, 55, 0.9);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    font-family: inherit;
}

.chatbot-chip:hover {
    background: rgba(212, 175, 55, 0.15);
    border-color: rgba(212, 175, 55, 0.5);
    color: #d4af37;
}

/* --- Input Bar — floats above 3D at bottom --- */
.chatbot-input-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    background: linear-gradient(to top, rgba(10, 10, 10, 0.92) 0%, rgba(10, 10, 10, 0.7) 80%, transparent 100%);
}

.chatbot-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 0.55rem 0.8rem;
    color: #ffffff;
    font-size: 0.82rem;
    outline: none;
    transition: border-color 0.2s ease;
    font-family: inherit;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.chatbot-input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.chatbot-input:focus {
    border-color: rgba(212, 175, 55, 0.4);
}

.chatbot-send-btn,
.chatbot-mic-btn,
.chatbot-speak-btn {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chatbot-send-btn:hover,
.chatbot-mic-btn:hover,
.chatbot-speak-btn:hover {
    background: rgba(212, 175, 55, 0.15);
    color: #d4af37;
}

.chatbot-send-btn svg,
.chatbot-mic-btn svg,
.chatbot-speak-btn svg {
    width: 16px;
    height: 16px;
}

.chatbot-mic-btn.listening {
    background: rgba(220, 38, 38, 0.25);
    color: #ef4444;
    animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.3);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(220, 38, 38, 0);
    }
}

.chatbot-speak-btn.speaking {
    color: #d4af37;
    background: rgba(212, 175, 55, 0.15);
}

/* Legacy compat */
.chatbot-spline-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: rgba(255, 255, 255, 0.2);
    font-size: 0.7rem;
}

/* --- Mobile Responsive --- */
@media (max-width: 768px) {
    .chatbot-trigger {
        bottom: 5.5rem;
        right: 1rem;
        width: 52px;
        height: 52px;
    }

    .chatbot-trigger svg {
        width: 24px;
        height: 24px;
    }

    /* Fullscreen chat on mobile */
    .chatbot-panel {
        bottom: 0;
        right: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    /* Safe area padding for notched phones */
    .chatbot-topbar {
        padding-top: max(0.6rem, env(safe-area-inset-top));
        padding-left: max(0.85rem, env(safe-area-inset-left));
        padding-right: max(0.85rem, env(safe-area-inset-right));
    }

    .chatbot-input-bar {
        padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
        padding-left: max(0.75rem, env(safe-area-inset-left));
        padding-right: max(0.75rem, env(safe-area-inset-right));
    }

    .chatbot-messages {
        padding: 0.4rem 0.75rem;
    }

    .chatbot-quick-replies {
        padding: 0.3rem 0.75rem 0.35rem;
        gap: 0.3rem;
    }

    .chatbot-msg {
        max-width: 90%;
        font-size: 0.82rem;
    }

    /* Ensure touch targets are at least 44px */
    .chatbot-close-btn {
        width: 36px;
        height: 36px;
    }

    .chatbot-close-btn svg {
        width: 16px;
        height: 16px;
    }

    .chatbot-send-btn,
    .chatbot-mic-btn,
    .chatbot-speak-btn {
        width: 40px;
        height: 40px;
    }

    .chatbot-send-btn svg,
    .chatbot-mic-btn svg,
    .chatbot-speak-btn svg {
        width: 18px;
        height: 18px;
    }

    .chatbot-input {
        font-size: 16px;
        /* Prevents iOS zoom on focus */
        padding: 0.6rem 0.85rem;
    }

    .chatbot-chip {
        padding: 0.4rem 0.8rem;
        font-size: 0.74rem;
    }
}

@media (max-width: 480px) {
    .chatbot-trigger {
        bottom: 5rem;
        right: 0.75rem;
        width: 48px;
        height: 48px;
    }

    .chatbot-trigger svg {
        width: 22px;
        height: 22px;
    }

    .chatbot-topbar-name {
        font-size: 0.85rem;
    }

    .chatbot-topbar-status {
        font-size: 0.55rem;
    }

    .chatbot-msg {
        max-width: 94%;
        font-size: 0.78rem;
        padding: 0.5rem 0.7rem;
    }

    .chatbot-chip {
        font-size: 0.7rem;
        padding: 0.35rem 0.65rem;
    }
}

/* Landscape on mobile — reduce vertical padding */
@media (max-height: 500px) {
    .chatbot-topbar {
        padding: 0.35rem 0.75rem;
    }

    .chatbot-input-bar {
        padding: 0.35rem 0.65rem;
    }

    .chatbot-messages {
        padding: 0.25rem 0.7rem;
        gap: 0.35rem;
    }

    .chatbot-msg {
        padding: 0.4rem 0.65rem;
        font-size: 0.76rem;
    }

    .chatbot-quick-replies {
        padding: 0.2rem 0.7rem;
    }

    .chatbot-chip {
        padding: 0.25rem 0.55rem;
        font-size: 0.68rem;
    }
}