/* KB Premium Styling */

/* Base Grid Layout */
.kb-sections-loop {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin: 40px 0;
}

.kb-sections-loop * {
    box-sizing: border-box;
}

/* Common Item Styles */
.kb-section-item {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kb-section-item.is-linked {
    text-decoration: none;
    color: inherit;
}

.kb-section-item.is-linked:hover {
    text-decoration: none;
}

.kb-section-item-header {
    display: flex;
    align-items: flex-start;
    /* Align to top for multi-line content */
    gap: 20px;
    margin-bottom: 25px;
}

.kb-section-title-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kb-section-icon-wrapper {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--section-icon-color, #fff);
    font-size: 24px;
    flex-shrink: 0;
    background-color: var(--section-color, #007cba);
}

.kb-section-image {
    width: 64px;
    height: 64px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.kb-section-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.kb-section-title {
    font-size: var(--section-title-size, 1.25rem);
    font-weight: 700;
    margin: 0;
    color: #1d2327;
}

.kb-section-title a {
    color: inherit;
    text-decoration: none;
}

.kb-section-title a:hover {
    color: #0073aa;
}

.kb-section-description {
    font-size: 0.95rem;
    color: #50575e;
    line-height: 1.5;
}

.kb-section-description p {
    margin: 0;
}

.kb-docs-loop {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--post-gap, 12px);
}

.kb-doc-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding-left: var(--post-indent, 0);
}

.kb-doc-title {
    font-size: var(--post-title-size, 1rem);
    line-height: var(--post-line-height, 1.5);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.kb-sections-loop .kb-doc-title a {
    color: var(--post-link-color, #0073aa);
    text-decoration: none;
}

.kb-sections-loop .kb-doc-title a:hover {
    text-decoration: underline;
}

.kb-doc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kb-doc-icon svg {
    width: 1em;
    height: 1em;
    fill: currentColor;
}

.kb-doc-thumbnail {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
}

.kb-doc-content {
    flex: 1;
}

.kb-doc-date {
    display: block;
    font-size: 0.75rem;
    color: #8c8f94;
    margin-top: 2px;
}

/* ==========================================================================
   STYLE: LIST (Standard)
   ========================================================================== */
.kb-sections-loop.is-style-list {
    grid-template-columns: 1fr;
    /* Full width items */
    gap: 20px;
}

.kb-sections-loop.is-style-list .kb-section-item {
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f0f1;
}

.kb-sections-loop.is-style-list .kb-section-item-header {
    margin-bottom: 15px;
    align-items: center;
}


/* No icon alignment */
.kb-sections-loop.is-style-list .kb-section-item-header:not(:has(.kb-section-icon-wrapper)):not(:has(.kb-section-image))+.kb-docs-loop {
    padding-left: 0;
}


/* ==========================================================================
   STYLE: CARDS
   ========================================================================== */
.kb-sections-loop.is-style-cards .kb-section-item {
    background: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.kb-sections-loop.is-style-cards .kb-section-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);
}

.kb-sections-loop.is-style-cards .kb-section-item-header {
    flex-direction: column;
}

.kb-sections-loop.is-style-cards .kb-docs-loop {
    border-top: 1px solid #f0f0f1;
    padding-top: 20px;
    flex-grow: 1;
}


/* Breadcrumbs */
.kb-breadcrumb {
    margin-bottom: 30px;
    color: #8c8f94;
    font-size: 0.9rem;
}

.kb-breadcrumb ol {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
}

.kb-breadcrumb li {
    display: flex;
    align-items: center;
}

.kb-breadcrumb li:not(:last-child):after {
    content: "/";
    margin: 0 10px;
    opacity: 0.5;
}

.kb-breadcrumb a {
    color: inherit;
    text-decoration: none;
}

.kb-breadcrumb a:hover {
    color: #0073aa;
}

.kb-breadcrumb .active {
    color: #1d2327;
    font-weight: 500;
}

/* ==========================================================================
   KB Sidebar Navigation
   ========================================================================== */
.kb-sidebar {
    position: sticky;
    top: 20px;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: #f9f9f9;
    padding: 30px 20px;
    border-right: 1px solid #e0e0e0;
}

.kb-sidebar__logo-wrapper,
.kb-sidebar__site-title {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.kb-sidebar__logo-wrapper a,
.kb-sidebar__site-title a {
    display: block;
    text-decoration: none;
}

.kb-sidebar__logo {
    max-width: 100%;
    height: auto;
    max-height: 60px;
}

.kb-sidebar__site-title a {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1d2327;
}

.kb-sidebar__nav {
    flex: 1;
    overflow-y: auto;
}

.kb-sidebar__sections {
    list-style: none;
    padding: 0;
    margin: 0;
}

.kb-sidebar__section-item {
    margin-bottom: 8px;
}

.kb-sidebar__section-item a {
    display: block;
    padding: 10px 15px;
    color: #50575e;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.kb-sidebar__section-item a:hover {
    background-color: #e0e0e0;
    color: #1d2327;
}

.kb-sidebar__footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.kb-sidebar__home-link {
    display: block;
    padding: 10px 15px;
    color: #50575e;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.kb-sidebar__home-link:hover {
    background-color: #e0e0e0;
    color: #1d2327;
}

/* ==========================================================================
   KB Search
   ========================================================================== */
.kb-search {
    margin: 30px 0;
}

.kb-search__form {
    position: relative;
    max-width: 600px;
    margin: 0 auto;
}

.kb-search__input {
    width: 100%;
    padding: 15px 50px 15px 20px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s ease;
}

.kb-search__input:focus {
    border-color: #007cba;
}

.kb-search__button {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    color: #50575e;
    transition: color 0.2s ease;
}

.kb-search__button:hover {
    color: #007cba;
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ==========================================================================
   KB Breadcrumbs
   ========================================================================== */
.kb-breadcrumbs {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.kb-breadcrumbs__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    font-size: 0.9rem;
    color: #8c8f94;
}

.kb-breadcrumbs__item {
    display: flex;
    align-items: center;
}

.kb-breadcrumbs__link {
    color: #50575e;
    text-decoration: none;
    transition: color 0.2s ease;
}

.kb-breadcrumbs__link:hover {
    color: #007cba;
}

.kb-breadcrumbs__separator {
    margin: 0 8px;
    opacity: 0.5;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
    .kb-sidebar {
        position: static;
        height: auto;
        margin-bottom: 30px;
    }

    .kb-search__input {
        font-size: 14px;
        padding: 12px 45px 12px 15px;
    }
}

/* ==========================================================================
   KB Sections Navigator
   ========================================================================== */
.kb-sections-navigator {
    position: relative;
}

/* Disable link clicks in the editor to prevent accidental navigation */
.editor-styles-wrapper .kb-nav-link,
.editor-styles-wrapper .kb-nav-mobile-toggle {
    pointer-events: none;
}

/* Mobile toggle button - hidden on desktop */
.kb-nav-mobile-toggle {
    display: none;
}

.kb-nav-mobile-text {
    flex: 1;
}

.kb-nav-mobile-icon {
    transition: transform 0.2s ease;
}

.kb-nav-mobile-open .kb-nav-mobile-icon {
    transform: rotate(180deg);
}

/* Navigation menu */
.kb-nav-menu {
    display: block;
}

.kb-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.kb-nav-item {
    position: relative;
    margin-bottom: 4px;
}

.kb-nav-link {
    display: block;
    padding: 10px 15px;
    color: #50575e;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.kb-nav-link:hover {
    background-color: #f0f0f0;
    color: #1d2327;
}

.kb-nav-current>.kb-nav-link {
    font-weight: bold;
}


/* Nested levels - indentation */
.kb-nav-level-1 {
    padding-left: 20px;
    margin-top: 4px;
}

.kb-nav-level-2 {
    padding-left: 20px;
    margin-top: 4px;
}

.kb-nav-level-3 {
    padding-left: 20px;
    margin-top: 4px;
}

/* Expandable mode */
.kb-nav-mode-expandable .kb-nav-has-children {
    position: relative;
}

.kb-nav-toggle {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #50575e;
    z-index: 1;
}

.kb-nav-toggle-icon {
    display: inline-block;
    font-size: 10px;
    transition: transform 0.2s ease;
}

.kb-nav-mode-expandable .kb-nav-has-children>.kb-nav-link {
    padding-left: 30px;
}

.kb-nav-mode-expandable .kb-nav-collapsed>.kb-nav-list {
    display: none;
}

.kb-nav-mode-expandable .kb-nav-expanded>.kb-nav-toggle .kb-nav-toggle-icon {
    transform: rotate(90deg);
}

/* Mobile responsive */
@media (max-width: 768px) {
    .kb-nav-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        padding: 12px 15px;
        background: #fff;
        border: 2px solid #e0e0e0;
        border-radius: 6px;
        cursor: pointer;
        font-size: 16px;
        color: #1d2327;
        transition: all 0.2s ease;
    }

    .kb-nav-mobile-toggle:hover {
        border-color: #007cba;
    }

    .kb-nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        margin-top: 8px;
        background: #fff;
        border: 2px solid #e0e0e0;
        border-radius: 6px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        max-height: 400px;
        overflow-y: auto;
        z-index: 100;
        padding: 8px;
    }

    .kb-nav-mobile-open .kb-nav-menu {
        display: block;
    }

    /* On mobile, always show all sections expanded */
    .kb-nav-mode-expandable .kb-nav-collapsed>.kb-nav-list {
        display: block !important;
    }

    /* Hide toggle buttons on mobile since everything is expanded */
    .kb-nav-mode-expandable .kb-nav-toggle {
        display: none;
    }

    /* Remove extra padding since no toggle button */
    .kb-nav-mode-expandable .kb-nav-has-children>.kb-nav-link {
        padding-left: 15px;
    }
}