/* Knowledge Base — Layout, Canvas Header, Archive, Single */

/* ── KB canvas layout (logged-out) ─────────────────────── */

body.tbp-kb-layout {
    margin: 0;
    background: var(--portal-bg);
    color: var(--portal-text);
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

body.tbp-kb-layout h1,
body.tbp-kb-layout h2,
body.tbp-kb-layout h3,
body.tbp-kb-layout h4,
body.tbp-kb-layout h5,
body.tbp-kb-layout h6 {
    font-family: 'Playfair Display', serif;
    line-height: 1.25;
}

/* ── KB header (canvas) ─────────────────────────────────── */

.tbp-kb-header {
    position: sticky;
    top: 0;
    background: var(--portal-bg);
    border-bottom: 1px solid var(--portal-border);
    box-shadow: var(--portal-shadow-sm);
    z-index: 100;
}

.tbp-kb-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.tbp-kb-header__logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    text-decoration: none;
}

.tbp-kb-header__logo img {
    height: 36px;
    width: auto;
}

.tbp-kb-header__site-name {
    font-weight: 600;
    font-size: 17px;
    color: var(--portal-text);
}

/* ── KB header search widget ────────────────────────────── */

.tbp-kb-sw {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: auto;
}

/* Toggle (magnifier icon) */
.tbp-kb-sw__toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    background: transparent;
    color: var(--portal-muted);
    border-radius: var(--portal-radius);
    cursor: pointer;
    transition: color var(--portal-ease), background var(--portal-ease);
    flex-shrink: 0;
}

.tbp-kb-sw__toggle:hover,
.tbp-kb-sw--open .tbp-kb-sw__toggle {
    color: var(--portal-accent);
    background: var(--portal-accent-bg);
}

.tbp-kb-sw__toggle svg {
    width: 20px;
    height: 20px;
}

/* Expanding field — slides in from right */
.tbp-kb-sw__expand {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    overflow: hidden;
    transition: width .25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.tbp-kb-sw--open .tbp-kb-sw__expand {
    width: 320px;
    pointer-events: auto;
}

.tbp-kb-sw__wrap {
    position: relative;
    display: flex;
    align-items: center;
    padding-right: 42px; /* room for toggle */
}

.tbp-kb-sw__icon {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--portal-muted);
    pointer-events: none;
    flex-shrink: 0;
}

.tbp-kb-sw__input {
    width: 100%;
    height: 38px;
    padding: 0 34px 0 34px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    background: var(--portal-bg);
    box-shadow: var(--portal-shadow-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--portal-text);
    outline: none;
    white-space: nowrap;
    transition: border-color var(--portal-ease), box-shadow var(--portal-ease);
}

.tbp-kb-sw__input:focus {
    border-color: var(--portal-accent);
    box-shadow: 0 0 0 3px rgba(var(--portal-accent-rgb), .15);
}

.tbp-kb-sw__clear {
    position: absolute;
    right: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--portal-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: color var(--portal-ease);
    padding: 0;
}

.tbp-kb-sw__clear:hover { color: var(--portal-text); }
.tbp-kb-sw__clear svg { width: 14px; height: 14px; }

/* Results dropdown */
.tbp-kb-sw__results {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 360px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: 10px;
    box-shadow: var(--portal-shadow-md);
    z-index: 300;
}

.tbp-kb-sw__group {
    padding: 8px 0;
}

.tbp-kb-sw__group + .tbp-kb-sw__group {
    border-top: 1px solid var(--portal-border);
}

.tbp-kb-sw__group-label {
    padding: 4px 14px 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--portal-muted);
}

.tbp-kb-sw__group--category .tbp-kb-sw__group-label { color: var(--portal-accent); }

.tbp-kb-sw__group-items {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tbp-kb-sw__item a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    text-decoration: none;
    color: var(--portal-text);
    transition: background var(--portal-ease);
}

.tbp-kb-sw__item a:hover {
    background: var(--portal-surface);
}

.tbp-kb-sw__item-icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    color: var(--portal-muted);
}

.tbp-kb-sw__group--category .tbp-kb-sw__item-icon { color: var(--portal-accent); }

.tbp-kb-sw__item-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.tbp-kb-sw__item-title {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tbp-kb-sw__item-meta {
    font-size: 12px;
    color: var(--portal-muted);
}

.tbp-kb-sw__no-results {
    margin: 0;
    padding: 16px 14px;
    font-size: 14px;
    color: var(--portal-muted);
}

/* Inline variant — archive filter search */
.tbp-kb-sw__results--inline {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: auto;
    width: 420px;
    max-width: 90vw;
}

.tbp-kb-header__login {
    flex-shrink: 0;
    text-decoration: none;
}

/* ── KB footer (canvas) ─────────────────────────────────── */

.tbp-kb-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--portal-bg);
    border-top: 1px solid var(--portal-border);
    z-index: 90;
}

.tbp-kb-footer__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 24px;
    text-align: center;
}

.tbp-kb-footer__copy {
    margin: 0;
    font-size: 13px;
    color: var(--portal-muted);
}

/* ── KB header breadcrumb row ───────────────────────────── */

/* Breadcrumb sits inside .tbp-kb-header as a second full-width row.
   Override padding/border so the outer header border-bottom acts as
   the single bottom edge. */
.tbp-kb-header .tbp-breadcrumb {
    border-bottom: none;
    padding: 7px 0;
    max-width: none;
}

.tbp-kb-header .tbp-breadcrumb ol {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ── KB content (canvas) ────────────────────────────────── */

body.tbp-kb-layout .tbp-kb-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px calc(44px + 20px);
}

/* ── KB content (portal layout — logged in) ─────────────── */

body.tbp-portal-layout .tbp-kb-archive,
body.tbp-portal-layout .tbp-kb-single {
    max-width: 100%;
}

/* ── Shared archive wrapper ─────────────────────────────── */

.tbp-kb-archive {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* ── Archive header ─────────────────────────────────────── */

.tbp-kb-archive__header {
    padding: 0 4px;
}

.tbp-kb-archive__title {
    margin: 0 0 6px;
    font-size: 28px;
    color: var(--portal-text);
}

.tbp-kb-archive__subtitle {
    margin: 0;
    font-size: 15px;
    color: var(--portal-muted);
    font-family: 'DM Sans', sans-serif;
}

/* ── Filters ────────────────────────────────────────────── */

.tbp-kb-archive__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    padding: 16px 20px;
}

.tbp-kb-archive__filter-search-wrap {
    flex: 1;
    min-width: 200px;
    position: relative;
    display: flex;
    align-items: center;
    /* results dropdown is absolute inside this wrapper */
    z-index: 10;
}

.tbp-kb-archive__filter-search-wrap svg {
    position: absolute;
    left: 10px;
    width: 16px;
    height: 16px;
    color: var(--portal-muted);
    pointer-events: none;
}

.tbp-kb-archive__filter-search {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 34px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    background: var(--portal-surface);
    font-family: inherit;
    font-size: 14px;
    color: var(--portal-text);
    outline: none;
    transition: border-color var(--portal-ease), box-shadow var(--portal-ease);
}

.tbp-kb-archive__filter-search:focus {
    border-color: var(--portal-accent);
    box-shadow: 0 0 0 3px rgba(var(--portal-accent-rgb), .15);
    background: var(--portal-bg);
}

.tbp-kb-archive__filter-select {
    height: 38px;
    padding: 0 32px 0 12px;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    background: var(--portal-surface);
    font-family: inherit;
    font-size: 14px;
    color: var(--portal-text);
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    transition: border-color var(--portal-ease);
    min-width: 200px;
}

.tbp-kb-archive__filter-select:focus {
    border-color: var(--portal-accent);
}

/* ── Section title ──────────────────────────────────────── */

.tbp-kb-archive__section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tbp-kb-archive__section-title {
    margin: 0;
    font-size: 19px;
    font-family: 'Playfair Display', serif;
    color: var(--portal-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tbp-kb-archive__count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--portal-accent-bg);
    color: var(--portal-accent);
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 600;
}

.tbp-kb-archive__empty {
    margin: 0;
    color: var(--portal-muted);
    font-size: 14px;
}

/* ── Folder cards ───────────────────────────────────────── */

.tbp-kb-folders {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
}

.tbp-kb-folder {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    text-decoration: none;
    color: var(--portal-text);
    box-shadow: var(--portal-shadow-sm);
    transition: border-color var(--portal-ease), box-shadow var(--portal-ease), transform var(--portal-ease);
}

.tbp-kb-folder:hover {
    border-color: var(--portal-accent);
    box-shadow: var(--portal-shadow-md);
    transform: translateY(-1px);
}

.tbp-kb-folder__icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--portal-radius);
    background: var(--portal-accent-bg);
    color: var(--portal-accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

.tbp-kb-folder__icon svg {
    width: 22px;
    height: 22px;
}

.tbp-kb-folder__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tbp-kb-folder__name {
    font-weight: 500;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tbp-kb-folder__meta {
    font-size: 12px;
    color: var(--portal-muted);
}

.tbp-kb-folder__arrow {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: var(--portal-muted);
}

/* ── Article grid ───────────────────────────────────────── */

.tbp-kb-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.tbp-kb-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    background: var(--portal-bg);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    text-decoration: none;
    color: var(--portal-text);
    box-shadow: var(--portal-shadow-sm);
    transition: border-color var(--portal-ease), box-shadow var(--portal-ease), transform var(--portal-ease);
}

.tbp-kb-card:hover {
    border-color: var(--portal-accent);
    box-shadow: var(--portal-shadow-md);
    transform: translateY(-1px);
}

.tbp-kb-card__cat {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--portal-accent);
    background: var(--portal-accent-bg);
    padding: 2px 8px;
    border-radius: 4px;
    align-self: flex-start;
}

.tbp-kb-card__title {
    margin: 0;
    font-size: 16px;
    font-family: 'Playfair Display', serif;
    color: var(--portal-text);
    line-height: 1.35;
}

.tbp-kb-card__excerpt {
    margin: 0;
    font-size: 13px;
    color: var(--portal-muted);
    line-height: 1.55;
    flex: 1;
}

.tbp-kb-card__date {
    font-size: 12px;
    color: var(--portal-muted);
    margin-top: auto;
}

/* ── Breadcrumb ─────────────────────────────────────────── */

.tbp-kb-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 13px;
    color: var(--portal-muted);
    margin-bottom: 8px;
}

.tbp-kb-breadcrumb a {
    color: var(--portal-accent);
    text-decoration: none;
}

.tbp-kb-breadcrumb a:hover {
    text-decoration: underline;
}

.tbp-kb-breadcrumb__sep {
    color: var(--portal-border);
}

/* ── Single post ────────────────────────────────────────── */

.tbp-kb-single {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tbp-kb-single__layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}

.tbp-kb-single__main {
    padding: 32px;
    min-width: 0;
}

.tbp-kb-single__header {
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--portal-border);
}

.tbp-kb-single__cat {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--portal-accent);
    background: var(--portal-accent-bg);
    padding: 2px 8px;
    border-radius: 4px;
    text-decoration: none;
    margin-bottom: 10px;
}

.tbp-kb-single__cat:hover {
    background: #dbeafe;
}

.tbp-kb-single__title {
    margin: 0 0 12px;
    font-size: 26px;
}

.tbp-kb-single__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    color: var(--portal-muted);
}

.tbp-kb-single__date,
.tbp-kb-single__author {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Prose content */
.tbp-prose {
    font-size: 15px;
    line-height: 1.75;
    color: var(--portal-text);
}

.tbp-prose h2 { font-size: 20px; margin: 28px 0 10px; }
.tbp-prose h3 { font-size: 17px; margin: 24px 0 8px; }
.tbp-prose p  { margin: 0 0 16px; }
.tbp-prose ul,
.tbp-prose ol { margin: 0 0 16px; padding-left: 20px; }
.tbp-prose li { margin-bottom: 6px; }
.tbp-prose a  { color: var(--portal-accent); }
.tbp-prose blockquote {
    margin: 16px 0;
    padding: 12px 16px;
    border-left: 3px solid var(--portal-accent);
    background: var(--portal-accent-bg);
    border-radius: 0 4px 4px 0;
    font-style: italic;
    color: var(--portal-muted);
}
.tbp-prose code {
    font-family: 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: 3px;
    padding: 1px 5px;
}
.tbp-prose pre {
    background: var(--portal-surface);
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    padding: 16px;
    overflow-x: auto;
    margin: 0 0 16px;
}
.tbp-prose pre code {
    background: none;
    border: none;
    padding: 0;
}

/* ── Single sidebar ─────────────────────────────────────── */

.tbp-kb-single__sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 80px;
}

.tbp-kb-single__sidebar-card {
    padding: 20px;
}

.tbp-kb-single__sidebar-title {
    margin: 0 0 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--portal-text);
    font-family: 'DM Sans', sans-serif;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.tbp-kb-single__cat-list,
.tbp-kb-single__related-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tbp-kb-single__cat-list a,
.tbp-kb-single__related-list a {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--portal-text);
    text-decoration: none;
    line-height: 1.4;
}

.tbp-kb-single__cat-list a:hover,
.tbp-kb-single__related-list a:hover {
    color: var(--portal-accent);
}

.tbp-kb-single__cat-list svg,
.tbp-kb-single__related-list svg {
    flex-shrink: 0;
    color: var(--portal-muted);
}

/* ── Pagination ─────────────────────────────────────────── */

.tbp-kb-archive .tbp-pagination {
    margin-top: 8px;
}

.tbp-pagination .page-numbers {
    display: inline-flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 4px;
    flex-wrap: wrap;
}

.tbp-pagination .page-numbers li a,
.tbp-pagination .page-numbers li span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 6px;
    border-radius: var(--portal-radius);
    border: 1px solid var(--portal-border);
    font-size: 14px;
    color: var(--portal-text);
    text-decoration: none;
    background: var(--portal-bg);
    transition: border-color var(--portal-ease), background var(--portal-ease), color var(--portal-ease);
}

.tbp-pagination .page-numbers li a:hover {
    border-color: var(--portal-accent);
    color: var(--portal-accent);
}

.tbp-pagination .page-numbers li span.current {
    background: var(--portal-accent);
    border-color: var(--portal-accent);
    color: #fff;
}

/* ── Shared button styles (canvas layout) ───────────────── */

body.tbp-kb-layout .tbp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 16px;
    border-radius: var(--portal-radius);
    border: 1px solid transparent;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--portal-ease), border-color var(--portal-ease), color var(--portal-ease);
    white-space: nowrap;
}

body.tbp-kb-layout .tbp-btn--primary {
    background: var(--portal-accent);
    border-color: var(--portal-accent);
    color: #fff;
}

body.tbp-kb-layout .tbp-btn--primary:hover {
    background: var(--portal-accent-dark);
    border-color: var(--portal-accent-dark);
}

body.tbp-kb-layout .tbp-btn--ghost {
    background: transparent;
    border-color: var(--portal-border);
    color: var(--portal-text);
}

body.tbp-kb-layout .tbp-btn--ghost:hover {
    border-color: var(--portal-muted);
}

/* portal layout buttons (filter form) */
body.tbp-portal-layout .tbp-kb-archive__filters .tbp-btn--primary {
    height: 38px;
    padding: 0 16px;
    background: var(--portal-accent);
    border: 1px solid var(--portal-accent);
    border-radius: var(--portal-radius);
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    transition: background var(--portal-ease);
}

body.tbp-portal-layout .tbp-kb-archive__filters .tbp-btn--primary:hover {
    background: var(--portal-accent-dark);
}

body.tbp-portal-layout .tbp-kb-archive__filters .tbp-btn--ghost {
    height: 38px;
    padding: 0 16px;
    background: transparent;
    border: 1px solid var(--portal-border);
    border-radius: var(--portal-radius);
    color: var(--portal-text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    transition: border-color var(--portal-ease);
}

body.tbp-portal-layout .tbp-kb-archive__filters .tbp-btn--ghost:hover {
    border-color: var(--portal-muted);
}

/* ── Responsive ─────────────────────────────────────────── */

@media (max-width: 900px) {
    .tbp-kb-single__layout {
        grid-template-columns: 1fr;
    }
    .tbp-kb-single__sidebar {
        position: static;
    }
    .tbp-kb-single__main {
        padding: 24px;
    }
}

@media (max-width: 600px) {
    body.tbp-kb-layout .tbp-kb-content {
        padding: 0 16px calc(44px + 20px);
    }
    .tbp-kb-header .tbp-breadcrumb ol {
        padding: 0 16px;
    }
    .tbp-kb-header__inner {
        padding: 0 16px;
        gap: 12px;
    }
    .tbp-kb-sw--open .tbp-kb-sw__expand {
        width: calc(100vw - 120px);
    }
    .tbp-kb-sw__results {
        width: calc(100vw - 32px);
        right: -10px;
    }
    .tbp-kb-folders {
        grid-template-columns: 1fr;
    }
    .tbp-kb-grid {
        grid-template-columns: 1fr;
    }
    .tbp-kb-archive__filters {
        flex-direction: column;
        align-items: stretch;
    }
    .tbp-kb-archive__filter-select {
        min-width: 0;
        width: 100%;
    }
    .tbp-kb-archive__title {
        font-size: 22px;
    }
    .tbp-kb-single__main {
        padding: 16px;
    }
}

