/**
 * WooCommerce AI Chatbot - Frontend Widget Styles
 */

/* CSS Variables (set via inline styles from PHP) */
:root {
    --wac-primary-color: #7c3aed;
    --wac-text-color: #ffffff;
    --wac-header-bg-color: #7c3aed;
    --wac-header-text-color: #ffffff;
    --wac-bg-color: #ffffff;
    --wac-message-bg: #f3f4f6;
    --wac-border-color: #e5e7eb;
    --wac-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    --wac-radius: 16px;
}

/* Container */
.wac-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.wac-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.wac-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Toggle Button */
.wac-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wac-primary-color);
    color: var(--wac-text-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--wac-shadow);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.wac-toggle-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
}

.wac-toggle-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.3);
}

.wac-toggle-btn .wac-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.wac-toggle-btn svg {
    width: 28px;
    height: 28px;
}

/* Chat Widget */
.wac-chat-widget {
    position: absolute;
    bottom: 80px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: var(--wac-bg-color);
    border-radius: var(--wac-radius);
    box-shadow: var(--wac-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: wac-slide-up 0.3s ease;
}

.wac-position-bottom-right .wac-chat-widget {
    right: 0;
}

.wac-position-bottom-left .wac-chat-widget {
    left: 0;
}

@keyframes wac-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.wac-chat-header {
    background: var(--wac-header-bg-color) !important;
    color: var(--wac-header-text-color) !important;
    padding: 16px 20px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
    border: none !important;
    margin: 0 !important;
}

.wac-header-text {
    width: 100%;
}

.wac-header-info {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.wac-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wac-avatar svg {
    width: 24px;
    height: 24px;
}

.wac-header-text h3 {
    margin: 0 !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    color: var(--wac-header-text-color) !important;
    line-height: 1.3 !important;
    padding: 0 !important;
    border: none !important;
    background: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.wac-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wac-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

.wac-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wac-clear-btn,
.wac-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--wac-text-color);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.wac-clear-btn:hover,
.wac-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.wac-clear-btn svg,
.wac-close-btn svg {
    width: 18px;
    height: 18px;
}

/* Messages */
.wac-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wac-message {
    max-width: 85%;
    animation: wac-fade-in 0.3s ease;
}

@keyframes wac-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wac-message-bot {
    align-self: flex-start;
}

.wac-message-user {
    align-self: flex-end;
}

.wac-message-content {
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
}

.wac-message-bot .wac-message-content {
    background: var(--wac-message-bg);
    color: #374151;
    border-bottom-left-radius: 4px;
}

.wac-message-user .wac-message-content {
    background: var(--wac-primary-color);
    color: var(--wac-text-color);
    border-bottom-right-radius: 4px;
}

/* Typing Indicator */
.wac-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--wac-message-bg);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    max-width: fit-content;
}

.wac-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: wac-bounce 1.4s infinite ease-in-out both;
}

.wac-typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.wac-typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes wac-bounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Product Cards */
.wac-product-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 12px;
}

.wac-product-card {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--wac-border-color);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.wac-product-card:hover {
    border-color: var(--wac-primary-color);
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.1);
}

.wac-product-image {
    width: 70px;
    height: 70px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--wac-message-bg);
}

.wac-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.wac-product-title {
    font-weight: 500 !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #1f2937 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    max-width: 100% !important;
    border: none !important;
    background: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}

.wac-product-description {
    font-size: 11px;
    color: #6b7280;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wac-product-category {
    font-size: 10px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.wac-product-price-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.wac-product-price {
    font-weight: 600;
    color: var(--wac-primary-color);
    font-size: 14px;
}

.wac-product-sale-badge {
    font-size: 10px;
    background: #ef4444;
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.wac-product-stock {
    font-size: 11px;
    color: #22c55e;
    font-weight: 500;
}

.wac-product-stock.out-of-stock {
    color: #ef4444;
}

/* Chat Form */
.wac-chat-form {
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid var(--wac-border-color);
    flex-shrink: 0;
}

.wac-input-container {
    display: flex;
    gap: 8px;
    align-items: center;
    background: var(--wac-message-bg);
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
}

.wac-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 0;
    font-size: 14px;
    color: #374151;
    outline: none;
}

.wac-chat-input::placeholder {
    color: #9ca3af;
}

.wac-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--wac-primary-color);
    color: var(--wac-text-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

.wac-send-btn:hover {
    transform: scale(1.05);
}

.wac-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.wac-send-btn svg {
    width: 18px;
    height: 18px;
}

/* Error Message */
.wac-error-message {
    color: #ef4444;
    font-size: 13px;
    padding: 8px 12px;
    background: #fef2f2;
    border-radius: 8px;
    text-align: center;
}

/* Responsive */
@media (max-width: 480px) {
    .wac-chat-widget {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        max-height: 500px;
    }

    .wac-toggle-btn {
        width: 56px;
        height: 56px;
    }

    .wac-toggle-btn svg {
        width: 24px;
        height: 24px;
    }
}

/* Scrollbar */
.wac-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.wac-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wac-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.wac-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}
