/* Edwiser Store - Shop Page Styles */

/*
 * The declarations below intentionally use `!important` to override styles
 * coming from the active Moodle theme (Boost, RemUI, Classic and downstream
 * forks) and from Bootstrap utility classes. The plugin's host page selectors
 * (`#page-local-edwiserstore-*`, `.path-local-edwiserstore`) already provide
 * high specificity, but theme stylesheets load after this file and frequently
 * target the same shells, so `!important` is the documented escape hatch.
 */
/* stylelint-disable declaration-no-important */

/* Shop page, product cards, filters, and pagination */

.local-edwiserstore-shop-page {
    padding: 24px;
    width: 100%;
    max-width: 100%;
    margin: 0;
    min-height: calc(100vh - 200px);
}

/* Filters bar - no background or border */
.path-local-edwiserstore .shop-filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    padding: 8px 0;
}

.path-local-edwiserstore .shop-search-wrapper {
    position: relative;
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.path-local-edwiserstore .shop-search-input {
    width: 100%;
    padding: 10px 38px 10px 36px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    color: #1f2937;
}

.path-local-edwiserstore .shop-search-input::placeholder {
    color: #9ca3af;
}

.path-local-edwiserstore .shop-search-input:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    border-color: var(--edw-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--edw-primary) 10%, transparent);
}

.path-local-edwiserstore .shop-search-btn {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.path-local-edwiserstore .shop-search-btn:hover {
    color: var(--edw-primary);
}

.path-local-edwiserstore .shop-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    font-size: 16px;
    padding: 4px;
    line-height: 1;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.path-local-edwiserstore .shop-search-clear:hover {
    color: #ef4444;
    background: #fee2e2;
}

.path-local-edwiserstore .shop-category-wrapper {
    min-width: 180px;
}

.path-local-edwiserstore .shop-category-select,
.path-local-edwiserstore .shop-sort-select {
    padding: 10px 32px 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    appearance: none;
    color: #1f2937;
    min-width: 150px;
    background-image: url("../pix/caret-down.svg");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 10px;
}

.path-local-edwiserstore .shop-category-select:focus,
.path-local-edwiserstore .shop-sort-select:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    border-color: var(--edw-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--edw-primary) 10%, transparent);
}

.path-local-edwiserstore .shop-controls-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.path-local-edwiserstore .shop-view-toggle {
    display: flex;
    gap: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0;
    background: white;
    overflow: hidden;
}

.path-local-edwiserstore .shop-view-btn {
    background: white;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    border-radius: 0;
    margin: 0;
}

.path-local-edwiserstore .shop-view-icon {
    width: 16px;
    height: 16px;
    display: block;
    pointer-events: none;
    flex-shrink: 0;
}

.path-local-edwiserstore .shop-view-btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.path-local-edwiserstore .shop-view-btn:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.path-local-edwiserstore .shop-view-btn:not(:last-child) {
    border-right: 1px solid #d1d5db;
}

.path-local-edwiserstore .shop-view-btn.active {
    background: var(--edw-primary);
    color: white;
    border-right-color: transparent;
}

.path-local-edwiserstore .shop-view-btn.active + .shop-view-btn {
    border-left: none;
}

.path-local-edwiserstore .shop-view-btn:hover:not(.active) {
    background: #f3f4f6;
}

.path-local-edwiserstore .shop-view-btn:not(.active) .shop-view-icon {
    color: #6b7280;
}

.path-local-edwiserstore .shop-view-btn:hover:not(.active) .shop-view-icon {
    color: var(--edw-primary);
}

.path-local-edwiserstore .shop-view-btn.active .shop-view-icon {
    color: white;
}

.path-local-edwiserstore .shop-view-btn.active:hover {
    background: var(--edw-primary-hover);
}

.path-local-edwiserstore .shop-view-btn.active:hover .shop-view-icon {
    color: white;
}

.path-local-edwiserstore .shop-product-count {
    margin-bottom: 24px;
    color: #6b7280;
    font-size: 14px;
    font-weight: 400;
}

/* Empty States */
.path-local-edwiserstore .shop-empty-state {
    text-align: center;
    padding: 60px 20px 80px;
    margin-top: 40px;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.path-local-edwiserstore .shop-empty-state .empty-icon {
    margin-bottom: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.path-local-edwiserstore .shop-empty-state .empty-illustration {
    width: 200px;
    height: 200px;
    max-width: 100%;
    display: block;
}

.path-local-edwiserstore .shop-empty-state .empty-message {
    font-size: 24px;
    color: #374151;
    font-weight: 600;
    margin-top: 0;
    letter-spacing: -0.015em;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .path-local-edwiserstore .shop-empty-state {
        padding: 40px 20px 60px;
        margin-top: 30px;
    }

    .path-local-edwiserstore .shop-empty-state .empty-illustration {
        width: 160px;
        height: 160px;
    }

    .path-local-edwiserstore .shop-empty-state .empty-message {
        font-size: 20px;
    }
}

/* Products Container */
.path-local-edwiserstore .shop-products-container {
    margin-bottom: 40px;
    padding-top: 23px;
    border-top: 1px solid #e0e0e0;
}

/* Card View - Grid Layout */
.path-local-edwiserstore .shop-products-container.shop-view-card {
    display: grid;
    grid-template-columns:
        repeat(
            auto-fill,
            minmax(344px, 1fr)
        ); /* Figma: card width 344px */
    gap: 24px;
    width: 100%;
}

/* Card wrapper - should not interfere with grid layout */
.path-local-edwiserstore .shop-product-card-wrapper {
    width: 100%;
}

/* Responsive grid columns */
@media (min-width: 576px) {
    .path-local-edwiserstore .shop-products-container.shop-view-card {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .path-local-edwiserstore .shop-products-container.shop-view-card {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1200px) {
    .path-local-edwiserstore .shop-products-container.shop-view-card {
        grid-template-columns: repeat(4, 1fr);
    }
}

.path-local-edwiserstore .shop-product-card {
    background: white;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
    overflow: hidden;
    transition:
        transform 0.2s,
        box-shadow 0.2s;
    width: 100%;
    min-width: 0; /* Prevent flex items from expanding beyond container */
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: none;
}

.path-local-edwiserstore .shop-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.path-local-edwiserstore .shop-product-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0; /* Prevent flex items from expanding beyond container */
    width: 100%;
}

.path-local-edwiserstore .shop-product-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 344 / 200; /* Figma grid view image 344x200 */
    overflow: hidden;
    background: #f3f4f6;
    border-radius: 8px 8px 0 0;
}

.path-local-edwiserstore .shop-product-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Flex row container for labels on shop card image */
.path-local-edwiserstore .shop-product-labels {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    flex-direction: row;
    gap: 6px;
    z-index: 10;
}

.path-local-edwiserstore .shop-product-label {
    padding: 4px 10px; /* tighter padding */
    height: 24px;
    border-radius: 3px; /* match Figma tag */
    font-size: 12px; /* slightly smaller text */
    font-weight: 600;
    background-color: #fff;
    color: var(--edw-primary-dark);
    letter-spacing: 0.05em; /* subtle spacing */
    line-height: 1;
}

/* Bundle label badge on shop card image */
.path-local-edwiserstore .shop-label-bundle {
    background-color: #671dcf;
    color: #fff;
    font-size: 12px !important;
    font-weight: 600;
    border-radius: 3px;
    padding: 4px 8px;
    line-height: 1.2;
}

/* Type filter dropdown */
.path-local-edwiserstore .shop-type-wrapper {
    min-width: 140px;
}
.path-local-edwiserstore .shop-type-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background-color: #fff;
    cursor: pointer;
    outline: none;
}
.path-local-edwiserstore .shop-type-select:focus {
    border-color: var(--edw-primary-color, #4a6cf7);
}

/* Category tag positioned below image, centered */
.path-local-edwiserstore .shop-product-category-tag {
    background: var(--edw-primary-light);
    color: #313848;
    margin: -12px auto 12px 12px; /* center horizontally */
    padding: 4px 12px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    font-weight: 600;
    z-index: 5;
    position: relative;
    display: block; /* allows auto margins */
    width: fit-content;
    max-width: calc(100% - 32px); /* Safety fallback */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    text-align: center;
    font-size: 12px;
}

.path-local-edwiserstore .shop-product-info {
    padding: 16px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.path-local-edwiserstore .shop-product-title {
    font-size: 16px;
    font-weight: 400;
    margin-bottom: 14px;
    margin-top: 0;
    color: #313848;
    line-height: 24px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.path-local-edwiserstore .shop-product-title a {
    color: #313848;
    text-decoration: none;
}

.path-local-edwiserstore .shop-product-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #6b7280;
    flex-wrap: wrap;
    justify-content: space-between;
}

.path-local-edwiserstore .shop-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.path-local-edwiserstore .shop-meta-item i {
    font-size: 12px;
}

/* Star icon styling for ratings - yellow/gold color */
.path-local-edwiserstore .shop-meta-item i.fa-star {
    color: #f59e0b; /* Amber/yellow color matching design */
    font-size: 13px;
}

/* Footer section with price and button */
.path-local-edwiserstore .shop-product-footer {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-top: auto;
    padding-top: 12px;
}

.path-local-edwiserstore .shop-product-price {
    font-size: 16px;
    font-weight: 700;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-start;
}

.path-local-edwiserstore .shop-price-free,
.path-local-edwiserstore .shop-price-enrolled,
.path-local-edwiserstore .shop-price-actual {
    color: var(--edw-primary);
}

.path-local-edwiserstore .shop-price-free,
.path-local-edwiserstore .shop-price-enrolled {
    color: #313848 !important;
    text-transform: uppercase !important;
    font-size: 14px !important;
    font-weight: 700 !important;
}

.path-local-edwiserstore .shop-price-original {
    color: #9ca3af;
    text-decoration: line-through;
    font-size: 14px;
    font-weight: 400;
    margin-right: 0;
    line-height: 1.2;
}

.path-local-edwiserstore .shop-product-btn {
    padding: 8px 16px;
    background: white;
    color: var(--edw-primary-alt);
    border: 1px solid var(--edw-primary-alt);
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.4;
    height: fit-content;
}

.path-local-edwiserstore .shop-product-btn:hover {
    background: var(--edw-primary-alt);
    color: white;
    border-color: var(--edw-primary-alt);
}

/* List View */
.path-local-edwiserstore .shop-products-container.shop-view-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

/* List wrapper - should not interfere with flex layout */
.path-local-edwiserstore .shop-product-list-wrapper {
    width: 100%;
}

.path-local-edwiserstore .shop-product-list-item {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition:
        transform 0.2s,
        box-shadow 0.2s;
}

.path-local-edwiserstore .shop-product-list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.path-local-edwiserstore .shop-product-list-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    gap: 20px;
}

/* List view image wrapper fixed size */
.path-local-edwiserstore .shop-product-list-image-wrapper {
    position: relative;
    width: 390px;
    min-width: 390px;
    height: 208px; /* Figma list view image 390x208 */
    overflow: hidden;
    background: #f3f4f6;
}

.path-local-edwiserstore .shop-product-list-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.path-local-edwiserstore .shop-product-list-content {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.path-local-edwiserstore .shop-product-description {
    color: #6b7280;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.path-local-edwiserstore .shop-product-list-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: #6b7280;
}

.path-local-edwiserstore .shop-product-list-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: auto;
}

.path-local-edwiserstore .shop-product-list-footer .shop-product-btn {
    width: auto;
    min-width: 140px;
}

/* Pagination */
.path-local-edwiserstore .shop-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 40px;
}

.path-local-edwiserstore .shop-pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.path-local-edwiserstore .shop-pagination-link:hover {
    background: #f3f4f6;
    border-color: var(--edw-primary);
    color: var(--edw-primary);
}

.path-local-edwiserstore .shop-pagination-link.active {
    background: var(--edw-primary);
    border-color: var(--edw-primary);
    color: white;
}

.path-local-edwiserstore .shop-pagination-ellipsis {
    padding: 0 8px;
    color: #6b7280;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .path-local-edwiserstore .shop-filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .path-local-edwiserstore .shop-search-wrapper {
        max-width: 100%;
    }

    .path-local-edwiserstore .shop-controls-right {
        justify-content: space-between;
        width: 100%;
    }

    .path-local-edwiserstore .shop-products-container.shop-view-card {
        grid-template-columns: 1fr;
    }

    .path-local-edwiserstore .shop-product-list-link {
        flex-direction: column;
    }

    .path-local-edwiserstore .shop-product-list-image-wrapper {
        width: 100%;
        min-width: auto;
    }

    .path-local-edwiserstore .shop-product-list-footer {
        flex-direction: column;
        gap: 16px;
    }

    .path-local-edwiserstore .shop-product-list-footer .shop-product-btn {
        width: 100%;
    }
}

/* Design fixes */
#page-local-edwiserstore-shop #page {
    padding: 0 !important;
}

#page-local-edwiserstore-shop #topofscroll {
    padding: 0 !important;
    max-width: 100% !important;
}

#page-local-edwiserstore-shop #page-content div[role='main'] {
    padding: 0 !important;
}

#page-local-edwiserstore-shop #page-header {
    padding: 12px 24px !important;
    max-width: 1320px !important;
    margin: 0 auto !important;
}

#page-local-edwiserstore-shop .local-edwiserstore-shop-page {
    max-width: 1320px !important;
    margin: 0 auto !important;
}

#page-local-edwiserstore-shop .shop-product-link:hover,
#page-local-edwiserstore-shop .shop-product-link:focus,
#page-local-edwiserstore-shop .shop-product-list-link:hover,
#page-local-edwiserstore-shop .shop-product-list-link:focus {
    text-decoration: none !important;
}

#page-local-edwiserstore-shop .shop-product-list-link {
    gap: 0 !important;
}

#page-local-edwiserstore-shop .shop-product-link .shop-product-category-tag {
    margin-bottom: 0 !important;
}

#page-local-edwiserstore-shop
.shop-product-list-link
.shop-product-category-tag {
    margin-left: 0 !important;
    margin-top: 0 !important;
}

.local-edwiserstore-shop-page .shop-category-wrapper {
    max-width: 250px !important;
}

.local-edwiserstore-shop-page .shop-category-wrapper #shop-category-select {
    min-width: unset !important;
    width: 100% !important;
}

.local-edwiserstore-shop-page .shop-view-toggle {
    flex-shrink: 0 !important;
}

.local-edwiserstore-shop-page .shop-pagination-link:hover {
    text-decoration: none !important;
}

.local-edwiserstore-shop-page .shop-product-footer {
    align-items: center !important;
}

.local-edwiserstore-shop-page .shop-product-list-footer {
    justify-content: flex-end;
    gap: 24px;
}

.local-edwiserstore-shop-page .shop-product-price {
    flex: none;
}

.local-edwiserstore-shop-page .shop-product-list-image-wrapper {
    width: 100%;
    max-width: 390px;
    height: 100%;
    min-width: auto;
}

.local-edwiserstore-shop-page
.shop-product-list-image-wrapper
.shop-product-list-image {
    max-height: 245px;
}

@media (min-width: 768px) {
    .local-edwiserstore-shop-page .shop-products-container.shop-view-card {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (min-width: 1240px) {
    .local-edwiserstore-shop-page .shop-products-container.shop-view-card {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* Bundle courses hover popup */
.path-local-edwiserstore .shop-bundle-courses-trigger {
    position: relative;
    cursor: default;
}

.path-local-edwiserstore .shop-bundle-courses-popup {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    padding: 8px 12px;
    min-width: 180px;
    max-width: 260px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.path-local-edwiserstore .shop-bundle-courses-trigger:hover .shop-bundle-courses-popup {
    opacity: 1;
    pointer-events: auto;
}

.path-local-edwiserstore .shop-bundle-course-item {
    font-size: 12px;
    color: #374151;
    padding: 3px 0;
    line-height: 1.4;
    border-bottom: 1px solid #f3f4f6;
}

.path-local-edwiserstore .shop-bundle-course-item:last-child {
    border-bottom: none;
}
/* stylelint-enable declaration-no-important */
