/**
 * CM Kurs-Builder - Browse/Bibliothek Styles
 * Version: 1.2.0
 *
 * BEM mit cmkb- Prefix
 * Verwendet CSS-Variablen aus dem Child-Theme
 */

/* ===== Container ===== */

.cmkb-bibliothek {
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== Zielgruppe Tabs ===== */

.cmkb-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.cmkb-tab {
    padding: 8px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    background: #fff;
    color: #555;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.cmkb-tab:hover {
    border-color: var(--cm-primary, #005761);
    color: var(--cm-primary, #005761);
}

.cmkb-tab--active {
    background: var(--cm-primary, #005761);
    border-color: var(--cm-primary, #005761);
    color: #fff;
}

.cmkb-tab--active:hover {
    color: #fff;
}

/* ===== Filter Bar ===== */

.cmkb-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}

/* Suchfeld */
.cmkb-search {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 400px;
}

.cmkb-search__input {
    width: 100%;
    padding: 8px 36px 8px 14px !important;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 0.9em;
    background: #fff;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    height: 40px;
}

.cmkb-search__input:focus {
    outline: none;
    border-color: var(--cm-primary, #005761);
}

.cmkb-search__icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1em;
    opacity: 0.5;
    pointer-events: none;
}

/* Filter Dropdowns */
.cmkb-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cmkb-filter-dropdown {
    position: relative;
}

.cmkb-filter-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    background: #fff;
    color: #555;
    font-size: 0.9em;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    box-sizing: border-box;
    height: 40px;
}

.cmkb-filter-btn:hover {
    border-color: var(--cm-primary, #005761);
}

.cmkb-filter-btn--active {
    border-color: var(--cm-primary, #005761);
    background: var(--cm-accent-light, #C6DDE0);
    color: var(--cm-primary, #005761);
}

.cmkb-filter-btn::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    margin-left: 2px;
    transition: transform 0.2s ease;
}

.cmkb-filter-dropdown--open .cmkb-filter-btn::after {
    transform: rotate(180deg);
}

.cmkb-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 180px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    z-index: 100;
    overflow: hidden;
}

.cmkb-filter-dropdown--open .cmkb-dropdown {
    display: block;
}

.cmkb-dropdown__item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    text-align: left;
    font-size: 0.9em;
    color: #555;
    cursor: pointer;
    transition: background 0.15s ease;
}

.cmkb-dropdown__item:hover {
    background: #f5f5f5;
}

.cmkb-dropdown__item--active {
    color: var(--cm-primary, #005761);
    font-weight: 600;
    background: var(--cm-accent-light, #C6DDE0);
}

/* ===== Aktive Filter Badges ===== */

.cmkb-active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.cmkb-filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--cm-accent-light, #C6DDE0);
    color: var(--cm-primary, #005761);
    border-radius: 16px;
    font-size: 0.85em;
    font-weight: 500;
}

.cmkb-filter-badge__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border: none;
    background: none;
    color: var(--cm-primary, #005761);
    font-size: 1.1em;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    border-radius: 50%;
    transition: background 0.15s;
}

.cmkb-filter-badge__remove:hover {
    background: rgba(0,0,0,0.1);
}

/* ===== Grid Layout ===== */

.cmkb-grid-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.cmkb-grid-count {
    font-size: 0.95em;
    color: #666;
}

.cmkb-grid-reset {
    border: none;
    background: none;
    color: var(--cm-secondary, #5C003A);
    font-size: 0.9em;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.cmkb-grid-reset:hover {
    opacity: 0.7;
}

.cmkb-cards--grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

/* ===== Kurs-Karte ===== */

.cmkb-card {
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e8e8e8;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cmkb-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.cmkb-card__link {
    display: block;
    text-decoration: none;
    color: inherit;
}

.cmkb-card__link:hover {
    color: inherit;
}

/* Bild */
.cmkb-card__image {
    position: relative;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: #f0f0f0;
}

.cmkb-card__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.cmkb-card:hover .cmkb-card__image img {
    transform: scale(1.05);
}

.cmkb-card__placeholder {
    object-fit: contain;
    padding: 20px;
    opacity: 0.6;
}

/* Haekchen-Badge fuer abgeschlossene Inhalte (oben rechts auf Thumbnail) */
.cmkb-card__check {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2e7d32;
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

/* Badges unter dem Bild (Preis + Dauer) */
.cmkb-card__badges {
    display: flex;
    justify-content: space-around;
    margin: 5px 0 5px;
}

.cmkb-card__badge {
    padding: 3px 14px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    color: #fff;
    background: var(--cm-primary, #005761);
}

.cmkb-card__badge--free {
    background: #2e7d32;
}

/* Typ-Label (z.B. "Themenbaustein") */
.cmkb-card__type-label {
    display: block;
    font-size: 0.8em;
    color: var(--cm-primary, #005761);
    margin-bottom: 2px;
}

/* Format-Label (z.B. "Praxis") mit Hintergrundfarbe */
.cmkb-card__format {
    display: inline-block;
    font-size: 0.85em;
    margin-top: 8px;
    padding: 4px 16px;
    border-radius: 4px;
}

/* Typ-Badge (Legacy, nicht mehr auf Bild) */
.cmkb-card__type {
    display: none;
    letter-spacing: 0.05em;
    color: #fff;
}

.cmkb-card__type--cm_kurs {
    background: var(--cm-primary, #005761);
}

.cmkb-card__type--cm_lektion {
    background: #2E7D32;
}

.cmkb-card__type--cm_kursgruppe {
    background: #1565C0;
}

/* Body */
.cmkb-card__body {
    padding: 14px 16px 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
}

.cmkb-card__title {
    font-size: 1.1em;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 4px;
    line-height: 1.2em;
    min-height: 4.3em;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    hyphens: auto;
    -webkit-hyphens: auto;
    word-break: break-word;
}

/* ===== KOMPAKT-LAYOUT ===== */

.cmkb-card--kompakt .cmkb-card__body {
    padding: 0 16px 14px;
    text-align: left;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.cmkb-card--kompakt .cmkb-card__meta-row {
    margin-top: auto;
}

.cmkb-card--kompakt .cmkb-card__link {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cmkb-card--kompakt .cmkb-card__type-bar {
    margin: 0 -16px 8px;
    padding: 5px 16px;
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.cmkb-card--kompakt .cmkb-card__title {
    min-height: auto;
    text-align: left;
    margin-bottom: 8px;
}

.cmkb-card__meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85em;
    color: #555;
}

.cmkb-card__meta-left {
    font-weight: 600;
    white-space: nowrap;
}

.cmkb-card__meta-free {
    color: #5c003a;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.cmkb-card__meta-sep {
    margin: 0 4px;
    color: #bbb;
}

.cmkb-card__meta-right {
    margin-left: auto;
    color: #777;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ===== Pagination ===== */

.cmkb-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.cmkb-page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #555;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.15s;
}

.cmkb-page-btn:hover {
    border-color: var(--cm-primary, #005761);
    color: var(--cm-primary, #005761);
}

.cmkb-page-btn--active {
    background: var(--cm-primary, #005761);
    border-color: var(--cm-primary, #005761);
    color: #fff;
}

.cmkb-page-btn--active:hover {
    color: #fff;
}

.cmkb-page-dots {
    color: #999;
    padding: 0 4px;
}

/* ===== Ladeanzeige ===== */

.cmkb-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: #888;
    font-size: 0.95em;
}

.cmkb-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: var(--cm-primary, #005761);
    border-radius: 50%;
    animation: cmkb-spin 0.7s linear infinite;
}

@keyframes cmkb-spin {
    to { transform: rotate(360deg); }
}

/* ===== Empty State ===== */

.cmkb-empty {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.cmkb-empty p {
    font-size: 1.1em;
    margin-bottom: 16px;
}

/* ===== Sidebar ===== */

.cmkb-sidebar {
    position: sticky;
    top: 100px;
}

.cmkb-sidebar__group {
    margin-bottom: 28px;
}

.cmkb-sidebar__heading {
    font-size: 0.85em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #999;
    margin: 0;
}

.cmkb-sidebar__list {
    list-style: none;
    list-style-type: none;
    margin: 0;
    padding: 0 !important;
}

.cmkb-sidebar__list li {
    margin-bottom: 5px;
    list-style: none;
    list-style-type: none;
}

.cmkb-sidebar__link {
    display: block;
    width: 100%;
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    text-align: left;
    font-size: 0.95em;
    background: var(--cm-accent-light, #C6DDE0);
    color: var(--cm-primary, #005761);
    cursor: pointer;
    transition: all 0.15s;
}

.cmkb-sidebar__link:hover {
    background: #f5f5f5;
    color: var(--cm-primary, #005761);
}

.cmkb-sidebar__link--active {
    background: #005761;
    color: #FFFFFF !important;
    font-weight: 600;
}
.cmkb-sidebar__link--active:hover {
    background: #5c003a;
    color: #FFFFFF !important;
    font-weight: 600;
}

/* ===== Empfehlungen-Block ([cmkb_empfehlungen]) ===== */

.cmkb-empfehlungen {
    margin: 40px 0;
}

.cmkb-empfehlungen__titel {
    font-size: 1.4em;
    margin: 0 0 20px;
    color: #005761;
}

.cmkb-empfehlungen__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* ===== Responsive ===== */

/* Tablet */
@media (max-width: 980px) {
    .cmkb-cards--grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .cmkb-empfehlungen__grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }

    .cmkb-filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .cmkb-search {
        max-width: none;
    }

    .cmkb-sidebar {
        position: static;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .cmkb-tabs {
        gap: 6px;
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 12px;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .cmkb-tabs::-webkit-scrollbar {
        display: none;
    }

    .cmkb-tab {
        padding: 6px 14px;
        font-size: 0.85em;
    }

    .cmkb-filters {
        width: 100%;
    }

    .cmkb-filter-dropdown {
        flex: 1;
    }

    .cmkb-filter-btn {
        width: 100%;
        justify-content: center;
        font-size: 0.85em;
        padding: 6px 12px;
        height: 36px;
    }

    .cmkb-dropdown {
        width: 100%;
        min-width: auto;
    }

    .cmkb-cards--grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .cmkb-empfehlungen__grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .cmkb-card__body {
        padding: 10px 12px 12px;
    }

    .cmkb-card__title {
        font-size: 0.95em;
    }

    .cmkb-card__excerpt {
        display: none;
    }
}

/* =================================================================
   [cmkb_slider] - Horizontaler Slider mit Scroll-Snap + Pfeilnav
   (identische Kachel-Optik wie Kompakt-Layout)
   ================================================================= */

.cmkb-slider {
    position: relative;
    margin: 20px 0;
}

.cmkb-slider__track {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding: 5px 2px 15px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #c6dde0 transparent;
}

.cmkb-slider__track::-webkit-scrollbar {
    height: 6px;
}
.cmkb-slider__track::-webkit-scrollbar-track {
    background: transparent;
}
.cmkb-slider__track::-webkit-scrollbar-thumb {
    background: #c6dde0;
    border-radius: 3px;
}

.cmkb-slider__item {
    flex: 0 0 calc(25% - 15px);   /* 4 Kacheln Desktop */
    scroll-snap-align: start;
    min-width: 0;
    display: flex;
}

.cmkb-slider__item > .cmkb-card {
    width: 100%;
    height: 100%;
}

@media (max-width: 1024px) {
    .cmkb-slider__item { flex-basis: calc(33.333% - 14px); } /* 3 Tablet */
}
@media (max-width: 768px) {
    .cmkb-slider__item { flex-basis: calc(50% - 10px); }     /* 2 klein Tablet */
}
@media (max-width: 480px) {
    .cmkb-slider__item { flex-basis: 85%; }                   /* 1 + Peek Handy */
}

.cmkb-slider__nav {
    position: absolute;
    top: 40%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    z-index: 2;
    padding: 0;
    font-size: 18px;
    line-height: 38px;
    color: #005761;
    transition: background 0.15s, box-shadow 0.15s;
}

.cmkb-slider__nav:hover,
.cmkb-slider__nav:focus {
    background: #f7f7f7;
    outline: none;
    box-shadow: 0 3px 12px rgba(0,0,0,0.18);
}

.cmkb-slider__nav--prev { left: -12px; }
.cmkb-slider__nav--next { right: -12px; }

.cmkb-slider__nav:disabled {
    opacity: 0.3;
    cursor: default;
    box-shadow: none;
}

@media (max-width: 768px) {
    /* Mobile: Pfeile weg, Wischen reicht */
    .cmkb-slider__nav { display: none; }
}


/* Badge "Gekauft" auf Kacheln (statt Preis) — fuer alle CPT-Ebenen gleich */
.cmkb-card__badge--bought {
    display: inline-block;
    padding: 3px 12px;
    background: #5C003A;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    border-radius: 5px;
    line-height: 1.3;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

/* ----------------------------------------------------------------------
   [cmkb_grid] — statisches Grid, Karten gleich gross
   Eingebaut 2026-05-03 (Empty-Cart Empfehlungen)
   ---------------------------------------------------------------------- */
.cmkb-card-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 25px;
    margin: 25px 0;
}

.cmkb-card-grid__item {
    min-width: 0;
}

/* Tablet */
@media (max-width: 980px) {
    .cmkb-card-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px;
    }
}

/* Mobile */
@media (max-width: 600px) {
    .cmkb-card-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}
