/**
 * SinAI Chat Orb - Production v3.0
 * Advanced AI Assistant with Custom Font Rendering & Glassmorphism
 * Last Updated: November 2025
 */

/* ============================================
   SinAI Custom Font - Letter-by-Letter Rendering
   ============================================ */
@font-face {
    font-family: 'SinAI Custom';
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    src: local('Inter'), local('SF Pro Text'), local('Segoe UI');
}

@font-face {
    font-family: 'SinAI Custom';
    font-weight: 500;
    font-style: normal;
    font-display: swap;
    src: local('Inter Medium'), local('SF Pro Text Medium'), local('Segoe UI Semibold');
}

/* Letter-by-letter animation for AI responses */
@keyframes letter-appear {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.8);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

@keyframes letter-glow {
    0%, 100% {
        text-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
    }
    50% {
        text-shadow: 0 0 15px rgba(102, 126, 234, 0.6), 0 0 25px rgba(102, 126, 234, 0.3);
    }
}

.ai-message .letter {
    display: inline-block;
    animation: letter-appear 0.3s var(--ease-smooth) forwards;
    opacity: 0;
}

.ai-message.thinking .letter {
    animation: letter-appear 0.3s var(--ease-smooth) forwards, letter-glow 2s ease-in-out infinite;
}

/* ============================================
   CSS Variables - Premium Design System
   ============================================ */
/* ============================================
   GLOBAL PLATFORM FIX - Prevent Horizontal Scroll
   ============================================ */
html {
    overflow-x: hidden;
    width: 100%;
}

html body {
    overflow-x: hidden;
    width: 100%;
    position: relative;
}

:root {
    --sinai-primary: #667eea;
    --sinai-secondary: #764ba2;
    --sinai-accent: #ed64a6;
    --sinai-success: #48bb78;
    --sinai-text-dark: #2d3748;
    --sinai-text-light: #718096;
    --sinai-bg-light: #f7fafc;
    --sinai-border: #e2e8f0;
    
    /* Glassmorphism Variables */
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(102, 126, 234, 0.2);
    --glass-shadow: 0 8px 32px rgba(102, 126, 234, 0.15);
    
    /* Premium Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 12px 48px rgba(102, 126, 234, 0.25);
    --shadow-xl: 0 20px 64px rgba(102, 126, 234, 0.35);
    
    /* Smooth Animations */
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --ease-liquid: cubic-bezier(0.23, 1, 0.32, 1);
}

/* ============================================
   Chat Widget Container
   Smart Positioning: No fixed bottom/right - controlled by JS
   ============================================ */
.ai-chat-widget {
    position: fixed;
    /* No bottom/right here - smart positioning JS controls position */
    z-index: 10000; /* Force high z-index */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    /* Default fallback position (will be overridden by smart positioning) */
    bottom: 95px;
    /* Positioned at edge with 30% peek into gap */
    right: -32px; /* Push 30% off-screen for peeking effect (105px * 0.30 ≈ 32px) */
    transition: none; /* No CSS transition - JS handles smooth movement */
}

/* Admin Mode: Smart positioning will handle left side positioning */
.ai-chat-widget[data-user-role="admin"] {
    /* Smart positioning detects admin mode automatically */
    right: auto;
    /* Positioned at left edge */
    left: 20px; /* Standard edge positioning */
}

/* Adjust chat window position for admin mode */
.ai-chat-widget[data-user-role="admin"] .ai-chat-window {
    right: auto !important;
    left: 0 !important;
}

/* ============================================
   Dark Mode Support (Admin Dashboard)
   ============================================ */
[data-bs-theme="dark"] .ai-chat-widget .ai-chat-window {
    background: transparent !important;
}

[data-bs-theme="dark"] .ai-chat-widget .ai-chat-window::before {
    /* No background - bubbles float independently */
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
}

[data-bs-theme="dark"] .ai-chat-widget .chat-header {
    background: linear-gradient(135deg, #1e1e1e 0%, #2a2a2a 100%);
    border-bottom: 1px solid rgba(102, 126, 234, 0.3);
}

[data-bs-theme="dark"] .ai-chat-widget .chat-header-text h3 {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .ai-chat-widget .agent-status {
    color: #b0b0b0 !important;
}

[data-bs-theme="dark"] .ai-chat-widget .mode-badge {
    background: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
}

[data-bs-theme="dark"] .ai-chat-widget .mode-badge.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
}

[data-bs-theme="dark"] .ai-chat-widget .ai-chat-messages {
    background: transparent !important;
}

[data-bs-theme="dark"] .ai-chat-widget .message-text {
    color: #e8e8e8 !important;
}

/* Removed conflicting flat background - glassmorphism handled by ::before pseudo-element */
[data-bs-theme="dark"] .ai-chat-widget .ai-message {
    background: transparent !important;
    color: #e8e8e8 !important;
}

[data-bs-theme="dark"] .ai-chat-widget .user-message {
    background: rgba(102, 126, 234, 0.25) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .ai-chat-widget .chat-input-container {
    background: #2a2a2a;
    border-top: 1px solid rgba(102, 126, 234, 0.3);
}

[data-bs-theme="dark"] .ai-chat-widget .chat-input {
    background: #1e1e1e;
    color: #ffffff;
    border: 1px solid #404040;
}

[data-bs-theme="dark"] .ai-chat-widget .chat-input:focus {
    background: #252525;
    border-color: #667eea;
}

[data-bs-theme="dark"] .ai-chat-widget .chat-input::placeholder {
    color: #6b7280;
}

[data-bs-theme="dark"] .ai-chat-widget .send-button:disabled {
    background: rgba(102, 126, 234, 0.3);
}

[data-bs-theme="dark"] .ai-chat-widget .quick-actions-container {
    border-top-color: rgba(102, 126, 234, 0.25);
}

[data-bs-theme="dark"] .ai-chat-widget .quick-action-btn {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    color: #e0e0e0;
    border: 1px solid rgba(102, 126, 234, 0.3);
}

[data-bs-theme="dark"] .ai-chat-widget .quick-action-btn:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.35) 0%, rgba(118, 75, 162, 0.35) 100%);
    border-color: rgba(102, 126, 234, 0.5);
    color: #ffffff;
}

[data-bs-theme="dark"] .ai-chat-widget .quick-actions-label {
    color: #94a3b8;
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-content {
    background: #1e293b;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-text {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-close {
    color: #94a3b8;
}

/* ============================================
   Quick Actions Container (Admin Mode Only)
   ============================================ */
.quick-actions-container {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(102, 126, 234, 0.15);
}

.quick-actions-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--sinai-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.quick-actions-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.quick-action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--sinai-primary);
    cursor: pointer;
    transition: all 0.2s var(--ease-smooth);
    text-align: left;
    width: 100%;
}

.quick-action-btn:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15), rgba(118, 75, 162, 0.15));
    border-color: var(--sinai-primary);
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.quick-action-btn:active {
    transform: translateX(2px) scale(0.98);
}

.quick-action-btn .action-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.quick-action-btn .action-label {
    flex: 1;
}

/* ============================================
   Phase 4: Master Canvas for GPU-Accelerated Orb
   V3.0 - Utility Class Pattern
   ============================================ */

/* Utility class for orb canvas layer (reusable, maintainable) */
.orb-canvas-layer {
    position: fixed;
    inset: 0; /* top: 0; right: 0; bottom: 0; left: 0; */
    width: 100vw;
    height: 100vh;
    pointer-events: none; /* Don't block clicks */
    z-index: 1000; /* HIGH z-index to show above chat window when teleporting */
    display: block;
    opacity: 1;
}

/* Apply utility class to master canvas */
#orb-master-canvas {
    /* Canvas HIGH z-index to show particles above chat window during teleport */
    z-index: 1000 !important;
    pointer-events: none; /* Allow clicks to pass through to orb button */
}

/* Portal marker utility class */
.orb-portal {
    position: fixed;
    width: 1px;
    height: 1px;
    pointer-events: none;
    z-index: 1;
    opacity: 0; /* Invisible markers */
}

/* Debug mode: visualize portal positions (dev only) */
.orb-debug-mode .orb-portal {
    opacity: 1;
    width: 10px;
    height: 10px;
    background: rgba(255, 0, 255, 0.5);
    border: 2px solid magenta;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.orb-debug-mode .orb-portal::before {
    content: attr(data-portal);
    position: absolute;
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: magenta;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.8);
    padding: 2px 4px;
    border-radius: 3px;
}

/* ============================================
   Revolutionary Agent Orb with Particle System
   ============================================ */
.ai-chat-toggle.agent-orb {
    position: absolute !important;
    /* Fill the parent orb-particle-container */
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 50%;
    border: none;
    /* Fallback background for when canvas is loading or misaligned */
    background: radial-gradient(circle at 30% 30%, rgba(102, 126, 234, 0.95), rgba(118, 75, 162, 0.95)) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 0 8px rgba(102, 126, 234, 0.2) !important; /* Reduced from 25px 0.5 to 15px 0.3 */
    cursor: pointer;
    transition: opacity 0.6s ease, visibility 0.6s ease;
    display: flex !important;
    align-items: center;
    justify-content: center;
    overflow: visible !important;
    padding: 0;
    will-change: transform, opacity;
    z-index: 2 !important; /* Above glow layer (0), below particles */
    opacity: 1 !important;
    visibility: visible !important;
    /* Phase 4.1: Static toggle is just a button container */
    /* Physics orb renders on master canvas, not inside this element */
}

/* Phase 4.3: When chat opens, static icon hides but particles on master canvas remain */
.ai-chat-toggle.agent-orb.chat-open {
    /* Reduce to mini size when in chat header */
    width: 48px !important;
    height: 48px !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transition: all 0.6s cubic-bezier(0.23, 1, 0.32, 1);
}

/* ============================================
   MINI ORB CLONE - Appears in chat after teleport
   The main orb stays home as "return button"
   Particles travel and reform as this mini orb
   ============================================ */

/* Container for mini orb - replaces the static avatar */
.mini-orb-container {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* The actual mini orb - scaled down version of main orb */
.mini-orb {
    position: relative;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, 
        rgba(102, 126, 234, 0.95), 
        rgba(118, 75, 162, 0.95));
    box-shadow: 
        0 0 15px rgba(102, 126, 234, 0.5),
        0 0 30px rgba(102, 126, 234, 0.3),
        inset 0 0 10px rgba(255, 255, 255, 0.2);
    animation: mini-orb-pulse 2s ease-in-out infinite;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Mini orb layers for depth effect */
.mini-orb::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    right: 3px;
    bottom: 3px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%,
        rgba(255, 255, 255, 0.3),
        transparent 60%);
}

.mini-orb::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 60%;
    height: 60%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: radial-gradient(circle at center,
        rgba(102, 126, 234, 0.8),
        rgba(118, 75, 162, 0.6));
    box-shadow: inset 0 0 8px rgba(255, 255, 255, 0.3);
}

/* Mini orb face - simplified cute version */
.mini-orb-face {
    position: relative;
    z-index: 2;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mini-orb-face svg {
    width: 20px;
    height: 20px;
}

/* Mini orb pulse animation */
@keyframes mini-orb-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 
            0 0 15px rgba(102, 126, 234, 0.5),
            0 0 30px rgba(102, 126, 234, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 
            0 0 20px rgba(102, 126, 234, 0.6),
            0 0 40px rgba(102, 126, 234, 0.4);
    }
}

/* Mini orb particle ring - orbiting particles */
.mini-orb-particles {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
    animation: none; /* DISABLED rotation to prevent face flipping */
    pointer-events: none;
}

.mini-orb-particle {
    position: absolute;
    width: 3px;
    height: 3px;
    background: #667eea;
    border-radius: 50%;
    box-shadow: 0 0 4px #667eea;
}

.mini-orb-particle:nth-child(1) { top: 0; left: 50%; transform: translateX(-50%); }
.mini-orb-particle:nth-child(2) { top: 50%; right: 0; transform: translateY(-50%); }
.mini-orb-particle:nth-child(3) { bottom: 0; left: 50%; transform: translateX(-50%); }
.mini-orb-particle:nth-child(4) { top: 50%; left: 0; transform: translateY(-50%); }

@keyframes mini-orb-rotate {
    /* DISABLED to prevent face rotation */
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(0deg); } /* Changed to 0deg - no rotation */
}

/* Spawn animation - particles coalesce into orb */
.mini-orb-container.spawning .mini-orb {
    animation: mini-orb-spawn 0.6s ease-out forwards;
}

@keyframes mini-orb-spawn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.mini-orb-container.spawning .mini-orb-particles {
    animation: mini-orb-particles-spawn 0.6s ease-out forwards; /* REMOVED rotation */
}

@keyframes mini-orb-particles-spawn {
    0% {
        width: 80px;
        height: 80px;
        opacity: 1;
    }
    100% {
        width: 44px;
        height: 44px;
        opacity: 1;
    }
}

/* Phase 4.4: Hide static message avatar when mini orb appears */
.ai-chat-window.open .ai-message-group:first-child .message-avatar-small {
    /* Keep avatar visible initially so orb can teleport to it */
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Hide avatar only AFTER orb has teleported (added via JS after teleport complete) */
.ai-chat-window.open.orb-arrived .ai-message-group:first-child .message-avatar-small {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    transition: opacity 0.3s ease;
}

/* Scale down particle effects when orb is in chat window */
.ai-chat-toggle.agent-orb.chat-open .particle-ring {
    transform: scale(0.75);
}

.ai-chat-toggle.agent-orb.chat-open .particle {
    width: 3px;
    height: 3px;
}

/* Particle Ring System */
.particle-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    animation: none; /* DISABLED rotation to prevent face flipping */
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--sinai-primary);
    border-radius: 50%;
    opacity: 0.6;
    box-shadow: 0 0 10px var(--sinai-primary);
}

.particle:nth-child(1) { top: 0; left: 50%; transform: translateX(-50%); animation: particle-float 3s ease-in-out infinite; }
.particle:nth-child(2) { top: 25%; right: 10%; animation: particle-float 3.5s ease-in-out infinite 0.5s; }
.particle:nth-child(3) { top: 50%; right: 0; transform: translateY(-50%); animation: particle-float 3.2s ease-in-out infinite 1s; }
.particle:nth-child(4) { bottom: 25%; right: 10%; animation: particle-float 3.8s ease-in-out infinite 1.5s; }
.particle:nth-child(5) { bottom: 0; left: 50%; transform: translateX(-50%); animation: particle-float 3.3s ease-in-out infinite 2s; }
.particle:nth-child(6) { top: 50%; left: 0; transform: translateY(-50%); animation: particle-float 3.6s ease-in-out infinite 2.5s; }

@keyframes rotate-ring {
    /* DISABLED to prevent face rotation */
    from { transform: rotate(0deg); }
    to { transform: rotate(0deg); } /* Changed to 0deg - no rotation */
}

@keyframes particle-float {
    0%, 100% { transform: translateX(-50%) scale(1); opacity: 0.6; }
    50% { transform: translateX(-50%) scale(1.5) translateY(-5px); opacity: 1; }
}

/* CRITICAL FIX: Prevent any 3D rotation on orb elements */
.ai-chat-toggle,
.ai-chat-toggle *,
.orb-particle-container,
.orb-particle-container * {
    backface-visibility: hidden !important;
    perspective: none !important;
}

/* Core Orb Layers */
.orb-core {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transform-style: flat !important;
    transform: translate3d(0,0,0) !important; /* GPU acceleration but no rotation */
}

/* WebGL2 Canvas - positioned behind face, in front of glow */
#orb-master-canvas,
.orb-canvas-layer {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) translateZ(0px) !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 50%;
    z-index: 10 !important; /* Above glow (-10), below face (500) */
    pointer-events: none !important;
    opacity: 1 !important; /* Ensure particles visible */
    transition: opacity 0.4s ease !important; /* Smooth fade during teleport */
}

.orb-glow-layer {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 40% !important; /* Reduced to match orb-particles.css */
    height: 40% !important;
    border-radius: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.12) 0%, transparent 70%) !important;
    filter: blur(6px) !important; /* Reduced for subtler effect */
    z-index: -100 !important; /* Very low - behind everything */
    pointer-events: none !important;
    animation: pulse-glow 3s ease-in-out infinite !important;
    will-change: opacity !important;
}

@keyframes pulse-glow {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.5; }
}

.orb-layer {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
    transform: translate(-50%, -50%) translateZ(1px) !important; /* Slightly in front of canvas, behind face */
    z-index: 1 !important; /* Positive but below face */
}

.orb-outer {
    width: 30%; /* DRASTICALLY reduced for minimal flare */
    height: 30%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    box-shadow: 
        0 0 4px rgba(102, 126, 234, 0.08),
        inset 0 0 3px rgba(255, 255, 255, 0.02);
    z-index: -100 !important; /* Very low z-index - behind everything including nudge */
    opacity: 0.5;
    /* animation: pulse-orb 3s ease-in-out infinite; DISABLED - causes 3D flip */
}

.orb-middle {
    width: 50%; /* Reduced for minimal visual impact */
    height: 50%;
    background: linear-gradient(135deg, var(--sinai-primary) 0%, var(--sinai-secondary) 100%);
    box-shadow: 
        0 0 6px rgba(102, 126, 234, 0.2),
        inset 0 0 4px rgba(255, 255, 255, 0.1);
    z-index: -4 !important;
    opacity: 0.6;
    /* animation: pulse-orb 3s ease-in-out infinite 0.3s; DISABLED - causes 3D flip */
}

.orb-inner {
    width: 40%; /* Slightly smaller */
    height: 40%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    animation: shine-orb 2s ease-in-out infinite;
    z-index: -3 !important; /* Behind face */
    opacity: 0.6;
}

@keyframes pulse-orb {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.05); }
}

@keyframes shine-orb {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

/* Agent Face with Intelligent Eyes */
/* NOTE: Main transform is applied in NSIGHT GPU fix section below (line ~3430) */
.agent-face {
    position: absolute;
    top: 50%;
    left: 50%;
    /* transform moved to NSIGHT fix section - DO NOT ADD HERE */
    transform-origin: center center !important;
    width: 100%;
    height: 100%;
    display: flex !important;
    align-items: center;
    justify-content: center;
    /* z-index moved to NSIGHT fix section */
    pointer-events: none;
    opacity: 1 !important; /* Force visible */
    visibility: visible !important;
}

.agent-icon {
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
    position: relative;
    z-index: 15 !important; /* Highest priority - never hide */
    transform: none !important; /* Prevent any rotation */
    width: 48px !important; /* Make it BIGGER and visible */
    height: 48px !important;
    background: rgba(255, 255, 255, 0.3) !important; /* White background */
    border-radius: 50%;
    padding: 6px;
    display: block !important;
}

.eyes {
    animation: blink 4s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    48%, 52% { opacity: 0; }
}

.pupil-left,
.pupil-right {
    animation: look-around 6s ease-in-out infinite;
}

@keyframes look-around {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(1px, -0.5px); }
    50% { transform: translate(-1px, 0.5px); }
    75% { transform: translate(0.5px, 1px); }
}

.energy-wave {
    animation: expand-wave 2s ease-out infinite;
}

@keyframes expand-wave {
    0% {
        opacity: 0.5;
        transform: scale(0.8);
    }
    100% {
        opacity: 0;
        transform: scale(1.3);
    }
}

/* Hover State - Excited Agent */
.ai-chat-toggle.agent-orb:hover .orb-outer {
    box-shadow: 
        0 0 20px rgba(102, 126, 234, 0.5),
        inset 0 0 15px rgba(255, 255, 255, 0.2);
}

.ai-chat-toggle.agent-orb:hover .particle-ring {
    animation-duration: 10s;
}

.ai-chat-toggle.agent-orb:hover .particle {
    opacity: 1;
    transform: scale(1.5);
}

.ai-chat-toggle.agent-orb:active {
    transform: scale(0.92);
}

/* Active State - Agent Working */
.ai-chat-toggle.agent-orb.chat-open .orb-middle {
    background: linear-gradient(135deg, var(--sinai-accent) 0%, #c44569 100%);
    animation: none; /* DISABLED rotation to prevent face flipping */
}

@keyframes spin-orb {
    /* DISABLED to prevent face rotation */
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(0deg); } /* Changed to 0deg - no rotation */
}

/* Breathing pulse animation when idle */
@keyframes breathe {
    0%, 100% { 
        box-shadow: var(--shadow-lg);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 10px 40px rgba(102, 126, 234, 0.3), 0 4px 16px rgba(102, 126, 234, 0.25);
        transform: scale(1.03);
    }
}

/* Floating animation - DISABLED to prevent orb rolling */
@keyframes float-around {
    0%, 100% { 
        transform: translate(0, 0);
    }
}

.ai-chat-toggle:not(.chat-open) {
    animation: breathe 3.5s ease-in-out infinite; /* REMOVED float-around to prevent orb rolling */
}

/* ============================================
   Agent State Visual Feedback
   ============================================ */

/* Listening state - blue pulse when receiving user input */
@keyframes listening-pulse {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    50% { 
        box-shadow: 0 0 0 15px rgba(59, 130, 246, 0), 0 0 30px rgba(59, 130, 246, 0.5);
    }
}

.ai-chat-toggle.agent-listening .orb-outer {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    animation: listening-pulse 1.5s ease-in-out infinite;
}

/* Reading state - purple glow when processing user message */
@keyframes reading-glow {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(147, 51, 234, 0.6);
    }
    50% { 
        box-shadow: 0 0 40px rgba(147, 51, 234, 0.9), inset 0 0 20px rgba(147, 51, 234, 0.3);
    }
}

.ai-chat-toggle.agent-reading .orb-outer {
    background: linear-gradient(135deg, #9333ea 0%, #6b21a8 100%);
    animation: reading-glow 2s ease-in-out infinite;
}

/* Responding state - gradient pulse when generating response */
@keyframes responding-gradient {
    0% { 
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    50% { 
        background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    }
    100% { 
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
}

.ai-chat-toggle.agent-responding .orb-outer {
    animation: responding-gradient 3s ease-in-out infinite;
    box-shadow: 0 0 30px rgba(102, 126, 234, 0.7);
}

/* Agent Status Badge - Visual Indicator Only */
.agent-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 3px 12px rgba(16, 185, 129, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.badge-pulse {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.5);
        opacity: 0.6;
    }
}

.agent-badge.has-notification {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    animation: badge-glow 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.agent-badge:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.7);
}

@keyframes badge-glow {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 3px 12px rgba(245, 87, 108, 0.5);
    }
    50% { 
        transform: scale(1.15);
        box-shadow: 0 5px 20px rgba(245, 87, 108, 0.9), 0 0 24px rgba(245, 87, 108, 0.5);
    }
}

/* Agent State Indicators */
[data-agent-state="thinking"] .agent-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-agent-state="responding"] .agent-badge {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

[data-agent-state="listening"] .agent-badge {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    animation: listening-pulse 1s ease-in-out infinite;
}

@keyframes listening-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   Revolutionary Liquid Sales Agent Interface
   Dynamic, flowing space that adapts to user type
   ============================================ */
.ai-chat-window {
    position: fixed;
    bottom: 120px;
    right: 24px;
    width: 520px;
    height: 70vh;
    max-height: 800px;
    min-height: 400px; /* Reduced for mobile */
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    display: none;
    flex-direction: column;
    overflow: visible;
    opacity: 0;
    transform: scale(0.85) translateY(60px);
    transition: all 0.8s var(--ease-liquid);
    border: none;
    pointer-events: none;
    -webkit-backdrop-filter: blur(25px) saturate(150%);
    backdrop-filter: blur(25px) saturate(150%);
    z-index: 999998; /* Below nudge, above everything else */
}

/* CRITICAL: Admin positioning override */
.ai-chat-widget[data-admin-mode="true"] .ai-chat-window,
.ai-chat-widget[data-user-role="admin"] .ai-chat-window {
    right: auto !important;
    left: 24px !important;
}

.ai-chat-window.open {
    display: flex;
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* Ensure glassmorphic background is visible when open */
.ai-chat-window.open::before {
    opacity: 1;
    animation: liquid-morph 8s ease-in-out infinite;
}

/* ============================================
   PRESENTATION MODE - Expanded for demos/guidance
   ============================================ */
.ai-chat-window.presentation-mode {
    width: 680px !important;
    height: 85vh !important;
    max-height: 900px !important;
    bottom: 100px;
    transition: all 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-chat-window.presentation-mode::before {
    animation: liquid-morph 8s ease-in-out infinite, presentation-glow 3s ease-in-out infinite;
}

@keyframes presentation-glow {
    0%, 100% {
        box-shadow: 
            0 25px 100px rgba(102, 126, 234, 0.3),
            0 0 0 1px rgba(102, 126, 234, 0.2) inset;
    }
    50% {
        box-shadow: 
            0 30px 120px rgba(102, 126, 234, 0.5),
            0 0 0 1px rgba(102, 126, 234, 0.3) inset;
    }
}

/* ============================================
   GUIDE MODE - Minimized for navigation
   ============================================ */
.ai-chat-window.guide-mode {
    width: 380px !important;
    height: 420px !important;
    bottom: 100px;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-window.guide-mode .ai-chat-messages {
    max-height: 220px;
}

.ai-chat-window.guide-mode::after {
    content: '';
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, transparent, var(--sinai-primary), transparent);
    border-radius: 2px;
    opacity: 0.6;
}

/* Smooth state transitions */
.ai-chat-window {
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
                height 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
                bottom 0.6s ease-out,
                opacity 0.8s var(--ease-liquid),
                transform 0.8s var(--ease-liquid);
}

/* No Background Container - Let Message Bubbles Float */
.ai-chat-window::before {
    content: '';
    position: absolute;
    inset: 0;
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-radius: 0;
    opacity: 0;
    animation: none;
    z-index: -1;
}

@keyframes liquid-morph {
    0%, 100% {
        border-radius: 40px 40px 40px 40px;
        transform: scale(1);
    }
    25% {
        border-radius: 60px 30px 50px 30px;
        transform: scale(1.02) rotate(0.5deg);
    }
    50% {
        border-radius: 30px 60px 30px 50px;
        transform: scale(0.98) rotate(-0.5deg);
    }
    75% {
        border-radius: 50px 40px 60px 35px;
        transform: scale(1.01) rotate(0.3deg);
    }
}

/* Dark Theme - No Background Container, Let Bubbles Float */
[data-theme="dark"] .ai-chat-window::before,
[data-bs-theme="dark"] .ai-chat-window::before {
    /* Background removed to let message bubbles float independently */
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
}

/* User Type Indicators - No Background, Floating Bubbles */
.ai-chat-window.user-type-visitor::before,
.ai-chat-window.user-type-admin::before,
.ai-chat-window.user-type-guide::before {
    /* All user types have transparent background - no container */
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    border: none !important;
    box-shadow: none !important;
    animation: none !important;
}

/* Dark Theme Header - Enhanced Glassmorphic */
[data-theme="dark"] .ai-chat-header.agent-header,
[data-bs-theme="dark"] .ai-chat-header.agent-header {
    background: linear-gradient(135deg, rgba(30, 35, 50, 0.75) 0%, rgba(26, 31, 58, 0.7) 100%) !important;
    -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
    backdrop-filter: blur(40px) saturate(180%) !important;
    border: 1px solid rgba(102, 126, 234, 0.4) !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4), 
        0 0 0 1px rgba(255, 255, 255, 0.08) inset,
        0 4px 16px rgba(102, 126, 234, 0.2) !important;
}

@keyframes visitor-pulse {
    0%, 100% { opacity: 0.95; }
    50% { opacity: 1; }
}

@keyframes admin-glow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.15); }
}

@keyframes guide-shimmer {
    0%, 100% { filter: hue-rotate(0deg); }
    50% { filter: hue-rotate(15deg); }
}

/* ============================================
   Dynamic Floating Header - Glassmorphic Card
   ============================================ */
.ai-chat-header.agent-header {
    background: linear-gradient(135deg, rgba(26, 31, 58, 0.75) 0%, rgba(45, 31, 74, 0.7) 100%) !important;
    -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
    backdrop-filter: blur(40px) saturate(180%) !important;
    border: 1px solid rgba(102, 126, 234, 0.3) !important;
    border-radius: 24px !important;
    color: white;
    padding: 20px 24px !important;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    position: relative;
    overflow: visible;
    min-height: 80px;
    margin: 20px 20px 10px 20px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3), 
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 4px 16px rgba(102, 126, 234, 0.15) !important;
}

/* Floating Agent Identity Card - Glassmorphic */
.agent-identity {
    position: relative;
    padding: 20px 24px;
    background: linear-gradient(135deg, rgba(26, 31, 58, 0.75) 0%, rgba(45, 31, 74, 0.7) 100%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    backdrop-filter: blur(40px) saturate(180%);
    border-radius: 24px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3), 
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 4px 16px rgba(102, 126, 234, 0.15);
    animation: float-gentle 6s ease-in-out infinite;
}

@keyframes float-gentle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Circuit Pattern Background */
.circuit-pattern {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        linear-gradient(90deg, transparent 0%, transparent calc(50% - 0.5px), rgba(102, 126, 234, 0.15) 50%, transparent calc(50% + 0.5px), transparent 100%),
        linear-gradient(0deg, transparent 0%, transparent calc(50% - 0.5px), rgba(102, 126, 234, 0.15) 50%, transparent calc(50% + 0.5px), transparent 100%);
    background-size: 40px 40px;
    animation: circuit-flow 30s linear infinite;
    opacity: 0.3;
}

@keyframes circuit-flow {
    0% { 
        transform: translate(0, 0);
        opacity: 0.3;
    }
    50% {
        opacity: 0.5;
    }
    100% { 
        transform: translate(40px, 40px);
        opacity: 0.3;
    }
}

/* Add glowing nodes to circuit */
.circuit-pattern::before {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--sinai-primary);
    border-radius: 50%;
    box-shadow: 
        0 0 10px var(--sinai-primary),
        40px 0 10px var(--sinai-primary),
        80px 40px 10px var(--sinai-secondary),
        120px 0 10px var(--sinai-accent),
        0 40px 10px var(--sinai-accent);
    animation: glow-nodes 3s ease-in-out infinite;
}

@keyframes glow-nodes {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

.chat-header-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    position: relative;
    z-index: 1;
    position: relative;
    z-index: 1;
}

.chat-avatar,
.ai-chat-header .avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    position: relative;
}

[data-bs-theme="dark"] .chat-avatar,
[data-bs-theme="dark"] .ai-chat-header .avatar {
    background: rgba(60, 60, 60, 0.8);
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Online status indicator - generic ::after for non-agent avatars */
.chat-avatar::after,
.ai-chat-header .avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--sinai-success);
    border: 2px solid white;
    border-radius: 50%;
    animation: pulse-online 2.5s ease-in-out infinite;
}

@keyframes pulse-online {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; transform: scale(1.15); }
}

/* Disable ::after for agent avatar - uses explicit .status-indicator div instead */
.chat-avatar.agent-avatar::after {
    display: none;
}

/* Agent Avatar Orb Enhancement */
.chat-avatar.agent-avatar {
    width: 52px;
    height: 52px;
    background: transparent;
}

.avatar-orb {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 
        0 4px 12px rgba(0, 0, 0, 0.3),
        inset 0 0 20px rgba(102, 126, 234, 0.3);
    animation: avatar-breathe 3s ease-in-out infinite;
}

@keyframes avatar-breathe {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 
            0 4px 12px rgba(0, 0, 0, 0.3),
            inset 0 0 20px rgba(102, 126, 234, 0.3);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 
            0 4px 16px rgba(102, 126, 234, 0.5),
            inset 0 0 25px rgba(102, 126, 234, 0.5);
    }
}

.avatar-eyes {
    animation: avatar-blink 5s ease-in-out infinite;
}

@keyframes avatar-blink {
    0%, 100% { opacity: 1; }
    49%, 51% { opacity: 0; }
}

/* Status Indicator Dot */
.status-indicator {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #10b981;
    border: 3px solid #1a1f3a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% { 
        transform: scale(1);
        opacity: 1;
    }
    50% { 
        transform: scale(1.3);
        opacity: 0.7;
    }
}

.chat-header-text,
.ai-chat-header .info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chat-header-text h3,
.ai-chat-header .info h5 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.03em;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', system-ui, sans-serif;
    line-height: 1.3;
}

.agent-version {
    font-size: 10px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 7px;
    border-radius: 6px;
    letter-spacing: 0.8px;
    text-transform: uppercase;
}

.chat-header-text p.agent-status,
.ai-chat-header .info small {
    margin: 0;
    font-size: 12.5px;
    opacity: 0.9;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.2px;
}

.status-icon {
    color: #10b981;
    font-size: 8px;
    animation: status-blink 2s ease-in-out infinite;
}

@keyframes status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.context-divider {
    opacity: 0.5;
}

.context-label {
    font-weight: 500;
}

/* Agent Modes Badges */
.agent-modes {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.mode-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.mode-badge::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mode-badge:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.mode-badge:hover::before {
    opacity: 1;
}

.mode-badge.active {
    background: rgba(102, 126, 234, 0.3);
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
    transform: scale(1.05);
}

/* Dark mode badge enhancements */
[data-bs-theme="dark"] .mode-badge {
    background: rgba(50, 55, 70, 0.6);
    border: 1px solid rgba(102, 126, 234, 0.25);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

[data-bs-theme="dark"] .mode-badge.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.35), 0 0 0 1px rgba(102, 126, 234, 0.2) inset;
}

.mode-icon {
    font-size: 11px;
    font-style: normal;
}

.ai-chat-close.agent-close {
    background: rgba(237, 100, 166, 0.95); /* Red glow dot */
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 44px; /* Touch-friendly size */
    height: 44px;
    border-radius: 50%; /* Circular like orb */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s var(--ease-smooth);
    position: absolute;
    top: 20px;
    right: 20px; /* Separate from orb location */
    z-index: 999999 !important; /* Above chat window (999998), same as nudge */
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    box-shadow: 0 0 25px rgba(237, 100, 166, 0.7), 
                0 0 15px rgba(237, 100, 166, 0.5),
                inset 0 0 10px rgba(255, 255, 255, 0.3);
    transform: translateZ(100px); /* GPU layer in front */
    will-change: transform;
}

.ai-chat-close.agent-close:hover {
    background: rgba(255, 120, 186, 1); /* Brighter red on hover */
    border-color: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg) scale(1.15);
    box-shadow: 0 0 30px rgba(237, 100, 166, 0.8),
                inset 0 0 15px rgba(255, 255, 255, 0.4);
}

.ai-chat-close.agent-close:active {
    transform: rotate(90deg) scale(0.95);
}

.ai-chat-close,
.ai-chat-header .btn-close {
    background: rgba(255, 255, 255, 0.18);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.3s var(--ease-smooth);
    position: relative;
    z-index: 1;
    filter: none;
}

.ai-chat-close:hover,
.ai-chat-header .btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg) scale(1.1);
    opacity: 1;
}

/* ============================================
   Floating Messages Space - No Background Container
   ============================================ */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px 28px;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 28px;
    scroll-behavior: smooth;
    position: relative;
}

/* Subtle ambient particles - very light for floating effect */
.ai-chat-messages::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 30%, rgba(102, 126, 234, 0.01) 0%, transparent 40%),
                radial-gradient(circle at 80% 70%, rgba(147, 51, 234, 0.01) 0%, transparent 40%);
    pointer-events: none;
    animation: ambient-flow 20s ease-in-out infinite;
}

@keyframes ambient-flow {
    0%, 100% { opacity: 0.3; transform: translate(0, 0); }
    50% { opacity: 0.5; transform: translate(10px, -10px); }
}

[data-theme="dark"] .ai-chat-messages::before,
[data-bs-theme="dark"] .ai-chat-messages::before {
    background: radial-gradient(circle at 20% 30%, rgba(102, 126, 234, 0.02) 0%, transparent 40%),
                radial-gradient(circle at 80% 70%, rgba(147, 51, 234, 0.02) 0%, transparent 40%),
                radial-gradient(circle at 50% 50%, rgba(102, 126, 234, 0.01) 0%, transparent 60%);
}

[data-bs-theme="dark"] .ai-chat-messages {
    scrollbar-color: rgba(102, 126, 234, 0.4) transparent;
}

/* Premium Custom Scrollbar */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.25);
    border-radius: 3px;
    transition: background 0.2s ease;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(102, 126, 234, 0.45);
}

[data-theme="dark"] .ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.35);
}

/* ============================================
   Presentation Mode - Enhanced Message Display
   ============================================ */
.ai-chat-window.presentation-mode .ai-chat-messages {
    padding: 40px 35px;
    gap: 30px;
}

.ai-chat-window.presentation-mode .message-content {
    max-width: 85%;
}

.ai-chat-window.presentation-mode .message-text {
    font-size: 16px;
    line-height: 1.7;
    padding: 18px 24px;
}

/* Guide Mode - Compact Message Display */
.ai-chat-window.guide-mode .ai-chat-messages {
    padding: 20px 18px;
    gap: 16px;
}

.ai-chat-window.guide-mode .message-text {
    font-size: 14px;
    padding: 12px 16px;
}

.ai-chat-window.guide-mode .message-avatar {
    width: 32px;
    height: 32px;
}

/* ============================================
   Presentation Mode - Enhanced Message Display
   ============================================ */
.ai-chat-window.presentation-mode .ai-chat-messages {
    padding: 40px 35px;
    gap: 30px;
}

.ai-chat-window.presentation-mode .message-content {
    max-width: 85%;
}

.ai-chat-window.presentation-mode .message-text {
    font-size: 16px;
    line-height: 1.7;
    padding: 18px 24px;
}

/* Guide Mode - Compact Message Display */
.ai-chat-window.guide-mode .ai-chat-messages {
    padding: 20px 18px;
    gap: 16px;
}

.ai-chat-window.guide-mode .message-text {
    font-size: 14px;
    padding: 12px 16px;
}

.ai-chat-window.guide-mode .message-avatar {
    width: 32px;
    height: 32px;
}

/* ============================================
   Premium Message Bubbles with Smooth Animations
   ============================================ */
.chat-message,
.message {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 20px;
    animation: message-slide-in 0.45s var(--ease-smooth);
    opacity: 0;
    animation-fill-mode: forwards;
}

@keyframes message-slide-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Streaming state with typing caret */
.message.streaming .message-content p { position: relative; }
.message.streaming .message-content p::after {
    content: '▌';
    display: inline-block;
    margin-left: 4px;
    animation: blinkCaret 1.1s steps(1) infinite;
    color: var(--sinai-primary);
}

@keyframes blinkCaret { 50% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
    .message.streaming .message-content p::after { animation: none; }
}

.chat-message.user,
.user-message {
    flex-direction: row-reverse;
    justify-content: flex-start;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s var(--ease-smooth);
}

.message-avatar:hover {
    transform: scale(1.08);
}

.message-avatar.ai,
.bot-message .message-avatar {
    background: linear-gradient(135deg, var(--sinai-primary) 0%, var(--sinai-secondary) 100%);
    color: white;
}

.message-avatar.user,
.user-message .message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.message-content {
    flex: 1;
    max-width: 78%;
    position: relative;
}

.user-message .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.message-bubble,
.message-content p {
    margin: 0;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.65;
    position: relative;
    word-wrap: break-word;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s var(--ease-smooth);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', system-ui, sans-serif;
}

.message-bubble:hover,
.message-content p:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.chat-message.ai .message-bubble,
.bot-message .message-content p {
    background: transparent;
    border: none;
    box-shadow: none;
    color: #1a202c;
    border-radius: 0;
    padding: 0;
    margin: 0;
    font-family: 'SinAI Custom', -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
    position: relative;
    /* Force GPU layer and stacking context */
    isolation: isolate;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
    /* Prevent text from being behind ::before */
    display: flex;
    align-items: center;
    min-height: 40px;
}

/* Organic liquid words container for AI messages - ENHANCED GLASSMORPHIC BLUR */
.chat-message.ai .message-bubble::before,
.bot-message .message-content p::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(245, 247, 250, 0.8) 100%);
    -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
    backdrop-filter: blur(40px) saturate(180%) !important;
    border-radius: 28px 28px 28px 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.15), 
                0 0 0 1px rgba(255, 255, 255, 0.6) inset,
                0 4px 16px rgba(102, 126, 234, 0.1);
    /* Force behind text but in front of parent background */
    z-index: -1;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    animation: bubble-breathe 4s ease-in-out infinite;
}

/* Text content inside AI bubbles - above glassmorphic layer */
.chat-message.ai .message-bubble *,
.bot-message .message-content p * {
    position: relative;
    z-index: 1;
    padding: 16px 20px;
    display: block;
}

@keyframes bubble-breathe {
    0%, 100% { 
        border-radius: 28px 28px 28px 8px;
        transform: scale(1);
    }
    50% { 
        border-radius: 32px 24px 30px 10px;
        transform: scale(1.01);
    }
}

[data-theme="dark"] .chat-message.ai .message-bubble,
[data-theme="dark"] .bot-message .message-content p {
    color: #e2e8f0;
    z-index: 1;
    position: relative;
}

[data-theme="dark"] .chat-message.ai .message-bubble::before,
[data-theme="dark"] .bot-message .message-content p::before {
    background: linear-gradient(135deg, rgba(45, 55, 72, 0.75) 0%, rgba(30, 41, 59, 0.7) 100%);
    -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
    backdrop-filter: blur(40px) saturate(180%) !important;
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 
                0 0 0 1px rgba(102, 126, 234, 0.2) inset,
                0 4px 16px rgba(102, 126, 234, 0.15);
    z-index: 0;
}

.chat-message.user .message-bubble,
.user-message .message-content p {
    background: transparent;
    color: white;
    font-weight: 500;
    border-radius: 0;
    padding: 0;
    position: relative;
}

/* Flowing gradient for user messages */
.chat-message.user .message-bubble::before,
.user-message .message-content p::before {
    content: '';
    position: absolute;
    inset: -8px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    background-size: 200% 200%;
    border-radius: 28px 28px 8px 28px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 4px 24px rgba(240, 147, 251, 0.35),
                0 0 0 1px rgba(255, 255, 255, 0.2) inset;
    z-index: -1;
    animation: user-bubble-flow 5s ease-in-out infinite;
}

@keyframes user-bubble-flow {
    0%, 100% { 
        border-radius: 28px 28px 8px 28px;
        background-position: 0% 50%;
    }
    50% { 
        border-radius: 24px 32px 10px 30px;
        background-position: 100% 50%;
    }
}

.message-time {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85); /* Light color for dark backgrounds - 8.5:1 contrast */
    opacity: 1;
    margin-top: 6px;
    padding: 0 4px;
    transition: opacity 0.2s ease;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); /* Subtle shadow for readability */
}

.message:hover .message-time,
.message-group:hover .message-time {
    opacity: 0.9;
}

.chat-message.user .message-time,
.user-message-group .message-time {
    text-align: right;
}

/* Message Groups - Modern Layout */
.message-group {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 24px;
    animation: message-slide-in 0.45s var(--ease-smooth);
}

.message-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.message-avatar-small:hover {
    transform: scale(1.08);
}

.message-content-free {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 85%;
}

.message-text {
    padding: 20px 28px;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.7;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', 'Roboto', system-ui, sans-serif;
}

.message-text:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.message-text.ai-message {
    background: transparent;
    color: #1a202c !important;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 24px 32px;
    font-size: 16px;
    line-height: 1.75;
    font-weight: 500;
    font-family: 'SinAI Custom', -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', system-ui, sans-serif;
    position: relative;
    /* Force GPU layer and create stacking context */
    isolation: isolate;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Organic liquid background for AI message text - ENHANCED 40PX BLUR */
.message-text.ai-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(248, 250, 252, 0.2) 100%);
    -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
    backdrop-filter: blur(40px) saturate(180%) !important;
    border-radius: 28px 28px 28px 8px;
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.15), 
                0 0 0 1px rgba(255, 255, 255, 0.6) inset,
                0 4px 16px rgba(102, 126, 234, 0.1);
    z-index: -1;
    /* Force GPU layer for blur performance */
    transform: translate3d(0, 0, 0);
    will-change: transform;
    animation: ai-message-morph 6s ease-in-out infinite;
}

@keyframes ai-message-morph {
    0%, 100% { 
        border-radius: 28px 28px 28px 8px;
        transform: scale(1);
    }
    33% { 
        border-radius: 32px 24px 30px 10px;
        transform: scale(1.005) translateX(-1px);
    }
    66% { 
        border-radius: 24px 32px 26px 9px;
        transform: scale(1.005) translateX(1px);
    }
}

.message-text.ai-message {
    font-feature-settings: 'liga' 1, 'calt' 1;
    letter-spacing: 0.01em;
}

/* Removed duplicate [data-theme] selector - using [data-bs-theme] below for consistency */

/* Admin dark mode support for message bubbles */
[data-bs-theme="dark"] .message-text.ai-message {
    color: #f0f0f0 !important;
    font-size: 16px !important;
    line-height: 1.75 !important;
    font-weight: 400;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .message-text.ai-message::before {
    background: linear-gradient(135deg, 
        rgba(45, 55, 72, 0.35) 0%, 
        rgba(30, 41, 59, 0.3) 100%) !important;
    border: 1px solid rgba(102, 126, 234, 0.4) !important;
    border-radius: 28px 28px 28px 8px !important;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.5), 
        0 0 0 1px rgba(102, 126, 234, 0.25) inset,
        0 4px 16px rgba(102, 126, 234, 0.2) inset !important;
    -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
    backdrop-filter: blur(40px) saturate(180%) !important;
    /* GPU acceleration */
    transform: translate3d(0, 0, 0);
    will-change: transform;
}

/* Enhanced hover state for dark mode messages */
[data-bs-theme="dark"] .message-text.ai-message:hover::before {
    border-color: rgba(102, 126, 234, 0.5) !important;
    box-shadow: 
        0 12px 40px rgba(0, 0, 0, 0.7), 
        0 0 0 1px rgba(102, 126, 234, 0.3) inset,
        0 4px 20px rgba(102, 126, 234, 0.2) inset !important;
}

.message-text.user-message {
    background: transparent;
    color: white;
    font-weight: 500;
    border-radius: 0;
    border: none;
    box-shadow: none;
    padding: 24px 32px;
    font-size: 16px;
    line-height: 1.75;
    position: relative;
    z-index: 1;
}

/* Flowing gradient background for user messages */
.message-text.user-message::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(240, 147, 251, 0.98) 0%, rgba(245, 87, 108, 0.98) 100%);
    background-size: 200% 200%;
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border-radius: 28px 28px 8px 28px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 24px rgba(240, 147, 251, 0.4),
                0 0 0 1px rgba(255, 255, 255, 0.25) inset;
    z-index: -1;
    animation: user-message-flow 6s ease-in-out infinite;
}

@keyframes user-message-flow {
    0%, 100% { 
        border-radius: 24px 24px 6px 24px;
        background-position: 0% 50%;
    }
    33% { 
        border-radius: 28px 20px 8px 26px;
        background-position: 50% 50%;
    }
    66% { 
        border-radius: 20px 28px 7px 22px;
        background-position: 100% 50%;
    }
}

.user-message-group .message-content-free {
    align-items: flex-start;
}

.ai-message-group .message-content-free {
    align-items: flex-start;
}

/* Premium Welcome Message */
.welcome-message {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
    animation: welcome-fade-in 0.6s var(--ease-smooth);
}

@keyframes welcome-fade-in {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.welcome-message .message-bubble {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

/* ============================================
   Premium AI Thinking Indicator with Bouncing Animation
   ============================================ */
.ai-thinking,
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    animation: message-slide-in 0.4s var(--ease-smooth);
}

.ai-thinking .message-avatar {
    background: linear-gradient(135deg, var(--sinai-primary) 0%, var(--sinai-secondary) 100%);
    color: white;
}

.thinking-bubble,
.typing-dots {
    background: white;
    padding: 20px 28px;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    font-size: 15px;
    font-weight: 500;
    color: #667eea;
}

.thinking-bubble::before {
    content: 'Thinking...';
    margin-right: 8px;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

[data-bs-theme="dark"] .thinking-bubble,
[data-bs-theme="dark"] .typing-dots {
    background: rgba(50, 55, 70, 0.92);
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 
        0 6px 24px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(102, 126, 234, 0.15) inset;
    -webkit-backdrop-filter: blur(15px) saturate(150%);
    backdrop-filter: blur(15px) saturate(150%);
}

[data-bs-theme="dark"] .thinking-text {
    color: #d0d0d0 !important;
    font-weight: 400;
    transition: all 0.3s var(--ease-smooth);
}

[data-bs-theme="dark"] .thinking-dot,
[data-bs-theme="dark"] .typing-dots span {
    background: rgba(102, 126, 234, 0.9);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
}

.thinking-bubble:hover,
.typing-dots:hover {
    box-shadow: var(--shadow-lg);
}

[data-theme="dark"] .thinking-bubble,
[data-theme="dark"] .typing-dots {
    background: #2d3748;
}

.thinking-dot,
.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--sinai-primary);
    border-radius: 50%;
    animation: thinking-bounce 1.5s ease-in-out infinite;
}

.thinking-dot:nth-child(2),
.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dot:nth-child(3),
.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes thinking-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-14px);
        opacity: 1;
    }
}

.typing-indicator small {
    color: var(--sinai-text-light);
    font-size: 12px;
    font-weight: 500;
}

/* ============================================
   Premium Input Area with Smooth Interactions
   ============================================ */
.ai-chat-input-wrapper,
.ai-chat-input {
    padding: 20px 24px !important;
    margin: 10px 20px 20px 20px !important;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.75) 0%, rgba(245, 248, 255, 0.7) 100%) !important;
    border: 1px solid rgba(102, 126, 234, 0.2) !important;
    border-radius: 24px !important;
    position: relative;
    -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
    backdrop-filter: blur(40px) saturate(180%) !important;
    box-shadow: 
        0 -8px 32px rgba(102, 126, 234, 0.08),
        0 0 0 1px rgba(255, 255, 255, 0.3) inset,
        0 -4px 16px rgba(102, 126, 234, 0.05) !important;
}

/* Gradient accent line appears on focus */
.ai-chat-input-wrapper::before,
.ai-chat-input::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--sinai-primary) 0%, var(--sinai-secondary) 100%);
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.3);
}

.ai-chat-input-wrapper:focus-within::before,
.ai-chat-input:focus-within::before {
    opacity: 1;
}

[data-theme="dark"] .ai-chat-input-wrapper,
[data-theme="dark"] .ai-chat-input,
[data-bs-theme="dark"] .ai-chat-input-wrapper,
[data-bs-theme="dark"] .ai-chat-input {
    background: linear-gradient(180deg, rgba(30, 35, 50, 0.75) 0%, rgba(26, 31, 58, 0.7) 100%) !important;
    border: 1px solid rgba(102, 126, 234, 0.4) !important;
    border-radius: 24px !important;
    -webkit-backdrop-filter: blur(40px) saturate(180%) !important;
    backdrop-filter: blur(40px) saturate(180%) !important;
    box-shadow: 
        0 -8px 32px rgba(0, 0, 0, 0.2),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 -4px 16px rgba(102, 126, 234, 0.1) !important;
}

[data-bs-theme="dark"] .ai-chat-input-wrapper::before,
[data-bs-theme="dark"] .ai-chat-input::before {
    box-shadow: 0 2px 16px rgba(102, 126, 234, 0.4);
}

.ai-chat-input-container,
.ai-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.ai-chat-input textarea,
textarea.ai-chat-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.6);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid rgba(102, 126, 234, 0.25);
    border-radius: 20px;
    padding: 14px 20px;
    font-size: 14.5px;
    font-family: inherit;
    color: var(--sinai-text-dark);
    resize: none;
    min-height: 48px;
    max-height: 120px;
    transition: all 0.5s var(--ease-liquid);
    line-height: 1.5;
    box-shadow: 0 2px 16px rgba(102, 126, 234, 0.08);
}

.ai-chat-input textarea:focus,
textarea.ai-chat-input:focus {
    outline: none;
    border-color: rgba(102, 126, 234, 0.4);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 4px 24px rgba(102, 126, 234, 0.15),
                0 0 0 1px rgba(102, 126, 234, 0.1) inset;
    border-radius: 24px;
    transform: scale(1.01);
}

.ai-chat-input textarea::placeholder,
textarea.ai-chat-input::placeholder {
    color: var(--sinai-text-light);
}

[data-theme="dark"] .ai-chat-input textarea,
[data-theme="dark"] textarea.ai-chat-input,
[data-bs-theme="dark"] .ai-chat-input textarea,
[data-bs-theme="dark"] textarea.ai-chat-input {
    background: rgba(40, 45, 60, 0.6);
    border-color: rgba(102, 126, 234, 0.35);
    color: #f0f0f0;
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .ai-chat-input textarea:focus,
[data-theme="dark"] textarea.ai-chat-input:focus,
[data-bs-theme="dark"] .ai-chat-input textarea:focus,
[data-bs-theme="dark"] textarea.ai-chat-input:focus {
    background: rgba(45, 50, 65, 0.85);
    border-color: rgba(102, 126, 234, 0.5);
    box-shadow: 
        0 4px 24px rgba(102, 126, 234, 0.25),
        0 0 0 1px rgba(102, 126, 234, 0.2) inset;
    transform: scale(1.01);
}

[data-bs-theme="dark"] .ai-chat-input textarea::placeholder,
[data-bs-theme="dark"] textarea.ai-chat-input::placeholder {
    color: rgba(200, 200, 200, 0.5);
}

/* Liquid Floating Send Button */
.ai-chat-send,
.btn-send {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--sinai-primary) 0%, var(--sinai-secondary) 100%);
    color: white;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s var(--ease-liquid);
    flex-shrink: 0;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4),
                0 0 0 1px rgba(255, 255, 255, 0.2) inset;
    position: relative;
    overflow: hidden;
    animation: send-button-float 3s ease-in-out infinite;
}

@keyframes send-button-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* Ripple effect on click */
.ai-chat-send::before,
.btn-send::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ai-chat-send:active::before,
.btn-send:active::before {
    width: 100px;
    height: 100px;
}

.ai-chat-send:hover:not(:disabled),
.btn-send:hover:not(:disabled) {
    transform: scale(1.12) translateY(-3px);
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.6),
                0 0 0 2px rgba(255, 255, 255, 0.3) inset;
    animation: none;
}

.ai-chat-send:active:not(:disabled),
.btn-send:active:not(:disabled) {
    transform: scale(0.95);
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.4);
}

.ai-chat-send:disabled,
.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* ============================================
   Premium Powered By Footer - INTEGRATED WITH INPUT
   ============================================ */
.chat-powered-by,
.ai-chat-footer {
    padding: 8px 0;
    margin: 0 20px 20px 20px;
    text-align: center;
    font-size: 11px;
    color: var(--sinai-text-light);
    background: transparent;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.chat-powered-by:hover,
.ai-chat-footer:hover {
    opacity: 1;
}

[data-theme="dark"] .chat-powered-by,
[data-theme="dark"] .ai-chat-footer {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
}

.chat-powered-by a,
.ai-chat-footer a {
    color: var(--sinai-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.chat-powered-by a:hover,
.ai-chat-footer a:hover {
    color: var(--sinai-secondary);
}

.ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, var(--sinai-primary) 0%, var(--sinai-secondary) 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.25);
    transition: all 0.3s ease;
}

.ai-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.35);
}

.ai-chat-footer i {
    color: var(--sinai-primary);
    margin-right: 4px;
}

.ai-chat-footer small {
    font-size: 11px;
    color: var(--sinai-text-light);
}

/* ============================================
   Premium Error Messages with Shake Animation
   ============================================ */
.error-message {
    background: linear-gradient(135deg, #fed7d7 0%, #feb2b2 100%);
    color: #c53030;
    padding: 12px 16px;
    border-radius: 12px;
    margin: 12px 0;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: shake 0.5s ease-in-out;
    box-shadow: var(--shadow-sm);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

.error-message::before {
    content: '⚠️';
    font-size: 18px;
}

/* ============================================
   Code Blocks in Messages (if AI sends code)
   ============================================ */
.message-bubble pre,
.message-content pre {
    background: var(--sinai-bg-light);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    margin: 8px 0;
}

.message-bubble code,
.message-content code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background: var(--sinai-bg-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* ============================================
   Mobile Responsive Design
   ============================================ */
/* ============================================
   RESPONSIVE DESIGN - Mobile First Approach
   ============================================ */

/* Extra Small Devices (phones, portrait, < 576px) */
@media (max-width: 575.98px) {
    /* Orb positioning - fully visible on mobile, not pushed off edge */
    .ai-chat-widget {
        bottom: 20px;
        right: 16px; /* Visible position on mobile */
    }
    
    .ai-chat-toggle {
        width: 70px;
        height: 70px;
    }
    
    .orb-core {
        width: 70px;
        height: 70px;
    }
    
    /* Full screen chat on mobile */
    .ai-chat-window {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
        max-width: 100vw;
    }
    
    /* Admin mode also full screen */
    .ai-chat-widget[data-admin-mode="true"] .ai-chat-window,
    .ai-chat-widget[data-user-role="admin"] .ai-chat-window {
        width: 100vw !important;
        left: 0 !important;
    }
    
    /* Chat header adjustments */
    .ai-chat-header {
        padding: 16px;
        min-height: 80px;
    }
    
    .chat-header-text h3 {
        font-size: 16px;
    }
    
    .agent-status {
        font-size: 12px;
    }
    
    /* Messages take full width */
    .ai-chat-messages {
        padding: 12px;
        height: calc(100vh - 240px);
    }
    
    .message-content {
        max-width: 85%;
        font-size: 14px;
    }
    
    .message-bubble {
        padding: 10px 14px;
    }
    
    /* Input area */
    .ai-chat-input-wrapper {
        padding: 12px;
    }
    
    .ai-chat-input {
        font-size: 15px;
        padding: 12px;
        min-height: 44px; /* Touch-friendly */
    }
    
    .ai-chat-send,
    .btn-send {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    /* Glow layer smaller on mobile */
    .orb-glow-layer {
        width: 40%;
        height: 40%;
        filter: blur(15px);
    }
    
    /* Close button touch-friendly */
    .ai-chat-close {
        width: 40px;
        height: 40px;
        top: 16px;
        right: 16px;
    }
}

/* Small Devices (landscape phones, 576px - 767.98px) */
@media (min-width: 576px) and (max-width: 767.98px) {
    .ai-chat-widget {
        bottom: 24px;
        right: 24px;
    }
    
    .ai-chat-toggle {
        width: 75px;
        height: 75px;
    }
    
    .ai-chat-window {
        width: calc(100vw - 48px);
        height: 85vh;
        max-height: 700px;
        bottom: 100px;
        right: 24px;
    }
    
    .ai-chat-messages {
        padding: 16px;
    }
    
    .message-content {
        max-width: 80%;
    }
}

/* ============================================
   Accessibility Enhancements
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
button:focus-visible,
textarea:focus-visible,
.ai-chat-toggle:focus-visible,
.ai-chat-send:focus-visible,
.btn-send:focus-visible {
    outline: 2px solid var(--sinai-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ai-chat-toggle,
    .ai-chat-send,
    .btn-send,
    .message-avatar {
        border: 2px solid currentColor;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 767.98px) and (orientation: landscape) {
    .ai-chat-window {
        height: 90vh !important;
        max-height: 90vh !important;
    }
    
    .ai-chat-messages {
        height: calc(90vh - 200px) !important;
    }
    
    .ai-chat-header {
        min-height: 60px;
        padding: 12px 16px;
    }
    
    .chat-header-text h3 {
        font-size: 14px;
    }
}

/* ============================================
   Print Styles (hide widget when printing)
   ============================================ */
@media print {
    .ai-chat-widget {
        display: none !important;
    }
}

/* ============================================
   Smooth Transitions for All Interactive Elements
   ============================================ */
button,
input,
textarea,
.message-bubble,
.message-content p,
.message-avatar {
    transition: all 0.3s var(--ease-smooth);
}

/* ============================================
   Proactive Engagement Nudge
   ============================================ */
/* ============================================
   ORBLIQUID CLOUD NUDGE - Revolutionary Graphics-First Design
   Ultra-transparent, dynamically positioned, orb-connected
   Foundation for full orb interface redesign
   ============================================ */

.ai-chat-nudge.orb-cloud.orb-emanation {
    position: fixed;
    z-index: 10050; /* MUCH higher - definitely above all orb elements */
    pointer-events: none;
    animation: cloudEmergeFromOrb 1.8s cubic-bezier(0.34, 1.56, 0.64, 1);
    will-change: transform;
    transform: translate3d(0, 0, 200px); /* Force MUCH higher GPU layer */
    isolation: isolate; /* Create new stacking context */
}

/* Dramatic emergence from orb with upward float */
@keyframes cloudEmergeFromOrb {
    0% {
        opacity: 0;
        transform: scale(0.2) translateY(80px);
        filter: blur(20px);
    }
    40% {
        opacity: 0.6;
        transform: scale(0.8) translateY(20px);
        filter: blur(5px);
    }
    70% {
        opacity: 1;
        transform: scale(1.08);
        filter: blur(0px);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0px);
    }
}

.ai-chat-nudge.orb-cloud.blow-away {
    animation: cloudBlowAwayEthereal 1.5s cubic-bezier(0.4, 0, 1, 0.5) forwards;
}

/* Enhanced dispersal with rotation and stronger blur */
@keyframes cloudBlowAwayEthereal {
    0% {
        opacity: 1;
        transform: scale(1) translateX(0) translateY(0) rotate(0deg);
        filter: blur(0px);
    }
    20% {
        opacity: 0.9;
        transform: scale(1.05) translateX(5px) translateY(-10px) rotate(3deg);
        filter: blur(1px);
    }
    60% {
        opacity: 0.4;
        transform: scale(1.3) translateX(50px) translateY(-40px) rotate(15deg);
        filter: blur(15px);
    }
    100% {
        opacity: 0;
        transform: scale(1.8) translateX(120px) translateY(-80px) rotate(30deg);
        filter: blur(30px);
    }
}

/* Orb connection beam - pulsing energy thread */
.ai-chat-nudge .orb-connection-beam {
    position: absolute;
    bottom: -150px;
    left: 50%;
    width: 2px;
    height: 150px;
    background: linear-gradient(
        to top,
        rgba(102, 126, 234, 0) 0%,
        rgba(102, 126, 234, 0.4) 20%,
        rgba(147, 197, 253, 0.6) 50%,
        rgba(102, 126, 234, 0.3) 80%,
        rgba(102, 126, 234, 0) 100%
    );
    transform: translateX(-50%);
    pointer-events: none;
    opacity: 0.8;
    animation: beamPulse 2.5s ease-in-out infinite;
    filter: blur(1px);
}

@keyframes beamPulse {
    0%, 100% {
        opacity: 0.3;
        transform: translateX(-50%) scaleY(1);
    }
    50% {
        opacity: 0.8;
        transform: translateX(-50%) scaleY(1.05);
    }
}

.ai-chat-nudge .cloud-container {
    position: relative;
    pointer-events: auto;
}

/* Enhanced 5-particle system with varied sizes and speeds */
.ai-chat-nudge .cloud-particles {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.ai-chat-nudge .cloud-particles .particle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(102, 126, 234, 0.25) 0%, rgba(147, 197, 253, 0.1) 50%, transparent 80%);
    pointer-events: none;
}

/* Particle 1 - Large slow drift */
.ai-chat-nudge .cloud-particles .p1 {
    top: -20px;
    left: -20px;
    width: 80px;
    height: 80px;
    animation: particleDrift1 5s ease-in-out infinite;
}

/* Particle 2 - Medium fast pulse */
.ai-chat-nudge .cloud-particles .p2 {
    top: 10px;
    right: -15px;
    width: 60px;
    height: 60px;
    animation: particleDrift2 3.5s ease-in-out infinite;
    animation-delay: 0.5s;
}

/* Particle 3 - Small rapid orbit */
.ai-chat-nudge .cloud-particles .p3 {
    bottom: -10px;
    left: 20px;
    width: 40px;
    height: 40px;
    animation: particleDrift3 2.8s ease-in-out infinite;
    animation-delay: 1s;
}

/* Particle 4 - Medium slow float */
.ai-chat-nudge .cloud-particles .p4 {
    bottom: 15px;
    right: 10px;
    width: 55px;
    height: 55px;
    animation: particleDrift4 4.2s ease-in-out infinite;
    animation-delay: 1.5s;
}

/* Particle 5 - Large ethereal pulse */
.ai-chat-nudge .cloud-particles .p5 {
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    transform: translate(-50%, -50%);
    animation: particleDrift5 6s ease-in-out infinite;
    animation-delay: 0.8s;
    opacity: 0.3;
}

@keyframes particleDrift1 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.5;
    }
    50% {
        transform: translate(-8px, -12px) scale(1.2);
        opacity: 0.8;
    }
}

@keyframes particleDrift2 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.4;
    }
    50% {
        transform: translate(10px, -8px) scale(1.4);
        opacity: 0.2;
    }
}

@keyframes particleDrift3 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translate(-5px, 10px) scale(1.3);
        opacity: 0.3;
    }
}

@keyframes particleDrift4 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0.45;
    }
    50% {
        transform: translate(8px, 6px) scale(1.25);
        opacity: 0.7;
    }
}

@keyframes particleDrift5 {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.2;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.15);
        opacity: 0.4;
    }
}

/* Ultra-transparent liquid glass content - Foundation for graphics-heavy interface */
.ai-chat-nudge .nudge-cloud-content {
    position: relative;
    z-index: 10060; /* CRITICAL: Must be ABOVE orb particle container (10002) */
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    isolation: isolate;
    border-radius: 28px;
    cursor: pointer;
    max-width: 220px;
    overflow: hidden;
    
    /* Visible semi-transparent glass with better contrast */
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(40px) saturate(200%);
    backdrop-filter: blur(40px) saturate(200%);
    border: 1.5px solid rgba(102, 126, 234, 0.4);
    box-shadow: 
        0 12px 48px rgba(102, 126, 234, 0.35),
        0 4px 16px rgba(0, 0, 0, 0.12),
        inset 0 2px 0 rgba(255, 255, 255, 0.8),
        inset 0 -2px 0 rgba(102, 126, 234, 0.15);
    
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(100px); /* GPU layer - in front of orb */
}

.ai-chat-nudge .nudge-cloud-content:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(147, 197, 253, 0.5);
    box-shadow: 
        0 16px 64px rgba(102, 126, 234, 0.35),
        0 6px 20px rgba(0, 0, 0, 0.12),
        inset 0 2px 0 rgba(255, 255, 255, 0.6),
        inset 0 -2px 0 rgba(102, 126, 234, 0.3);
    transform: translateY(-2px) scale(1.02);
}

/* Stronger radial glow with breathing effect */
.ai-chat-nudge .cloud-glow {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1; /* Behind content and text */
    border-radius: 28px;
    background: radial-gradient(
        circle at 40% 40%,
        rgba(147, 197, 253, 0.5) 0%,
        rgba(102, 126, 234, 0.3) 30%,
        rgba(118, 75, 162, 0.15) 60%,
        transparent 80%
    );
    opacity: 0.9;
    animation: glowBreath 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes glowBreath {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.08);
    }
}

/* Icon-first minimal design */
.ai-chat-nudge .nudge-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.ai-chat-nudge .nudge-icon-pulse {
    font-size: 22px;
    line-height: 1;
    animation: iconPulse 2s ease-in-out infinite;
    filter: drop-shadow(0 2px 8px rgba(102, 126, 234, 0.4));
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 2px 8px rgba(102, 126, 234, 0.4));
    }
    50% {
        transform: scale(1.15);
        filter: drop-shadow(0 4px 16px rgba(102, 126, 234, 0.6));
    }
}

.ai-chat-nudge .nudge-text-minimal {
    position: relative;
    z-index: 20; /* Above all nudge elements including glow */
    font-size: 14px;
    font-weight: 500;
    color: rgba(45, 55, 72, 0.95);
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8);
    flex: 1;
    white-space: nowrap;
    transform: translateZ(20px); /* GPU layer for text clarity */
}

.ai-chat-nudge .nudge-close {
    position: relative;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(102, 126, 234, 0.1);
    color: rgba(45, 55, 72, 0.7);
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s var(--ease-smooth);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.ai-chat-nudge .nudge-close:hover {
    background: rgba(102, 126, 234, 0.2);
    color: var(--sinai-primary);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* ============================================
   RESPONSIVE DESIGN - Mobile & Tablet Constraints
   ============================================ */

/* Mobile devices: Reduced size and constrained animations */
/* Medium Devices (tablets, 768px - 991.98px) */
@media (min-width: 768px) and (max-width: 991.98px) {
    .ai-chat-widget {
        bottom: 24px;
        right: 24px;
    }
    
    .ai-chat-toggle {
        width: 85px;
        height: 85px;
    }
    
    .ai-chat-window {
        width: 480px;
        height: 65vh;
        max-height: 700px;
        bottom: 110px;
        right: 24px;
    }
    
    .ai-chat-header {
        padding: 20px;
    }
    
    .ai-chat-messages {
        padding: 18px;
    }
}

/* Large Devices (desktops, 992px - 1199.98px) */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .ai-chat-widget {
        bottom: 24px;
        right: 24px;
    }
    
    .ai-chat-toggle {
        width: 95px;
        height: 95px;
    }
    
    .ai-chat-window {
        width: 520px;
        height: 70vh;
        max-height: 800px;
        bottom: 120px;
        right: 24px;
    }
}

/* Extra Large Devices (large desktops, >= 1200px) */
@media (min-width: 1200px) {
    .ai-chat-widget {
        bottom: 30px;
        right: 30px;
    }
    
    .ai-chat-toggle {
        width: 105px;
        height: 105px;
    }
    
    .orb-core {
        width: 105px;
        height: 105px;
    }
    
    .ai-chat-window {
        width: 560px;
        height: 75vh;
        max-height: 900px;
        bottom: 140px;
        right: 30px;
    }
    
    .ai-chat-header {
        padding: 24px;
    }
    
    .ai-chat-messages {
        padding: 24px;
    }
    
    .message-content {
        font-size: 15px;
    }
}

/* Ultra Wide Screens (>= 1920px) */
@media (min-width: 1920px) {
    .ai-chat-window {
        width: 600px;
        max-height: 1000px;
    }
    
    .ai-chat-toggle {
        width: 110px;
        height: 110px;
    }
}

@media (max-width: 767.98px) {
    .ai-chat-nudge.orb-cloud.orb-emanation {
        /* Mobile responsive positioning - closer to viewport edge */
        right: 10px !important;
    }
    
    .ai-chat-nudge .nudge-cloud-content {
        /* Smaller padding and max-width */
        padding: 12px 16px;
        max-width: 180px;
        border-radius: 20px;
    }
    
    .ai-chat-nudge .nudge-icon-wrapper {
        width: 28px;
        height: 28px;
    }
    
    .ai-chat-nudge .nudge-icon-pulse {
        font-size: 18px;
    }
    
    .ai-chat-nudge .nudge-text-minimal {
        font-size: 13px;
    }
    
    .ai-chat-nudge .nudge-close {
        width: 20px;
        height: 20px;
        font-size: 14px;
    }
    
    /* Reduce particle sizes on mobile */
    .ai-chat-nudge .cloud-particles .p1 {
        width: 60px;
        height: 60px;
    }
    
    .ai-chat-nudge .cloud-particles .p2 {
        width: 45px;
        height: 45px;
    }
    
    .ai-chat-nudge .cloud-particles .p3 {
        width: 30px;
        height: 30px;
    }
    
    .ai-chat-nudge .cloud-particles .p4 {
        width: 40px;
        height: 40px;
    }
    
    .ai-chat-nudge .cloud-particles .p5 {
        width: 70px;
        height: 70px;
    }
    
    /* Constrain blow-away animation on mobile to prevent off-screen overflow */
    .ai-chat-nudge.orb-cloud.blow-away {
        animation: cloudBlowAwayMobile 1.5s cubic-bezier(0.4, 0, 1, 0.5) forwards;
    }
    
    @keyframes cloudBlowAwayMobile {
        0% {
            opacity: 1;
            transform: scale(1) translateX(0) translateY(0) rotate(0deg);
            filter: blur(0px);
        }
        20% {
            opacity: 0.9;
            transform: scale(1.05) translateX(3px) translateY(-8px) rotate(2deg);
            filter: blur(1px);
        }
        60% {
            opacity: 0.4;
            transform: scale(1.2) translateX(30px) translateY(-30px) rotate(10deg);
            filter: blur(12px);
        }
        100% {
            opacity: 0;
            transform: scale(1.4) translateX(60px) translateY(-50px) rotate(20deg);
            filter: blur(20px);
        }
    }
}

/* Tablet devices: Moderate constraints */
@media (min-width: 768px) and (max-width: 1023px) {
    .ai-chat-nudge .nudge-cloud-content {
        max-width: 200px;
        padding: 14px 18px;
    }
    
    /* Slightly reduce particle animation ranges */
    @keyframes particleDrift1 {
        0%, 100% {
            transform: translate(0, 0) scale(1);
            opacity: 0.5;
        }
        50% {
            transform: translate(-6px, -10px) scale(1.15);
            opacity: 0.8;
        }
    }
    
    @keyframes particleDrift2 {
        0%, 100% {
            transform: translate(0, 0) scale(1);
            opacity: 0.4;
        }
        50% {
            transform: translate(8px, -6px) scale(1.3);
            opacity: 0.2;
        }
    }
}

/* ============================================
   DARK MODE - Ethereal Purple/Blue Aesthetics
   ============================================ */
[data-bs-theme="dark"] .ai-chat-nudge .nudge-cloud-content {
    background: rgba(20, 20, 30, 0.08);
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 
        0 12px 48px rgba(102, 126, 234, 0.4),
        0 4px 16px rgba(118, 75, 162, 0.3),
        inset 0 2px 0 rgba(147, 197, 253, 0.3),
        inset 0 -2px 0 rgba(102, 126, 234, 0.4);
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-cloud-content:hover {
    background: rgba(20, 20, 30, 0.15);
    border-color: rgba(147, 197, 253, 0.6);
    box-shadow: 
        0 16px 64px rgba(102, 126, 234, 0.5),
        0 6px 20px rgba(118, 75, 162, 0.4),
        inset 0 2px 0 rgba(147, 197, 253, 0.4),
        inset 0 -2px 0 rgba(102, 126, 234, 0.5);
}

[data-bs-theme="dark"] .ai-chat-nudge .cloud-glow {
    background: radial-gradient(
        circle at 40% 40%,
        rgba(147, 197, 253, 0.6) 0%,
        rgba(102, 126, 234, 0.5) 30%,
        rgba(118, 75, 162, 0.3) 60%,
        transparent 80%
    );
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-text-minimal {
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

[data-bs-theme="dark"] .ai-chat-nudge .orb-connection-beam {
    background: linear-gradient(
        to top,
        rgba(102, 126, 234, 0) 0%,
        rgba(102, 126, 234, 0.6) 20%,
        rgba(147, 197, 253, 0.8) 50%,
        rgba(102, 126, 234, 0.5) 80%,
        rgba(102, 126, 234, 0) 100%
    );
    filter: blur(2px);
}

[data-bs-theme="dark"] .ai-chat-nudge .cloud-particles .particle {
    background: radial-gradient(circle, rgba(147, 197, 253, 0.4) 0%, rgba(102, 126, 234, 0.2) 50%, transparent 80%);
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-close {
    background: rgba(102, 126, 234, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-close:hover {
    background: rgba(102, 126, 234, 0.4);
    color: rgba(255, 255, 255, 1);
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.5);
}

@keyframes glowPulse {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

.ai-chat-nudge .nudge-cloud-content:hover {
    transform: translateY(-4px) scale(1.02);
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow: 
        0 12px 48px rgba(102, 126, 234, 0.25),
        0 4px 16px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.5),
        inset 0 -1px 0 rgba(255, 255, 255, 0.2);
}

.ai-chat-nudge .nudge-cloud-content:hover .cloud-glow {
    opacity: 1;
    transform: scale(1.1);
}

.ai-chat-nudge .nudge-text {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: rgba(30, 41, 59, 0.95);
    line-height: 1.5;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
    position: relative;
    z-index: 1;
    letter-spacing: 0.01em;
}

.ai-chat-nudge .nudge-close {
    position: relative;
    z-index: 2;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: rgba(30, 41, 59, 0.7);
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.ai-chat-nudge .nudge-close:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Dark mode - even more ethereal */
[data-bs-theme="dark"] .ai-chat-nudge .nudge-cloud-content {
    background: rgba(20, 20, 30, 0.25);
    border: 1px solid rgba(102, 126, 234, 0.3);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 2px 8px rgba(102, 126, 234, 0.2),
        inset 0 1px 0 rgba(147, 197, 253, 0.1),
        inset 0 -1px 0 rgba(102, 126, 234, 0.1);
}

[data-bs-theme="dark"] .ai-chat-nudge .cloud-glow {
    background: radial-gradient(
        circle at 30% 30%,
        rgba(147, 197, 253, 0.25) 0%,
        rgba(102, 126, 234, 0.15) 40%,
        transparent 70%
    );
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-cloud-content:hover {
    background: rgba(30, 30, 50, 0.35);
    border-color: rgba(147, 197, 253, 0.5);
    box-shadow: 
        0 12px 48px rgba(102, 126, 234, 0.3),
        0 4px 16px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(147, 197, 253, 0.2),
        inset 0 -1px 0 rgba(102, 126, 234, 0.2);
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-text {
    color: rgba(241, 245, 249, 0.95);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-close {
    background: rgba(30, 41, 59, 0.4);
    border-color: rgba(147, 197, 253, 0.2);
    color: rgba(241, 245, 249, 0.8);
}

[data-bs-theme="dark"] .ai-chat-nudge .nudge-close:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}

/* Mobile responsive */
@media (max-width: 767.98px) {
    .ai-chat-nudge.orb-cloud {
        right: 16px;
        bottom: 90px;
    }
    
    .ai-chat-nudge .nudge-cloud-content {
        max-width: calc(100vw - 32px);
        padding: 14px 18px;
    }
    
    .ai-chat-nudge .nudge-text {
        font-size: 13px;
    }
}

/* ============================================
   NUCLEAR FIX: Stop ALL orb transforms/scaling
   Face was flipping due to parent transform animations
   ============================================ */
#ai-chat-toggle,
#ai-chat-toggle.proactive-pulse,
#ai-chat-toggle.guide-pulse,
.ai-chat-toggle,
.orb-core,
.orb-outer,
.orb-middle,
.orb-inner {
    animation: none !important;
    transform: none !important;
}

/* Re-apply ONLY the essential centering transforms */
.orb-layer {
    transform: translate(-50%, -50%) !important;
    z-index: 1 !important; /* Low - background layers */
}

/* ============================================
   NSIGHT COPILOT BULLET-PROOF FIX (v4)
   Move face OUTSIDE .orb-core AND OUTSIDE button to escape stacking context.
   Face lives in .orb-face-wrapper as sibling of button (both children of .orb-particle-container).
   This prevents button's z-index: 2 stacking context from limiting face z-index.
   ============================================ */

/* 1️⃣ Container - stop clipping the face */
.orb-particle-container {
    overflow: visible !important;
    position: relative !important;
}

/* 2️⃣ Canvas - keep it behind, inside orb-core */
.orb-core canvas.orb-particles,
#orb-master-canvas,
canvas.orb-particles {
    position: absolute !important;
    inset: 0 !important;
    z-index: -1 !important; /* NEGATIVE z-index to guarantee behind face */
    pointer-events: none !important;
    mix-blend-mode: normal !important; /* Prevent blend mode from affecting layering */
}

/* 3️⃣ New wrapper - sibling of BUTTON (escapes button's stacking context) */
.orb-face-wrapper {
    position: absolute !important;
    inset: 0 !important; /* Fill container (same as button) */
    pointer-events: none !important; /* Allow clicks to pass through to button */
    z-index: 100 !important; /* Above orb layers, below close button */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important; /* Teleport with orb */
}

/* 4️⃣ Face - own GPU compositor layer - TELEPORTS WITH ORB */
.agent-face {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 48px !important;
    height: 48px !important;
    transform: translate(-50%, -50%) translateZ(50px) !important; /* Highest Z - in front of everything */
    will-change: transform, opacity !important;
    isolation: isolate !important;
    backface-visibility: visible !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    mix-blend-mode: normal !important;
    z-index: 500 !important; /* Highest z-index - always on top of orb */
    transition: inherit !important; /* Inherit teleport transition from wrapper */
}

/* 5️⃣ Override ANY script that tries to hide the face */
.orb-particle-container .agent-face,
.orb-particle-container .agent-face *,
.orb-face-wrapper .agent-face,
.orb-face-wrapper .agent-face * {
    opacity: 1 !important;
    visibility: visible !important;
    display: flex !important;
}

/* Face SVG icon */
.agent-icon {
    width: 48px !important;
    height: 48px !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

/* ============================================
   EMOTION-REACTIVE ORB SYSTEM
   GPU-Compositor Safe: Only toggles display/visibility
   No layout-affecting properties changed
   ============================================ */

/* Base visibility helpers */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

/* Smooth transitions for emotion changes (GPU-accelerated) */
.agent-face {
    transition: transform 0.2s ease-out, opacity 0.2s ease-out !important;
}

/* ========== NEUTRAL EMOTION (default) ========== */
.emotion-neutral .eyes.neutral,
.emotion-neutral .mouth.neutral {
    display: block !important;
}

.emotion-neutral .eyes:not(.neutral),
.emotion-neutral .mouth:not(.neutral) {
    display: none !important;
}

/* ========== HAPPY EMOTION ========== */
.emotion-happy .eyes.happy,
.emotion-happy .mouth.happy {
    display: block !important;
}

.emotion-happy .eyes:not(.happy),
.emotion-happy .mouth:not(.happy) {
    display: none !important;
}

/* Subtle bounce animation for happy state */
.emotion-happy .agent-face {
    animation: orbHappyBounce 0.6s ease-out;
}

@keyframes orbHappyBounce {
    0%, 100% { transform: translate(-50%, -50%) translateZ(10px) scale(1); }
    50% { transform: translate(-50%, -50%) translateZ(10px) scale(1.05); }
}

/* ========== SAD EMOTION ========== */
.emotion-sad .eyes.sad,
.emotion-sad .mouth.sad {
    display: block !important;
}

.emotion-sad .eyes:not(.sad),
.emotion-sad .mouth:not(.sad) {
    display: none !important;
}

/* Subtle downward drift for sad state */
.emotion-sad .agent-face {
    animation: orbSadDrift 1s ease-out;
}

@keyframes orbSadDrift {
    0% { transform: translate(-50%, -50%) translateZ(10px); }
    50% { transform: translate(-50%, -52%) translateZ(10px); }
    100% { transform: translate(-50%, -50%) translateZ(10px); }
}

/* ========== ANGRY EMOTION ========== */
.emotion-angry .eyes.angry,
.emotion-angry .mouth.angry {
    display: block !important;
}

.emotion-angry .eyes:not(.angry),
.emotion-angry .mouth:not(.angry) {
    display: none !important;
}

/* Subtle shake for angry state */
.emotion-angry .agent-face {
    animation: orbAngryShake 0.4s ease-out;
}

@keyframes orbAngryShake {
    0%, 100% { transform: translate(-50%, -50%) translateZ(10px); }
    25% { transform: translate(-52%, -50%) translateZ(10px); }
    75% { transform: translate(-48%, -50%) translateZ(10px); }
}

/* Change glow color to red for angry */
.emotion-angry ~ button .orb-glow-layer {
    filter: blur(15px) hue-rotate(300deg) !important;
}

/* ========== CURIOUS EMOTION ========== */
.emotion-curious .eyes.curious,
.emotion-curious .mouth.curious {
    display: block !important;
}

.emotion-curious .eyes:not(.curious),
.emotion-curious .mouth:not(.curious) {
    display: none !important;
}

/* Subtle tilt for curious state */
.emotion-curious .agent-face {
    animation: orbCuriousTilt 0.8s ease-out;
}

@keyframes orbCuriousTilt {
    0%, 100% { transform: translate(-50%, -50%) translateZ(10px) rotate(0deg); }
    50% { transform: translate(-50%, -50%) translateZ(10px) rotate(5deg); }
}

/* ========== THINKING EMOTION ========== */
.emotion-thinking .eyes.thinking,
.emotion-thinking .mouth.thinking {
    display: block !important;
}

.emotion-thinking .eyes:not(.thinking),
.emotion-thinking .mouth:not(.thinking) {
    display: none !important;
}

/* Pulsing animation for thinking state */
.emotion-thinking .agent-face {
    animation: orbThinkingPulse 1.5s ease-in-out infinite;
}

@keyframes orbThinkingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ========== SURPRISED EMOTION ========== */
.emotion-surprised .eyes.surprised,
.emotion-surprised .mouth.surprised {
    display: block !important;
}

.emotion-surprised .eyes:not(.surprised),
.emotion-surprised .mouth:not(.surprised) {
    display: none !important;
}

/* Quick pop animation for surprised state */
.emotion-surprised .agent-face {
    animation: orbSurprisedPop 0.3s ease-out;
}

@keyframes orbSurprisedPop {
    0% { transform: translate(-50%, -50%) translateZ(10px) scale(0.9); }
    50% { transform: translate(-50%, -50%) translateZ(10px) scale(1.1); }
    100% { transform: translate(-50%, -50%) translateZ(10px) scale(1); }
}

/* ========== ACCESSIBILITY ========== */

/* Screen-reader only content (for ARIA announcements) */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .agent-face,
    .emotion-happy .agent-face,
    .emotion-sad .agent-face,
    .emotion-angry .agent-face,
    .emotion-curious .agent-face,
    .emotion-thinking .agent-face,
    .emotion-surprised .agent-face {
        animation: none !important;
        transition: none !important;
    }
}
