/* ============================================================
   OMS AI Assistant — Floating Chat Bubble
   Adapted from vanilla/agent/public/agent.css.
   Self-contained: every selector is namespaced under .oms-ai-*
   so it cannot collide with the Kendo / Bootstrap UI of nomsGithub.
   ============================================================ */

.oms-ai-root {
    --oai-blue:        #275991;
    --oai-blue-hover:  #3c71ad;
    --oai-bg:          #f8f9fa;
    --oai-text:        #212529;
    --oai-muted:       #6c757d;
    --oai-border:      #dee2e6;
    --oai-success:     #28a745;
    --oai-danger:      #dc3545;
    --oai-rec-red:     #e53935;
    --oai-user-bg:     #e3f0ff;
    --oai-ai-bg:       #ffffff;
    --oai-radius:      12px;
    --oai-shadow:      0 6px 22px rgba(0, 0, 0, 0.18);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.oms-ai-root *,
.oms-ai-root *:before,
.oms-ai-root *:after {
    box-sizing: border-box;
}

.oms-ai-hidden { display: none !important; }

/* ── Floating bubble (closed state) ───────────────────── */
.oms-ai-bubble {
    position: fixed;
    bottom: 22px;
    right: 22px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--oai-blue);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: var(--oai-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    z-index: 99990;
    transition: background 0.2s, transform 0.15s;
}
.oms-ai-bubble:hover { background: var(--oai-blue-hover); transform: scale(1.04); }
.oms-ai-bubble .oms-ai-bubble-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 10px; height: 10px;
    background: var(--oai-success);
    border-radius: 50%;
    border: 2px solid #fff;
}

/* ── Chat panel (open state) ──────────────────────────── */
.oms-ai-panel {
    position: fixed;
    bottom: 22px;
    right: 22px;
    width: 380px;
    max-width: calc(100vw - 24px);
    height: 560px;
    max-height: calc(100vh - 44px);
    background: #fff;
    color: var(--oai-text);
    border-radius: var(--oai-radius);
    box-shadow: var(--oai-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 99991;
    animation: oai-rise 0.18s ease;
}
@keyframes oai-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.oms-ai-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: var(--oai-blue);
    color: #fff;
}
.oms-ai-header .oai-icon { font-size: 22px; }
.oms-ai-header h3 { font-size: 15px; font-weight: 700; margin: 0; }
.oms-ai-header .oai-sub { font-size: 12px; opacity: 0.85; margin-left: auto; max-width: 150px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.oms-ai-header .oai-x {
    background: none; border: none; color: #fff; font-size: 22px; cursor: pointer;
    width: 28px; height: 28px; line-height: 1; padding: 0; opacity: 0.8;
}
.oms-ai-header .oai-x:hover { opacity: 1; }

/* ── Login overlay (inside the panel) ─────────────────── */
.oms-ai-login {
    flex: 1;
    background: var(--oai-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.oms-ai-login form {
    background: #fff;
    border: 1px solid var(--oai-border);
    border-radius: var(--oai-radius);
    padding: 18px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.oms-ai-login h4 { color: var(--oai-blue); font-size: 16px; margin: 0 0 4px 0; text-align: center; }
.oms-ai-login p  { font-size: 12px; color: var(--oai-muted); text-align: center; margin: 0 0 6px 0; }
.oms-ai-login input {
    padding: 10px 12px;
    border: 1px solid var(--oai-border);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
}
.oms-ai-login input:focus { border-color: var(--oai-blue); }
.oms-ai-login button {
    padding: 10px;
    background: var(--oai-blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.oms-ai-login button:hover  { background: var(--oai-blue-hover); }
.oms-ai-login button:disabled { opacity: 0.5; cursor: default; }
.oms-ai-login .oai-error { color: var(--oai-danger); font-size: 12px; min-height: 14px; }

/* ── Chat surface ─────────────────────────────────────── */
.oms-ai-chat {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--oai-bg);
}
.oms-ai-welcome {
    text-align: center;
    color: var(--oai-muted);
    font-size: 13px;
    line-height: 1.6;
    margin: auto 8px;
}
.oms-ai-welcome ul { padding-left: 18px; text-align: left; margin-top: 6px; }
.oms-ai-welcome ul li { margin: 2px 0; }

.oms-ai-bubble-msg {
    max-width: 88%;
    padding: 8px 12px;
    border-radius: var(--oai-radius);
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
    animation: oai-fade 0.18s ease;
}
.oms-ai-bubble-msg.user { align-self: flex-end; background: var(--oai-user-bg); border-bottom-right-radius: 4px; }
.oms-ai-bubble-msg.ai   { align-self: flex-start; background: var(--oai-ai-bg);   border: 1px solid var(--oai-border); border-bottom-left-radius: 4px; }
.oms-ai-bubble-msg .label  { font-size: 10px; color: var(--oai-muted); margin-bottom: 2px; font-weight: 600; }
.oms-ai-bubble-msg .timing { font-size: 10px; color: var(--oai-muted); margin-top: 4px; }
.oms-ai-bubble-msg code    { background: #f0f0f0; padding: 1px 5px; border-radius: 3px; font-size: 12px; font-family: Consolas, Monaco, monospace; }
@keyframes oai-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.oms-ai-bubble-msg.thinking .dots span {
    display: inline-block; width: 6px; height: 6px; margin: 0 2px;
    background: var(--oai-muted); border-radius: 50%;
    animation: oai-blink 1.4s infinite both;
}
.oms-ai-bubble-msg.thinking .dots span:nth-child(2) { animation-delay: 0.2s; }
.oms-ai-bubble-msg.thinking .dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes oai-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* ── Context chip (current screen indicator) ──────────── */
.oms-ai-ctx {
    font-size: 11px;
    color: var(--oai-muted);
    padding: 4px 12px;
    background: #f1f3f5;
    border-bottom: 1px solid var(--oai-border);
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 22px;
}
.oms-ai-ctx .oai-dot { width: 6px; height: 6px; background: var(--oai-success); border-radius: 50%; flex: none; }
.oms-ai-ctx span.label { font-weight: 600; color: var(--oai-text); }
.oms-ai-ctx .oai-ctx-clear {
    margin-left: auto; background: none; border: none; color: var(--oai-muted);
    font-size: 11px; cursor: pointer; padding: 0;
}
.oms-ai-ctx .oai-ctx-clear:hover { color: var(--oai-text); }

/* ── Input bar ─────────────────────────────────────────── */
.oms-ai-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--oai-border);
    background: #fff;
}
.oms-ai-input .oai-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    border: 1px solid var(--oai-border);
    border-radius: 22px;
    overflow: hidden;
    padding: 0 4px 0 12px;
}
.oms-ai-input input[type="text"] {
    flex: 1;
    border: none;
    outline: none;
    font-size: 14px;
    padding: 8px 0;
    background: transparent;
    font-family: inherit;
}
.oms-ai-input .oai-send {
    background: none; border: none; font-size: 18px; color: var(--oai-blue-hover);
    cursor: pointer; padding: 4px 8px;
}
.oms-ai-input .oai-send:disabled { opacity: 0.3; cursor: default; }

.oms-ai-input .oai-stop {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: var(--oai-danger); color: #fff; font-size: 14px;
    cursor: pointer; flex: none;
}
.oms-ai-input .oai-stop:hover { background: #c82333; }

.oms-ai-input .oai-mic {
    position: relative;
    width: 44px; height: 44px; border-radius: 50%; border: none;
    background: var(--oai-blue); color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex: none;
    transition: background 0.2s;
}
.oms-ai-input .oai-mic:hover { background: var(--oai-blue-hover); }
.oms-ai-input .oai-mic.recording { background: var(--oai-rec-red); }
.oms-ai-input .oai-mic svg { width: 20px; height: 20px; }
.oms-ai-input .oai-mic .pulse {
    position: absolute; inset: -4px; border-radius: 50%;
    border: 2px solid var(--oai-rec-red); opacity: 0; pointer-events: none;
}
.oms-ai-input .oai-mic.recording .pulse { animation: oai-pulse 1s ease-out infinite; }
@keyframes oai-pulse { 0% { transform: scale(1); opacity: 0.6; } 100% { transform: scale(1.4); opacity: 0; } }
.oms-ai-input .oai-mic:disabled { opacity: 0.5; cursor: default; }

.oms-ai-status {
    font-size: 11px;
    color: var(--oai-muted);
    text-align: center;
    padding: 2px;
    min-height: 14px;
    background: #fff;
}
.oms-ai-status.error { color: var(--oai-danger); }

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    .oms-ai-panel {
        bottom: 0; right: 0; left: 0;
        width: 100%; max-width: 100%;
        height: 100dvh; max-height: 100dvh;
        border-radius: 0;
    }
}
