/* ============================================================
   khoa-hoc.css — Course Listing Page Styles
   Used by: page-khoa-hoc.php (Flatsome Child)
   ============================================================ */

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
    --kh-primary:        #1a3c8f;
    --kh-primary-light:  #e8edf8;
    --kh-accent:         #f5a623;
    --kh-free-bg:        #2ecc71;
    --kh-bundle-bg:      #e67e22;
    --kh-paid-bg:        #3498db;
    --kh-text:           #1a1a2e;
    --kh-text-muted:     #6b7280;
    --kh-border:         #e5e7eb;
    --kh-card-shadow:    0 2px 12px rgba(0, 0, 0, 0.08);
    --kh-card-hover:     0 8px 32px rgba(26, 60, 143, 0.15);
    --kh-radius:         10px;
    --kh-sidebar-width:  255px;
    --kh-gap:            24px;
}

/* ── Page Wrapper ──────────────────────────────────────────── */
body.page-template-page-khoa-hoc #main,
body.page-template-page-bai-tap #main {
    background-color: #F3F5F8;
}

#kh-page {
    display: flex;
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 24px 60px;
    align-items: stretch;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.kh-sidebar {
    width: var(--kh-sidebar-width);
    flex-shrink: 0;
    background-color: #fff;
    box-shadow: 0px 4px 28.7px 0px #0000000D;
    border-radius: 12px;
    padding: 10px;
}

.kh-cat-list,
.kh-subcat-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.kh-cat-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    color: var(--kh-text);
    font-size: 18px;
    font-weight: 400;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
    line-height: 1.4;
}

.kh-cat-link:hover {
    background: var(--kh-primary-light);
    color: var(--kh-primary);
}

.kh-cat-link.is-active {
    background: linear-gradient(321.04deg, #0200B9 22.36%, #020207 77.64%);
    color: #fff;
    font-weight: 600;
}

.kh-cat-link.is-active .kh-cat-arrow {
    color: #fff;
}

.kh-cat-arrow {
    font-size: 1.1rem;
    color: var(--kh-text-muted);
    transition: transform 0.25s;
    line-height: 1;
}

.kh-cat-item.is-open > .kh-cat-link .kh-cat-arrow {
    transform: rotate(90deg);
}

/* Sub-category list */
.kh-subcat-list {
    display: none;
    background: #f9fafb;
    border-top: 1px solid var(--kh-border);
}

.kh-cat-item.is-open > .kh-subcat-list {
    display: block;
}

.kh-subcat-link {
    padding-left: 32px;
    font-weight: 400;
    font-size: 0.875rem;
    color: var(--kh-text-muted);
}

.kh-subcat-link:hover {
    color: var(--kh-primary);
    background: var(--kh-primary-light);
}

.kh-subcat-link.is-active {
    color: var(--kh-primary);
    font-weight: 600;
    background: var(--kh-primary-light);
}

/* ── Main Content ──────────────────────────────────────────── */
.kh-main {
    flex: 1;
    min-width: 0;
}

/* Header row */
.kh-main-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.kh-page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--kh-text);
    margin: 0;
    flex-shrink: 0;
}

.kh-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-left: auto;
    width: 100%;
}

/* Search */
.kh-search-form {
    margin: 0;
    width: 531px;
    max-width: 100%;
}

.kh-search-wrap {
    display: flex;
    align-items: center;
    border: 1px solid rgba(90, 88, 84, 0.26);
    border-radius: 8px;
    padding: 6px;
    overflow: hidden;
    background: #FAFAFA;
    transition: border-color 0.2s;
}

.kh-search-wrap:focus-within {
    border-color: var(--kh-primary);
}

.kh-search-form .kh-search-input {
    border: none;
    outline: none;
    padding: 10px 14px;
    font-size: 16px;
    font-weight: 400;
    color: #171717;
    background: transparent;
    margin: 0;
    box-shadow: none !important;
}

.kh-search-input::placeholder {
    color: #171717;
}

.kh-search-btn {
    background: #30358B;
    border: none;
    padding: 10px 14px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    margin: 0;
    border-radius: 4px;
    transition: background 0.2s;
}

.kh-search-btn:hover {
    background: #152f72;
}

/* Sort */
.kh-sort-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--kh-text-muted);
}

.kh-sort-label {
    white-space: nowrap;
    font-weight: 400;
    color: #171717;
    font-size: 16px;
    margin-right: 36px;
    margin-bottom: 0;
}

.kh-sort-select-wrap {
    position: relative;
}

.kh-sort-select {
    height: 50px;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid rgba(90, 88, 84, 0.26);
    border-radius: 8px;
    padding: 12px 35px;
    font-size: 16px;
    font-weight: 400;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
    cursor: pointer;
    min-width: 154px;
    color: #171717;
    margin-bottom: 0;
}

.kh-sort-select:focus {
    outline: none;
}

/* ── Course Grid ───────────────────────────────────────────── */
.kh-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 36px;
}

/* ── Course Card ───────────────────────────────────────────── */
.kh-card {
    background: #fff;
    border: 1px solid #30358B;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 12px;
    box-shadow: var(--kh-card-shadow);
}

/* Thumbnail */
.kh-card-thumb {
    position: relative;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    border-radius: 10px;
}

.kh-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s;
}

.kh-card:hover .kh-card-thumb img {
    transform: scale(1.04);
}

/* Badge */
.kh-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    font-size: 18px;
    font-weight: 400;
    color: #fff;
    border-radius: 5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
}

/* .kh-badge.badge--free   { background: var(--kh-free-bg); }
.kh-badge.badge--bundle { background: var(--kh-bundle-bg); }
.kh-badge.badge--paid   { background: var(--kh-paid-bg); }
.kh-badge.badge--custom { background: var(--kh-primary); } */

/* Card body */
.kh-card-body {
    padding: 12px 0 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kh-card-title {
    font-size: 20px;
    font-weight: 700;
    color: #202020;
    margin: 0;
    line-height: 1.35;
}

.kh-card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s;
}

.kh-card-title a:hover {
    color: var(--kh-primary);
}

.kh-card-excerpt {
    font-size: 15px;
    color: #5C5D67;
    font-weight: 400;
    margin: 0;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

/* Meta list */
.kh-card-meta {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.kh-card-meta li {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--kh-text-muted);
}

.kh-card-meta li svg {
    flex-shrink: 0;
    color: var(--kh-primary);
}

/* Card footer */
.kh-card-footer {
    display: flex;
    gap: 10px;
    padding: 14px 0 0;
    margin-top: auto;
}

/* Buttons */
.kh-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 400;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    line-height: 1;
    border: 1px solid transparent;
}

.kh-btn--outline {
    border-color: #020207;
    color: #020207;
    background: transparent;
}

.kh-btn--solid {
    background: linear-gradient(321.04deg, #0200B9 22.36%, #020207 77.64%);
    color: #fff;
    margin: 0;
    text-transform: capitalize;
    width: max-content;
    flex: unset;
}

/* Save button saved state */
.kh-btn--save.is-saved {
    background: #e8edf8;
    color: var(--kh-primary);
    border-color: var(--kh-primary);
}

/* ── Empty state ───────────────────────────────────────────── */
.kh-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--kh-text-muted);
}

.kh-empty p {
    font-size: 1rem;
    margin-bottom: 16px;
}

/* ── Pagination ────────────────────────────────────────────── */
.kh-pagination {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.kh-pager {
    display: flex;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.kh-page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1.5px solid var(--kh-border);
    border-radius: 7px;
    color: var(--kh-text);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    background: #fff;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.kh-page-link:hover {
    border-color: var(--kh-primary);
    color: var(--kh-primary);
    background: var(--kh-primary-light);
}

.kh-page-link.is-current {
    background: var(--kh-primary);
    border-color: var(--kh-primary);
    color: #fff;
    cursor: default;
    pointer-events: none;
}

.kh-page-prev,
.kh-page-next {
    font-size: 1.1rem;
}

.kh-page-dots {
    padding: 0 4px;
    color: var(--kh-text-muted);
}

/* ── Loading overlay ───────────────────────────────────────── */
.kh-loading {
    position: relative;
    pointer-events: none;
}

.kh-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--kh-radius);
    z-index: 10;
}

#wrapper .tutor-card-md .tutor-card-body,
#wrapper .tutor-card-md .tutor-card-footer {
    padding: 20px;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .kh-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    #kh-page {
        flex-direction: column;
        padding: 20px 16px 40px;
    }

    .kh-sidebar {
        width: 100%;
        position: static;
    }

    .kh-subcat-list {
        display: none !important;
    }

    .kh-cat-item.is-open > .kh-subcat-list {
        display: block !important;
    }

    .kh-main-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .kh-controls {
        margin-left: 0;
        width: 100%;
    }

    .kh-search-input {
        width: 100%;
        min-width: 0;
    }

    .kh-search-wrap {
        flex: 1;
    }

    .kh-search-form {
        flex: 1;
    }
}

@media (max-width: 560px) {
    .kh-grid {
        grid-template-columns: 1fr;
    }

    .kh-sort-wrap {
        flex-wrap: wrap;
    }
}
