/* ============================================================================
   Alliant Games — EspoCRM 10.0.3  |  Knowledge Base card browser
   Install path on server: client/custom/css/knowledge-base-cards.css
   Loaded via: custom/Espo/Custom/Resources/metadata/app/client.json

   THEME-SAFE: cards, badges, search box, toggle, article list and article pane
   reuse EspoCRM's own `.panel`, `.label`, `.btn`, `.list-group`, `.form-control`,
   `.complex-text` and `.text-*` classes, so they follow the active theme. This
   file only adds LAYOUT (grid, fixed card sizes, hover) plus a couple of brand
   accent colors (the article icon, the hover bar). Switch themes and the themed
   parts recolor themselves.

   Scoped under `.kb-cards` so it can't leak elsewhere.

   Brand accent (edit to match the login screen palette):
     --ag-blue: #2563EB   --ag-purple: #7C3AED   --ag-cyan: #22D3EE
   ============================================================================ */

.kb-cards {
    --ag-blue: #2563EB;
    --ag-purple: #7C3AED;
    --ag-cyan: #22D3EE;
    padding: 4px 2px 24px;
}

/* -------- Toolbar: search stretches to fill, toggle pinned right ------------- */
.kb-cards .kb-cards-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin: 2px 2px 14px;
}

/* Grow to fill all space up to the toggle (no fixed cap). */
.kb-cards .kb-search {
    position: relative;
    flex: 1 1 auto;
    min-width: 220px;
}

.kb-cards .kb-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    pointer-events: none;
}

.kb-cards .kb-search-input { padding-left: 34px; border-radius: 8px; }

.kb-cards .kb-view-toggle { flex: 0 0 auto; }

/* -------- Breadcrumb -------- */
.kb-cards .kb-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 4px 2px 18px;
    font-size: 14px;
}
.kb-cards .kb-crumb { text-decoration: none; cursor: pointer; }
.kb-cards .kb-crumb-current { font-weight: 600; cursor: default; }
.kb-cards .kb-crumb-sep { opacity: 0.4; }

/* -------- Search-results header -------- */
.kb-cards .kb-search-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 2px 2px 18px;
    font-size: 14px;
}
.kb-cards .kb-clear { text-decoration: none; cursor: pointer; }

/* -------- Section heading (shown when both categories & articles present) ---- */
.kb-cards .kb-section-title {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 6px 2px 12px;
}
.kb-cards .kb-section-title + .kb-cards-grid,
.kb-cards .kb-section-title + .list-group { margin-bottom: 26px; }

/* -------- Grids -------- */
.kb-cards .kb-cards-grid {
    display: grid;
    gap: 16px;
    align-items: stretch;   /* equal-height cards within a row */
}
.kb-cards .kb-grid-categories { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.kb-cards .kb-grid-articles   { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }

/* -------- Card (shared) -------- */
.kb-cards .kb-card {
    margin: 0;
    cursor: pointer;
    display: flex;
    overflow: hidden;
    position: relative;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.kb-cards .kb-card .panel-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}
.kb-cards .kb-card::before {
    content: "";
    position: absolute;
    left: 0; top: 0;
    height: 3px; width: 100%;
    background: linear-gradient(90deg, var(--ag-blue), var(--ag-purple) 55%, var(--ag-cyan));
    opacity: 0;
    transition: opacity 0.12s ease;
}
.kb-cards .kb-card:hover,
.kb-cards .kb-card:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    outline: none;
}
.kb-cards .kb-card:hover::before,
.kb-cards .kb-card:focus::before { opacity: 1; }

/* -------- Category card: fixed size + clamped description -------- */
.kb-cards .kb-card-category { min-height: 184px; }
.kb-cards .kb-card-category .panel-body { padding: 22px 20px; }
.kb-cards .kb-card-category .kb-card-icon { font-size: 40px; line-height: 1; }
.kb-cards .kb-card-category .kb-card-title {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.kb-cards .kb-card-category .kb-card-sub {
    font-size: 13.5px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* -------- Article card: smaller, uniform, purple icon, published date -------- */
.kb-cards .kb-card-article { min-height: 128px; }
.kb-cards .kb-card-article .panel-body { padding: 18px 16px; gap: 8px; }
.kb-cards .kb-card-article .kb-card-icon {
    font-size: 30px;
    line-height: 1;
    color: var(--ag-purple);   /* brand accent instead of grey */
}
.kb-cards .kb-card-article .kb-card-title {
    font-size: 14.5px;
    font-weight: 500;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.kb-cards .kb-card-date {
    font-size: 12px;
    margin-top: auto;   /* pin date to the bottom so cards stay tidy */
}
.kb-cards .kb-card-date .fas { margin-right: 4px; opacity: 0.8; }

/* -------- Article list (compact toggle option) -------- */
.kb-cards .kb-article-list .kb-article-row {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    text-decoration: none;
}
.kb-cards .kb-article-row .kb-row-icon {
    flex: 0 0 auto;
    font-size: 16px;
    color: var(--ag-purple);   /* match the card icon */
}
.kb-cards .kb-article-row .kb-row-title { flex: 1 1 auto; word-break: break-word; }
.kb-cards .kb-article-row .kb-row-date {
    flex: 0 0 auto;
    font-size: 12.5px;
    white-space: nowrap;
}

/* -------- Count badge (reuses .label for theme colors) -------- */
.kb-cards .kb-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1;
    min-width: 22px;
    text-align: center;
    border-radius: 11px;
}

/* -------- Article reading pane (in-place, wide, responsive) -------- */
.kb-cards .kb-article { margin: 0; }
.kb-cards .kb-article .panel-body { padding: 26px 28px; }
.kb-cards .kb-article-title { margin: 0 0 6px; line-height: 1.3; word-break: break-word; }
.kb-cards .kb-article-meta { font-size: 13px; margin-bottom: 18px; }
.kb-cards .kb-article-meta .fas { margin-right: 5px; opacity: 0.8; }
.kb-cards .kb-article-body { font-size: 15px; line-height: 1.6; }
.kb-cards .kb-article-body img { max-width: 100%; height: auto; }

/* -------- States -------- */
.kb-cards .kb-loading,
.kb-cards .kb-empty {
    padding: 40px 8px;
    text-align: center;
    font-size: 14px;
}

/* -------- Small screens -------- */
@media (max-width: 560px) {
    .kb-cards .kb-grid-categories { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
    .kb-cards .kb-grid-articles   { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .kb-cards .kb-card-category   { min-height: 160px; }
    .kb-cards .kb-article .panel-body { padding: 20px 18px; }
}
