/*
 * smooth-operator-react default stylesheet.
 *
 * Import once in your app:
 *   import '@smooai/smooth-operator/react/styles.css';
 *
 * EVERYTHING is driven by `--smooth-*` CSS custom properties declared on the
 * `.smooth-chat` root (NOT `:root`, so nothing leaks into your page). Retheme by
 * overriding any of them — in plain CSS, in a Tailwind `@layer base`, with
 * `theme()` tokens, via a `prefers-color-scheme` block, or per-instance with the
 * `<SmoothChat theme={…}>` prop (which sets these inline). You can also restyle
 * the `.smooth-chat__*` classes directly; treat this file as a starting point.
 */

.smooth-chat {
    /* ---- Themeable tokens (override these) ---- */
    --smooth-color-text: #0f172a;
    --smooth-color-bg: #ffffff;
    --smooth-color-surface: #f8fafc;
    --smooth-color-primary: #4f46e5;
    --smooth-color-primary-text: #ffffff;
    --smooth-color-assistant-bubble: #eef2ff;
    --smooth-color-assistant-bubble-text: #0f172a;
    --smooth-color-user-bubble: var(--smooth-color-primary);
    --smooth-color-user-bubble-text: var(--smooth-color-primary-text);
    --smooth-color-border: #e2e8f0;
    --smooth-color-muted: #64748b;
    --smooth-radius: 12px;
    --smooth-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    display: flex;
    flex-direction: column;
    background: var(--smooth-color-bg);
    color: var(--smooth-color-text);
    border: 1px solid var(--smooth-color-border);
    border-radius: var(--smooth-radius);
    overflow: hidden;
    font-family: var(--smooth-font);
}

.smooth-chat *,
.smooth-chat *::before,
.smooth-chat *::after {
    box-sizing: border-box;
}

.smooth-chat--panel {
    width: 100%;
    max-width: 420px;
    height: 560px;
}

.smooth-chat--fullpage {
    width: 100%;
    height: 100%;
    min-height: 100%;
    max-width: none;
    border: none;
    border-radius: 0;
}

/* ---- Header ---- */
.smooth-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--smooth-color-primary);
    color: var(--smooth-color-primary-text);
}
.smooth-chat__title {
    font-weight: 600;
    font-size: 15px;
}
.smooth-chat__status {
    font-size: 11px;
    opacity: 0.85;
}
.smooth-chat__status--error {
    opacity: 1;
    font-weight: 600;
}

/* ---- Messages ---- */
.smooth-chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--smooth-color-surface);
}

.smooth-chat__bubble {
    max-width: 82%;
    padding: 9px 12px;
    border-radius: var(--smooth-radius);
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}
.smooth-chat__bubble--assistant {
    align-self: flex-start;
    background: var(--smooth-color-assistant-bubble);
    color: var(--smooth-color-assistant-bubble-text);
    border-bottom-left-radius: 4px;
}
.smooth-chat__bubble--user {
    align-self: flex-end;
    background: var(--smooth-color-user-bubble);
    color: var(--smooth-color-user-bubble-text);
    border-bottom-right-radius: 4px;
}
.smooth-chat__greeting {
    opacity: 0.85;
    font-style: italic;
}

.smooth-chat__cursor::after {
    content: '▋';
    margin-left: 1px;
    animation: smooth-chat-blink 1s steps(2, start) infinite;
}
@keyframes smooth-chat-blink {
    to {
        visibility: hidden;
    }
}

/* ---- Sources / citations ---- */
.smooth-chat__sources {
    align-self: flex-start;
    max-width: 82%;
    margin-top: -4px;
    font-size: 12.5px;
    color: var(--smooth-color-muted);
}
.smooth-chat__sources summary {
    cursor: pointer;
    font-weight: 600;
    list-style: none;
    user-select: none;
    padding: 2px 0;
}
.smooth-chat__sources summary::-webkit-details-marker {
    display: none;
}
.smooth-chat__sources summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.15s ease;
}
.smooth-chat__sources details[open] summary::before {
    transform: rotate(90deg);
}
.smooth-chat__sources ol {
    margin: 6px 0 0;
    padding-left: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.smooth-chat__sources li {
    border-left: 2px solid var(--smooth-color-primary);
    padding-left: 10px;
}
.smooth-chat__source-title {
    color: var(--smooth-color-primary);
    text-decoration: none;
    font-weight: 600;
    word-break: break-word;
}
a.smooth-chat__source-title:hover {
    text-decoration: underline;
}
span.smooth-chat__source-title {
    color: var(--smooth-color-text);
    opacity: 0.95;
}
.smooth-chat__source-snippet {
    display: block;
    margin-top: 2px;
    opacity: 0.75;
    line-height: 1.4;
    white-space: normal;
}

/* ---- Composer ---- */
.smooth-chat__composer {
    display: flex;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid var(--smooth-color-border);
    background: var(--smooth-color-bg);
}
.smooth-chat__input {
    flex: 1;
    resize: none;
    border: 1px solid var(--smooth-color-border);
    border-radius: calc(var(--smooth-radius) - 4px);
    padding: 8px 10px;
    font-family: inherit;
    font-size: 14px;
    background: var(--smooth-color-bg);
    color: var(--smooth-color-text);
    max-height: 120px;
    line-height: 1.4;
}
.smooth-chat__input:focus {
    outline: 2px solid var(--smooth-color-primary);
    outline-offset: -1px;
}
.smooth-chat__send {
    border: none;
    border-radius: calc(var(--smooth-radius) - 4px);
    padding: 0 16px;
    cursor: pointer;
    background: var(--smooth-color-primary);
    color: var(--smooth-color-primary-text);
    font-weight: 600;
    font-size: 14px;
}
.smooth-chat__send:disabled {
    opacity: 0.5;
    cursor: default;
}

/* ---- Rich Interaction cards (choices / AskUserQuestion) ---- */
.smooth-chat__interaction {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--smooth-color-border);
    border-radius: var(--smooth-radius);
    background: var(--smooth-color-surface);
    color: var(--smooth-color-text);
    font-family: var(--smooth-font);
}
.smooth-chat__interaction-reason {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}
.smooth-chat__interaction-question {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    border: none;
}
.smooth-chat__interaction-legend {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0;
    margin-bottom: 2px;
}
.smooth-chat__interaction-header {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--smooth-color-muted);
}
.smooth-chat__interaction-prompt {
    font-size: 14px;
}
.smooth-chat__interaction-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--smooth-color-border);
    border-radius: calc(var(--smooth-radius) - 4px);
    cursor: pointer;
    background: var(--smooth-color-bg);
}
.smooth-chat__interaction-option--checked {
    border-color: var(--smooth-color-primary);
    outline: 1px solid var(--smooth-color-primary);
}
.smooth-chat__interaction-option input {
    margin-top: 2px;
    accent-color: var(--smooth-color-primary);
}
.smooth-chat__interaction-option:focus-within {
    outline: 2px solid var(--smooth-color-primary);
    outline-offset: 1px;
}
.smooth-chat__interaction-option-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.smooth-chat__interaction-option-label {
    font-size: 14px;
    font-weight: 500;
}
.smooth-chat__interaction-option-desc {
    font-size: 12px;
    color: var(--smooth-color-muted);
}
.smooth-chat__interaction-other-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 14px;
    outline: none;
}
.smooth-chat__interaction-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.smooth-chat__interaction-field-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    color: var(--smooth-color-muted);
}
.smooth-chat__interaction-required {
    color: var(--smooth-color-primary);
}
.smooth-chat__interaction-input {
    padding: 8px 10px;
    border: 1px solid var(--smooth-color-border);
    border-radius: calc(var(--smooth-radius) - 4px);
    background: var(--smooth-color-bg);
    color: var(--smooth-color-text);
    font: inherit;
    font-size: 14px;
    outline: none;
}
.smooth-chat__interaction-input:focus {
    border-color: var(--smooth-color-primary);
    outline: 1px solid var(--smooth-color-primary);
}
.smooth-chat__interaction-input--invalid {
    border-color: #dc2626;
}
.smooth-chat__interaction-error {
    margin: 0;
    font-size: 12px;
    color: #dc2626;
}
.smooth-chat__interaction-actions {
    display: flex;
    gap: 8px;
}
.smooth-chat__interaction-submit,
.smooth-chat__interaction-decline {
    border-radius: calc(var(--smooth-radius) - 4px);
    padding: 8px 16px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
}
.smooth-chat__interaction-submit {
    border: none;
    background: var(--smooth-color-primary);
    color: var(--smooth-color-primary-text);
}
.smooth-chat__interaction-decline {
    border: 1px solid var(--smooth-color-border);
    background: transparent;
    color: var(--smooth-color-text);
}
.smooth-chat__interaction-submit:disabled {
    opacity: 0.5;
    cursor: default;
}
