/* Local AI Bridge — widgets + agent console */

/* ---------- Visitor floating widget ---------- */
#ai-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #007cba;
    color: #fff;
    font-size: 26px;
    line-height: 56px;
    text-align: center;
    cursor: pointer;
    z-index: 99999;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    user-select: none;
}
#ai-fab:hover { background: #006ba1; }

#ai-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 340px;
    max-width: calc(100vw - 40px);
    height: 460px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
    font-family: sans-serif;
}
#ai-panel[hidden] { display: none; }

#ai-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: #007cba;
    color: #fff;
    font-weight: 600;
}
#ai-panel-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

#ai-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f9f9f9;
    font-size: 14px;
}
#ai-chat-log .ai-hint { color: #888; }

#ai-chat-log .ai-me,
#ai-chat-log .ai-bot,
#ai-chat-log .ai-bot2,
#ai-chat-log .ai-sys,
#ai-agent-msgs .ai-me,
#ai-agent-msgs .ai-bot,
#ai-agent-msgs .ai-bot2,
#ai-agent-msgs .ai-sys {
    padding: 8px 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    word-wrap: break-word;
}
.ai-me { background: #e1f5fe; }
.ai-bot, .ai-bot2 { background: #e8f5e9; }
.ai-bot2 { background: #e3f2fd; } /* agent in admin */
.ai-sys { background: #fff3cd; color: #7a5b00; font-style: italic; }

#ai-chat-log .ai-thinking {
    background: #eef2f7;
    color: #555;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 2px;
}
.ai-dots::after {
    content: '';
    animation: ai-dots 1.2s steps(4, end) infinite;
}
@keyframes ai-dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

#ai-status-banner {
    padding: 8px 12px;
    background: #fff3cd;
    color: #7a5b00;
    font-size: 13px;
    border-top: 1px solid #eee;
}
#ai-status-banner[hidden] { display: none; }

#ai-chat-form {
    display: flex;
    border-top: 1px solid #eee;
    padding: 10px;
    background: #fff;
}
#ai-chat-form input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}
#ai-chat-form button {
    margin-left: 8px;
    padding: 10px 14px;
    border: none;
    border-radius: 5px;
    background: #007cba;
    color: #fff;
    cursor: pointer;
}
#ai-chat-form button:disabled { opacity: 0.6; cursor: default; }

#ai-escalate {
    border: none;
    border-top: 1px solid #eee;
    background: #f1f3f5;
    color: #007cba;
    padding: 10px;
    cursor: pointer;
    font-size: 13px;
}
#ai-escalate:hover { background: #e9ecef; }

#ai-escalate-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid #eee;
    background: #f1f3f5;
}
#ai-escalate-form[hidden] { display: none; }
#ai-escalate-form input {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 13px;
}
#ai-escalate-form button {
    padding: 8px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 13px;
}
#ai-escalate-confirm { background: #007cba; color: #fff; }
#ai-escalate-cancel { background: #dde1e5; color: #333; }

#ai-register {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px;
    background: #f1f3f5;
    border-bottom: 1px solid #eee;
}
#ai-register[hidden] { display: none; }
#ai-register .ai-hint { color: #555; margin: 0; }
#ai-register input {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    box-sizing: border-box;
}
#ai-register button {
    padding: 10px;
    border: none;
    border-radius: 5px;
    background: #007cba;
    color: #fff;
    cursor: pointer;
}
#ai-register .ai-reg-error {
    color: #b00020;
    font-size: 13px;
}
#ai-register .ai-reg-error[hidden] { display: none; }
#ai-chat-body[hidden] { display: none; }

/* ---------- Agent console (wp-admin) ---------- */
.ai-agent-wrap {
    display: flex;
    gap: 16px;
    margin-top: 16px;
    height: calc(100vh - 180px);
}
.ai-agent-list {
    width: 320px;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    overflow-y: auto;
    padding: 12px;
}
.ai-agent-list h2 { margin: 0 0 10px; font-size: 16px; }
.ai-conv {
    border: 1px solid #e2e4e7;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
    cursor: pointer;
    background: #fafbfc;
}
.ai-conv:hover { border-color: #007cba; }
.ai-conv.active { border-color: #007cba; background: #e8f1fb; }
.ai-conv-meta { font-size: 12px; color: #555; margin-bottom: 4px; }
.ai-conv-last { font-size: 13px; color: #222; }

.ai-agent-thread {
    flex: 1;
    border: 1px solid #ccc;
    border-radius: 6px;
    background: #fff;
    display: flex;
    flex-direction: column;
    padding: 12px;
    overflow: hidden;
}
.ai-agent-thread .ai-hint { color: #888; }
#ai-agent-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 6px;
}
#ai-agent-reply {
    display: flex;
    margin-top: 10px;
}
#ai-agent-reply input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}
#ai-agent-reply button {
    margin-left: 8px;
    padding: 10px 16px;
    border: none;
    border-radius: 5px;
    background: #007cba;
    color: #fff;
    cursor: pointer;
}

.ai-agent-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
#ai-agent-status { font-size: 13px; color: #555; }
#ai-agent-close {
    padding: 6px 12px;
    border: 1px solid #007cba;
    border-radius: 5px;
    background: #fff;
    color: #007cba;
    cursor: pointer;
    font-size: 13px;
}
#ai-agent-close:hover { background: #007cba; color: #fff; }
#ai-agent-mode {
    padding: 6px 12px;
    border: 1px solid #999;
    border-radius: 5px;
    background: #f1f3f5;
    color: #555;
    cursor: pointer;
    font-size: 13px;
}
#ai-agent-mode.on {
    border-color: #19753b;
    background: #e3f2e8;
    color: #19753b;
}
