/**
 * SmokyAI - Visual Enhancements & Mobile Optimizations
 * Additional visual improvements and responsive design
 */

/* Advanced animations and transitions */
@keyframes smokyGlow {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(106, 90, 205, 0.3);
    }
    50% { 
        box-shadow: 0 0 30px rgba(106, 90, 205, 0.5);
    }
}

@keyframes messageGlow {
    from {
        box-shadow: 0 0 0 rgba(0, 123, 255, 0);
    }
    to {
        box-shadow: 0 0 20px rgba(0, 123, 255, 0.3);
    }
}

@keyframes pulseRing {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Enhanced toggle button with notification ring */
.smokyai-chat-toggle {
    position: relative;
}

.smokyai-chat-toggle::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border: 2px solid var(--smokyai-primary-color);
    border-radius: 50%;
    opacity: 0;
    animation: pulseRing 2s infinite;
}

.smokyai-chat-toggle.has-notification::after {
    opacity: 1;
}

/* Notification badge */
.smokyai-chat-toggle .notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: linear-gradient(135deg, #ff4757 0%, #ff3838 100%);
    border: 2px solid white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: bold;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-3px);
    }
    60% {
        transform: translateY(-1px);
    }
}

/* Enhanced message animations */
.smokyai-message {
    animation: messageSlide 0.4s ease-out, messageGlow 0.1s ease-out 0.3s;
}

.smokyai-message.user .smokyai-message-content {
    animation: userMessageSlide 0.4s ease-out;
}

@keyframes userMessageSlide {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Enhanced product card interactions */
.smokyai-product-card {
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    cursor: pointer;
}

.smokyai-product-card:hover {
    animation: smokyGlow 2s infinite;
}

.smokyai-product-card:active {
    transform: translateY(-2px) scale(0.98);
}

/* Enhanced input field with focus effects */
.smokyai-chat-input:focus {
    animation: inputFocus 0.3s ease-out;
}

@keyframes inputFocus {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
    }
}

/* Enhanced suggestion buttons */
.smokyai-suggestion-btn {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}

.smokyai-suggestion-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(0, 123, 255, 0.2) 0%, transparent 70%);
    transition: all 0.3s ease;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.smokyai-suggestion-btn:hover::before {
    width: 300px;
    height: 300px;
}

/* Loading states */
.smokyai-loading {
    position: relative;
    pointer-events: none;
}

.smokyai-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.1);
    border-radius: inherit;
    animation: loadingPulse 1.5s infinite;
}

@keyframes loadingPulse {
    0%, 100% { opacity: 0.1; }
    50% { opacity: 0.3; }
}

/* Enhanced mobile experience */
@media (max-width: 768px) {
    /* Improved touch targets */
    .smokyai-chat-toggle {
        width: 60px;
        height: 60px;
        font-size: 26px;
    }
    
    .smokyai-suggestion-btn,
    .smokyai-product-btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    /* Better spacing for mobile */
    .smokyai-chat-messages {
        padding: 16px 12px;
    }
    
    .smokyai-message {
        margin-bottom: 12px;
    }
    
    .smokyai-message-content {
        padding: 12px 16px;
        font-size: 15px;
        line-height: 1.4;
    }
    
    /* Improved input area for mobile */
    .smokyai-chat-input-area {
        padding: 16px 12px;
        background: var(--smokyai-background);
        border-top: 2px solid var(--smokyai-border-color);
    }
    
    .smokyai-chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }
    
    .smokyai-send-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    /* Mobile-specific animations */
    .smokyai-chat-window.open {
        animation: mobileSlideUp 0.3s ease-out;
    }
    
    @keyframes mobileSlideUp {
        from {
            opacity: 0;
            transform: translateY(100%);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Tablet optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .smokyai-chat-window {
        width: 400px;
        height: 650px;
    }
    
    .smokyai-products-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    }
}

/* Large screen optimizations */
@media (min-width: 1200px) {
    .smokyai-chat-window {
        width: 420px;
        height: 700px;
    }
    
    .smokyai-products-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .smokyai-chat-toggle,
    .smokyai-product-card,
    .smokyai-message-content {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .smokyai-chat-toggle::after,
    .smokyai-typing-dot,
    .smokyai-suggestion-btn::before {
        animation: none !important;
    }
    
    .smokyai-chat-window.open {
        animation: none !important;
    }
    
    * {
        transition-duration: 0.1s !important;
    }
}

/* Dark theme enhancements */
@media (prefers-color-scheme: dark) {
    .smokyai-chat-widget {
        --smokyai-shadow: 0 4px 20px rgba(0,0,0,0.6);
        --smokyai-shadow-large: 0 8px 32px rgba(0,0,0,0.8);
    }
}

/* Print optimizations */
@media print {
    .smokyai-chat-widget,
    .smokyai-chat-toggle {
        display: none !important;
    }
}

/* Accessibility enhancements */
.smokyai-chat-toggle:focus,
.smokyai-chat-input:focus,
.smokyai-send-btn:focus,
.smokyai-suggestion-btn:focus,
.smokyai-product-btn:focus {
    outline: 2px solid var(--smokyai-primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .smokyai-chat-widget {
        --smokyai-border-color: #ffffff;
        --smokyai-text-light: #ffffff;
    }
    
    .smokyai-product-card,
    .smokyai-message-content,
    .smokyai-chat-input,
    .smokyai-suggestion-btn {
        border-width: 2px !important;
        border-style: solid !important;
    }
    
    .smokyai-chat-toggle,
    .smokyai-send-btn,
    .smokyai-product-btn {
        border: 3px solid white !important;
    }
}

/* RTL enhancements */
[dir="rtl"] .smokyai-chat-widget,
.smokyai-rtl {
    /* Enhanced RTL animations */
    direction: rtl;
}

[dir="rtl"] .smokyai-message.user .smokyai-message-content,
.smokyai-rtl .smokyai-message.user .smokyai-message-content {
    animation: userMessageSlideRTL 0.4s ease-out;
}

@keyframes userMessageSlideRTL {
    from {
        opacity: 0;
        transform: translateX(-30px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Performance optimizations */
.smokyai-chat-widget {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

.smokyai-chat-window {
    transform: translateZ(0);
    will-change: opacity, transform;
}

.smokyai-message-content,
.smokyai-product-card {
    transform: translateZ(0);
}

/* Custom scrollbar for better UX */
.smokyai-chat-messages {
    scrollbar-width: thin;
    scrollbar-color: var(--smokyai-primary-color) var(--smokyai-dark-bg-secondary);
}

/* Improved loading states for images */
.smokyai-product-image {
    background: linear-gradient(45deg, var(--smokyai-dark-bg) 25%, var(--smokyai-dark-bg-secondary) 25%, var(--smokyai-dark-bg-secondary) 50%, var(--smokyai-dark-bg) 50%, var(--smokyai-dark-bg) 75%, var(--smokyai-dark-bg-secondary) 75%);
    background-size: 20px 20px;
    animation: loading-stripes 1s linear infinite;
}

.smokyai-product-image img {
    transition: opacity 0.3s ease;
}

.smokyai-product-image img:not([src]),
.smokyai-product-image img[src=""] {
    opacity: 0;
}

@keyframes loading-stripes {
    0% { background-position: 0 0; }
    100% { background-position: 20px 0; }
}

/* Enhanced error states */
.smokyai-error {
    background: linear-gradient(135deg, #ff4757 0%, #ff3838 100%);
    color: white;
    padding: 12px 16px;
    border-radius: var(--smokyai-border-radius-small);
    margin: 10px 0;
    animation: errorShake 0.5s ease-in-out;
}

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

/* Success states */
.smokyai-success {
    background: linear-gradient(135deg, #2ed573 0%, #1dd1a1 100%);
    color: white;
    padding: 12px 16px;
    border-radius: var(--smokyai-border-radius-small);
    margin: 10px 0;
    animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

