/* Lakpura® Agent staff assistant — slide-in panel.
 *
 * Fixed-position right-side dock, 420px wide on desktop, full-width on
 * mobile. Deliberately self-contained (prefix `.lk-agent-*`) so it doesn't
 * fight any Tabler component. No JS framework.
 */

#lk-agent-panel {
    position: fixed;
    top: 0; right: 0; bottom: 0;
    width: 420px;
    max-width: 100vw;
    background: #fff;
    border-left: 1px solid #e6e7e9;
    box-shadow: -12px 0 32px rgba(15,23,42,0.10);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.22s ease;
    z-index: 1050;
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
#lk-agent-panel.is-open {
    transform: translateX(0);
}

/* Page-push effect: when the panel opens we add `lk-agent-panel-open` to
 * <body> so the main app content slides left in step with the panel
 * instead of being covered by it. Matches Gemini/Workspace docked-panel
 * behaviour. The Tabler navbar uses position:sticky inside the body, so
 * a body padding-right is enough — the navbar moves with everything else.
 *
 * Mobile (<576px): panel is full-width, so suppress the push (the
 * content would be offscreen anyway). */
body.lk-agent-panel-open {
    padding-right: 420px;
    transition: padding-right 0.22s ease;
}
@media (max-width: 576px) {
    #lk-agent-panel { width: 100vw; }
    body.lk-agent-panel-open { padding-right: 0; }
}

/* Header */
.lk-agent-header {
    display: flex; align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid #eceef1;
    flex: 0 0 auto;
    gap: 8px;
    background: linear-gradient(180deg, #fafbff 0%, #fff 100%);
}
.lk-agent-title {
    display: flex; align-items: center; gap: 8px;
    flex: 1 1 auto; min-width: 0;
}
.lk-agent-title i.ti { color: #6366f1; font-size: 22px; }
.lk-agent-title strong { font-size: 15px; }
.lk-agent-subtitle {
    color: #5b6b85;
    font-size: 12px;
    margin-left: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.lk-agent-header-actions { display: flex; gap: 4px; flex: 0 0 auto; }
.lk-agent-icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: #4b5563;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    line-height: 1;
}
.lk-agent-icon-btn:hover { background: #f1f3f7; color: #111; }

/* History drawer */
.lk-agent-history-panel {
    flex: 0 0 auto;
    max-height: 260px;
    overflow-y: auto;
    border-bottom: 1px solid #eceef1;
    padding: 8px 14px 10px;
    background: #f8f9fc;
}
.lk-agent-history-title {
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
    color: #6b7280; margin-bottom: 6px;
}
.lk-agent-history-list {
    list-style: none; padding: 0; margin: 0;
}
.lk-agent-history-list li {
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: #1f2937;
    display: flex; gap: 8px; align-items: center;
}
.lk-agent-history-list li:hover { background: #e9eef7; }
.lk-agent-history-list li .lk-agent-history-meta {
    margin-left: auto; color: #9ca3af; font-size: 11px; flex-shrink: 0;
}

/* Conversation */
.lk-agent-conversation {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px 8px;
    background: #fff;
}
.lk-agent-empty {
    text-align: center;
    padding: 32px 8px 0;
    color: #64748b;
}
.lk-agent-empty h3 {
    margin: 8px 0 6px; font-size: 16px; color: #1f2937; font-weight: 600;
}
.lk-agent-empty p { font-size: 13px; line-height: 1.5; margin: 0 4px 16px; }
.lk-agent-examples {
    display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
}
.lk-agent-example {
    background: #f1f5ff; color: #4338ca;
    border: 1px solid #dde3f7;
    padding: 6px 10px; border-radius: 14px;
    font-size: 12px; cursor: pointer;
}
.lk-agent-example:hover { background: #e6ecff; }

.lk-agent-msg {
    display: flex; gap: 8px;
    margin-bottom: 14px;
    font-size: 14px;
    line-height: 1.55;
}
.lk-agent-msg.is-user        { flex-direction: row-reverse; }
.lk-agent-msg .lk-agent-bubble {
    padding: 8px 12px; border-radius: 10px;
    max-width: 90%; word-wrap: break-word; overflow-wrap: anywhere;
    white-space: pre-wrap;
}
.lk-agent-msg.is-user .lk-agent-bubble       { background: #4338ca; color: #fff; border-top-right-radius: 2px; }
.lk-agent-msg.is-assistant .lk-agent-bubble  { background: #f3f4f7; color: #1f2937; border-top-left-radius: 2px; }
.lk-agent-msg.is-thinking .lk-agent-bubble {
    background: transparent; color: #6b7280; font-style: italic;
}
.lk-agent-msg .lk-agent-avatar {
    flex: 0 0 24px; width: 24px; height: 24px;
    border-radius: 6px; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px;
}
.lk-agent-msg.is-user .lk-agent-avatar      { background: #4338ca; }
.lk-agent-msg.is-assistant .lk-agent-avatar { background: #6366f1; }
.lk-agent-bubble strong { color: inherit; font-weight: 600; }
.lk-agent-bubble code    { background: rgba(0,0,0,.06); padding: 1px 4px; border-radius: 3px; font-size: 13px; }
.lk-agent-msg.is-user .lk-agent-bubble code { background: rgba(255,255,255,.18); color: #fff; }
.lk-agent-bubble ul      { margin: 6px 0; padding-left: 20px; }
.lk-agent-bubble li      { margin: 2px 0; }
.lk-agent-bubble a       { color: #4338ca; text-decoration: underline; }
.lk-agent-msg.is-user .lk-agent-bubble a { color: #fff; }

/* Composer */
.lk-agent-composer {
    flex: 0 0 auto;
    display: flex; gap: 8px; align-items: flex-end;
    padding: 10px 12px 12px;
    border-top: 1px solid #eceef1;
    background: #fff;
}
.lk-agent-composer textarea {
    flex: 1 1 auto;
    resize: none;
    border: 1px solid #d7dae0;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px; font-family: inherit;
    /* min-height fits two lines so a wrapped placeholder doesn't get clipped
     * at the bottom — line-height 1.4 × 14px = ~19.6px × 2 + 20px padding ≈ 60. */
    min-height: 60px; max-height: 140px;
    line-height: 1.4;
    transition: border-color .1s ease, box-shadow .1s ease;
}
.lk-agent-composer textarea:focus {
    outline: none; border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.18);
}
.lk-agent-send {
    background: #4338ca; color: #fff;
    border: none; border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
}
.lk-agent-send:hover { background: #3730a3; }
.lk-agent-send:disabled { opacity: .45; cursor: default; }

/* Backdrop — optional dim on mobile */
@media (max-width: 576px) {
    #lk-agent-panel.is-open::before {
        content: ''; position: fixed; inset: 0 420px 0 0;
        background: rgba(15,23,42,.25);
        pointer-events: none; z-index: -1;
    }
}
