/*
 * local.aiagent chat UI.
 * Shared by the Bitrix admin test chat, transcript viewer, and future public widget.
 * Keep this file framework-neutral: no Bitrix-only selectors in core chat blocks.
 */

:root {
    --aiagent-page: #f7f7f4;
    --aiagent-card: #ffffff;
    --aiagent-card-soft: #fbfbf8;
    --aiagent-line: #deded7;
    --aiagent-line-soft: #ecece6;
    --aiagent-text: #1f1f1f;
    --aiagent-muted: #6f6f68;
    --aiagent-faint: #9a9a91;
    --aiagent-user: #f0f0ed;
    --aiagent-user-border: #e6e6df;
    --aiagent-accent: #10a37f;
    --aiagent-accent-deep: #0d7f68;
    --aiagent-accent-soft: #e7f6f1;
    --aiagent-launcher-bg: #202123;
    --aiagent-panel-bg: #ffffff;
    --aiagent-send-bg: #202123;
    --aiagent-widget-offset-x: 22px;
    --aiagent-widget-offset-bottom: 22px;
    --aiagent-danger: #b42318;
    --aiagent-code: #f4f4f0;
    --aiagent-shadow: 0 24px 70px rgba(32, 33, 35, .11);
    --aiagent-shadow-soft: 0 10px 28px rgba(32, 33, 35, .08);
    --aiagent-radius-xl: 28px;
    --aiagent-radius-lg: 18px;
    --aiagent-radius-md: 12px;
    --aiagent-font: "Söhne", "Aptos", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
    --aiagent-mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* === Chat Shell ======================================================== */

.aiagent-chat-frame {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    height: min(760px, calc(100vh - 220px));
    min-height: 560px;
    max-width: 940px;
    margin: 18px auto;
    overflow: hidden;
    background:
        radial-gradient(circle at 18% 0%, rgba(16, 163, 127, .08), transparent 34%),
        linear-gradient(180deg, var(--aiagent-panel-bg) 0%, var(--aiagent-card-soft) 100%);
    color: var(--aiagent-text);
    border: 1px solid var(--aiagent-line);
    border-radius: var(--aiagent-radius-xl);
    box-shadow: var(--aiagent-shadow);
    font-family: var(--aiagent-font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* === Header ============================================================ */

.aiagent-chat-header {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 72px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, .82);
    border-bottom: 1px solid var(--aiagent-line-soft);
    backdrop-filter: blur(18px);
    flex-shrink: 0;
}

.aiagent-chat-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 13px;
    background: linear-gradient(135deg, #18b58e, #087f68);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .04em;
    box-shadow: 0 8px 22px rgba(16, 163, 127, .24);
    flex-shrink: 0;
}

.aiagent-chat-title-block {
    flex: 1;
    min-width: 0;
}

.aiagent-chat-title {
    overflow: hidden;
    color: var(--aiagent-text);
    font-size: 15px;
    font-weight: 650;
    letter-spacing: -.01em;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aiagent-chat-subtitle {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 2px;
    color: var(--aiagent-muted);
    font-size: 12px;
}

.aiagent-chat-dot {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--aiagent-accent);
    box-shadow: 0 0 0 4px rgba(16, 163, 127, .12);
}

.aiagent-chat-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--aiagent-muted);
    background: #f5f5f1;
    border: 1px solid var(--aiagent-line-soft);
    border-radius: 12px;
    cursor: pointer;
    font-size: 18px;
    transition: background .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
    flex-shrink: 0;
}

.aiagent-chat-clear:hover {
    color: var(--aiagent-text);
    background: #eeeeea;
    border-color: var(--aiagent-line);
    transform: rotate(-12deg);
}

/* === Messages ========================================================== */

.aiagent-chat-messages {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 28px clamp(18px, 4vw, 46px) 22px;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #c9c9c1 transparent;
}

.aiagent-chat-messages::-webkit-scrollbar {
    width: 10px;
}

.aiagent-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.aiagent-chat-messages::-webkit-scrollbar-thumb {
    background: #c9c9c1;
    border: 3px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

.aiagent-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #adada5;
    border: 3px solid transparent;
    background-clip: padding-box;
}

.aiagent-chat-msg {
    display: flex;
    max-width: 100%;
    flex-direction: column;
    animation: aiagent-message-in .22s ease-out;
}

@keyframes aiagent-message-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.aiagent-chat-msg-user {
    align-items: flex-end;
}

.aiagent-chat-msg-bot {
    align-items: flex-start;
}

.aiagent-chat-author {
    margin: 0 7px 4px;
    color: var(--aiagent-muted);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: -.01em;
    line-height: 1.1;
}

.aiagent-chat-msg-user .aiagent-chat-author {
    color: var(--aiagent-faint);
}

.aiagent-chat-bubble {
    display: inline-block;
    width: auto;
    max-width: min(74%, 660px);
    margin: 0;
    padding: 11px 15px;
    color: var(--aiagent-text);
    line-height: 1.55;
    overflow-wrap: anywhere;
    word-break: normal;
}

.aiagent-chat-msg-user .aiagent-chat-bubble {
    background: var(--aiagent-user);
    border: 1px solid var(--aiagent-user-border);
    border-radius: 21px 21px 7px 21px;
    box-shadow: 0 1px 0 rgba(32, 33, 35, .04);
    white-space: pre-wrap;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble {
    display: block;
    width: 100%;
    max-width: min(88%, 760px);
    padding: 2px 0;
    background: transparent;
    border-radius: 0;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble:empty::before {
    content: "";
    display: block;
    width: 36px;
    height: 10px;
}

.aiagent-chat-meta {
    margin: 5px 7px 0;
    color: var(--aiagent-faint);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

/* === Rich Text ========================================================= */

.aiagent-chat-msg-bot .aiagent-chat-bubble strong {
    font-weight: 700;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble em {
    font-style: italic;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble a {
    color: var(--aiagent-accent-deep);
    text-decoration: underline;
    text-decoration-color: rgba(13, 127, 104, .28);
    text-underline-offset: 3px;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble a:hover {
    text-decoration-color: var(--aiagent-accent-deep);
}

.aiagent-chat-msg-bot .aiagent-chat-bubble code,
.aiagent-chat-bubble code {
    padding: 2px 6px;
    background: var(--aiagent-code);
    border: 1px solid var(--aiagent-line-soft);
    border-radius: 7px;
    font-family: var(--aiagent-mono);
    font-size: 13px;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble pre {
    max-width: 100%;
    margin: 14px 0;
    overflow-x: auto;
    padding: 14px 16px;
    background: var(--aiagent-send-bg);
    border: 1px solid #2f3033;
    border-radius: 14px;
    color: #f7f7f2;
    box-shadow: var(--aiagent-shadow-soft);
    font-size: 13px;
    line-height: 1.55;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble pre code {
    padding: 0;
    color: inherit;
    background: transparent;
    border: 0;
    border-radius: 0;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble ul,
.aiagent-chat-msg-bot .aiagent-chat-bubble ol {
    margin: 10px 0;
    padding-left: 24px;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble li {
    margin: 5px 0;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble table {
    width: 100%;
    margin: 14px 0;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border: 1px solid var(--aiagent-line);
    border-radius: 14px;
    box-shadow: 0 1px 0 rgba(32, 33, 35, .04);
}

.aiagent-chat-msg-bot .aiagent-chat-bubble th,
.aiagent-chat-msg-bot .aiagent-chat-bubble td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--aiagent-line-soft);
    text-align: left;
    vertical-align: top;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble th {
    background: #f4f4f0;
    font-weight: 650;
}

.aiagent-chat-msg-bot .aiagent-chat-bubble tr:last-child td {
    border-bottom: 0;
}

/* === Structured AI Components ========================================= */

.aiagent-component {
    width: 100%;
    margin: 16px 0;
    padding: 15px;
    background: rgba(255, 255, 255, .82);
    border: 1px solid var(--aiagent-line);
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(32, 33, 35, .06);
}

.aiagent-component-title {
    margin: 0 0 4px;
    color: var(--aiagent-text);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -.01em;
}

.aiagent-component-desc {
    max-width: 680px;
    margin: 0 0 12px;
    color: var(--aiagent-muted);
    font-size: 13px;
    line-height: 1.55;
}

.aiagent-table-scroll {
    overflow-x: auto;
    border: 1px solid var(--aiagent-line-soft);
    border-radius: 14px;
}

.aiagent-component .aiagent-table-scroll table {
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.aiagent-component .aiagent-table-scroll th,
.aiagent-component .aiagent-table-scroll td {
    min-width: 120px;
}

.aiagent-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 10px;
}

.aiagent-info-card {
    min-width: 0;
    padding: 13px;
    background: var(--aiagent-card-soft);
    border: 1px solid var(--aiagent-line-soft);
    border-radius: 15px;
}

.aiagent-info-card-title {
    color: var(--aiagent-text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.aiagent-info-card-subtitle {
    margin-top: 3px;
    color: var(--aiagent-faint);
    font-size: 12px;
}

.aiagent-info-card-text {
    margin-top: 9px;
    color: var(--aiagent-muted);
    font-size: 13px;
    line-height: 1.45;
}

.aiagent-info-card-value {
    margin-top: 10px;
    color: var(--aiagent-accent-deep);
    font-size: 18px;
    font-weight: 750;
    letter-spacing: -.02em;
}

.aiagent-info-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.aiagent-info-card-tags span {
    padding: 3px 8px;
    background: #ffffff;
    border: 1px solid var(--aiagent-line-soft);
    border-radius: 999px;
    color: var(--aiagent-muted);
    font-size: 11px;
}

.aiagent-component-link {
    display: inline-flex;
    align-items: center;
    margin-top: 12px;
    padding: 7px 10px;
    background: #202123;
    border-radius: 10px;
    color: #ffffff !important;
    font-size: 12px;
    font-weight: 650;
    text-decoration: none !important;
}

.aiagent-component-link:hover {
    background: #111214;
}

.aiagent-chart-bars {
    display: grid;
    gap: 12px;
}

.aiagent-chart-label {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
    color: var(--aiagent-muted);
    font-size: 12px;
}

.aiagent-chart-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aiagent-chart-label strong {
    color: var(--aiagent-text);
    font-size: 12px;
    white-space: nowrap;
}

.aiagent-chart-track {
    height: 10px;
    overflow: hidden;
    background: #ecece6;
    border-radius: 999px;
}

.aiagent-chart-fill {
    height: 100%;
    min-width: 3px;
    background: linear-gradient(90deg, var(--aiagent-accent), var(--aiagent-accent-deep));
    border-radius: inherit;
}

.aiagent-diagram-flow {
    display: grid;
    gap: 10px;
}

.aiagent-diagram-step {
    position: relative;
    display: grid;
    grid-template-columns: 32px 1fr;
    gap: 10px;
    min-width: 0;
}

.aiagent-diagram-step:not(:last-child)::after {
    content: "";
    position: absolute;
    top: 34px;
    left: 15px;
    width: 2px;
    height: calc(100% - 22px);
    background: var(--aiagent-line);
}

.aiagent-diagram-num {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--aiagent-accent-soft);
    border: 1px solid rgba(16, 163, 127, .2);
    border-radius: 12px;
    color: var(--aiagent-accent-deep);
    font-size: 12px;
    font-weight: 750;
}

.aiagent-diagram-label {
    color: var(--aiagent-text);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.35;
}

.aiagent-diagram-text {
    margin-top: 3px;
    color: var(--aiagent-muted);
    font-size: 13px;
    line-height: 1.45;
}

.aiagent-lead-form {
    display: grid;
    gap: 10px;
}

.aiagent-lead-form label {
    display: grid;
    gap: 5px;
    color: var(--aiagent-muted);
    font-size: 12px;
}

.aiagent-lead-form input,
.aiagent-lead-form select,
.aiagent-lead-form textarea {
    width: 100%;
    min-height: 39px;
    padding: 9px 11px;
    color: var(--aiagent-text);
    background: #ffffff;
    border: 1px solid var(--aiagent-line);
    border-radius: 11px;
    font: 13px/1.35 var(--aiagent-font);
    outline: none;
}

.aiagent-lead-form textarea {
    min-height: 82px;
    resize: vertical;
}

.aiagent-lead-form input:focus,
.aiagent-lead-form select:focus,
.aiagent-lead-form textarea:focus {
    border-color: rgba(16, 163, 127, .52);
    box-shadow: 0 0 0 3px rgba(16, 163, 127, .1);
}

.aiagent-lead-form button {
    justify-self: start;
    min-height: 38px;
    padding: 9px 13px;
    background: var(--aiagent-accent);
    border: 0;
    border-radius: 11px;
    color: #ffffff;
    cursor: pointer;
    font: 650 13px/1 var(--aiagent-font);
}

.aiagent-lead-form button:hover {
    background: var(--aiagent-accent-deep);
}

.aiagent-lead-form-note {
    color: var(--aiagent-faint);
    font-size: 12px;
}

.aiagent-chat-error {
    display: inline-block;
    margin-top: 8px;
    color: var(--aiagent-danger);
}

/* === Typing Indicator ================================================== */

.aiagent-chat-typing-wrap {
    margin-top: 2px;
}

.aiagent-chat-typing {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    width: auto !important;
    padding: 11px 14px !important;
    background: var(--aiagent-user) !important;
    border: 1px solid var(--aiagent-user-border) !important;
    border-radius: 18px 18px 18px 6px !important;
}

.aiagent-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #8f8f88;
    animation: aiagent-typing 1.1s infinite ease-in-out both;
}

.aiagent-chat-typing span:nth-child(2) {
    animation-delay: .14s;
}

.aiagent-chat-typing span:nth-child(3) {
    animation-delay: .28s;
}

@keyframes aiagent-typing {
    0%, 80%, 100% {
        opacity: .34;
        transform: translateY(0) scale(.72);
    }
    40% {
        opacity: 1;
        transform: translateY(-2px) scale(1);
    }
}

/* === Citations ========================================================= */

.aiagent-chat-citations {
    margin-top: 14px;
    padding-top: 10px;
    border-top: 1px solid var(--aiagent-line-soft);
    color: var(--aiagent-muted);
    font-size: 12px;
    line-height: 1.7;
}

.aiagent-chat-cit-label {
    margin-right: 6px;
    color: var(--aiagent-faint);
}

.aiagent-chat-cit-chip {
    display: inline-flex;
    align-items: center;
    max-width: 240px;
    margin: 2px 4px 2px 0;
    overflow: hidden;
    padding: 3px 9px;
    background: var(--aiagent-accent-soft);
    border: 1px solid rgba(16, 163, 127, .16);
    border-radius: 999px;
    color: var(--aiagent-accent-deep);
    font-family: var(--aiagent-mono);
    font-size: 11px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Input ============================================================= */

.aiagent-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 16px 18px 18px;
    background: rgba(255, 255, 255, .9);
    border-top: 1px solid var(--aiagent-line-soft);
    flex-shrink: 0;
}

.aiagent-chat-input {
    flex: 1;
    min-height: 48px;
    max-height: 180px;
    resize: none;
    padding: 13px 16px;
    color: var(--aiagent-text);
    background: #ffffff;
    border: 1px solid var(--aiagent-line);
    border-radius: 18px;
    box-shadow: 0 2px 10px rgba(32, 33, 35, .04);
    font: inherit;
    line-height: 1.45;
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.aiagent-chat-input::placeholder {
    color: var(--aiagent-faint);
}

.aiagent-chat-input:focus {
    background: #ffffff;
    border-color: rgba(16, 163, 127, .52);
    box-shadow: 0 0 0 4px rgba(16, 163, 127, .12), 0 8px 22px rgba(32, 33, 35, .08);
}

.aiagent-chat-send {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    color: #ffffff;
    background: #202123;
    border: 0;
    border-radius: 16px;
    box-shadow: 0 12px 26px rgba(32, 33, 35, .18);
    cursor: pointer;
    transition: transform .14s ease, box-shadow .14s ease, background .14s ease;
    flex-shrink: 0;
}

.aiagent-chat-send:hover:not(:disabled) {
    background: #111214;
    box-shadow: 0 16px 32px rgba(32, 33, 35, .22);
    transform: translateY(-1px);
}

.aiagent-chat-send:active:not(:disabled) {
    transform: translateY(0);
}

.aiagent-chat-send:disabled {
    color: #aaa;
    background: #deded8;
    box-shadow: none;
    cursor: not-allowed;
}

.aiagent-chat-send svg {
    display: block;
}

/* === Public Floating Widget =========================================== */

.aiagent-public-widget {
    position: fixed;
    right: var(--aiagent-widget-offset-x);
    bottom: var(--aiagent-widget-offset-bottom);
    z-index: 2147483000;
    font-family: var(--aiagent-font);
}

.aiagent-public-widget[data-aiagent-position="left"] {
    right: auto;
    left: var(--aiagent-widget-offset-x);
}

.aiagent-public-widget[data-aiagent-position="center"] {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

.aiagent-public-widget *,
.aiagent-public-widget *::before,
.aiagent-public-widget *::after {
    box-sizing: border-box;
}

.aiagent-public-launcher {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 54px;
    padding: 8px 16px 8px 8px;
    color: #ffffff;
    background: var(--aiagent-launcher-bg);
    border: 0;
    border-radius: 999px;
    box-shadow: 0 18px 46px rgba(32, 33, 35, .28);
    cursor: pointer;
    font: 700 14px/1 var(--aiagent-font);
    letter-spacing: -.01em;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.aiagent-public-launcher:hover {
    background: #111214;
    box-shadow: 0 22px 56px rgba(32, 33, 35, .34);
    transform: translateY(-2px);
}

.aiagent-public-launcher-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 14px;
    background: linear-gradient(135deg, #18b58e, #087f68);
    color: #ffffff;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .05em;
}

.aiagent-public-panel {
    position: absolute;
    right: 0;
    bottom: 70px;
    width: min(420px, calc(100vw - 28px));
    transform-origin: right bottom;
    animation: aiagent-public-panel-in .18s ease-out;
}

@keyframes aiagent-public-panel-in {
    from {
        opacity: 0;
        transform: translateY(12px) scale(.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.aiagent-public-widget[data-aiagent-position="left"] .aiagent-public-panel {
    right: auto;
    left: 0;
    transform-origin: left bottom;
}

.aiagent-public-widget[data-aiagent-position="center"] .aiagent-public-panel {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    transform-origin: center bottom;
}

.aiagent-public-widget[data-aiagent-theme="graphite"] {
    --aiagent-accent: #4b5563;
    --aiagent-accent-deep: #111827;
    --aiagent-accent-soft: #eef0f3;
    --aiagent-launcher-bg: #111827;
    --aiagent-send-bg: #111827;
    --aiagent-user: #eef0f3;
}

.aiagent-public-widget[data-aiagent-theme="blue"] {
    --aiagent-accent: #2563eb;
    --aiagent-accent-deep: #1d4ed8;
    --aiagent-accent-soft: #eaf1ff;
    --aiagent-launcher-bg: #172554;
    --aiagent-send-bg: #1d4ed8;
    --aiagent-user: #edf4ff;
}

.aiagent-public-widget[data-aiagent-theme="sand"] {
    --aiagent-accent: #b7791f;
    --aiagent-accent-deep: #8a5a17;
    --aiagent-accent-soft: #fff4db;
    --aiagent-launcher-bg: #3d2f1f;
    --aiagent-send-bg: #8a5a17;
    --aiagent-user: #f7efe1;
}

.aiagent-public-widget[data-aiagent-theme="surron"] {
    --aiagent-accent: #f97316;
    --aiagent-accent-deep: #c2410c;
    --aiagent-accent-soft: #fff1e8;
    --aiagent-launcher-bg: #111111;
    --aiagent-send-bg: #111111;
    --aiagent-user: #fff3eb;
}

.aiagent-public-widget[data-aiagent-theme="leasing"] {
    --aiagent-accent: #0f766e;
    --aiagent-accent-deep: #115e59;
    --aiagent-accent-soft: #e6fffb;
    --aiagent-launcher-bg: #0f172a;
    --aiagent-send-bg: #0f766e;
    --aiagent-user: #ecfdf5;
}

.aiagent-chat-frame.aiagent-chat-frame-public {
    width: 100%;
    height: min(680px, calc(100dvh - 112px));
    min-height: 520px;
    max-width: none;
    margin: 0;
    border-radius: 26px;
}

.aiagent-chat-frame-public .aiagent-chat-header {
    min-height: 66px;
    padding: 14px 15px;
}

.aiagent-public-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--aiagent-muted);
    background: #f5f5f1;
    border: 1px solid var(--aiagent-line-soft);
    border-radius: 12px;
    cursor: pointer;
    font: 400 24px/1 var(--aiagent-font);
    transition: background .16s ease, border-color .16s ease, color .16s ease;
    flex-shrink: 0;
}

.aiagent-public-close:hover {
    color: var(--aiagent-text);
    background: #eeeeea;
    border-color: var(--aiagent-line);
}

.aiagent-chat-frame-public .aiagent-chat-messages {
    padding: 22px 18px 18px;
}

.aiagent-chat-frame-public .aiagent-chat-bubble {
    max-width: 86%;
}

.aiagent-chat-frame-public .aiagent-chat-msg-bot .aiagent-chat-bubble {
    max-width: 96%;
}

.aiagent-chat-frame-public .aiagent-chat-input-row {
    padding: 13px;
}

.aiagent-chat-frame-public .aiagent-chat-input {
    min-height: 44px;
    min-width: 0;
    border-radius: 16px;
    font-size: 14px;
}

.aiagent-chat-frame-public .aiagent-chat-send {
    width: 44px;
    height: 44px;
    border-radius: 15px;
}

/* === Transcript View =================================================== */

.aiagent-chat-frame.aiagent-chat-frame-static {
    height: min(740px, calc(100vh - 300px));
    min-height: 460px;
}

.aiagent-chat-frame.aiagent-chat-frame-static .aiagent-chat-messages {
    overflow-y: auto;
    padding-bottom: 28px;
}

.aiagent-transcript-toolbar {
    max-width: 940px;
    margin: 0 auto 12px;
}

.aiagent-transcript-meta {
    max-width: 940px;
    margin: 0 auto 16px;
    padding: 16px 18px;
    background: #ffffff;
    border: 1px solid var(--aiagent-line);
    border-radius: 18px;
    box-shadow: var(--aiagent-shadow-soft);
    color: var(--aiagent-text);
    font: 13px/1.65 var(--aiagent-font);
}

.aiagent-transcript-meta a {
    color: var(--aiagent-accent-deep);
}

.aiagent-transcript-meta code {
    padding: 2px 6px;
    background: var(--aiagent-code);
    border-radius: 7px;
    color: #3b3b37;
    font-family: var(--aiagent-mono);
    font-size: 11px;
}

/* === Conversation List ================================================= */

.aiagent-admin-panel {
    margin: 14px 0;
    padding: 16px 18px;
    background: #ffffff;
    border: 1px solid var(--aiagent-line);
    border-radius: 18px;
    box-shadow: var(--aiagent-shadow-soft);
    font-family: var(--aiagent-font);
}

.aiagent-admin-kpis {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 14px;
}

.aiagent-admin-kpi {
    padding: 10px 13px;
    background: var(--aiagent-card-soft);
    border: 1px solid var(--aiagent-line-soft);
    border-radius: 14px;
    color: var(--aiagent-muted);
    font-size: 13px;
}

.aiagent-admin-kpi strong {
    color: var(--aiagent-text);
    font-size: 16px;
}

.aiagent-conv-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
    margin: 0;
}

.aiagent-conv-filter label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: var(--aiagent-muted);
    font-size: 12px;
}

.aiagent-conv-filter input[type="date"],
.aiagent-conv-filter input[type="text"] {
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--aiagent-line);
    border-radius: 10px;
    color: var(--aiagent-text);
    background: #ffffff;
}

.aiagent-conv-filter input[name="q"] {
    width: min(420px, 72vw);
}

.aiagent-conv-table-wrap {
    overflow-x: auto;
    margin-top: 14px;
    background: #ffffff;
    border: 1px solid var(--aiagent-line);
    border-radius: 18px;
    box-shadow: var(--aiagent-shadow-soft);
}

.aiagent-conv-table-wrap .adm-list-table {
    margin: 0;
    border: 0;
}

.aiagent-conv-table-wrap .adm-list-table-header td {
    background: #f5f5f1 !important;
}

.aiagent-conv-table-wrap .adm-list-table-row:hover td {
    background: #fbfbf7 !important;
}

.aiagent-conv-url,
.aiagent-conv-snippet {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aiagent-conv-url {
    max-width: 280px;
}

.aiagent-conv-snippet {
    max-width: 420px;
    color: #55554f;
}

.aiagent-muted {
    color: var(--aiagent-faint);
}

.aiagent-pager {
    margin: 16px 0;
    text-align: center;
}

@media (max-width: 760px) {
    .aiagent-chat-frame {
        height: calc(100vh - 170px);
        min-height: 480px;
        margin: 10px 0;
        border-radius: 22px;
    }

    .aiagent-chat-messages {
        padding: 22px 16px 18px;
    }

    .aiagent-chat-bubble,
    .aiagent-chat-msg-bot .aiagent-chat-bubble {
        max-width: 92%;
    }

    .aiagent-chat-input-row {
        padding: 12px;
    }

    .aiagent-component {
        padding: 12px;
        border-radius: 16px;
    }

    .aiagent-card-grid {
        grid-template-columns: 1fr;
    }

    .aiagent-transcript-meta,
    .aiagent-transcript-toolbar {
        max-width: none;
    }

    .aiagent-public-widget {
        right: max(var(--aiagent-widget-offset-x), env(safe-area-inset-right));
        bottom: calc(var(--aiagent-widget-offset-bottom) + 54px + env(safe-area-inset-bottom));
        left: max(var(--aiagent-widget-offset-x), env(safe-area-inset-left));
        display: flex;
        justify-content: flex-end;
        pointer-events: none;
        transform: none;
    }

    .aiagent-public-widget[data-aiagent-position="left"] {
        justify-content: flex-start;
    }

    .aiagent-public-widget[data-aiagent-position="center"] {
        justify-content: center;
    }

    .aiagent-public-launcher,
    .aiagent-public-panel {
        pointer-events: auto;
    }

    .aiagent-public-launcher {
        margin-left: auto;
    }

    .aiagent-public-widget[data-aiagent-position="left"] .aiagent-public-launcher {
        margin-right: auto;
        margin-left: 0;
    }

    .aiagent-public-panel {
        position: fixed;
        right: max(8px, env(safe-area-inset-right));
        bottom: calc(70px + env(safe-area-inset-bottom));
        left: max(8px, env(safe-area-inset-left));
        width: auto;
    }

    .aiagent-public-widget[data-aiagent-position="left"] .aiagent-public-panel {
        right: max(8px, env(safe-area-inset-right));
        left: max(8px, env(safe-area-inset-left));
    }

    .aiagent-chat-frame.aiagent-chat-frame-public {
        height: min(640px, calc(100dvh - 88px));
        min-height: min(460px, calc(100dvh - 88px));
        border-radius: 22px;
    }

    .aiagent-public-launcher-text {
        display: none;
    }

    .aiagent-public-launcher {
        min-height: 56px;
        padding: 9px;
    }

    .aiagent-public-launcher-icon {
        width: 40px;
        height: 40px;
    }

    .aiagent-chat-frame-public .aiagent-chat-header {
        padding: 12px;
    }

    .aiagent-chat-frame-public .aiagent-chat-messages {
        padding: 18px 14px 14px;
    }

    .aiagent-chat-frame-public .aiagent-chat-input-row {
        gap: 8px;
        padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    }

    .aiagent-chat-frame-public .aiagent-chat-send {
        width: 42px;
        height: 42px;
        border-radius: 14px;
    }
}
