/* ── Chatbot Toggle Button ────────────────────────────── */
.ai-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #0067b2, #004d85);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 103, 178, 0.4);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-chat-toggle svg {
    fill: #fff;
    stroke: #fff;
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0, 103, 178, 0.6);
}

/* ── Chat Window ─────────────────────────────────────── */
.ai-chat-window {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 420px;
    height: 600px;
    background: #0a0f14;
    border: 1px solid #1a4a6d;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    color: #e0e0e0;
    overflow: hidden;
}

@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        bottom: 8px;
        right: 8px;
    }
}

/* ── Header ──────────────────────────────────────────── */
.ai-chat-header {
    background: linear-gradient(90deg, #0a1520, #0d1a2b);
    border-bottom: 1px solid #1a4a6d;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

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

.ai-chat-header-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #0067b2, #004d85);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #fff;
}

.ai-chat-header-title {
    color: #fff;
    font-weight: 600;
    font-size: 14px;
}

.ai-chat-header-sub {
    color: #88c8f0;
    font-size: 10px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.ai-chat-close {
    background: none;
    border: none;
    color: #888;
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.ai-chat-close:hover {
    color: #fff;
}

/* ── Catalog Status Bar ─────────────────────────────── */
.ai-chat-status {
    background: #0d1520;
    border-bottom: 1px solid #1a3a5a;
    padding: 6px 16px;
    font-size: 11px;
    color: #88c8f0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.ai-chat-status-icon {
    animation: ai-spin 1s linear infinite;
    display: inline-block;
}

@keyframes ai-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ── Messages ────────────────────────────────────────── */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #1a2a4a;
    border-radius: 2px;
}

.ai-chat-msg {
    display: flex;
    flex-direction: column;
}

.ai-chat-msg-user {
    align-items: flex-end;
}

.ai-chat-msg-assistant {
    align-items: flex-start;
}

.ai-chat-bubble {
    max-width: 85%;
    padding: 10px 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.ai-chat-bubble-user {
    background: linear-gradient(135deg, #0d2a4d, #0a1f3a);
    border: 1px solid #1a4a7a;
    border-radius: 12px 12px 2px 12px;
}

.ai-chat-bubble-assistant {
    background: #0f1520;
    border: 1px solid #1a2a4a;
    border-radius: 12px 12px 12px 2px;
}

/* ── Typing indicator ────────────────────────────────── */
.ai-chat-typing {
    display: flex;
    gap: 5px;
    padding: 14px 18px;
}

.ai-chat-typing span {
    width: 7px;
    height: 7px;
    background: #0067b2;
    border-radius: 50%;
    animation: ai-bounce 1.2s ease-in-out infinite;
}

.ai-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Part Cards ──────────────────────────────────────── */
.ai-chat-parts {
    max-width: 85%;
    width: 100%;
}

.ai-chat-part-card {
    background: linear-gradient(135deg, #0d1520, #0a1018);
    border: 1px solid #1a4a6d;
    border-radius: 8px;
    padding: 12px 14px;
    margin-top: 8px;
    font-size: 12px;
}

.ai-chat-part-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 6px;
    gap: 8px;
}

.ai-chat-part-name {
    color: #fff;
    font-weight: 600;
    font-size: 13px;
}

.ai-chat-part-price {
    color: #f0c040;
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
}

.ai-chat-part-meta {
    display: flex;
    gap: 12px;
    color: #aaa;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.ai-chat-in-stock { color: #88c8f0; }
.ai-chat-no-stock { color: #f44336; }

.ai-chat-part-locations {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #1a2030;
}

.ai-chat-loc-item { display: inline; }
.ai-chat-loc-name { color: #fff; }
.ai-chat-loc-qty-ok { color: #18dd46; font-weight: 600; }
.ai-chat-loc-qty-empty { color: #dc143c; font-weight: 600; }

/* ── Part Actions (Sell button) ──────────────────────── */
.ai-chat-part-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #1a2030;
}

.ai-chat-sell-btn {
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, #e6a817, #c48a0a);
    color: #000;
    box-shadow: 0 0 10px rgba(230, 168, 23, 0.3);
}

.ai-chat-sell-btn:disabled {
    cursor: not-allowed;
    box-shadow: none;
}

.ai-chat-sell-loading {
    background: #1a2030;
    color: #555;
}

.ai-chat-sell-sold {
    background: linear-gradient(135deg, #0d3a5a, #0a2a4a);
    color: #88c8f0;
}

.ai-chat-sell-error {
    background: #3a1a1a;
    color: #f44336;
}

.ai-chat-sell-nostock {
    background: #1a1a1a;
    color: #444;
}

.ai-chat-wc-link {
    color: #555;
    font-size: 11px;
    text-decoration: none;
    transition: color 0.2s;
}

.ai-chat-wc-link:hover {
    color: #0067b2;
}

.ai-chat-action-error {
    color: #f44336;
    font-size: 11px;
}

.ai-chat-part-id {
    margin-left: auto;
    color: #444;
    font-size: 10px;
}

/* ── Add to Cart Button (frontend) ─────────────────── */
.ai-chat-cart-btn {
    padding: 6px 16px;
    border-radius: 6px;
    border: none;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: linear-gradient(135deg, #0067b2, #004d85);
    color: #fff !important;
    box-shadow: 0 0 10px rgba(0, 103, 178, 0.3);
}

.ai-chat-cart-btn:hover:not(:disabled) {
    box-shadow: 0 0 16px rgba(0, 103, 178, 0.5);
    transform: translateY(-1px);
}

.ai-chat-cart-btn:disabled {
    cursor: not-allowed;
    box-shadow: none;
}

.ai-chat-cart-loading {
    background: #1a2030;
    color: #555;
}

.ai-chat-cart-added {
    background: linear-gradient(135deg, #0d3a5a, #0a2a4a);
    color: #88c8f0;
}

.ai-chat-cart-error {
    background: #3a1a1a;
    color: #f44336;
}

.ai-chat-cart-nostock {
    background: #1a1a1a;
    color: #444;
}

.ai-chat-product-link {
    color: #fff;
    font-size: 11px;
    text-decoration: none;
    transition: color 0.2s;
}

.ai-chat-product-link:hover {
    color: #88c8f0;
}

/* ── Suggestions ─────────────────────────────────────── */
.ai-chat-suggestions {
    padding: 8px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
}

.ai-chat-suggestion {
    background: transparent;
    border: 1px solid #1a2a4a;
    border-radius: 16px;
    padding: 5px 10px;
    color: #888;
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.ai-chat-suggestion:hover {
    border-color: #0067b2;
    color: #88c8f0;
}

/* ── Input Area ──────────────────────────────────────── */
.ai-chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-top: 1px solid #1a2030;
    background: #080a10;
    flex-shrink: 0;
}

.ai-chat-input {
    flex: 1;
    background: transparent;
    border: 1px solid #1a2a4a;
    border-radius: 6px;
    padding: 8px 12px;
    color: #e0e0e0;
    font-size: 13px;
    font-family: inherit;
    outline: none;
}

.ai-chat-input:focus {
    border-color: #0067b2;
}

.ai-chat-input::placeholder {
    color: #555;
}

.ai-chat-send {
    background: linear-gradient(135deg, #0067b2, #004d85);
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.ai-chat-send:disabled {
    background: #1a2030;
    color: #444;
    cursor: not-allowed;
}

.ai-chat-send:not(:disabled):hover {
    opacity: 0.9;
}

/* ── Seller page: larger chat window ─────────────────── */
body.ai-seller-body .ai-chat-window {
    width: 504px;
    height: 720px;
}

@media (max-width: 480px) {
    body.ai-seller-body .ai-chat-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 80px);
        bottom: 8px;
        right: 8px;
    }
}

/* ── Admin-specific overrides ────────────────────────── */
body.wp-admin .ai-chat-window {
    bottom: 40px;
}

body.wp-admin .ai-chat-toggle {
    bottom: 40px;
}
