/**
 * WooCommerce AI Chat - Chat Widget Styles
 */

:root {
    --wac-primary: #7952b3;
    --wac-button: #7952b3;
    --wac-bg: #ffffff;
    --wac-surface: #f8f9fa;
    --wac-border: #e9ecef;
    --wac-text: #212529;
    --wac-text-muted: #6c757d;
    --wac-user-bubble: var(--wac-primary);
    --wac-ai-bubble: #f1f3f5;
    --wac-ai-text: #212529;
    --wac-header-bg: var(--wac-primary);
    --wac-header-text: #ffffff;
    --wac-radius: 12px;
    --wac-shadow: 0 4px 20px rgba(0,0,0,0.12);
}

/* Dark scheme */
.wac-scheme-dark {
    --wac-bg: #1a1a2e;
    --wac-surface: #16213e;
    --wac-border: #2d3748;
    --wac-text: #e2e8f0;
    --wac-text-muted: #a0aec0;
    --wac-ai-bubble: #2d3748;
    --wac-ai-text: #e2e8f0;
}

/* Auto scheme */
@media (prefers-color-scheme: dark) {
    .wac-scheme-auto {
        --wac-bg: #1a1a2e;
        --wac-surface: #16213e;
        --wac-border: #2d3748;
        --wac-text: #e2e8f0;
        --wac-text-muted: #a0aec0;
        --wac-ai-bubble: #2d3748;
        --wac-ai-text: #e2e8f0;
    }
}

/* ===== CONTAINER ===== */
.wac-chat-wrapper {
    max-width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wac-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--wac-bg);
    border-radius: var(--wac-radius);
    overflow: hidden;
    box-shadow: var(--wac-shadow);
    border: 1px solid var(--wac-border);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    color: var(--wac-text);
}

/* ===== HEADER ===== */
.wac-chat-header {
    background: var(--wac-header-bg);
    color: var(--wac-header-text);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.wac-chat-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wac-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.wac-chat-avatar img { width: 100%; height: 100%; object-fit: cover; }

.wac-chat-name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.wac-chat-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wac-status-dot {
    width: 7px;
    height: 7px;
    background: #4ade80;
    border-radius: 50%;
    display: inline-block;
}

.wac-chat-minimize {
    background: transparent;
    border: none;
    cursor: pointer;
    color: white;
    opacity: 0.8;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: opacity 0.2s;
}
.wac-chat-minimize:hover { opacity: 1; }

/* ===== MESSAGES ===== */
.wac-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.wac-chat-messages::-webkit-scrollbar { width: 4px; }
.wac-chat-messages::-webkit-scrollbar-track { background: transparent; }
.wac-chat-messages::-webkit-scrollbar-thumb { background: var(--wac-border); border-radius: 2px; }

/* Message rows */
.wac-message {
    display: flex;
    gap: 8px;
    max-width: 100%;
    animation: wacMsgIn 0.2s ease;
}

@keyframes wacMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wac-message.wac-user {
    flex-direction: row-reverse;
}

/* Bubble */
.wac-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    max-width: 80%;
    line-height: 1.5;
    word-break: break-word;
}

.wac-message.wac-ai .wac-bubble {
    background: var(--wac-ai-bubble);
    color: var(--wac-ai-text);
    border-bottom-left-radius: 4px;
}

.wac-message.wac-user .wac-bubble {
    background: var(--wac-user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}

.wac-bubble strong { font-weight: 600; }

/* ===== TYPING INDICATOR ===== */
.wac-typing-indicator .wac-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.wac-typing-dot {
    width: 7px;
    height: 7px;
    background: var(--wac-text-muted);
    border-radius: 50%;
    animation: wacTyping 1.2s ease-in-out infinite;
}
.wac-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.wac-typing-dot:nth-child(3) { animation-delay: 0.30s; }

@keyframes wacTyping {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ===== QUICK BUTTONS ===== */
.wac-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
}

.wac-quick-btn {
    background: var(--wac-surface);
    border: 1px solid var(--wac-border);
    color: var(--wac-primary);
    border-radius: 20px;
    padding: 7px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}
.wac-quick-btn:hover {
    background: var(--wac-primary);
    color: white;
    border-color: var(--wac-primary);
}

/* ===== PRODUCT CARDS ===== */
.wac-product-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 10px;
    width: 100%;
}

.wac-product-card {
    background: var(--wac-bg);
    border: 1px solid var(--wac-border);
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}

.wac-product-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.wac-product-img-wrap {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--wac-surface);
}

.wac-product-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wac-product-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.wac-product-badge.best-match { background: var(--wac-primary); }

.wac-product-info {
    padding: 8px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.wac-product-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--wac-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wac-product-price {
    font-size: 13px;
    font-weight: 700;
    color: var(--wac-primary);
    margin-top: auto;
}

.wac-product-price .wac-sale-price { color: #ef4444; }
.wac-product-price .wac-regular-price-crossed { text-decoration: line-through; color: var(--wac-text-muted); font-size: 11px; margin-left: 3px; font-weight: 400; }

.wac-product-stock {
    font-size: 11px;
    font-weight: 500;
}
.wac-product-stock.instock { color: #22c55e; }
.wac-product-stock.outofstock { color: #ef4444; }

.wac-product-rating {
    font-size: 11px;
    color: var(--wac-text-muted);
}

.wac-product-view-btn {
    display: block;
    text-align: center;
    background: var(--wac-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 7px;
    text-decoration: none;
    border-radius: 0 0 8px 8px;
    transition: opacity 0.2s;
}
.wac-product-view-btn:hover { opacity: 0.9; color: white; }

/* ===== INPUT AREA ===== */
.wac-chat-input-area {
    padding: 12px 16px 16px;
    border-top: 1px solid var(--wac-border);
    background: var(--wac-bg);
    flex-shrink: 0;
}

.wac-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--wac-surface);
    border: 1px solid var(--wac-border);
    border-radius: 24px;
    padding: 8px 8px 8px 14px;
    transition: border-color 0.2s;
}
.wac-chat-input-wrap:focus-within {
    border-color: var(--wac-primary);
}

.wac-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 14px;
    font-family: inherit;
    color: var(--wac-text);
    outline: none;
    max-height: 120px;
    min-height: 22px;
    line-height: 1.5;
}

.wac-chat-input::placeholder { color: var(--wac-text-muted); }

.wac-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--wac-primary);
    border: none;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}
.wac-send-btn:hover { filter: brightness(1.1); }
.wac-send-btn:active { transform: scale(0.95); }
.wac-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== TERMS ===== */
.wac-terms-notice {
    padding: 6px 16px 10px;
    font-size: 11px;
    color: var(--wac-text-muted);
    text-align: center;
    line-height: 1.5;
}
.wac-terms-notice a { color: var(--wac-primary); }

/* ===== PRODUCT SEARCH WIDGET ===== */
.wac-product-search-widget {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.wac-search-bar {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wac-search-input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--wac-border, #e9ecef);
    border-radius: 30px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}
.wac-search-input:focus { border-color: var(--wac-primary); }

.wac-search-btn {
    padding: 10px 20px;
    background: var(--wac-primary);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: filter 0.2s;
}
.wac-search-btn:hover { filter: brightness(1.1); }

.wac-search-results {
    margin-top: 16px;
}

/* ===== LOGIN NOTICE ===== */
.wac-login-notice {
    text-align: center;
    padding: 20px;
    color: var(--wac-text-muted, #6c757d);
    font-style: italic;
}
