/**
 * AI Chat Widget Styles - Complete with Mobile Responsive
 * File: platform/plugins/ai-chat/public/css/ai-chat.css
 */

/* ===================================
   CHAT BUTTON
   =================================== */
.ai-chat-button {
    position: fixed;
    bottom: 55px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #fcb800;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transition: all 0.3s ease;
}

.ai-chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* ===================================
   CHAT WINDOW
   =================================== */
.ai-chat-window {
    position: fixed;
    width: 400px;
    height: 600px;
    max-height: 90vh;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.ai-chat-window.bottom-right {
    bottom: 55px;
    right: 20px;
}

.ai-chat-window.bottom-left {
    bottom: 55px;
    left: 20px;
}

.ai-chat-window.top-right {
    top: 20px;
    right: 20px;
}

.ai-chat-window.top-left {
    top: 20px;
    left: 20px;
}

.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

/* ===================================
   HEADER
   =================================== */
.ai-chat-header {
    background: #fcb800;
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chat-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.ai-chat-icon {
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chat-header-text h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
}

.ai-chat-header-text p {
    margin: 4px 0 0;
    font-size: 13px;
    opacity: 0.9;
    line-height: 1.2;
}

.ai-chat-header-actions {
    display: flex;
    gap: 8px;
}

.ai-chat-header-btn {
    background: rgba(0, 0, 0, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
    min-width: 32px; /* Prevent shrinking */
}

.ai-chat-header-btn:hover {
    background: rgba(0, 0, 0, 0.3);
    transform: scale(1.1);
}

.ai-chat-header-btn:active {
    transform: scale(0.95);
}

/* ===================================
   MESSAGES AREA
   =================================== */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.ai-chat-message {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.ai-chat-message.user {
    justify-content: flex-end;
}

.ai-chat-message.bot {
    justify-content: flex-start;
}

.ai-chat-message-content {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 85%;
}

.ai-chat-message.user .ai-chat-message-content {
    flex-direction: row-reverse;
}

.ai-chat-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fcb800;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    min-width: 32px; /* Prevent shrinking */
}

.ai-chat-avatar.user {
    background: #4CAF50;
}

.ai-chat-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.ai-chat-message.bot .ai-chat-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
}

.ai-chat-message.user .ai-chat-bubble {
    background: #fcb800;
    color: white;
    border-bottom-right-radius: 4px;
}

/* ===================================
   TYPING INDICATOR
   =================================== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #90a4ae;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ===================================
   QUICK ACTIONS
   =================================== */
.ai-chat-quick-actions {
    margin-top: 8px;
}

.ai-chat-quick-title {
    font-size: 13px;
    color: #666;
    margin: 0 0 8px 0;
    font-weight: 500;
}

.ai-chat-quick-btn {
    display: block;
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: #333;
    min-height: 44px; /* Better touch target */
    display: flex;
    align-items: center;
}

.ai-chat-quick-btn:hover {
    background: #f5f5f5;
    border-color: #fcb800;
    transform: translateX(4px);
}

.ai-chat-quick-btn:active {
    background: #ebebeb;
    transform: translateX(2px);
}

/* ===================================
   PRODUCT CARDS
   =================================== */
.ai-chat-products {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 8px;
}

.ai-chat-product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    animation: slideUp 0.3s ease;
}

.ai-chat-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.ai-chat-product-card:active {
    transform: translateY(0);
}

.product-image-container {
    position: relative;
    width: 100%;
    height: 180px;
    overflow: hidden;
    background: #f5f5f5;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0e0e0;
    color: #999;
    font-size: 14px;
}

.product-badges {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.product-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    backdrop-filter: blur(8px);
}

.product-badge.discount {
    background: rgba(244, 67, 54, 0.9);
}

.product-badge.popular {
    background: rgba(255, 152, 0, 0.9);
}

.product-info {
    padding: 12px;
}

.product-name {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.product-price-current {
    font-size: 18px;
    font-weight: 700;
    color: #fcb800;
}

.product-price-old {
    font-size: 14px;
    color: #999;
    text-decoration: line-through;
}

.product-view-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: #fcb800;
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    min-height: 44px; /* Better touch target */
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-view-btn:hover {
    background: #e5a500;
    transform: scale(1.02);
}

.product-view-btn:active {
    background: #d49800;
    transform: scale(0.98);
}

/* ===================================
   INPUT AREA
   =================================== */
.ai-chat-input-container {
    display: flex;
    gap: 8px;
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px; /* Prevent zoom on iOS */
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    min-height: 44px;
    max-height: 120px;
}

.ai-chat-input:focus {
    border-color: #fcb800;
}

.ai-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: #f5f5f5;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    min-width: 44px; /* Better touch target */
}

.ai-chat-send:hover {
    background: #e0e0e0;
    transform: scale(1.05);
}

.ai-chat-send:active {
    transform: scale(0.95);
    background: #d0d0d0;
}

/* ===================================
   ANIMATIONS
   =================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===================================
   MOBILE RESPONSIVE
   =================================== */

/* Small Mobile Devices (320px - 480px) */
@media (max-width: 480px) {
    /* Chat Button - Smaller and better positioned */
    .ai-chat-button {
        width: 56px;
        height: 56px;
        bottom: 90px;
        right: 16px;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
        z-index: 99999;
    }

    /* Chat Window - Full screen on mobile */
    .ai-chat-window {
        width: calc(100vw - 16px) !important;
        height: 75vh !important;
        max-height: 600px !important;
        bottom: 70px !important;
        left: 8px !important;
        right: 8px !important;
        top: auto !important;
        border-radius: 16px 16px 0 0 !important;
        z-index: 100000;
    }

    .ai-chat-container {
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    /* Header - Compact on mobile */
    .ai-chat-header {
        padding: 12px 16px;
    }

    .ai-chat-icon {
        width: 36px;
        height: 36px;
    }

    .ai-chat-header-text h3 {
        font-size: 16px;
    }

    .ai-chat-header-text p {
        font-size: 12px;
    }

    /* Messages - More padding on mobile */
    .ai-chat-messages {
        padding: 16px;
        gap: 12px;
    }

    .ai-chat-message-content {
        max-width: 90%;
    }

    .ai-chat-avatar {
        width: 28px;
        height: 28px;
        font-size: 11px;
        min-width: 28px;
    }

    .ai-chat-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }

    /* Quick Actions - Larger touch targets */
    .ai-chat-quick-btn {
        padding: 14px 16px;
        font-size: 14px;
        min-height: 48px;
    }

    /* Product Cards - Optimized for mobile */
    .product-image-container {
        height: 160px;
    }

    .product-info {
        padding: 14px;
    }

    .product-name {
        font-size: 15px;
        margin-bottom: 10px;
    }

    .product-price-current {
        font-size: 20px;
    }

    .product-price-old {
        font-size: 15px;
    }

    .product-view-btn {
        padding: 14px;
        font-size: 15px;
        min-height: 48px;
    }

    /* Input Area - Larger for mobile */
    .ai-chat-input-container {
        padding: 12px;
        gap: 10px;
    }

    .ai-chat-input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 14px;
        min-height: 48px;
    }

    .ai-chat-send {
        width: 48px;
        height: 48px;
        min-width: 48px;
    }

    /* Disable hover effects on mobile */
    .ai-chat-button:hover {
        transform: none;
    }

    .ai-chat-product-card:hover {
        transform: none;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    .ai-chat-quick-btn:hover {
        transform: none;
    }

    /* Better scrollbar for mobile */
    .ai-chat-messages::-webkit-scrollbar {
        width: 4px;
    }
}

@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 480px) {
        .ai-chat-input-container {
            padding-bottom: calc(12px + env(safe-area-inset-bottom));
        }

        .ai-chat-button {
            bottom: calc(90px + env(safe-area-inset-bottom));
        }

        .ai-chat-window {
            bottom: calc(70px + env(safe-area-inset-bottom)) !important;
        }
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .ai-chat-window {
        width: 380px;
        height: 550px;
    }

    .ai-chat-button {
        width: 58px;
        height: 58px;
    }

    .product-image-container {
        height: 170px;
    }

    .ai-chat-message-content {
        max-width: 80%;
    }
}

/* Landscape Mobile (smaller height) */
@media (max-width: 768px) and (max-height: 500px) and (orientation: landscape) {
    .ai-chat-window {
        height: 100vh !important;
    }

    .ai-chat-messages {
        padding: 12px;
    }

    .product-image-container {
        height: 120px;
    }

    .ai-chat-header {
        padding: 10px 16px;
    }

    .ai-chat-input-container {
        padding: 10px;
    }
}

/* Large Tablets & Small Desktops (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .ai-chat-window {
        width: 420px;
        height: 620px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Better tap targets for touch devices */
    .ai-chat-header-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .ai-chat-quick-btn {
        min-height: 48px;
    }

    .product-view-btn {
        min-height: 48px;
    }

    .ai-chat-send {
        min-width: 48px;
        min-height: 48px;
    }

    /* Remove hover effects on touch devices */
    .ai-chat-button:hover,
    .ai-chat-header-btn:hover,
    .ai-chat-quick-btn:hover,
    .ai-chat-product-card:hover,
    .product-view-btn:hover,
    .ai-chat-send:hover {
        transform: none;
    }
}

@media (prefers-color-scheme: dark) {
    .ai-chat-messages {
        background: #1a1a1a;
    }

    .ai-chat-message.bot .ai-chat-bubble {
        background: #2d2d2d;
        color: #e0e0e0;
    }

    .ai-chat-quick-btn {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #3d3d3d;
    }

    .ai-chat-product-card {
        background: #2d2d2d;
    }

    .product-name {
        color: #e0e0e0;
    }

    .ai-chat-input {
        background: #2d2d2d;
        color: #e0e0e0;
        border-color: #3d3d3d;
    }

    .ai-chat-container {
        background: #1a1a1a;
    }
}

/* Print Styles */
@media print {
    .ai-chat-button,
    .ai-chat-window {
        display: none !important;
    }
}

/* Performance Optimizations */
* {
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.ai-chat-message,
.ai-chat-product-card {
    will-change: transform; /* Optimize animations */
}

/* Accessibility Improvements */
.ai-chat-button:focus,
.ai-chat-header-btn:focus,
.ai-chat-quick-btn:focus,
.product-view-btn:focus,
.ai-chat-send:focus,
.ai-chat-input:focus {
    outline: 2px solid #fcb800;
    outline-offset: 2px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}