/* AI assistant drawer + topbar launcher button.
   Mirrors the rksam-* convention: global stylesheet linked from App.razor,
   no Blazor scoped CSS (wasn't being applied to AiChatPanel — switching
   to a plain global file matches every other page in the project). */

/* Launcher rendered inline in the topbar — same visual size as the
   previous fixed-position FAB (56px round) but lives in the document
   flow so it lines up with the bell / support buttons. */
.rksam-ai-launcher {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}

.rksam-ai-launcher:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
}

.rksam-ai-launcher__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

/* Right-side drawer. Hidden by default; slides in when --open is set. */
.rksam-ai-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 380px;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    border-left: 1px solid #e5e7eb;
    box-shadow: -2px 0 12px rgba(0, 0, 0, .08);
    transform: translateX(100%);
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
    z-index: 1199;
}

.rksam-ai-drawer--open {
    transform: translateX(0);
}

.rksam-ai-drawer__header {
    padding: 14px 18px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rksam-ai-drawer__close {
    background: transparent;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #6b7280;
    line-height: 1;
}

.rksam-ai-context {
    padding: 8px 18px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
    font-size: 12px;
    color: #4b5563;
}

.rksam-ai-context__label {
    font-weight: 600;
    margin-right: 4px;
}

.rksam-ai-context__period {
    color: #6b7280;
    margin-left: 4px;
}

.rksam-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rksam-ai-empty {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.4;
}

.rksam-ai-suggestions {
    list-style: none;
    padding: 0;
    margin: 12px 0 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rksam-ai-suggestions button {
    text-align: left;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #1f2937;
    transition: background-color .12s ease;
    width: 100%;
}

.rksam-ai-suggestions button:hover:not(:disabled) {
    background: #eef2ff;
}

.rksam-ai-msg {
    display: flex;
}

.rksam-ai-msg--user {
    justify-content: flex-end;
}

.rksam-ai-msg--assistant {
    justify-content: flex-start;
}

.rksam-ai-msg__bubble {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.rksam-ai-msg--user .rksam-ai-msg__bubble {
    background: var(--rksam-primary, #2563eb);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.rksam-ai-msg--assistant .rksam-ai-msg__bubble {
    background: #f3f4f6;
    color: #111827;
    border-bottom-left-radius: 4px;
}

/* Markdown rendering inside assistant bubbles. Markdig generates
   <p>, <ul>, <strong> etc. — keep them readable but compact (the
   bubble is narrow). */
.rksam-ai-msg--assistant .rksam-ai-msg__bubble > p,
.rksam-ai-msg--assistant .rksam-ai-msg__bubble > ul,
.rksam-ai-msg--assistant .rksam-ai-msg__bubble > ol {
    margin: 0;
    white-space: normal;
}
.rksam-ai-msg--assistant .rksam-ai-msg__bubble > p + p,
.rksam-ai-msg--assistant .rksam-ai-msg__bubble > p + ul,
.rksam-ai-msg--assistant .rksam-ai-msg__bubble > p + ol,
.rksam-ai-msg--assistant .rksam-ai-msg__bubble > ul + p,
.rksam-ai-msg--assistant .rksam-ai-msg__bubble > ol + p {
    margin-top: 8px;
}
.rksam-ai-msg--assistant .rksam-ai-msg__bubble ul,
.rksam-ai-msg--assistant .rksam-ai-msg__bubble ol {
    padding-left: 18px;
}
.rksam-ai-msg--assistant .rksam-ai-msg__bubble li {
    margin: 2px 0;
}
.rksam-ai-msg--assistant .rksam-ai-msg__bubble strong {
    font-weight: 600;
    color: #111827;
}
.rksam-ai-msg--assistant .rksam-ai-msg__bubble code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12.5px;
}

/* Typing indicator: three dots that pulse. */
.rksam-ai-msg__bubble--typing {
    display: inline-flex;
    gap: 4px;
    padding: 14px 16px;
}

.rksam-ai-msg__bubble--typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: rksam-ai-typing 1s ease-in-out infinite;
}

.rksam-ai-msg__bubble--typing span:nth-child(2) { animation-delay: .15s; }
.rksam-ai-msg__bubble--typing span:nth-child(3) { animation-delay: .3s; }

@keyframes rksam-ai-typing {
    0%, 80%, 100% { transform: scale(.6); opacity: .4; }
    40%           { transform: scale(1);  opacity: 1; }
}

.rksam-ai-sources {
    font-size: 11px;
    color: #6b7280;
    text-align: center;
    margin-top: 4px;
}

.rksam-ai-input {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
}

.rksam-ai-input input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
}

.rksam-ai-input button {
    padding: 9px 14px;
    border: none;
    background: var(--rksam-primary, #2563eb);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.rksam-ai-input button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.rksam-ai-error {
    padding: 8px 16px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 12px;
    border-top: 1px solid #fecaca;
}
