/* /assets/css/chat.css — paired with /assets/js/chat.js.
 *
 * Variables fall back to dumbshit's defaults if the host app hasn't defined
 * them (so the panel works dropped into any page). Override per-app by
 * setting --bg, --bg-2, --border, --text, --text-dim, --text-mute, --accent
 * on a container.
 */

.chat-panel {
    background: var(--bg-2, #18181b);
    border: 1px solid var(--border, #3f3f46);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: 500px;
    overflow: hidden;
    color: var(--text, #fafafa);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border, #3f3f46);
    color: var(--text-dim, #a1a1aa);
    font-family: ui-monospace, monospace;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.chat-toggle {
    appearance: none;
    background: transparent;
    border: 0;
    color: var(--text-dim, #a1a1aa);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    line-height: 1;
}
.chat-toggle:hover { color: var(--text, #fafafa); }

.chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.chat-msg { word-wrap: break-word; overflow-wrap: anywhere; }
.chat-msg .who {
    color: var(--accent, #10b981);
    font-weight: 700;
    margin-right: 6px;
}
.chat-msg.system {
    color: var(--text-mute, #71717a);
    font-style: italic;
}
.chat-msg.system .who {
    color: var(--text-mute, #71717a);
    font-weight: 400;
    margin-right: 6px;
}

.chat-form {
    display: flex;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid var(--border, #3f3f46);
    align-items: stretch;
}
/* `flex: 1 1 0` + `min-width: 0` lets the input shrink/grow in the flex
   container regardless of placeholder length. */
.chat-form input {
    flex: 1 1 0;
    min-width: 0;
    margin: 0;
    background: var(--bg, #09090b);
    border: 1px solid var(--border, #3f3f46);
    border-radius: 6px;
    color: var(--text, #fafafa);
    font-family: ui-monospace, monospace;
    font-size: 12px;
    padding: 8px 10px;
}
.chat-form input:focus {
    outline: none;
    border-color: var(--accent, #10b981);
}
/* `flex: 0 0 auto` + `width: auto` defend against host pages that style
   `.btn { width: 100% }` site-wide — without this the Send button expanded
   to 100% and squeezed the input to nothing. */
.chat-form .btn {
    appearance: none;
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    border: 1px solid var(--accent, #10b981);
    background: var(--accent, #10b981);
    color: var(--bg, #09090b);
    font-family: inherit;
    font-weight: 700;
    font-size: 12px;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: filter 0.12s;
}
.chat-form .btn:hover  { filter: brightness(1.1); }
.chat-form .btn:active { filter: brightness(0.95); }

.chat-panel.is-collapsed .chat-log,
.chat-panel.is-collapsed .chat-form { display: none; }
.chat-panel.is-collapsed { height: auto; }

/* Ensure the input doesn't trigger iOS auto-zoom — chat.css ships with this
   baked in so any page picking up chat.js also gets the fix, even if
   responsive.css isn't included for some reason. */
@media (max-width: 640px) {
    .chat-form input { font-size: 16px; }
}
