/* WooCommerce AI Assistant - Frontend Styles */

.wc-ai-assistant-chat {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Floating Widget Mode */
.wc-ai-assistant-floating {
    position: fixed;
    z-index: 999999;
}

/* Embedded Mode */
.wc-ai-assistant-embedded {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    display: block;
}

.wc-ai-assistant-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wc-ai-assistant-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.wc-ai-assistant-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.wc-ai-assistant-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.wc-ai-assistant-toggle:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
}

/* Chat Window */
.wc-ai-assistant-window {
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

/* Floating Widget Window */
.wc-ai-assistant-floating .wc-ai-assistant-window {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 100px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.wc-ai-assistant-position-bottom-left .wc-ai-assistant-window {
    left: 0;
}

.wc-ai-assistant-position-bottom-right .wc-ai-assistant-window {
    right: 0;
}

/* Embedded Window */
.wc-ai-assistant-embedded .wc-ai-assistant-window {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 400px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.wc-ai-assistant-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wc-ai-assistant-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.wc-ai-assistant-minimize,
.wc-ai-assistant-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.wc-ai-assistant-minimize:hover,
.wc-ai-assistant-close:hover {
    opacity: 1;
}

.wc-ai-assistant-minimize:focus,
.wc-ai-assistant-close:focus {
    outline: 2px solid rgba(255, 255, 255, 0.8);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Messages Container */
.wc-ai-assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Product Cards Container - Group multiple products */
.wc-ai-assistant-messages .wc-ai-assistant-product-card + .wc-ai-assistant-product-card {
    margin-top: 16px;
}

.wc-ai-assistant-message {
    display: flex;
    flex-direction: column;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wc-ai-assistant-message-user {
    align-items: flex-end;
}

.wc-ai-assistant-message-assistant {
    align-items: flex-start;
}

.wc-ai-assistant-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.wc-ai-assistant-message-user .wc-ai-assistant-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.wc-ai-assistant-message-assistant .wc-ai-assistant-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Product Cards */
.wc-ai-assistant-product-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-top: 12px;
    margin-bottom: 12px;
    max-width: 100%;
    animation: fadeIn 0.3s ease;
    -webkit-animation: fadeIn 0.3s ease; /* Safari support */
    /* Ensure card is visible in Safari/iOS */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative;
    z-index: 1;
}

.wc-ai-assistant-product-card-image-wrapper {
    position: relative;
    width: 100%;
}

.wc-ai-assistant-product-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    -webkit-object-fit: cover; /* Safari support */
    display: block;
    transition: opacity 0.3s ease, transform 0.3s ease;
    -webkit-transition: opacity 0.3s ease, transform 0.3s ease; /* Safari support */
    /* Ensure images load properly in Safari */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Product Gallery Thumbnails */
.wc-ai-assistant-product-gallery {
    display: flex;
    display: -webkit-flex; /* Safari support */
    gap: 8px;
    padding: 8px;
    background: #f8f9fa;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Safari gap fallback for older versions that don't support gap */
@supports not (gap: 8px) {
    .wc-ai-assistant-product-gallery {
        margin: -4px;
    }
    
    .wc-ai-assistant-product-gallery > * {
        margin: 4px; /* Fallback for gap property in older Safari */
    }
}

.wc-ai-assistant-product-gallery-thumb {
    width: 60px;
    height: 60px;
    object-fit: cover;
    -webkit-object-fit: cover; /* Safari support */
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    -webkit-transition: all 0.2s ease; /* Safari support */
    flex-shrink: 0;
    -webkit-flex-shrink: 0; /* Safari support */
    /* Ensure images display properly in Safari */
    display: block;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.wc-ai-assistant-product-gallery-thumb:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.wc-ai-assistant-product-gallery-thumb.active {
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.wc-ai-assistant-product-card-content {
    padding: 16px;
}

.wc-ai-assistant-product-card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 8px 0;
    color: #333;
}

.wc-ai-assistant-product-card-description {
    font-size: 14px;
    color: #666;
    margin: 0 0 12px 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* Standard property for compatibility */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wc-ai-assistant-product-card-price {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
    margin: 0 0 12px 0;
}

.wc-ai-assistant-product-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.wc-ai-assistant-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.wc-ai-assistant-btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    flex: 1;
}

.wc-ai-assistant-btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.wc-ai-assistant-btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.wc-ai-assistant-btn-secondary:hover {
    background: #e0e0e0;
}

.wc-ai-assistant-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.wc-ai-assistant-stock-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 8px;
}

.wc-ai-assistant-stock-badge.in-stock {
    background: #d4edda;
    color: #155724;
}

.wc-ai-assistant-stock-badge.out-of-stock {
    background: #f8d7da;
    color: #721c24;
}

/* Input Container */
.wc-ai-assistant-input-container {
    display: flex;
    gap: 8px;
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.wc-ai-assistant-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.wc-ai-assistant-input:focus {
    border-color: #667eea;
    outline: 2px solid rgba(102, 126, 234, 0.2);
    outline-offset: 2px;
}

.wc-ai-assistant-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #f5f5f5;
}

.wc-ai-assistant-send {
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.wc-ai-assistant-send:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.wc-ai-assistant-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Loading Indicator */
.wc-ai-assistant-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.wc-ai-assistant-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.wc-ai-assistant-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.wc-ai-assistant-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Screen Reader Text */
.screen-reader-text {
    clip: rect(1px, 1px, 1px, 1px);
    position: absolute !important;
    height: 1px;
    width: 1px;
    overflow: hidden;
}

/* Responsive */
@media (max-width: 480px) {
    .wc-ai-assistant-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 80px);
        bottom: 10px;
    }
    
    .wc-ai-assistant-position-bottom-left .wc-ai-assistant-window,
    .wc-ai-assistant-position-bottom-right .wc-ai-assistant-window {
        left: 10px;
        right: 10px;
    }
    
    .wc-ai-assistant-product-card {
        margin-top: 8px;
        margin-bottom: 8px;
    }
    
    .wc-ai-assistant-product-card-image {
        height: 180px;
    }
    
    .wc-ai-assistant-product-gallery-thumb {
        width: 50px;
        height: 50px;
    }
    
    .wc-ai-assistant-product-card-actions {
        flex-direction: column;
    }
    
    .wc-ai-assistant-btn {
        width: 100%;
    }
}
