/**
 * AI Pharmacist Puppet CSS - Enhanced with Word-by-Word Captions
 * Updated: Word-by-word caption display without fixed caption box
 * NO GLOW EFFECTS - Normal mode only
 */

/* ==================== CENTERED CONTAINER ==================== */
.ai-puppet-container {
    position: fixed !important;
    bottom: 50px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 99999 !important;
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: transparent !important;
    transition: all 0.3s ease !important;
    display: block !important;
    width: 140px !important;
    height: 140px !important;
    /* NO GLOW FILTER */
    filter: none !important;
}

/* ==================== WORD-BY-WORD CAPTION SYSTEM ==================== */
.ai-caption-container {
    position: fixed !important;
    bottom: 160px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 100002 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: opacity 0.3s ease !important;
    pointer-events: none !important;
    width: auto !important;
    max-width: 400px !important;
    text-align: center !important;
    display: flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
    align-items: center !important;
    gap: 4px 6px !important;
    padding: 0 !important;
    background: none !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    min-height: 0 !important;
}

/* Individual word styling */
.ai-caption-word {
    display: inline-block !important;
    background: rgba(10, 25, 47, 0.92) !important;
    color: #f2e8fd !important;
    padding: 6px 10px !important;
    border-radius: 6px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    border: 1px solid rgba(106, 17, 203, 0.4) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    opacity: 0 !important;
    transform: translateY(10px) !important;
    transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
    word-break: keep-all !important;
    white-space: nowrap !important;
    max-width: 200px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

/* Pharmacist word styling */
.ai-caption-word.pharmacist-word {
    background: rgba(46, 204, 113, 0.92) !important;
    border-color: rgba(46, 204, 113, 0.6) !important;
    color: white !important;
}

/* Word states */
.ai-caption-word.visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
}

.ai-caption-word.current {
    background: rgba(106, 17, 203, 0.95) !important;
    color: white !important;
    border-color: #6a11cb !important;
    transform: scale(1.05) !important;
    box-shadow: 0 6px 16px rgba(106, 17, 203, 0.5) !important;
    font-weight: 600 !important;
}

/* Pharmacist current word */
.ai-caption-word.pharmacist-word.current {
    background: rgba(46, 204, 113, 0.95) !important;
    border-color: #2ecc71 !important;
    box-shadow: 0 6px 16px rgba(46, 204, 113, 0.5) !important;
}

.ai-caption-word.fading {
    opacity: 0.4 !important;
    transform: scale(0.95) !important;
    background: rgba(10, 25, 47, 0.6) !important;
}

/* Container states */
.ai-caption-container.visible {
    opacity: 1 !important;
    visibility: visible !important;
}

/* ==================== CENTERED INPUT UI - SMALLER ==================== */
.ai-puppet-ui {
    position: fixed !important;
    bottom: 160px !important;
    left: 50% !important;
    transform: translateX(-50%) translateY(20px) !important;
    z-index: 100001 !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-radius: 16px !important;
    padding: 16px !important;
    width: 300px !important;
    max-width: 85vw !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) !important;
    background: rgba(10, 25, 47, 0.98) !important;
    border: 2px solid #662aa5 !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6) !important;
    display: none !important;
}

.ai-puppet-ui:after {
    content: '';
    position: absolute !important;
    top: 100% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    border-width: 10px !important;
    border-style: solid !important;
    border-color: #662aa5 transparent transparent transparent !important;
}

.ai-puppet-ui.visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateX(-50%) translateY(0) !important;
    display: block !important;
}

.ai-puppet-ui.hidden {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateX(-50%) translateY(20px) !important;
    display: none !important;
}

/* ==================== INPUT FIELD - SMALLER ==================== */
.ai-input {
    width: 100% !important;
    box-sizing: border-box !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    resize: none !important;
    outline: none !important;
    transition: all 0.2s ease !important;
    padding: 12px !important;
    background: rgba(0, 30, 60, 0.9) !important;
    border: 1px solid #613491 !important;
    color: #ffffff !important;
    margin: 8px 0 16px 0 !important;
    min-height: 70px !important;
    font-family: inherit !important;
}

.ai-input:focus {
    border-color: #00a8ff !important;
    box-shadow: 0 0 0 2px rgba(0, 168, 255, 0.2) !important;
}

.ai-input::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* ==================== BUTTONS ==================== */
.ai-input-footer {
    display: flex !important;
    gap: 8px !important;
    margin-top: 12px !important;
    flex-wrap: wrap !important;
}

.ai-send-btn {
    flex: 1 !important;
    border: none !important;
    border-radius: 22px !important;
    color: white !important;
    padding: 10px 0 !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    background: linear-gradient(135deg, #00a8ff, #0097e6) !important;
    min-width: 120px !important;
}

.ai-send-btn:hover:not(:disabled) {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.ai-send-btn:active:not(:disabled) {
    transform: translateY(0) !important;
}

.ai-send-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* ==================== EXIT TICKET BUTTON ==================== */
.ai-exit-ticket-btn {
    flex: 1 !important;
    border: none !important;
    border-radius: 22px !important;
    color: white !important;
    padding: 10px 0 !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    transition: all 0.2s ease !important;
    min-height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    background: linear-gradient(135deg, #ff6b6b, #ff5252) !important;
    min-width: 120px !important;
}

.ai-exit-ticket-btn.hidden {
    display: none !important;
}

.ai-exit-ticket-btn:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4) !important;
    background: linear-gradient(135deg, #ff5252, #ff3838) !important;
}

.ai-exit-ticket-btn:active {
    transform: translateY(0) !important;
}

/* ==================== CLOSE BUTTON ==================== */
.ai-close-btn {
    position: absolute !important;
    top: 10px !important;
    right: 10px !important;
    background: rgba(255, 255, 255, 0.1) !important;
    border: none !important;
    color: #e1c5ff !important;
    font-size: 20px !important;
    width: 30px !important;
    height: 30px !important;
    cursor: pointer !important;
    border-radius: 50% !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    z-index: 100003 !important;
}

.ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: white !important;
}

/* ==================== HEADER ==================== */
.ai-input-header {
    display: flex !important;
    justify-content: space-between !important;
    margin-bottom: 8px !important;
    font-size: 11px !important;
    gap: 4px !important;
    flex-wrap: wrap !important;
}

.ai-mode-indicator {
    background: #6a11cb !important;
    color: white !important;
    padding: 4px 8px !important;
    border-radius: 10px !important;
    font-weight: bold !important;
    font-size: 10px !important;
    white-space: nowrap !important;
}

.ai-ticket-id {
    background: #2ecc71 !important;
    color: white !important;
    padding: 4px 8px !important;
    border-radius: 10px !important;
    font-weight: bold !important;
    font-size: 10px !important;
    display: none !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 80px !important;
}

.ai-ticket-id.visible {
    display: inline-block !important;
}

.ai-temperature-indicator {
    background: #6a11cb !important;
    color: white !important;
    padding: 4px 8px !important;
    border-radius: 10px !important;
    font-weight: bold !important;
    font-size: 10px !important;
    white-space: nowrap !important;
}

/* Temperature-specific colors */
.ai-temperature-indicator[style*="freezing"] {
    background: #4488ff !important;
}
.ai-temperature-indicator[style*="cold"] {
    background: #66aaff !important;
}
.ai-temperature-indicator[style*="cool"] {
    background: #88ccff !important;
}
.ai-temperature-indicator[style*="warm"] {
    background: #ff8844 !important;
}
.ai-temperature-indicator[style*="hot"] {
    background: #ff4444 !important;
}
.ai-temperature-indicator[style*="burning"] {
    background: #ff0000 !important;
}

/* ==================== HINT ==================== */
.ai-hint {
    margin-top: 12px !important;
    text-align: center !important;
    color: rgba(255, 255, 255, 0.6) !important;
    font-size: 10px !important;
    line-height: 1.3 !important;
    padding-top: 8px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* ==================== VOICE STATUS (HIDDEN) ==================== */
.ai-voice-status {
    display: none !important;
}

/* ==================== ENHANCED REALISTIC PUPPET CANVAS ==================== */
.ai-puppet-canvas {
    display: block !important;
    border-radius: 50% !important;
    touch-action: none !important;
    cursor: pointer !important;
    width: 140px !important;
    height: 140px !important;
    
    /* Enhanced 3D neumorphic effect - NO GLOW */
    background: linear-gradient(145deg, 
        rgba(255, 255, 255, 0.1), 
        rgba(0, 0, 0, 0.05)
    ) !important;
    
    border: 4px solid rgba(255, 255, 255, 0.2) !important;
    
    /* NO GLOW - Just 3D shadows for normal look */
    box-shadow: 
        /* 3D depth shadow only - NO OUTER GLOW */
        15px 15px 30px rgba(0, 0, 0, 0.3),
        -8px -8px 20px rgba(255, 255, 255, 0.1),
        
        /* Inner 3D effect */
        inset 5px 5px 10px rgba(255, 255, 255, 0.3),
        inset -5px -5px 10px rgba(0, 0, 0, 0.2),
        
        /* Border highlight */
        inset 0 0 0 1px rgba(255, 255, 255, 0.1) !important;
    
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    
    /* 3D perspective */
    perspective: 1000px !important;
    transform-style: preserve-3d !important;
}

/* Hover effect with enhanced 3D - NO GLOW */
.ai-puppet-canvas:hover {
    transform: scale(1.08) rotateX(5deg) rotateY(5deg) !important;
    
    /* NO GLOW on hover either */
    box-shadow: 
        20px 20px 40px rgba(0, 0, 0, 0.5),
        -10px -10px 30px rgba(255, 255, 255, 0.15),
        inset 8px 8px 15px rgba(255, 255, 255, 0.4),
        inset -8px -8px 15px rgba(0, 0, 0, 0.3),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15) !important;
    
    border-color: rgba(255, 255, 255, 0.3) !important;
}

/* Ticket mode - Green theme - NO GLOW */
.ai-puppet-canvas.ticket-mode {
    box-shadow: 
        15px 15px 30px rgba(0, 0, 0, 0.4),
        -8px -8px 20px rgba(255, 255, 255, 0.1),
        inset 5px 5px 10px rgba(255, 255, 255, 0.3),
        inset -5px -5px 10px rgba(0, 0, 0, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1) !important;
}

.ai-puppet-canvas.ticket-mode:hover {
    box-shadow: 
        20px 20px 40px rgba(0, 0, 0, 0.5),
        -10px -10px 30px rgba(255, 255, 255, 0.15),
        inset 8px 8px 15px rgba(255, 255, 255, 0.4),
        inset -8px -8px 15px rgba(0, 0, 0, 0.3),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15) !important;
}

/* Listening mode - Red theme - NO GLOW */
.ai-puppet-canvas.listening {
    box-shadow: 
        15px 15px 30px rgba(0, 0, 0, 0.4),
        -8px -8px 20px rgba(255, 255, 255, 0.1),
        inset 5px 5px 10px rgba(255, 255, 255, 0.3),
        inset -5px -5px 10px rgba(0, 0, 0, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1) !important;
}

/* Speaking mode - Blue theme - NO GLOW */
.ai-puppet-canvas.speaking {
    box-shadow: 
        15px 15px 30px rgba(0, 0, 0, 0.4),
        -8px -8px 20px rgba(255, 255, 255, 0.1),
        inset 5px 5px 10px rgba(255, 255, 255, 0.3),
        inset -5px -5px 10px rgba(0, 0, 0, 0.2),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1) !important;
}

/* ==================== PERMISSION PROMPT (HIDDEN) ==================== */
.ai-permission-prompt {
    display: none !important;
}

/* ==================== ANIMATIONS ==================== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes subtlePulse {
    0% {
        box-shadow: 
            15px 15px 30px rgba(0, 0, 0, 0.4),
            -8px -8px 20px rgba(255, 255, 255, 0.1),
            inset 5px 5px 10px rgba(255, 255, 255, 0.3),
            inset -5px -5px 10px rgba(0, 0, 0, 0.2) !important;
    }
    50% {
        box-shadow: 
            18px 18px 35px rgba(0, 0, 0, 0.45),
            -6px -6px 25px rgba(255, 255, 255, 0.15),
            inset 6px 6px 12px rgba(255, 255, 255, 0.35),
            inset -6px -6px 12px rgba(0, 0, 0, 0.25) !important;
    }
    100% {
        box-shadow: 
            15px 15px 30px rgba(0, 0, 0, 0.4),
            -8px -8px 20px rgba(255, 255, 255, 0.1),
            inset 5px 5px 10px rgba(255, 255, 255, 0.3),
            inset -5px -5px 10px rgba(0, 0, 0, 0.2) !important;
    }
}

@keyframes ticketPulse {
    0% {
        box-shadow: 
            15px 15px 30px rgba(0, 0, 0, 0.4),
            -8px -8px 20px rgba(255, 255, 255, 0.1),
            inset 5px 5px 10px rgba(255, 255, 255, 0.3),
            inset -5px -5px 10px rgba(0, 0, 0, 0.2) !important;
    }
    50% {
        box-shadow: 
            18px 18px 35px rgba(0, 0, 0, 0.45),
            -6px -6px 25px rgba(255, 255, 255, 0.15),
            inset 6px 6px 12px rgba(255, 255, 255, 0.35),
            inset -6px -6px 12px rgba(0, 0, 0, 0.25) !important;
    }
    100% {
        box-shadow: 
            15px 15px 30px rgba(0, 0, 0, 0.4),
            -8px -8px 20px rgba(255, 255, 255, 0.1),
            inset 5px 5px 10px rgba(255, 255, 255, 0.3),
            inset -5px -5px 10px rgba(0, 0, 0, 0.2) !important;
    }
}

@keyframes wordPop {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    70% {
        opacity: 1;
        transform: translateY(0) scale(1.05);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes wordFade {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0.3;
        transform: scale(0.95);
    }
}

.pulse {
    animation: subtlePulse 3s ease-in-out infinite !important;
}

.ticket-pulse {
    animation: ticketPulse 3s ease-in-out infinite !important;
}

.word-pop {
    animation: wordPop 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards !important;
}

.word-fade {
    animation: wordFade 0.5s ease forwards !important;
}

/* ==================== MOBILE RESPONSIVE ==================== */
@media (max-width: 768px) {
    .ai-puppet-container {
        bottom: 30px !important;
        width: 100px !important;
        height: 100px !important;
    }
    
    .ai-caption-container {
        bottom: 140px !important;
        max-width: calc(100vw - 40px) !important;
        gap: 3px 4px !important;
    }
    
    .ai-caption-word {
        font-size: 12px !important;
        padding: 5px 8px !important;
        border-radius: 5px !important;
        max-width: 150px !important;
    }
    
    .ai-puppet-ui {
        bottom: 140px !important;
        width: 260px !important;
        padding: 14px !important;
    }
    
    .ai-input {
        font-size: 14px !important;
        min-height: 60px !important;
        padding: 10px !important;
    }
    
    .ai-input-footer {
        flex-direction: column !important;
    }
    
    .ai-send-btn,
    .ai-exit-ticket-btn {
        width: 100% !important;
        min-width: unset !important;
    }
    
    .ai-send-btn {
        padding: 9px 0 !important;
        font-size: 13px !important;
        min-height: 36px !important;
    }
    
    .ai-exit-ticket-btn {
        padding: 9px 0 !important;
        font-size: 13px !important;
        min-height: 36px !important;
    }
    
    .ai-puppet-canvas {
        width: 100px !important;
        height: 100px !important;
    }
    
    .ai-close-btn {
        width: 28px !important;
        height: 28px !important;
        font-size: 18px !important;
    }
    
    .ai-input-header {
        font-size: 10px !important;
    }
    
    .ai-mode-indicator,
    .ai-ticket-id,
    .ai-temperature-indicator {
        padding: 3px 6px !important;
        font-size: 9px !important;
    }
}

@media (max-width: 480px) {
    .ai-puppet-container {
        bottom: 20px !important;
        width: 80px !important;
        height: 80px !important;
    }
    
    .ai-caption-container {
        bottom: 120px !important;
        max-width: calc(100vw - 30px) !important;
        gap: 2px 3px !important;
    }
    
    .ai-caption-word {
        font-size: 11px !important;
        padding: 4px 6px !important;
        border-radius: 4px !important;
        max-width: 120px !important;
    }
    
    .ai-puppet-ui {
        width: 240px !important;
        padding: 12px !important;
    }
    
    .ai-puppet-canvas {
        width: 80px !important;
        height: 80px !important;
    }
    
    .ai-input {
        font-size: 13px !important;
        min-height: 50px !important;
        padding: 8px !important;
    }
    
    .ai-send-btn {
        padding: 8px 0 !important;
        font-size: 12px !important;
        min-height: 32px !important;
    }
    
    .ai-exit-ticket-btn {
        padding: 8px 0 !important;
        font-size: 12px !important;
        min-height: 32px !important;
    }
    
    .ai-input-header {
        justify-content: center !important;
        gap: 3px !important;
    }
    
    .ai-hint {
        font-size: 9px !important;
    }
}

/* ==================== DARK MODE SUPPORT ==================== */
@media (prefers-color-scheme: dark) {
    .ai-puppet-ui {
        background: rgba(5, 15, 30, 0.98) !important;
        border-color: #552288 !important;
    }
    
    .ai-caption-word {
        background: rgba(5, 15, 30, 0.92) !important;
        border-color: rgba(85, 34, 136, 0.4) !important;
    }
    
    .ai-caption-word.current {
        background: rgba(106, 17, 203, 0.95) !important;
        border-color: #6a11cb !important;
    }
    
    .ai-caption-word.pharmacist-word {
        background: rgba(35, 155, 86, 0.92) !important;
        border-color: rgba(35, 155, 86, 0.6) !important;
    }
    
    .ai-input {
        background: rgba(0, 20, 40, 0.9) !important;
    }
}

/* ==================== HIGH CONTRAST MODE ==================== */
@media (prefers-contrast: high) {
    .ai-puppet-ui {
        border-width: 3px !important;
    }
    
    .ai-caption-word {
        background: rgba(0, 0, 0, 0.95) !important;
        border: 2px solid white !important;
        color: white !important;
    }
    
    .ai-caption-word.current {
        background: rgba(106, 17, 203, 1) !important;
        border: 2px solid yellow !important;
    }
    
    .ai-send-btn,
    .ai-exit-ticket-btn {
        border: 2px solid white !important;
    }
}

/* ==================== ACCESSIBILITY ==================== */
.ai-send-btn:focus-visible,
.ai-exit-ticket-btn:focus-visible,
.ai-close-btn:focus-visible,
.ai-input:focus-visible {
    outline: 3px solid #00a8ff !important;
    outline-offset: 2px !important;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .ai-puppet-container,
    .ai-puppet-ui,
    .ai-caption-container,
    .ai-puppet-canvas,
    .ai-send-btn,
    .ai-exit-ticket-btn,
    .ai-close-btn {
        transition: none !important;
        animation: none !important;
    }
    
    .ai-caption-word {
        transition: none !important;
        animation: none !important;
    }
}