/* Assistant: chat list on the left, conversation on the right. Uses the theme tokens of sonar.css. */

.as-panel { display: flex; gap: 0; padding: 0; height: calc(100vh - 5rem); min-height: 480px; overflow: hidden; position: relative; }
/* The sidebar's striped ribbon along the top edge (clipped to the panel's rounded corners) */
.as-panel::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 6px; z-index: 1; pointer-events: none;
    background: repeating-linear-gradient(-45deg, var(--secondary) 0 15px, #0f172a 15px 30px); }

.as-sidebar { width: 250px; flex: 0 0 250px; border-right: 1px solid var(--border); background: var(--surface-2); display: flex; flex-direction: column; padding: 1rem; gap: 0.8rem; border-radius: 12px 0 0 12px; }
.as-usage { border-top: 1px solid var(--border); padding-top: 0.7rem; font-size: 0.78rem; color: var(--text-light); }
.as-usage:empty { display: none; }
.as-usage-head { display: flex; justify-content: space-between; margin-bottom: 0.35rem; font-weight: 600; color: var(--text); }
.as-usage-head span + span { font-weight: 400; color: var(--text-faint); }
.as-usage-bar { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; margin-bottom: 0.4rem; }
.as-usage-bar i { display: block; height: 100%; background: var(--secondary); border-radius: 3px; }
.as-usage-bar.as-usage-high i { background: var(--warning); }
.as-usage-bar.as-usage-over i { background: var(--danger); }
.as-usage-line strong { color: var(--primary); }
.as-new-btn { display: flex; align-items: center; justify-content: center; gap: 0.4rem; width: 100%; min-height: 40px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); color: var(--primary); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.as-new-btn:hover { border-color: var(--secondary); color: var(--secondary); }
.as-chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.as-list-empty { color: var(--text-faint); font-size: 0.85rem; padding: 0.5rem; }
.as-chat-item { display: flex; align-items: center; gap: 0.3rem; padding: 0.5rem 0.4rem 0.5rem 0.7rem; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 0.87rem; }
.as-chat-item:hover { background: var(--surface-3); }
.as-chat-item.active { background: rgba(var(--secondary-rgb), 0.12); color: var(--primary); font-weight: 600; }
.as-chat-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.as-chat-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.as-chat-date { color: var(--text-faint); font-size: 0.75rem; font-weight: 400; }
.as-chat-btn { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 0.2rem; opacity: 0; font-size: 0.95rem; }
.as-chat-item:hover .as-chat-btn, .as-chat-btn:focus-visible { opacity: 1; }
.as-chat-btn:hover { color: var(--secondary); }
.as-chat-delete:hover { color: var(--danger); }
.as-chat-item.archived .as-chat-title { color: var(--text-light); }

/* Chat list filter: search, and a fold-out with the date range and archive choice */
.as-filters { display: flex; flex-direction: column; gap: 0.4rem; }
.as-filters input[type="search"] { min-height: 34px; padding: 0.35rem 0.7rem; font-size: 0.85rem; }
.as-filter-more { font-size: 0.82rem; color: var(--text-light); }
.as-filter-more summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 0.35rem; }
.as-filter-more summary::-webkit-details-marker { display: none; }
.as-filter-more summary::before { content: '▸'; font-size: 0.7rem; transition: transform 0.15s; }
.as-filter-more[open] summary::before { transform: rotate(90deg); }
.as-filter-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--secondary); display: inline-block; }
.as-filter-dot[hidden] { display: none; }
.as-filter-more[open] { display: flex; flex-direction: column; gap: 0.4rem; }
.as-filter-more label { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.as-filter-more input[type="date"], .as-filter-more select { min-height: 32px; padding: 0.25rem 0.5rem; font-size: 0.82rem; width: auto; flex: 1; }
.as-filter-clear { align-self: flex-start; background: none; border: none; color: var(--link); cursor: pointer; font: inherit; font-size: 0.8rem; padding: 0; }

.as-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }
/* A soft fade under the striped ribbon, so scrolled text doesn't run into it */
.as-main::before { content: ''; position: absolute; top: 6px; left: 0; right: 0; height: 26px; z-index: 1; pointer-events: none;
    background: linear-gradient(var(--surface), transparent); }
.as-messages { flex: 1; overflow-y: auto; padding: 1.5rem 2rem; display: flex; flex-direction: column; gap: 1rem; }

.as-empty { margin: auto; text-align: center; max-width: 560px; color: var(--text-light); }
.as-empty h2 { color: var(--primary); font-size: 1.25rem; margin: 0.5rem 0 1.2rem; }
/* Short striped bar under the heading, like the page titles */
.as-empty h2::after { content: ''; display: block; width: 42px; height: 4px; margin: 0.5rem auto 0; border-radius: 2px; background: var(--stripes); }
.as-empty-icon { font-size: 2.6rem; color: var(--secondary); }
.as-examples { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.as-example { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 0.45rem 0.9rem; color: var(--text); font: inherit; font-size: 0.85rem; cursor: pointer; text-align: left; }
.as-example:hover { border-color: var(--secondary); color: var(--secondary); }

.as-msg { max-width: 820px; line-height: 1.55; font-size: 0.95rem; overflow-wrap: anywhere; }
.as-user { align-self: flex-end; background: var(--secondary); color: #fff; padding: 0.6rem 0.95rem; border-radius: 14px 14px 4px 14px; white-space: pre-wrap; max-width: 75%; }
.as-answer { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 0.8rem 1.1rem; border-radius: 14px 14px 14px 4px; }
.as-answer p { margin: 0 0 0.6rem; }
.as-answer p:last-child, .as-answer ul:last-child, .as-answer ol:last-child { margin-bottom: 0; }
.as-answer h4 { color: var(--primary); font-size: 0.98rem; margin: 0.9rem 0 0.4rem; }
.as-answer h4:first-child { margin-top: 0; }
.as-answer ul, .as-answer ol { margin: 0 0 0.6rem 1.3rem; }
.as-answer li { margin-bottom: 0.2rem; }
.as-answer strong { color: var(--primary); }
.as-answer a { color: var(--link); }
.as-answer code { background: var(--surface-3); padding: 0.05rem 0.3rem; border-radius: 4px; font-family: Consolas, monospace; font-size: 0.88em; }
.as-answer pre { background: var(--surface-3); padding: 0.7rem; border-radius: 6px; overflow-x: auto; margin: 0 0 0.6rem; }
.as-answer pre code { background: none; padding: 0; }
.as-answer hr { border: none; border-top: 1px solid var(--border); margin: 0.8rem 0; }
.as-table-wrap { overflow-x: auto; margin: 0 0 0.7rem; }
.as-answer table { border-collapse: collapse; font-size: 0.87rem; min-width: 60%; }
.as-answer th, .as-answer td { border: 1px solid var(--border); padding: 0.35rem 0.6rem; text-align: left; vertical-align: top; }
.as-answer th { background: var(--surface-3); color: var(--primary); font-weight: 600; }
.as-sources { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 0.8rem; padding-top: 0.6rem; border-top: 1px solid var(--border); color: var(--text-faint); font-size: 0.78rem; }
.as-sources span { background: var(--surface-3); border-radius: 10px; padding: 0.1rem 0.55rem; color: var(--text-light); }
/* Header of an open chat */
.as-chat-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding-bottom: 0.8rem; border-bottom: 1px solid var(--border); }
.as-chat-head-text { display: flex; flex-direction: column; min-width: 0; }
.as-chat-head-text strong { color: var(--primary); font-size: 1rem; overflow: hidden; text-overflow: ellipsis; }
.as-chat-head-text span { color: var(--text-faint); font-size: 0.78rem; }
.as-chat-head-actions { display: flex; gap: 0.4rem; }
.as-archived-tag { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 0 0.4rem; }

.as-actions { display: flex; gap: 0.4rem; margin-top: 0.7rem; }
.as-action { display: inline-flex; align-items: center; gap: 0.3rem; background: none; border: 1px solid var(--border); border-radius: 6px; padding: 0.2rem 0.6rem; color: var(--text-light); font: inherit; font-size: 0.78rem; cursor: pointer; }
.as-action:hover:not(:disabled) { border-color: var(--secondary); color: var(--secondary); }
.as-action:disabled { cursor: default; }

.as-error { color: var(--err-text); margin: 0; }
.as-warning { margin-top: 0.7rem; font-size: 0.85rem; }

.as-pending { display: flex; align-items: center; gap: 0.6rem; color: var(--text-light); }
.as-dots { display: inline-flex; gap: 4px; }
.as-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--secondary); opacity: 0.3; animation: as-blink 1.2s infinite; }
.as-dots i:nth-child(2) { animation-delay: 0.2s; }
.as-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes as-blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .as-dots i { animation: none; opacity: 0.7; } }

.as-form { display: flex; gap: 0.6rem; align-items: flex-end; padding: 0.9rem 2rem 0.3rem; border-top: 1px solid var(--border); }
.as-form textarea { flex: 1; resize: none; min-height: 46px; max-height: 200px; padding: 0.7rem 0.9rem; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--input-bg); color: var(--text); font: inherit; font-size: 0.95rem; line-height: 1.4; }
.as-form textarea:focus { outline: none; border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(var(--secondary-rgb), 0.15); }
.as-form button[type="submit"] { width: 46px; height: 46px; padding: 0; margin: 0; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; border-radius: 10px; flex: 0 0 46px; }
.as-form button[type="submit"]:disabled { opacity: 0.5; cursor: default; transform: none; }
.as-disclaimer { color: var(--text-faint); font-size: 0.75rem; padding: 0 2rem 0.8rem; margin: 0.3rem 0 0; }

@media (max-width: 900px) {
    .as-panel { flex-direction: column; height: auto; min-height: 0; overflow: visible; }
    .as-sidebar { width: 100%; flex: none; border-right: none; border-bottom: 1px solid var(--border); border-radius: 12px 12px 0 0; }
    .as-chat-list { max-height: 150px; }
    .as-chat-btn { opacity: 1; }
    .as-messages { padding: 1rem; min-height: 50vh; max-height: 65vh; }
    .as-form { padding: 0.8rem 1rem 0.3rem; }
    .as-disclaimer { padding: 0 1rem 0.8rem; }
    .as-user { max-width: 90%; }
}
.as-usage-sub { font-size: 0.72rem; color: var(--text-faint); }
.as-usage-err { margin-top: 0.25rem; font-size: 0.72rem; color: var(--err-text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
