/**
 * TPG Popular Courses — Shortcode Component Styles
 *
 * Layout: Featured card (left) + stacked horizontal cards (right).
 * All classes prefixed .tpg-pop-* to avoid theme conflicts.
 *
 * Thumbnail rendering uses .tpg-html-thumb classes from html-thumbnails.css,
 * which must be enqueued alongside this stylesheet.
 *
 * @package TPG Addons for LifterLMS
 * @since   2.25.0
 */

/* ==========================================================================
   Grid Layout
   ========================================================================== */

.tpg-pop-section {
    background: var(--tpg-white, #FFFFFF);
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
}

.tpg-pop-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

/* ==========================================================================
   Featured Card (left column)
   ========================================================================== */

.tpg-pop-featured {
    background: var(--tpg-white, #FFFFFF);
    border: 1px solid var(--tpg-border-gray, #EDEDED);
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.tpg-pop-featured:hover {
    border-color: var(--tpg-dark-orange, #F05A28);
}

.tpg-pop-featured > a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.tpg-pop-featured .tpg-pop-thumb {
    overflow: hidden;
    background: var(--tpg-light-gray, #F0F4F7);
}

/* Photo thumbnails inside the featured card */
.tpg-pop-featured .tpg-pop-thumb .tpg-course-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.tpg-pop-featured .tpg-pop-content {
    padding: 18px 22px 22px;
}

/* Meta bar: categories left, duration/difficulty right */
.tpg-pop-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.tpg-pop-cats {
    display: flex;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.tpg-pop-cats li a {
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--tpg-dark-blue, #294196);
    text-decoration: none;
}

.tpg-pop-cats li a:hover {
    color: var(--tpg-dark-orange, #F05A28);
}

.tpg-pop-details {
    display: flex;
    align-items: center;
    gap: 14px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.tpg-pop-details li {
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-size: 14px;
    color: var(--tpg-medium-gray, #595A5B);
    display: flex;
    align-items: center;
    gap: 4px;
}

.tpg-pop-details li i {
    font-size: 11px;
}

/* Title */
.tpg-pop-title {
    font-family: var(--tpg-font-heading, 'Lora', Georgia, serif);
    font-weight: 700;
    line-height: 1.3;
    color: var(--tpg-black, #212122);
    margin: 0 0 6px;
}

.tpg-pop-featured .tpg-pop-title {
    font-size: 22px;
}

/* Excerpt (featured card only) */
.tpg-pop-excerpt {
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-size: 14px;
    line-height: 1.5;
    color: var(--tpg-medium-gray, #595A5B);
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Author + rating row */
.tpg-pop-author-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.tpg-pop-author {
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-size: 14px;
    color: var(--tpg-medium-gray, #595A5B);
}

/* Rating */
.tpg-pop-rating {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.tpg-pop-rating-val {
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-size: 14px;
    font-weight: 700;
    color: var(--tpg-orange, #F88E4E);
    margin-right: 2px;
}

.tpg-pop-rating-stars {
    display: inline-flex;
    gap: 2px;
}

.tpg-pop-rating-stars i {
    font-size: 12px;
    color: var(--tpg-orange, #F88E4E);
}

.tpg-pop-rating-stars i.far {
    color: var(--tpg-gray, #D8DDE2);
}

.tpg-pop-rating-count {
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-size: 14px;
    color: var(--tpg-medium-gray, #595A5B);
    margin-left: 2px;
}

/* Price */
.tpg-pop-price {
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-weight: 700;
    color: var(--tpg-price-dark, #333333);
    line-height: 1.3;
    margin-bottom: 10px;
}

.tpg-pop-featured .tpg-pop-price {
    font-size: 20px;
}

.tpg-pop-price del {
    font-weight: 400;
    color: var(--tpg-category-gray, #8D8F90);
    font-size: 0.82em;
    margin-left: 5px;
}

.tpg-pop-price-sale {
    display: inline-block;
    color: var(--tpg-dark-orange, #F05A28);
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 5px;
}

.tpg-pop-price-free {
    color: var(--tpg-dark-orange, #F05A28);
}

/* Tags */
.tpg-pop-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.tpg-pop-tag {
    display: inline-block;
    padding: 3px 12px;
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-size: 14px;
    font-weight: 600;
    color: var(--tpg-white, #FFFFFF);
    background: var(--tpg-dark-orange, #F05A28);
    border-radius: 100px;
    text-decoration: none;
}

/* Image placeholder */
.tpg-pop-featured .tpg-course-image-placeholder,
.tpg-pop-card .tpg-course-image-placeholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tpg-light-gray, #F0F4F7);
}

.tpg-course-image-placeholder i {
    font-size: 32px;
    color: var(--tpg-category-gray, #8D8F90);
}

/* ==========================================================================
   Mini-Wide HTML Thumbnail (sidebar cards)
   ==========================================================================
   Gradient + pattern + CoP badge + TPG logo. No title text — the course
   name is displayed beside the thumbnail in the card body.
   Mirrors the WooCommerce cart mini thumbnail but at 16:9 aspect ratio.
   ========================================================================== */

.tpg-html-thumb--mini-wide {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 3px;
}

.tpg-html-thumb--mini-wide .t-pattern {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.tpg-html-thumb--mini-wide .t-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 3;
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-size: 8px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 2px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    line-height: 1.3;
    max-width: 85%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tpg-html-thumb--mini-wide .t-logo-wrap {
    position: absolute;
    bottom: 6px;
    right: 6px;
    z-index: 3;
}

.tpg-html-thumb--mini-wide .tpg-logo {
    height: 14px;
    width: auto;
    display: block;
    opacity: 0.85;
}

/* Photo layer — course featured image behind the gradient scrim */
.tpg-html-thumb--mini-wide .t-photo {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    z-index: 0 !important;
    border-radius: 0 !important;
    transition: none !important;
}

/* ==========================================================================
   Sidebar: Stacked Horizontal Cards (right column)
   ========================================================================== */

.tpg-pop-sidebar {
    display: flex;
    flex-direction: column;
}

.tpg-pop-card {
    border-bottom: 1px solid var(--tpg-border-gray, #EDEDED);
    padding: 14px 0;
}

.tpg-pop-card:first-child {
    padding-top: 0;
}

.tpg-pop-card:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

/* Card inner: thumbnail left, body right */
.tpg-pop-card-inner {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

/* Thumbnail link (left side) */
.tpg-pop-card .tpg-pop-thumb-link {
    flex: 0 0 190px;
    width: 190px;
    display: block;
    overflow: hidden;
    background: var(--tpg-light-gray, #F0F4F7);
    border-radius: 3px;
    text-decoration: none;
}

/* Photo thumbnails inside sidebar cards */
.tpg-pop-card .tpg-pop-thumb-link .tpg-course-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    border-radius: 3px;
}

/* Body (right side) */
.tpg-pop-card .tpg-pop-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Title link — separate <a> to avoid nested anchors */
.tpg-pop-card .tpg-pop-title-link {
    text-decoration: none;
    color: inherit;
}

.tpg-pop-card .tpg-pop-title-link:hover .tpg-pop-title {
    color: var(--tpg-dark-orange, #F05A28);
}

/* Sidebar card overrides */
.tpg-pop-card .tpg-pop-title {
    font-size: 16px;
    margin-bottom: 3px;
}

.tpg-pop-card .tpg-pop-author {
    font-size: 14px;
    margin-bottom: 4px;
    display: block;
}

.tpg-pop-card .tpg-pop-rating {
    margin-bottom: 4px;
}

.tpg-pop-card .tpg-pop-rating-val {
    font-size: 14px;
}

.tpg-pop-card .tpg-pop-rating-stars i {
    font-size: 12px;
}

.tpg-pop-card .tpg-pop-rating-count {
    font-size: 14px;
}

.tpg-pop-card .tpg-pop-price {
    font-size: 16px;
    margin-bottom: 6px;
}

.tpg-pop-card .tpg-pop-price del {
    font-size: 14px;
}

.tpg-pop-card .tpg-pop-tags {
    gap: 4px;
}

.tpg-pop-card .tpg-pop-tag {
    font-size: 14px;
    padding: 3px 11px;
}

/* ==========================================================================
   Action Row: CTA Link + Favourites Heart
   ========================================================================== */

.tpg-pop-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 8px;
}

/* Push action row to bottom of featured card */
.tpg-pop-featured .tpg-pop-action-row {
    margin-top: 0;
}

/* CTA text link */
.tpg-pop-cta {
    font-family: var(--tpg-font-body, 'Source Sans 3', sans-serif);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.00096em;
    color: var(--tpg-dark-orange, #F05A28);
    text-decoration: none;
    transition: color 0.2s ease;
}

.tpg-pop-cta:hover {
    color: var(--tpg-dark-blue, #294196);
}

.tpg-pop-featured .tpg-pop-cta {
    font-size: 18px;
}

/* Adding state */
.tpg-pop-cta.tpg-adding {
    opacity: 0.6;
    pointer-events: none;
}

/* View Basket variant */
.tpg-pop-view-basket {
    color: var(--tpg-dark-blue, #294196);
}

/* Heart button — aggressive resets to override theme/Elementor button styles.
   Scoped to .tpg-pop-section for maximum specificity against theme rules
   like .elementor-widget-container button or .home-cours-area button */
.tpg-pop-section .tpg-pop-heart,
.tpg-pop-section button.tpg-pop-heart,
.elementor-widget-container .tpg-pop-heart {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    cursor: pointer;
    padding: 4px !important;
    margin: 0 !important;
    line-height: 1 !important;
    transition: transform 0.15s ease;
    width: auto !important;
    height: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    border-radius: 0 !important;
    outline: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    color: inherit !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-size: inherit !important;
}

.tpg-pop-section .tpg-pop-heart:hover,
.tpg-pop-section .tpg-pop-heart:focus,
.tpg-pop-section .tpg-pop-heart:active,
.tpg-pop-section button.tpg-pop-heart:hover,
.tpg-pop-section button.tpg-pop-heart:focus,
.tpg-pop-section button.tpg-pop-heart:active {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
}

.tpg-pop-section .tpg-pop-heart i {
    font-size: 18px;
    color: var(--tpg-gray, #D8DDE2);
    transition: color 0.2s ease;
}

.tpg-pop-section .tpg-pop-heart:hover i {
    color: var(--tpg-dark-orange, #F05A28);
}

.tpg-pop-section .tpg-pop-heart.is-favorited i {
    color: var(--tpg-dark-orange, #F05A28);
}

.tpg-pop-section .tpg-pop-heart:active {
    transform: scale(0.9);
}

.tpg-pop-section .tpg-pop-heart.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* Sidebar card: smaller heart */
.tpg-pop-section .tpg-pop-card .tpg-pop-heart i {
    font-size: 16px;
}

.tpg-pop-section .tpg-pop-card .tpg-pop-cta {
    font-size: 14px;
}

/* ==========================================================================
   Responsive Breakpoints — aligned with TPG B1–B6 grid system
   (mirrors course-archive.css container widths + padding)
   ========================================================================== */

/* --- B5: 1024–1279px ---------------------------------------------------- */
@media (min-width: 1024px) and (max-width: 1279px) {
    .tpg-pop-section {
        max-width: 960px;
        margin-left: auto;
        margin-right: auto;
    }

    .tpg-pop-grid {
        gap: 20px;
    }
}

/* --- B4: 840–1023px ----------------------------------------------------- */
@media (min-width: 840px) and (max-width: 1023px) {
    .tpg-pop-section {
        max-width: 960px;
        margin-left: auto;
        margin-right: auto;
    }

    .tpg-pop-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .tpg-pop-card .tpg-pop-thumb-link {
        flex: 0 0 180px;
        width: 180px;
    }
}

/* --- B3: 600–839px ------------------------------------------------------ */
@media (min-width: 600px) and (max-width: 839px) {
    .tpg-pop-section {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .tpg-pop-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .tpg-pop-card .tpg-pop-thumb-link {
        flex: 0 0 160px;
        width: 160px;
    }

    .tpg-pop-featured .tpg-pop-title {
        font-size: 18px;
    }
}

/* --- B2: 480–599px ------------------------------------------------------ */
@media (min-width: 480px) and (max-width: 599px) {
    .tpg-pop-section {
        max-width: 100%;
        padding-left: 20px;
        padding-right: 20px;
    }

    .tpg-pop-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .tpg-pop-card .tpg-pop-thumb-link {
        flex: 0 0 140px;
        width: 140px;
    }

    .tpg-pop-featured .tpg-pop-title {
        font-size: 18px;
    }

    .tpg-pop-featured .tpg-pop-excerpt {
        display: none;
    }

    .tpg-pop-meta-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

/* --- B1: ≤479px --------------------------------------------------------- */
@media (max-width: 479px) {
    .tpg-pop-section {
        max-width: 100%;
        padding-left: 20px;
        padding-right: 20px;
    }

    .tpg-pop-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .tpg-pop-card-inner {
        flex-direction: column;
        gap: 8px;
    }

    .tpg-pop-card .tpg-pop-thumb-link {
        flex: none;
        width: 100%;
    }

    .tpg-pop-featured .tpg-pop-title {
        font-size: 18px;
    }

    .tpg-pop-featured .tpg-pop-excerpt {
        display: none;
    }

    .tpg-pop-featured .tpg-pop-cta {
        font-size: 14px;
    }

    .tpg-pop-meta-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}
