/* AI Magic Wand + chat widget. Everything is prefixed .skp-ai- to stay clear of theme styles. */

.skp-ai-wand {
    position: absolute;
    z-index: 2147483000;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    color: #fff;
    box-shadow: 0 2px 8px rgba(124, 58, 237, .45);
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease, box-shadow .15s ease;
}
.skp-ai-wand.skp-ai-visible { display: flex; }
.skp-ai-wand:hover, .skp-ai-wand:focus { transform: scale(1.12); box-shadow: 0 3px 12px rgba(236, 72, 153, .55); outline: none; }
.skp-ai-wand svg { width: 18px; height: 18px; overflow: visible; }
.skp-ai-wand .skp-ai-spark { transform-box: fill-box; transform-origin: center; animation: skp-ai-twinkle 1.8s ease-in-out infinite; }
.skp-ai-wand .skp-ai-spark.s2 { animation-delay: .6s; }
.skp-ai-wand .skp-ai-spark.s3 { animation-delay: 1.1s; }
@keyframes skp-ai-twinkle {
    0%, 100% { opacity: .35; transform: scale(.6); }
    50%      { opacity: 1;   transform: scale(1.25); }
}
@media (prefers-reduced-motion: reduce) {
    .skp-ai-wand .skp-ai-spark { animation: none; opacity: 1; }
}

/* Panel */
.skp-ai-panel {
    position: absolute;
    z-index: 2147483001;
    width: 340px;
    max-width: calc(100vw - 16px);
    background: #fff;
    color: #222;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    font-size: 14px;
    line-height: 1.4;
    padding: 12px;
}
.skp-ai-panel h6 { margin: 0 0 8px; font-size: 14px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.skp-ai-panel select, .skp-ai-panel input[type=text] {
    width: 100%; box-sizing: border-box; margin-bottom: 8px; padding: 6px 8px; border: 1px solid #ccc; border-radius: 6px; font-size: 14px; height: auto;
}
.skp-ai-panel .skp-ai-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.skp-ai-panel button.skp-ai-btn {
    border: 1px solid #7c3aed; background: #7c3aed; color: #fff; border-radius: 6px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.skp-ai-panel button.skp-ai-btn.skp-ai-secondary { background: #fff; color: #7c3aed; }
.skp-ai-panel button.skp-ai-btn:disabled { opacity: .55; cursor: default; }
.skp-ai-panel .skp-ai-close { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: #666; padding: 0 4px; }
.skp-ai-preview {
    max-height: 220px; overflow: auto; border: 1px solid #eee; border-radius: 6px; background: #faf8ff; padding: 8px; margin: 8px 0; word-wrap: break-word;
}
.skp-ai-preview.skp-ai-plain { white-space: pre-wrap; }
.skp-ai-msg { margin: 6px 0; font-size: 13px; }
.skp-ai-msg.skp-ai-error { color: #b91c1c; }
.skp-ai-msg.skp-ai-muted { color: #666; }
.skp-ai-scope { font-size: 13px; margin-bottom: 8px; }
.skp-ai-scope label { margin-right: 10px; font-weight: normal; }

/* Chat */
.skp-ai-chat-btn {
    position: fixed; right: 20px; bottom: 20px; z-index: 2147482000;
    width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
    background: linear-gradient(135deg, #7c3aed, #ec4899); box-shadow: 0 6px 18px rgba(124, 58, 237, .5);
    display: flex; align-items: center; justify-content: center; transition: transform .15s ease;
}
.skp-ai-chat-btn:hover, .skp-ai-chat-btn:focus { transform: scale(1.08); outline: none; }
.skp-ai-chat-btn svg { width: 28px; height: 28px; }
.skp-ai-chat {
    position: fixed; right: 20px; bottom: 88px; z-index: 2147482001;
    width: 360px; max-width: calc(100vw - 24px); height: 480px; max-height: calc(100vh - 110px);
    display: none; flex-direction: column; background: #fff; border-radius: 14px; overflow: hidden;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .25); border: 1px solid #e5e5e5; font-size: 14px; color: #222;
}
.skp-ai-chat.skp-ai-open { display: flex; }
.skp-ai-chat-head { background: linear-gradient(135deg, #7c3aed, #ec4899); color: #fff; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.skp-ai-chat-head button { background: none; border: 0; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.skp-ai-chat-body { flex: 1; overflow-y: auto; padding: 12px; background: #fafafa; }
.skp-ai-bubble { max-width: 88%; padding: 8px 11px; border-radius: 12px; margin-bottom: 8px; word-wrap: break-word; line-height: 1.45; }
.skp-ai-bubble.skp-ai-bot { background: #fff; border: 1px solid #e8e8e8; border-bottom-left-radius: 3px; }
.skp-ai-bubble.skp-ai-me { background: #7c3aed; color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.skp-ai-bubble a { color: #6d28d9; text-decoration: underline; }
.skp-ai-bubble.skp-ai-me a { color: #fff; }
.skp-ai-bubble ul { margin: 4px 0 4px 18px; padding: 0; }
.skp-ai-chat-foot { border-top: 1px solid #eee; padding: 8px; background: #fff; }
.skp-ai-chat-foot form { display: flex; gap: 6px; margin: 0; }
.skp-ai-chat-foot input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid #ccc; border-radius: 8px; font-size: 14px; height: auto; }
.skp-ai-chat-foot button { border: 0; background: #7c3aed; color: #fff; border-radius: 8px; padding: 0 14px; cursor: pointer; font-size: 14px; }
.skp-ai-chat-foot button:disabled { opacity: .55; cursor: default; }
.skp-ai-chat-note { font-size: 11px; color: #777; text-align: center; margin-top: 4px; }
.skp-ai-typing span { display: inline-block; width: 6px; height: 6px; margin: 0 1px; background: #999; border-radius: 50%; animation: skp-ai-bounce 1s infinite ease-in-out; }
.skp-ai-typing span:nth-child(2) { animation-delay: .15s; }
.skp-ai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes skp-ai-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }

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

/* AI search box in the top navigation:
   magnifier on the left (normal search), "Ask AI" pill on the right (AI answer). */
.header-search-wrap.skp-ai-search-on input.form-control { padding-left: 42px; padding-right: 96px; }
.header-search-wrap.skp-ai-search-on .header-search-btn { right: auto; left: 0; }
.skp-ai-search-wand {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    height: 28px; padding: 0 12px 0 9px; border: 0; border-radius: 14px; cursor: pointer; color: #fff;
    background: linear-gradient(135deg, #7c3aed, #ec4899); box-shadow: 0 1px 5px rgba(124, 58, 237, .45);
    display: flex; align-items: center; justify-content: center; gap: 5px;
    font-size: 13px; font-weight: 600; line-height: 1; white-space: nowrap; transition: box-shadow .15s ease;
}
.skp-ai-search-wand:hover, .skp-ai-search-wand:focus { box-shadow: 0 2px 9px rgba(236, 72, 153, .6); outline: none; }
.skp-ai-search-wand:disabled { opacity: .6; cursor: default; }
.skp-ai-search-wand svg { width: 16px; height: 16px; flex: 0 0 auto; }
@media (max-width: 575px) {
    /* Phones: sparkle only, so it fits inside the bar. */
    .header-search-wrap.skp-ai-search-on input.form-control { padding-right: 44px; }
    .skp-ai-search-wand { width: 28px; padding: 0; }
    .skp-ai-search-wand-label { display: none; }
}
.skp-ai-search-panel {
    position: absolute; z-index: 2147482500; left: 0; top: 100%; margin-top: 6px;
    width: 420px; max-width: calc(100vw - 16px); max-height: 60vh; overflow: auto;
    background: #fff; color: #222; border: 1px solid #ddd; border-radius: 10px; padding: 12px 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2); font-size: 14px; line-height: 1.45; text-align: left;
}
.skp-ai-search-panel[hidden] { display: none; }
.skp-ai-search-panel p { margin: 0 0 8px; }
.skp-ai-search-panel ul { margin: 0 0 8px 18px; padding: 0; }
.skp-ai-search-panel a { color: #6d28d9; text-decoration: underline; }
.skp-ai-search-hint { color: #555; }
.skp-ai-search-note { font-size: 11px; color: #777; }
.skp-ai-search-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #eee; padding-top: 8px; font-size: 13px; }
.skp-ai-search-close { border: 0; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: #666; }
