/* Agent Platform UI
   Scoped under .ap-* class names so it cannot affect the notification tool's
   existing pages, which load static/style.css instead. */

:root {
    --ap-bg: #f4f6fb;
    --ap-surface: #ffffff;
    --ap-sidebar-bg: #131a2b;
    --ap-sidebar-fg: #9aa6c0;
    --ap-sidebar-fg-active: #ffffff;
    --ap-border: #e4e8f2;
    --ap-text: #1b2338;
    --ap-muted: #6b7590;
    --ap-primary: #4b5ee4;
    --ap-primary-soft: #eef0fe;
    --ap-success: #16a34a;
    --ap-warning: #d97706;
    --ap-danger: #dc2626;
    --ap-radius: 14px;
    --ap-shadow: 0 1px 2px rgba(19, 26, 43, .06), 0 8px 24px rgba(19, 26, 43, .06);
    --ap-sidebar-width: 260px;
}

body {
    margin: 0;
    background: var(--ap-bg);
    color: var(--ap-text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------- Layout ---------- */
.ap-layout { display: flex; min-height: 100vh; }

.ap-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ap-content {
    padding: 1.75rem clamp(1rem, 3vw, 2.25rem) 3rem;
    flex: 1;
}

/* ---------- Sidebar ---------- */
.ap-sidebar {
    width: var(--ap-sidebar-width);
    flex-shrink: 0;
    background: var(--ap-sidebar-bg);
    color: var(--ap-sidebar-fg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.ap-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.ap-brand-mark {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--ap-primary), #7c4be4);
    color: #fff;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.ap-brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ap-brand-text strong { color: #fff; font-size: .98rem; }
.ap-brand-text small { color: var(--ap-sidebar-fg); font-size: .74rem; }

.ap-sidebar-close, .ap-menu-toggle {
    color: inherit;
    border: none;
    background: transparent;
    margin-left: auto;
}

.ap-nav { padding: 1rem .75rem; flex: 1; }
.ap-nav-group + .ap-nav-group { margin-top: 1.25rem; }

.ap-nav-heading {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #5d6884;
    margin: 0 0 .4rem .6rem;
    font-weight: 600;
}

.ap-nav-link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .58rem .7rem;
    border-radius: 9px;
    color: var(--ap-sidebar-fg);
    text-decoration: none;
    font-size: .9rem;
    transition: background .15s ease, color .15s ease;
}

.ap-nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.ap-nav-link.is-active { background: var(--ap-primary); color: var(--ap-sidebar-fg-active); font-weight: 500; }
.ap-nav-link.is-pending { opacity: .62; }
.ap-nav-link i { font-size: 1rem; width: 1.1rem; text-align: center; }

.ap-badge-soon {
    margin-left: auto;
    font-size: .62rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .13rem .42rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, .12);
    color: #c6cee2;
}

.ap-card-header .ap-badge-soon {
    background: var(--ap-primary-soft);
    color: var(--ap-primary);
}

.ap-sidebar-footer { padding: .75rem; border-top: 1px solid rgba(255, 255, 255, .07); }
.ap-sidebar-backdrop { display: none; }

/* ---------- Header ---------- */
.ap-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem clamp(1rem, 3vw, 2.25rem);
    background: var(--ap-surface);
    border-bottom: 1px solid var(--ap-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.ap-header-titles { min-width: 0; flex: 1; }
.ap-page-title { font-size: 1.22rem; font-weight: 650; margin: 0; }
.ap-page-subtitle { margin: .15rem 0 0; color: var(--ap-muted); font-size: .85rem; }

.ap-header-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.ap-status-pill {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .34rem .7rem;
    border-radius: 20px;
    background: var(--ap-bg);
    border: 1px solid var(--ap-border);
    font-size: .78rem;
    color: var(--ap-muted);
    white-space: nowrap;
}

.ap-status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--ap-muted);
}

.ap-status-pill.is-online .ap-status-dot { background: var(--ap-success); }
.ap-status-pill.is-degraded .ap-status-dot { background: var(--ap-warning); }
.ap-status-pill.is-disabled .ap-status-dot { background: var(--ap-danger); }

.ap-version-tag {
    font-size: .75rem;
    color: var(--ap-muted);
    padding: .3rem .55rem;
    border-radius: 7px;
    background: var(--ap-bg);
    border: 1px solid var(--ap-border);
}

/* ---------- Cards ---------- */
.ap-card {
    background: var(--ap-surface);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow);
    overflow: hidden;
}

.ap-card-header {
    padding: 1.05rem 1.25rem .7rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
}

.ap-card-title { font-size: .98rem; font-weight: 640; margin: 0; }
.ap-card-subtitle { margin: .1rem 0 0; font-size: .82rem; color: var(--ap-muted); flex-basis: 100%; }
.ap-card-body { padding: .5rem 1.25rem 1.25rem; }

.ap-sticky { position: sticky; top: 90px; }

/* ---------- Stats ---------- */
.ap-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 1rem;
}

.ap-stat {
    background: var(--ap-surface);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--ap-shadow);
    margin: 0;
}

.ap-stat-label {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--ap-muted);
    margin: 0 0 .35rem;
    font-weight: 600;
}

.ap-stat-value {
    font-size: 1.3rem;
    font-weight: 650;
    margin: 0;
    overflow-wrap: anywhere;
}

.ap-stat-meta { margin: .3rem 0 0; font-size: .8rem; color: var(--ap-muted); }

.ap-chip {
    display: inline-block;
    padding: .15rem .55rem;
    border-radius: 20px;
    font-size: .74rem;
    font-weight: 550;
}

.ap-chip-online { background: #dcfce7; color: #15803d; }
.ap-chip-degraded { background: #fef3c7; color: #b45309; }
.ap-chip-disabled { background: #fee2e2; color: #b91c1c; }
.ap-chip-idle { background: var(--ap-bg); color: var(--ap-muted); }

/* ---------- Lists ---------- */
.ap-capability-list { list-style: none; margin: 0; padding: 0; }

.ap-capability-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .7rem 0;
    border-bottom: 1px solid var(--ap-border);
    font-size: .88rem;
}

.ap-capability-list li:last-child { border-bottom: none; }
.ap-capability-list i { color: var(--ap-muted); margin-right: .45rem; }
.ap-capability-value { text-align: right; }
.ap-capability-value code {
    background: var(--ap-primary-soft);
    color: var(--ap-primary);
    padding: .1rem .4rem;
    border-radius: 5px;
    font-size: .78rem;
}

.ap-list { list-style: none; margin: 0; padding: 0; }
.ap-list-item { border-bottom: 1px solid var(--ap-border); }
.ap-list-item:last-child { border-bottom: none; }

.ap-list-item a {
    display: flex;
    flex-direction: column;
    padding: .65rem .3rem;
    text-decoration: none;
    color: var(--ap-text);
    border-radius: 8px;
}

.ap-list-item a:hover { background: var(--ap-bg); }
.ap-list-title { font-size: .87rem; font-weight: 520; }
.ap-list-meta { font-size: .76rem; color: var(--ap-muted); }
.ap-list-empty { font-size: .85rem; color: var(--ap-muted); padding: .5rem .3rem; }

.ap-empty { text-align: center; padding: 1.75rem 1rem; color: var(--ap-muted); }
.ap-empty i { font-size: 1.7rem; opacity: .5; display: block; margin-bottom: .5rem; }
.ap-empty p { margin: 0 0 .6rem; font-size: .9rem; }

/* ---------- Module cards ---------- */
.ap-module-card {
    display: flex;
    flex-direction: column;
    gap: .3rem;
    height: 100%;
    padding: 1rem;
    border: 1px solid var(--ap-border);
    border-radius: 11px;
    text-decoration: none;
    color: var(--ap-text);
    background: var(--ap-bg);
    transition: border-color .15s ease, transform .15s ease;
}

.ap-module-card:hover { border-color: var(--ap-primary); transform: translateY(-2px); }
.ap-module-card i { font-size: 1.25rem; color: var(--ap-primary); }
.ap-module-name { font-weight: 600; font-size: .9rem; }
.ap-module-desc { font-size: .8rem; color: var(--ap-muted); }

/* ---------- Coming soon ---------- */
.ap-coming-soon { text-align: center; padding: 3rem 1.5rem; max-width: 520px; margin: 0 auto; }

.ap-coming-icon {
    width: 68px; height: 68px;
    display: grid; place-items: center;
    margin: 0 auto 1.1rem;
    border-radius: 18px;
    background: var(--ap-primary-soft);
    color: var(--ap-primary);
    font-size: 1.8rem;
}

.ap-coming-soon h2 { font-size: 1.3rem; font-weight: 650; margin: 0 0 .5rem; }
.ap-coming-desc { color: var(--ap-text); font-size: .95rem; margin-bottom: .75rem; }
.ap-coming-note { color: var(--ap-muted); font-size: .85rem; margin-bottom: 1.5rem; }

/* ---------- Forms ---------- */
.ap-form .form-label { font-weight: 540; font-size: .85rem; margin-bottom: .35rem; }
.ap-form .form-control, .ap-form .form-select { border-color: var(--ap-border); }

.ap-form .form-control:focus, .ap-form .form-select:focus {
    border-color: var(--ap-primary);
    box-shadow: 0 0 0 .2rem rgba(75, 94, 228, .16);
}

.ap-prompt { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.55; }
.ap-switch-lg .form-check-input { width: 2.6em; height: 1.35em; }
.ap-disabled-section { opacity: .72; }
.ap-btn-spinner { display: inline-flex; align-items: center; gap: .4rem; }

/* ---------- Chat ---------- */
.ap-chat-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 1.25rem;
    align-items: start;
}

.ap-chat-card {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 190px);
    min-height: 440px;
}

.ap-chat-thread {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.ap-chat-empty { margin: auto; }
.ap-chat-empty span { font-size: .82rem; }

.ap-message { display: flex; gap: .7rem; max-width: 82%; }
.ap-message-user { margin-left: auto; flex-direction: row-reverse; }

.ap-avatar {
    width: 30px; height: 30px;
    flex-shrink: 0;
    border-radius: 9px;
    display: grid; place-items: center;
    font-size: .82rem;
}

.ap-avatar-agent { background: var(--ap-primary-soft); color: var(--ap-primary); }
.ap-avatar-user { background: #e8ebf3; color: var(--ap-muted); }

.ap-bubble {
    padding: .65rem .9rem;
    border-radius: 13px;
    background: var(--ap-bg);
    font-size: .89rem;
    line-height: 1.55;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.ap-message-user .ap-bubble { background: var(--ap-primary); color: #fff; }
.ap-message-error .ap-bubble { background: #fee2e2; color: #991b1b; }
.ap-bubble-meta { display: block; margin-top: .35rem; font-size: .7rem; opacity: .65; }

/* ---------- Tool list (configuration page) ---------- */
.ap-tool-list { display: flex; flex-direction: column; gap: .5rem; }

.ap-tool {
    display: flex; gap: .65rem; align-items: flex-start;
    padding: .6rem .7rem;
    border: 1px solid var(--ap-border);
    border-radius: 11px;
    cursor: pointer;
}
.ap-tool:hover { border-color: var(--ap-primary); background: var(--ap-primary-soft); }
.ap-tool .form-check-input { margin-top: .15rem; flex-shrink: 0; }
.ap-tool-body { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.ap-tool-name { font-size: .82rem; font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.ap-tool-desc {
    font-size: .75rem; color: var(--ap-muted); line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Message column: bubble plus any product cards the turn produced. */
.ap-message-column { display: flex; flex-direction: column; gap: .6rem; min-width: 0; }
.ap-message-user .ap-message-column { align-items: flex-end; }

/* ---------- Product card ---------- */
.ap-product-card {
    display: flex;
    gap: 1rem;
    padding: .9rem;
    background: var(--ap-surface);
    border: 1px solid var(--ap-border);
    border-radius: var(--ap-radius);
    box-shadow: var(--ap-shadow);
    max-width: 460px;
}

.ap-product-media {
    flex: 0 0 96px;
    width: 96px; height: 96px;
    border-radius: 11px;
    background: var(--ap-bg);
    display: grid; place-items: center;
    overflow: hidden;
}
.ap-product-media img { width: 100%; height: 100%; object-fit: contain; }

.ap-product-body { display: flex; flex-direction: column; gap: .45rem; min-width: 0; flex: 1; }

.ap-product-store {
    font-size: .68rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--ap-muted);
}

.ap-product-title {
    margin: 0;
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.4;
    /* Amazon titles run very long; two lines is enough to identify the item. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ap-product-facts { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.ap-product-price { font-size: 1.15rem; font-weight: 700; color: var(--ap-text); }

.ap-chip-soft {
    padding: .15rem .5rem;
    border-radius: 999px;
    background: var(--ap-bg);
    color: var(--ap-muted);
    font-size: .72rem;
    font-weight: 500;
}

.ap-cost-table {
    margin-top: .3rem;
    border-top: 1px solid var(--ap-border);
    padding-top: .5rem;
    display: flex; flex-direction: column; gap: .25rem;
}
.ap-cost-row { display: flex; justify-content: space-between; gap: 1rem; font-size: .8rem; color: var(--ap-muted); }
.ap-cost-value { font-variant-numeric: tabular-nums; color: var(--ap-text); }
.ap-cost-total {
    margin-top: .3rem; padding-top: .45rem;
    border-top: 1px solid var(--ap-border);
    font-weight: 600; color: var(--ap-text);
}

.ap-product-lkr {
    display: flex; align-items: baseline; justify-content: space-between; gap: .75rem;
    margin-top: .1rem; padding: .55rem .7rem;
    border-radius: 11px;
    background: var(--ap-primary-soft);
    color: var(--ap-primary);
}
.ap-product-lkr span { font-size: .72rem; font-weight: 500; }
.ap-product-lkr strong { font-size: 1rem; font-variant-numeric: tabular-nums; }

.ap-product-note { margin: 0; font-size: .74rem; color: var(--ap-muted); }

/* ---------- Buttons on cards ---------- */
.ap-card-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .35rem; }

.ap-btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .45rem .85rem;
    border: 1px solid transparent;
    border-radius: 9px;
    font-size: .8rem; font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.ap-btn-primary { background: var(--ap-primary); color: #fff; }
.ap-btn-primary:hover { background: #3f50c9; color: #fff; }
.ap-btn-ghost { background: transparent; border-color: var(--ap-border); color: var(--ap-text); }
.ap-btn-ghost:hover { border-color: var(--ap-primary); color: var(--ap-primary); }
.ap-btn:disabled { opacity: .6; cursor: default; }

.ap-card-notice { border-left: 3px solid var(--ap-warning); }

/* ---------- Order form ---------- */
.ap-modal-overlay {
    position: fixed; inset: 0; z-index: 1080;
    background: rgba(19, 26, 43, .45);
    display: grid; place-items: center;
    padding: 1rem;
    overflow-y: auto;
}

.ap-modal {
    width: min(480px, 100%);
    background: var(--ap-surface);
    border-radius: var(--ap-radius);
    box-shadow: 0 20px 60px rgba(19, 26, 43, .25);
    max-height: 92vh; display: flex; flex-direction: column;
}

.ap-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.15rem; border-bottom: 1px solid var(--ap-border);
}
.ap-modal-title { margin: 0; font-size: 1rem; font-weight: 600; }
.ap-modal-close { border: 0; background: transparent; color: var(--ap-muted); font-size: .9rem; cursor: pointer; }
.ap-modal-close:hover { color: var(--ap-text); }

.ap-modal-body { padding: 1.15rem; overflow-y: auto; display: flex; flex-direction: column; gap: .8rem; }

.ap-order-summary {
    display: flex; gap: .75rem; align-items: center;
    padding: .65rem; border-radius: 11px; background: var(--ap-bg);
}
.ap-order-summary img { width: 44px; height: 44px; object-fit: contain; border-radius: 8px; background: #fff; }
.ap-order-summary-text { display: flex; flex-direction: column; gap: .15rem; min-width: 0; }
.ap-order-summary-text strong {
    font-size: .8rem; line-height: 1.35;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ap-order-summary-text span { font-size: .78rem; font-weight: 600; color: var(--ap-primary); }

.ap-field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.ap-field { display: flex; flex-direction: column; gap: .25rem; }
.ap-field .form-label { margin: 0; font-size: .78rem; font-weight: 600; }

/* Throttle summary on the configuration page. */
.ap-throttle-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .45rem; }
.ap-throttle-list li {
    display: flex; justify-content: space-between; align-items: center; gap: .75rem;
    padding: .45rem .6rem; border: 1px solid var(--ap-border); border-radius: 8px;
    font-size: .84rem;
}
.ap-throttle-list strong { color: var(--ap-primary); font-size: .84rem; white-space: nowrap; }

/* Public embed — the chat alone, filling whatever frame it is given. */
body.ap-embed {
    margin: 0; background: var(--ap-bg);
}
.ap-embed-shell {
    height: 100vh; height: 100dvh; /* dvh where supported: mobile URL bars */
    display: flex; padding: 0;
}
.ap-embed-shell .ap-chat-card {
    flex: 1; display: flex; flex-direction: column;
    border-radius: 0; border: 0; height: 100%;
}
.ap-embed-shell .ap-chat-thread { flex: 1; }

.ap-embed-header {
    display: flex; align-items: center; gap: .65rem;
    padding: .8rem 1rem; border-bottom: 1px solid var(--ap-border);
    background: var(--ap-surface);
}
.ap-embed-avatar { width: 38px; height: 38px; font-size: 1.05rem; }
.ap-embed-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ap-embed-title strong { font-size: .95rem; }
.ap-embed-title span { font-size: .72rem; color: var(--ap-muted); }
.ap-embed-online {
    margin-left: auto; font-size: .72rem; font-weight: 600; color: #146c43;
    display: flex; align-items: center; gap: .3rem;
}
.ap-embed-online .bi { font-size: .5rem; }

.ap-typing-label { font-size: .76rem; color: var(--ap-muted); }

.ap-embed-new {
    margin-left: .6rem; border: 1px solid var(--ap-border); background: transparent;
    border-radius: 9px; padding: .35rem .7rem; font-size: .76rem; font-weight: 600;
    color: var(--ap-muted); cursor: pointer; white-space: nowrap;
}
.ap-embed-new:hover { color: var(--ap-text); border-color: var(--ap-muted); }

.ap-embed-note {
    margin: 0; padding: .35rem 1.25rem .7rem; text-align: center;
    font-size: .7rem; color: var(--ap-muted);
}

/* Option buttons under Shiraza's latest question. */
.ap-quick-replies { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .5rem; }
.ap-quick-reply {
    border: 1px solid var(--ap-primary); background: var(--ap-surface);
    color: var(--ap-primary); border-radius: 999px; padding: .4rem .85rem;
    font-size: .82rem; font-weight: 600; cursor: pointer;
}
.ap-quick-reply:hover { background: var(--ap-primary); color: #fff; }

/* Mobile: most Kapruka traffic is phones inside the iframe. */
@media (max-width: 575.98px) {
    body.ap-embed .ap-embed-header { padding: .6rem .75rem; }
    body.ap-embed .ap-embed-title span { display: none; } /* keep the name, drop the tagline */
    body.ap-embed .ap-chat-thread { padding: .75rem; }
    body.ap-embed .ap-bubble { max-width: 100%; font-size: .92rem; }
    body.ap-embed .ap-product-card { width: 100%; }
    body.ap-embed .ap-composer { padding-bottom: calc(.6rem + env(safe-area-inset-bottom)); }
    body.ap-embed .ap-composer textarea { font-size: 16px; } /* stops iOS zoom-on-focus */
    body.ap-embed .ap-composer .btn { min-width: 46px; min-height: 46px; }
    body.ap-embed .ap-quick-reply { padding: .55rem 1rem; } /* comfortable touch target */
    body.ap-embed .ap-embed-note { padding-bottom: calc(.5rem + env(safe-area-inset-bottom)); }
}

/* Assistant bubbles carry real paragraphs and option lists. */
.ap-bubble p { margin: 0; }
.ap-bubble p + p, .ap-bubble p + .ap-bubble-list, .ap-bubble .ap-bubble-list + p { margin-top: .5rem; }
.ap-bubble-list { margin: 0; padding-left: 1.25rem; }
.ap-bubble-list li { margin-top: .2rem; }
.ap-bubble-list li:first-child { margin-top: 0; }

/* Configuration command box — the settings equivalent of the chat composer. */
.ap-command-card { margin-bottom: 1.5rem; border-left: 3px solid var(--ap-primary); }
.ap-command-row { display: flex; gap: .5rem; align-items: center; }
.ap-command-row .form-control { flex: 1; }
.ap-command-row .ap-btn { flex: 0 0 auto; padding: .5rem 1rem; }

.ap-command-result {
    margin: .7rem 0 0; padding: .5rem .7rem; border-radius: 8px;
    font-size: .82rem; background: rgba(79, 70, 229, .07);
}
.ap-command-result.is-pending { color: var(--ap-muted); }
.ap-command-result.is-applied { background: rgba(25, 135, 84, .1); color: #146c43; }
.ap-command-result.is-skipped { background: rgba(255, 193, 7, .13); color: #997404; }
.ap-command-result.is-error { background: rgba(220, 53, 69, .1); color: #b02a37; }

@media (max-width: 575.98px) {
    .ap-command-row { flex-direction: column; align-items: stretch; }
    .ap-command-row .ap-btn { justify-content: center; }
}

/* Inline validation. The message sits directly under the control it is about,
   so nobody has to match a toast in the corner to a field in the form. */
.ap-field-error {
    margin: .15rem 0 0; font-size: .74rem; font-weight: 500; color: #dc3545;
    display: flex; align-items: flex-start; gap: .3rem;
}
.ap-field-error::before { content: "!"; font-weight: 700; }
.ap-field .form-control.is-invalid, .ap-field .form-select.is-invalid {
    border-color: #dc3545; background-image: none;
}
.ap-field .form-control.is-invalid:focus {
    box-shadow: 0 0 0 .18rem rgba(220, 53, 69, .18);
}

/* Delivery city picker — Kapruka delivers to a fixed list, so the field is a
   searchable listbox rather than a text box that can hold anything. */
.ap-combo { position: relative; }
.ap-combo-list {
    position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
    margin: 0; padding: .25rem; list-style: none; max-height: 216px; overflow-y: auto;
    background: #fff; border: 1px solid var(--ap-border); border-radius: 10px;
    box-shadow: 0 12px 28px rgba(16, 24, 40, .14);
}
.ap-combo-option {
    display: flex; flex-direction: column; gap: .05rem;
    padding: .4rem .55rem; border-radius: 7px; cursor: pointer; font-size: .84rem;
}
.ap-combo-option small {
    font-size: .7rem; color: var(--ap-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ap-combo-option.is-active { background: var(--ap-primary); color: #fff; }
.ap-combo-option.is-active small { color: rgba(255, 255, 255, .8); }
.ap-combo-empty { padding: .5rem .55rem; font-size: .8rem; color: var(--ap-muted); }

.ap-delivery-rate {
    display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
    margin-top: .3rem; padding: .35rem .6rem; border-radius: 8px;
    background: rgba(79, 70, 229, .07); font-size: .78rem; color: var(--ap-text);
}
.ap-delivery-rate strong { margin-left: auto; font-size: .84rem; color: var(--ap-primary); }
.ap-delivery-rate small { flex-basis: 100%; font-size: .7rem; color: var(--ap-muted); }
.ap-delivery-rate.is-loading { color: var(--ap-muted); }

.ap-modal-note { margin: 0; font-size: .74rem; color: var(--ap-muted); }

.ap-modal-footer {
    display: flex; justify-content: flex-end; gap: .5rem;
    padding-top: .3rem; border-top: 1px solid var(--ap-border); margin-top: .2rem;
}
.ap-modal-footer .ap-btn { padding: .5rem 1rem; }

@media (max-width: 575.98px) {
    .ap-field-grid { grid-template-columns: 1fr; }
    .ap-modal-footer { flex-direction: column-reverse; }
    .ap-modal-footer .ap-btn { justify-content: center; }
}

.ap-product-link {
    align-self: flex-start;
    font-size: .76rem; font-weight: 600;
    color: var(--ap-primary); text-decoration: none;
}
.ap-product-link:hover { text-decoration: underline; }

@media (max-width: 575.98px) {
    .ap-product-card { flex-direction: column; }
    .ap-product-media { width: 100%; height: 150px; flex-basis: auto; }
}

.ap-typing { display: flex; align-items: center; gap: .7rem; padding: 0 1.25rem 1rem; }

.ap-typing-dots { display: inline-flex; gap: .28rem; padding: .6rem .85rem; background: var(--ap-bg); border-radius: 13px; }
.ap-typing-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--ap-muted);
    animation: ap-bounce 1.3s infinite ease-in-out;
}
.ap-typing-dots span:nth-child(2) { animation-delay: .18s; }
.ap-typing-dots span:nth-child(3) { animation-delay: .36s; }

@keyframes ap-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.ap-composer {
    display: flex;
    gap: .6rem;
    padding: .9rem 1.25rem 1.1rem;
    border-top: 1px solid var(--ap-border);
    align-items: flex-end;
}

.ap-composer textarea { resize: none; max-height: 160px; border-radius: 11px; }
.ap-composer .btn { border-radius: 11px; padding: .5rem .95rem; }

.ap-chat-sidebar { max-height: calc(100vh - 190px); overflow-y: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
    .ap-chat-layout { grid-template-columns: 1fr; }
    .ap-chat-sidebar { max-height: none; }
    .ap-sticky { position: static; }
}

@media (max-width: 991.98px) {
    .ap-sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform .22s ease;
    }

    .ap-sidebar.is-open { transform: translateX(0); }

    .ap-sidebar-backdrop.is-visible {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(19, 26, 43, .45);
        z-index: 1040;
    }

    .ap-chat-card { height: auto; min-height: 60vh; }
    .ap-message { max-width: 94%; }
}

@media (max-width: 575.98px) {
    .ap-page-subtitle { display: none; }
    .ap-status-pill .ap-status-text { display: none; }
}
