/* WooAI Chat Widget */
#wooai-widget {
    position: fixed; bottom: 20px; right: 20px; z-index: 9999;
    --wooai-primary: var(--wp--preset--color--primary, #0066cc);
    --wooai-primary-hover: var(--wp--preset--color--primary, #0052a3);
    --wooai-text-color: var(--wp--preset--color--contrast, #333);
    --wooai-font-family: inherit;
    font-family: var(--wooai-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif);
    color: var(--wooai-text-color);
}
#wooai-widget-button { width: 56px; height: 56px; background: var(--wooai-primary); color: #fff; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.2); font-size: 16px; font-weight: bold; transition: transform .15s ease; overflow: hidden; }
#wooai-widget-button:hover { transform: scale(1.08); }
#wooai-widget-button img { width: 28px; height: 28px; object-fit: contain; }
#wooai-widget-panel { width: 360px; height: 480px; max-height: 80vh; background: #fff; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); display: flex; flex-direction: column; overflow: hidden; }
#wooai-widget-header { background: var(--wooai-primary); color: #fff; padding: 12px 14px; font-weight: bold; font-size: 15px; }
#wooai-widget-messages { flex: 1; padding: 10px; overflow-y: auto; background: #f6f8fb; display: flex; flex-direction: column; }
#wooai-widget-footer { display: flex; border-top: 1px solid #ddd; padding: 8px; gap: 6px; }
#wooai-widget-input { flex: 1; padding: 10px; border: 1px solid #ccc; border-radius: 8px; font-size: 14px; outline: none; font-family: var(--wooai-font-family, inherit); }
#wooai-widget-input:focus { border-color: var(--wooai-primary); box-shadow: 0 0 0 2px rgba(0,102,204,.15); }
#wooai-widget-send { background: var(--wooai-primary); color: #fff; border: none; padding: 10px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; white-space: nowrap; transition: background .15s ease; font-family: var(--wooai-font-family, inherit); }
#wooai-widget-send:hover:not(:disabled) { background: var(--wooai-primary-hover); }

/* Messages */
.wooai-widget-message { margin-bottom: 8px; padding: 10px 12px; border-radius: 12px; max-width: 85%; word-wrap: break-word; line-height: 1.45; font-size: 14px; }
.wooai-widget-message.user { background: #c8e0ff; align-self: flex-end; border-bottom-right-radius: 4px; }
.wooai-widget-message.bot { background: #e9ecef; align-self: flex-start; border-bottom-left-radius: 4px; }
.wooai-widget-message a { color: var(--wooai-primary); text-decoration: underline; }

/* Product cards */
.wooai-widget-card { margin-top: 8px; padding: 10px; border: 1px solid #e0e0e0; border-radius: 10px; background: #fff; }
.wooai-widget-card strong { display: block; margin-bottom: 4px; font-size: 14px; }
.wooai-widget-card-image { max-width: 100%; max-height: 160px; height: auto; display: block; margin: 6px 0; border-radius: 6px; object-fit: cover; }
.wooai-widget-card-actions { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.wooai-widget-card-actions a { display: inline-flex; align-items: center; padding: 7px 14px; border: 1px solid var(--wooai-primary); border-radius: 6px; color: var(--wooai-primary); text-decoration: none; font-size: 13px; transition: background .15s ease, color .15s ease; }
.wooai-widget-card-actions a:hover { background: var(--wooai-primary); color: #fff; text-decoration: none; }
.wooai-widget-card-actions button { background: var(--wooai-primary); color: #fff; border: none; padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: background .15s ease; margin-top: 0; }
.wooai-widget-card-actions button:hover:not(:disabled) { background: var(--wooai-primary-hover); }
.wooai-widget-card-actions button:disabled { opacity: .6; cursor: not-allowed; }

/* Typing indicator */
.wooai-typing-indicator { display: flex; align-items: center; gap: 4px; padding: 10px 12px; }
.wooai-typing-indicator span { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #999; animation: wooai-bounce 1.2s infinite ease-in-out both; }
.wooai-typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.wooai-typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
.wooai-typing-indicator span:nth-child(3) { animation-delay: 0s; }
@keyframes wooai-bounce { 0%, 80%, 100% { transform: scale(0.4); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* Disable state while waiting */
#wooai-widget-send:disabled, #wooai-widget-input:disabled { opacity: 0.6; cursor: not-allowed; }

/* ---- Mobile ---- */
@media (max-width: 480px) {
    #wooai-widget { bottom: 0; right: 0; left: 0; }
    #wooai-widget-button { position: fixed; bottom: 16px; right: 16px; }
    #wooai-widget-panel { width: 100%; height: 100vh; max-height: 100vh; border-radius: 0; position: fixed; top: 0; left: 0; right: 0; bottom: 0; }
    #wooai-widget-header { padding: 14px 16px; font-size: 16px; }
    #wooai-widget-footer { padding: 10px 12px; }
    #wooai-widget-input { font-size: 16px; /* prevents iOS zoom */ }
    #wooai-widget-send { padding: 10px 20px; font-size: 15px; }
    .wooai-widget-message { max-width: 90%; }
}
