/* Knowledge Centre — floating widget + focused chat platform */

/* ========== Platform shell ========== */
.kc-platform {
    --kc-bg: var(--background-light, #f8f9fc);
    --kc-surface: #ffffff;
    --kc-text: var(--text-primary, #16151f);
    --kc-muted: var(--text-secondary, #585b70);
    --kc-border: var(--border-light, #e8e9ef);
    --kc-primary: var(--primary-color, #3d3a9e);
    --kc-primary-dark: var(--primary-dark, #2a2873);
    --kc-accent: var(--accent-teal, #16b8a6);
    --kc-soft: var(--primary-ultra-light, #eeedfb);
    background: var(--kc-bg);
    color: var(--kc-text);
    padding-bottom: 2.5rem;
}

.kc-platform[data-kc-theme="dark"] {
    --kc-bg: #12131a;
    --kc-surface: #1c1e2a;
    --kc-text: #f2f3f8;
    --kc-muted: #a7abc0;
    --kc-border: #2e3144;
    --kc-soft: #262844;
    --kc-primary: #7b78e0;
    --kc-primary-dark: #5d5ac9;
    --kc-accent: #2dd4bf;
}

.kc-section {
    padding: clamp(2rem, 4vw, 3rem) 0;
}

.kc-empty {
    color: var(--kc-muted);
    margin: 0;
}

/* ========== Hero ========== */
.kc-hero {
    background: linear-gradient(135deg, var(--primary-dark, #2a2873) 0%, var(--primary-color, #3d3a9e) 100%);
    color: #fff;
    padding: clamp(3rem, 6vw, 4.5rem) 0;
}

.kc-hero--platform {
    position: relative;
    overflow: hidden;
    padding: clamp(2.8rem, 6vw, 4.25rem) 0;
}

.kc-hero-mesh {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 15% 20%, rgba(22, 184, 166, 0.28), transparent 55%),
        radial-gradient(ellipse 50% 45% at 85% 70%, rgba(255, 255, 255, 0.12), transparent 50%),
        linear-gradient(135deg, #1f1d5c 0%, #3d3a9e 48%, #2a2873 100%);
    animation: kc-mesh 14s ease-in-out infinite alternate;
}

@keyframes kc-mesh {
    from { transform: scale(1) translate(0, 0); }
    to { transform: scale(1.05) translate(-1%, 1%); }
}

.kc-hero-inner {
    position: relative;
    z-index: 1;
}

.kc-hero-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.kc-hero-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.kc-tool-btn {
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.kc-tool-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.kc-tool-count {
    background: #fff;
    color: var(--primary-color, #3d3a9e);
    border-radius: 999px;
    min-width: 1.2rem;
    height: 1.2rem;
    font-size: 0.7rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.3rem;
}

.kc-hero h1 {
    color: #fff;
    margin: 0 0 0.75rem;
    font-size: clamp(1.9rem, 4.5vw, 3rem);
    font-family: var(--font-secondary, "Plus Jakarta Sans", sans-serif);
    letter-spacing: -0.03em;
}

.kc-hero-sub {
    margin: 0;
    max-width: 640px;
    color: rgba(255, 255, 255, 0.92);
    line-height: 1.6;
    font-size: 1.05rem;
}

.kc-breadcrumb {
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
}

.kc-breadcrumb a {
    color: rgba(255, 255, 255, 0.85);
}

/* ========== Agent panel ========== */
.kc-agent-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1rem;
    align-items: stretch;
}

.kc-agent-rail {
    background: var(--kc-surface);
    border: 1px solid var(--kc-border);
    border-radius: 18px;
    padding: 1rem 0.85rem;
    display: flex;
    flex-direction: column;
    min-height: 560px;
    max-height: min(720px, calc(100vh - 8rem));
}

.kc-rail-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.kc-rail-btn {
    border: 0;
    border-radius: 10px;
    background: var(--kc-primary);
    color: #fff;
    font-weight: 600;
    padding: 0.65rem 0.75rem;
    cursor: pointer;
    font: inherit;
}

.kc-rail-btn--ghost {
    background: transparent;
    color: var(--kc-muted);
    border: 1px solid var(--kc-border);
}

.kc-rail-label {
    margin: 0 0 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--kc-muted);
}

.kc-rail-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: auto;
    flex: 1;
}

.kc-rail-item {
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: var(--kc-text);
    padding: 0.65rem 0.55rem;
    border-radius: 10px;
    cursor: pointer;
    font: inherit;
    font-size: 0.86rem;
    line-height: 1.35;
}

.kc-rail-item:hover,
.kc-rail-item.is-active {
    background: var(--kc-soft);
}

.kc-rail-empty {
    color: var(--kc-muted);
    font-size: 0.85rem;
    padding: 0.5rem;
}

.kc-page {
    padding: clamp(2rem, 5vw, 3.5rem) 0 4rem;
    background: var(--background-light, #f8fafc);
}

.kc-embedded {
    max-width: 820px;
    margin: 0 auto;
}

.kc-widget {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
}

.kc-fab {
    border: 0;
    border-radius: 999px;
    background: var(--primary-color, #3d3a9e);
    color: #fff;
    font-weight: 650;
    padding: 0.85rem 1.25rem;
    box-shadow: 0 12px 30px rgba(61, 58, 158, 0.35);
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.kc-fab:hover {
    background: var(--primary-dark, #2a2873);
    transform: translateY(-1px);
}

.kc-fab:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(61, 58, 158, 0.25);
}

.kc-panel {
    width: min(400px, calc(100vw - 2rem));
    height: min(560px, calc(100vh - 6rem));
    max-height: min(560px, calc(100vh - 6rem));
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--border-light, #e8e9ef);
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(20, 19, 43, 0.18);
    overflow: hidden;
}

.kc-panel--embedded {
    width: 100%;
    max-width: 820px;
    height: min(640px, calc(100vh - 10rem));
    max-height: min(640px, calc(100vh - 10rem));
    min-height: 520px;
    margin: 0 auto;
}

.kc-panel--platform {
    width: 100%;
    max-width: none;
    height: min(720px, calc(100vh - 8rem));
    max-height: min(720px, calc(100vh - 8rem));
    min-height: 560px;
    background: var(--kc-surface);
    border-color: var(--kc-border);
    box-shadow: 0 16px 40px rgba(20, 19, 43, 0.08);
}

.kc-panel-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.15rem;
    background: linear-gradient(135deg, #2a2873, #3d3a9e);
    color: #fff;
}

.kc-panel-header strong {
    display: block;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
}

.kc-panel-header p {
    margin: 0.35rem 0 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.88);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.kc-status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
    flex-shrink: 0;
}

.kc-close {
    border: 0;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.kc-close:hover {
    background: rgba(255, 255, 255, 0.22);
}

.kc-messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem 1.05rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: linear-gradient(180deg, #f5f6fb 0%, #f8fafc 100%);
    scroll-behavior: smooth;
}

.kc-platform[data-kc-theme="dark"] .kc-messages {
    background: linear-gradient(180deg, #161824 0%, #1a1c28 100%);
}

.kc-bubble {
    max-width: 88%;
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    font-size: 0.94rem;
    line-height: 1.55;
    word-break: break-word;
}

.kc-bubble--user {
    align-self: flex-end;
    background: var(--primary-color, #3d3a9e);
    color: #fff;
    border-bottom-right-radius: 5px;
    box-shadow: 0 6px 16px rgba(61, 58, 158, 0.18);
    white-space: pre-wrap;
}

.kc-bubble--assistant {
    align-self: flex-start;
    background: #fff;
    border: 1px solid var(--border-light, #e8e9ef);
    color: var(--text-primary, #16151f);
    border-bottom-left-radius: 5px;
    box-shadow: 0 4px 14px rgba(20, 19, 43, 0.04);
}

.kc-platform[data-kc-theme="dark"] .kc-bubble--assistant {
    background: #232536;
    border-color: var(--kc-border);
    color: var(--kc-text);
}

.kc-md {
    white-space: normal;
}

.kc-md p {
    margin: 0 0 0.55rem;
}

.kc-md p:last-child {
    margin-bottom: 0;
}

.kc-md ul {
    margin: 0.35rem 0 0.55rem;
    padding-left: 1.2rem;
}

.kc-md code {
    font-size: 0.88em;
    background: rgba(61, 58, 158, 0.08);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

.kc-md a {
    color: var(--kc-primary);
}

.kc-sources {
    margin-top: 0.55rem;
    padding-top: 0.45rem;
    border-top: 1px solid rgba(20, 19, 43, 0.06);
    font-size: 0.75rem;
    color: var(--text-muted, #9094a6);
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.kc-source-chip {
    border: 1px solid var(--kc-border);
    background: var(--kc-soft);
    color: var(--kc-primary);
    border-radius: 999px;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    cursor: pointer;
}

.kc-bubble-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.55rem;
}

.kc-bubble-actions button {
    border: 0;
    background: transparent;
    color: var(--kc-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 0;
}

.kc-bubble-actions button:hover {
    color: var(--kc-primary);
}

.kc-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 0.3rem;
    padding: 0.7rem 0.9rem;
    background: #fff;
    border: 1px solid var(--border-light, #e8e9ef);
    border-radius: 999px;
}

.kc-typing span {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: #9aa0b5;
    animation: kc-bounce 1.1s infinite ease-in-out;
}

.kc-typing span:nth-child(2) { animation-delay: 0.15s; }
.kc-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes kc-bounce {
    0%, 80%, 100% { opacity: 0.35; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}

.kc-suggestions {
    flex-shrink: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.65rem 0.95rem;
    background: var(--kc-surface, #fff);
    border-top: 1px solid var(--kc-border, #e8e9ef);
    align-items: center;
}

.kc-suggestions-label {
    width: 100%;
    margin: 0 0 0.15rem;
    font-size: 0.78rem;
    color: var(--kc-muted);
}

.kc-chip {
    border: 1px solid rgba(61, 58, 158, 0.14);
    background: var(--primary-ultra-light, #eeedfb);
    color: var(--primary-color, #3d3a9e);
    border-radius: 999px;
    padding: 0.38rem 0.75rem;
    font-size: 0.76rem;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.kc-platform[data-kc-theme="dark"] .kc-chip {
    background: var(--kc-soft);
    border-color: var(--kc-border);
    color: var(--kc-text);
}

.kc-chip.is-active,
.kc-chip:hover:not(:disabled) {
    background: #e4e2f8;
    border-color: rgba(61, 58, 158, 0.28);
}

.kc-chip:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.kc-composer {
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
    padding: 0.85rem 0.95rem 0.55rem;
    background: var(--kc-surface, #fff);
    border-top: 1px solid var(--kc-border, #e8e9ef);
}

.kc-composer input,
.kc-composer textarea {
    flex: 1;
    border: 1px solid var(--kc-border, #e8e9ef);
    border-radius: 12px;
    padding: 0.72rem 0.9rem;
    font: inherit;
    background: #fafbff;
    color: var(--kc-text);
    resize: none;
    min-height: 2.7rem;
    max-height: 7rem;
}

.kc-platform[data-kc-theme="dark"] .kc-composer input,
.kc-platform[data-kc-theme="dark"] .kc-composer textarea {
    background: #161824;
    border-color: var(--kc-border);
}

.kc-composer input:focus,
.kc-composer textarea:focus {
    outline: none;
    border-color: rgba(61, 58, 158, 0.45);
    box-shadow: 0 0 0 3px rgba(61, 58, 158, 0.12);
    background: #fff;
}

.kc-composer button {
    border: 0;
    border-radius: 12px;
    background: var(--primary-color, #3d3a9e);
    color: #fff;
    font-weight: 650;
    padding: 0.72rem 1.05rem;
    cursor: pointer;
    align-self: flex-end;
}

.kc-composer button:hover:not(:disabled) {
    background: var(--primary-dark, #2a2873);
}

.kc-composer button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.kc-disclaimer {
    flex-shrink: 0;
    margin: 0;
    padding: 0 0.95rem 0.85rem;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text-muted, #9094a6);
    background: var(--kc-surface, #fff);
}

/* ========== Bookmarks drawer ========== */
.kc-bookmarks-overlay {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: flex;
    justify-content: flex-end;
}

.kc-bookmarks-backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(12, 10, 30, 0.45);
    cursor: pointer;
}

.kc-bookmarks-panel {
    position: relative;
    width: min(380px, 100%);
    height: 100%;
    background: var(--kc-surface);
    color: var(--kc-text);
    padding: 1.25rem;
    overflow: auto;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18);
}

.kc-bookmarks-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.kc-bookmarks-head h2 {
    margin: 0;
    font-size: 1.2rem;
}

.kc-bookmarks-head .kc-close {
    background: var(--kc-soft);
    color: var(--kc-text);
}

.kc-bookmarks-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.kc-bookmarks-list li {
    border: 1px solid var(--kc-border);
    border-radius: 12px;
    padding: 0.85rem;
}

.kc-bookmarks-list strong {
    display: block;
    margin-bottom: 0.35rem;
}

.kc-bookmarks-list p {
    margin: 0 0 0.55rem;
    color: var(--kc-muted);
    font-size: 0.88rem;
}

.kc-bookmarks-actions {
    display: flex;
    gap: 0.75rem;
}

.kc-bookmarks-actions a,
.kc-bookmarks-actions button {
    border: 0;
    background: transparent;
    color: var(--kc-primary);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    font: inherit;
}

/* ========== Responsive ========== */
@media (max-width: 1024px) {
    .kc-agent-shell {
        grid-template-columns: 1fr;
    }

    .kc-agent-rail {
        min-height: 0;
        max-height: none;
    }

    .kc-rail-list {
        display: flex;
        gap: 0.35rem;
        overflow: auto;
    }

    .kc-rail-list li {
        flex: 0 0 auto;
    }

    .kc-rail-item {
        white-space: nowrap;
        max-width: 180px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 480px) {
    .kc-widget {
        right: 0.75rem;
        bottom: 0.75rem;
    }

    .kc-panel:not(.kc-panel--embedded):not(.kc-panel--platform) {
        width: calc(100vw - 1.5rem);
        height: min(70vh, calc(100vh - 5.5rem));
        max-height: min(70vh, calc(100vh - 5.5rem));
    }

    .kc-panel--embedded {
        height: min(75vh, 620px);
        max-height: min(75vh, 620px);
        min-height: 420px;
    }

    .kc-panel--platform {
        min-height: 480px;
        height: min(75vh, 620px);
        max-height: min(75vh, 620px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .kc-messages {
        scroll-behavior: auto;
    }

    .kc-typing span,
    .kc-fab,
    .kc-hero-mesh {
        animation: none;
        transition: none;
    }
}
