/* ── Assistant Drawer (layout integration) ── */
.assistant-fab {
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: transform .15s, box-shadow .15s;
}
.assistant-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.assistant-fab.hidden { display: none; }

/* Drawer overlay */
.assistant-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.3);
    z-index: 1060;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.assistant-drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* Drawer panel */
.assistant-drawer {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    max-width: 100vw;
    height: 100vh;
    background: var(--bg, #fff);
    z-index: 1070;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 20px rgba(0,0,0,.15);
    transition: right .25s ease;
}
.assistant-drawer.open { right: 0; }

.assistant-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}
.assistant-drawer-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.assistant-drawer-header .drawer-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}
.assistant-drawer-header .drawer-actions button,
.assistant-drawer-header .drawer-actions a {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary, #6b7280);
    font-size: 14px;
    padding: 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    text-decoration: none;
}
.assistant-drawer-header .drawer-actions button:hover,
.assistant-drawer-header .drawer-actions a:hover { background: var(--surface, #f3f4f6); }

/* ── Shared transcript + input styles ── */
.assistant-transcript {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.assistant-welcome {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary, #6b7280);
}
.assistant-welcome-icon { width: 80px; height: 80px; margin-bottom: 12px; }
.assistant-welcome h2 { font-size: 18px; margin: 0 0 8px; color: var(--text, #111827); }
.assistant-welcome p { font-size: 13px; margin: 0; }

.assistant-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}
.assistant-msg.user {
    align-self: flex-end;
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.assistant-msg.assistant {
    align-self: flex-start;
    background: var(--surface, #f3f4f6);
    color: var(--text, #111827);
    border-bottom-left-radius: 4px;
}
.assistant-msg.assistant p { margin: 0 0 8px; }
.assistant-msg.assistant p:last-child { margin-bottom: 0; }
.assistant-msg.assistant code {
    background: rgba(0,0,0,.06);
    padding: 1px 4px;
    border-radius: 3px;
    font-size: 12.5px;
}

.assistant-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin: 6px 0;
    table-layout: fixed;
}
.assistant-table th,
.assistant-table td {
    border: 1px solid var(--border, #e5e7eb);
    padding: 4px 6px;
    text-align: left;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.assistant-table th:first-child,
.assistant-table td:first-child {
    width: 35%;
}
.assistant-table th {
    background: rgba(0,0,0,.04);
    font-weight: 600;
}
.assistant-table tr:hover td {
    background: rgba(0,0,0,.02);
}

/* Message action bar */
.assistant-msg-actions {
    display: flex;
    gap: 2px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}
.assistant-msg:hover .assistant-msg-actions {
    opacity: 1;
}
.msg-action-btn {
    background: none;
    border: none;
    color: var(--text-secondary, #9ca3af);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 12px;
    border-radius: 4px;
}
.msg-action-btn:hover {
    color: var(--text, #111827);
    background: rgba(0,0,0,.06);
}

/* Trace modal */
.trace-modal {
    position: fixed;
    inset: 0;
    z-index: 10100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.trace-modal .modal-overlay-bg {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.4);
}
.trace-modal-content {
    position: relative;
    background: var(--bg, #fff);
    border-radius: 10px;
    width: 600px;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.trace-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.trace-modal-header h4 {
    margin: 0;
    font-size: 14px;
}
.trace-modal-header button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-secondary);
    padding: 4px;
}
.trace-modal-body {
    padding: 12px 16px;
    overflow-y: auto;
    font-size: 13px;
}
.trace-item {
    margin-bottom: 12px;
}
.trace-item:last-child {
    margin-bottom: 0;
}
.trace-header {
    font-weight: 600;
    margin-bottom: 6px;
}
.trace-latency {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 12px;
}
.trace-section {
    margin-bottom: 8px;
}
.trace-section strong {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.trace-section pre {
    margin: 0;
    padding: 8px 10px;
    font-size: 11px;
    background: var(--surface, #f8f8f8);
    border-radius: 6px;
    overflow-x: auto;
    max-height: 200px;
    white-space: pre-wrap;
    word-break: break-all;
}

.assistant-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}
.assistant-typing span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary, #9ca3af);
    border-radius: 50%;
    animation: assistantBounce .6s infinite alternate;
}
.assistant-typing span:nth-child(2) { animation-delay: .2s; }
.assistant-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes assistantBounce {
    to { opacity: .3; transform: translateY(-4px); }
}
.assistant-tool-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-secondary, #9ca3af);
    font-style: italic;
}
.assistant-tool-indicator i { font-size: 11px; }
.assistant-msg-content { min-height: 0; }

.assistant-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border, #e5e7eb);
    flex-shrink: 0;
}
.assistant-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--surface, #f3f4f6);
    border-radius: 10px;
    padding: 8px 12px;
}
.assistant-input-wrapper textarea {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    resize: none;
    font-size: 13.5px;
    line-height: 1.4;
    max-height: 120px;
    font-family: inherit;
    color: var(--text, #111827);
}
.assistant-send-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
    transition: opacity .15s;
}
.assistant-send-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Full-page layout ── */
.assistant-fullpage {
    display: flex;
    height: calc(100vh - 60px);
    margin: -24px;
}
.assistant-sidebar {
    width: 280px;
    border-right: 1px solid var(--border, #e5e7eb);
    display: flex;
    flex-direction: column;
    background: var(--surface, #f9fafb);
    flex-shrink: 0;
}
.assistant-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #e5e7eb);
}
.assistant-sidebar-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}
.assistant-sidebar-actions { display: flex; align-items: center; gap: 6px; }
.assistant-new-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}
.assistant-convo-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.assistant-convo-item {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text, #111827);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.assistant-convo-item:hover { background: var(--border, #e5e7eb); }
.assistant-convo-item.active { background: var(--primary); color: #fff; }
.assistant-convo-item .convo-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}
.assistant-convo-item .convo-delete {
    opacity: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    font-size: 12px;
    padding: 2px 4px;
}
.assistant-convo-item:hover .convo-delete { opacity: .6; }

.assistant-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ── Mobile ── */
@media (max-width: 768px) {
    .assistant-drawer { width: 100vw; right: -100vw; }
    .assistant-fullpage { flex-direction: column; }
    .assistant-sidebar { width: 100%; height: 160px; border-right: none; border-bottom: 1px solid var(--border); }
}

/* ── Shared markdown rendering (used by FAB assistant and the claim chat drawer) ── */
.ai-chat-table { border-collapse: collapse; margin: 6px 0; font-size: 13px; }
.ai-chat-table th, .ai-chat-table td { border: 1px solid var(--border, #e5e7eb); padding: 4px 8px; text-align: left; }
.ai-chat-table th { background: rgba(0,0,0,0.04); font-weight: 600; }
.ai-chat-heading { margin: 10px 0 4px 0; font-weight: 600; line-height: 1.25; }
h1.ai-chat-heading { font-size: 16px; }
h2.ai-chat-heading { font-size: 15px; }
h3.ai-chat-heading, h4.ai-chat-heading,
h5.ai-chat-heading, h6.ai-chat-heading { font-size: 14px; }
.ai-chat-list { margin: 4px 0 6px 20px; padding: 0; }
.ai-chat-list li { margin: 2px 0; }
