/**
 * Chat Window Styles
 * 
 * @package AIShoppingHelperWoo
 */

.ai-shopping-helper-chat-window {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    border: 1px solid #e1e5e9;
}

.ai-shopping-helper-chat-window[data-position="bottom-left"] {
    bottom: 80px;
    left: 20px;
    right: auto;
}

.ai-shopping-helper-chat-window[data-position="bottom-right"] {
    bottom: 80px;
    right: 20px;
    left: auto;
}

.ai-shopping-helper-chat-window[data-position="top-left"] {
    top: 80px;
    left: 20px;
    bottom: auto;
    right: auto;
}

.ai-shopping-helper-chat-window[data-position="top-right"] {
    top: 80px;
    right: 20px;
    bottom: auto;
    left: auto;
}

/* Chat Header */
.ai-shopping-helper-chat-header {
    background: var(--ai-theme-color, #0073aa);
    color: white;
    padding: 16px 20px;
    border-radius: 12px 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.ai-shopping-helper-chat-header h3 {
    margin: 0;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.ai-shopping-helper-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.ai-shopping-helper-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Chat Messages */
.ai-shopping-helper-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-shopping-helper-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-shopping-helper-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ai-shopping-helper-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ai-shopping-helper-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Message Styles */
.ai-sh-message {
    max-width: 80%;
    word-wrap: break-word;
    animation: ai-sh-fadeIn 0.3s ease;
}

@keyframes ai-sh-fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-sh-message.user {
    align-self: flex-end;
}

.ai-sh-message.ai {
    align-self: flex-start;
}

.ai-sh-message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    margin: 0;
    line-height: 1.4;
    font-size: 14px;
}

.ai-sh-message.user .ai-sh-message-bubble {
    background: var(--ai-theme-color, #0073aa);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-sh-message.ai .ai-sh-message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 4px;
}

.ai-sh-message-time {
    font-size: 11px;
    color: #666;
    margin-top: 4px;
    text-align: right;
}

.ai-sh-message.ai .ai-sh-message-time {
    text-align: left;
}

/* Product Cards in Messages */
.ai-sh-product-card {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ai-sh-product-card:hover {
    border-color: var(--ai-theme-color, #0073aa);
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.15);
}

.ai-sh-product-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.ai-sh-product-info {
    flex: 1;
    min-width: 0;
}

.ai-sh-product-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    line-height: 1.3;
    color: var(--ai-theme-color, #0073aa);
}

/* Product Link */
.ai-sh-product-link {
    color: var(--ai-theme-color, #0073aa);
    text-decoration: none;
    transition: color 0.2s ease;
}

.ai-sh-product-link:hover {
    color: var(--ai-theme-color, #0073aa);
    text-decoration: underline;
    opacity: 0.8;
}

.ai-sh-product-price {
    font-size: 14px;
    font-weight: 600;
    color: #0073aa;
    margin-bottom: 6px;
}

.ai-sh-product-price .ai-sh-regular-price {
    text-decoration: line-through;
    color: #666;
    font-size: 12px;
    font-weight: normal;
    margin-left: 4px;
}

.ai-sh-product-description {
    font-size: 12px;
    color: #666;
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ai-sh-add-to-cart {
    background: var(--ai-theme-color, #0073aa);
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-weight: 500;
    line-height: 1.2;
}

.ai-sh-add-to-cart:hover {
    background: #005a87;
}

.ai-sh-add-to-cart.ai-sh-loading {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Typing Indicator */
.ai-sh-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}

.ai-sh-typing-dot {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: ai-sh-typing 1.4s infinite ease-in-out;
}

.ai-sh-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-sh-typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes ai-sh-typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Chat Input */
.ai-shopping-helper-chat-input {
    padding: 16px 20px;
    border-top: 1px solid #e1e5e9;
    background: white;
    border-radius: 0 0 12px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.ai-shopping-helper-chat-input input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.ai-shopping-helper-chat-input input:focus {
    border-color: var(--ai-theme-color, #0073aa);
}

.ai-shopping-helper-chat-input button {
    background: var(--ai-theme-color, #0073aa);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.ai-shopping-helper-chat-input button:hover {
    background: var(--ai-theme-color, #0073aa);
    opacity: 0.8;
}

.ai-shopping-helper-chat-input button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .ai-shopping-helper-chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        max-height: 100vh;
    }
    
    .ai-shopping-helper-chat-window[data-position="bottom-left"],
    .ai-shopping-helper-chat-window[data-position="bottom-right"],
    .ai-shopping-helper-chat-window[data-position="top-left"],
    .ai-shopping-helper-chat-window[data-position="top-right"] {
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
    }
    
    .ai-shopping-helper-chat-header {
        border-radius: 0;
    }
    
    .ai-shopping-helper-chat-input {
        border-radius: 0;
    }
    
    .ai-sh-message {
        max-width: 90%;
    }
    
    .ai-sh-product-card {
        flex-direction: column;
        text-align: center;
    }
    
    .ai-sh-product-image {
        width: 100%;
        height: 200px;
        object-fit: cover;
    }
}

/* Error messages */
.ai-sh-error-message {
    background: #ffebee;
    color: #c62828;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #c62828;
    font-size: 13px;
    margin: 8px 0;
}

/* Success messages */
.ai-sh-success-message {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 12px 16px;
    border-radius: 8px;
    border-left: 4px solid #2e7d32;
    font-size: 13px;
    margin: 8px 0;
}

/* Welcome message */
.ai-sh-welcome-message {
    background: linear-gradient(135deg, #0073aa, #005a87);
    color: white;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    text-align: center;
}

.ai-sh-welcome-message h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-sh-welcome-message p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
}

/* Loading History Styles */
.ai-sh-loading-history {
    padding: 20px;
    text-align: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin: 10px 0;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-sh-loading-text {
    color: #ffffff;
    font-size: 14px;
    margin-bottom: 12px;
    font-weight: 500;
}

.ai-sh-loading-dots {
    display: flex;
    gap: 6px;
    justify-content: center;
    align-items: center;
}

.ai-sh-loading-dot {
    width: 8px;
    height: 8px;
    background: #0073aa;
    border-radius: 50%;
    animation: ai-sh-loading-pulse 1.4s infinite ease-in-out;
}

.ai-sh-loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-sh-loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

.ai-sh-loading-dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes ai-sh-loading-pulse {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Message timestamp improvements */
.ai-sh-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
    font-style: italic;
}

.ai-sh-message.ai .ai-sh-message-time {
    text-align: left;
}

/* Bubble Notification Styles */
.ai-sh-notification-pulse {
    animation: ai-sh-notification-pulse 2s infinite;
}

@keyframes ai-sh-notification-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(0, 115, 170, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(0, 115, 170, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(0, 115, 170, 0);
    }
}

.ai-sh-notification-tooltip {
    position: absolute;
    background: var(--ai-theme-color, #0073aa);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    z-index: 10001;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: ai-sh-tooltip-fade-in 0.3s ease;
}

.ai-sh-notification-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--ai-theme-color, #0073aa);
}

@keyframes ai-sh-tooltip-fade-in {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Suggestion Buttons */
.ai-sh-suggestions-container {
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
}

.ai-sh-suggestions-container p {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.ai-sh-suggestion-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ai-sh-suggestion-btn {
    background: white;
    border: 1px solid var(--ai-theme-color, #0073aa);
    color: var(--ai-theme-color, #0073aa);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    font-weight: 500;
}

.ai-sh-suggestion-btn:hover {
    background: var(--ai-theme-color, #0073aa);
    color: white;
}

/* Product Action Tracking in Admin */
.ai-sh-product-actions {
    margin-top: 8px;
    padding: 8px;
    background: #f0f8ff;
    border-radius: 4px;
    font-size: 11px;
}

.ai-sh-action-item {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.ai-sh-action-item:last-child {
    margin-bottom: 0;
}

.ai-sh-action-icon {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    font-weight: bold;
}

.ai-sh-action-icon.add_to_cart {
    background: #28a745;
    color: white;
}

.ai-sh-action-icon.add_to_cart::before {
    content: '+';
}

.ai-sh-action-text {
    color: #666;
}

.ai-sh-action-time {
    color: #999;
    font-size: 10px;
    margin-left: auto;
}

/* Guest Registration Form */
.ai-sh-guest-registration {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    border-radius: 8px;
    margin: 10px;
}

.ai-sh-registration-header h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.ai-sh-registration-header p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

.ai-sh-registration-form {
    max-width: 300px;
    margin: 0 auto;
}

.ai-sh-form-group {
    margin-bottom: 16px;
    text-align: left;
}

.ai-sh-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
    color: #333;
}

.ai-sh-form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.ai-sh-form-group input:focus {
    outline: none;
    border-color: var(--ai-theme-color, #0073aa);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

.ai-sh-form-group input::placeholder {
    color: #999;
}

.ai-sh-form-actions {
    text-align: center;
}

.ai-sh-register-btn {
    background: var(--ai-theme-color, #0073aa);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
    margin-bottom: 8px;
}

.ai-sh-register-btn:hover:not(:disabled) {
    background: #005a87;
}

.ai-sh-register-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.ai-sh-form-note {
    margin: 8px 0 0 0;
    font-size: 12px;
    color: #666;
    font-style: italic;
}

.ai-sh-registration-error {
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 4px;
    border-left: 4px solid #c62828;
    font-size: 12px;
    margin-bottom: 12px;
    text-align: left;
}

.ai-sh-registration-success {
    background: #e8f5e8;
    color: #2e7d32;
    padding: 16px;
    border-radius: 6px;
    border-left: 4px solid #2e7d32;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

/* Mobile responsiveness for guest registration */
@media (max-width: 768px) {
    .ai-sh-guest-registration {
        margin: 10px;
        padding: 16px;
    }
    
    .ai-sh-registration-form {
        max-width: 100%;
    }
    
    .ai-sh-form-group input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}
