/**
 * Weland Configurator V02 Frontend Styles
 */

.weland-product-badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    border-radius: 3px;
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 10;
}

.weland-configurator-badge {
    background-color: #0073aa;
    color: #fff;
}

.weland-normal-badge {
    background-color: #46b450;
    color: #fff;
}

.woocommerce ul.products li.product {
    position: relative;
}

.weland-category-configurator-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 20px 0;
}

.weland-category-info {
    align-self: flex-end;
    max-width: 400px;
    padding: 20px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.weland-category-title {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 28px;
    font-weight: bold;
    color: #333;
    line-height: 1.2;
}

.weland-category-description {
    line-height: 1.6;
    color: #666;
    font-size: 14px;
}

.weland-configurator-container {
    width: 100%;
    border: 1px solid #ddd;
    padding: 10px;
    background: #fff;
    border-radius: 5px;
    position: relative;
}

#weland-configurator-iframe {
    width: 100%;
    min-height: 800px;
    border: none;
    display: block;
}

/* Configurator loading overlay (category iframe) */
.weland-configurator-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    z-index: 10;
}

.weland-configurator-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: weland-spin 0.8s linear infinite;
}

.weland-configurator-loading-text {
    margin-top: 12px;
    font-size: 14px;
    color: #555;
}

@keyframes weland-spin {
    to {
        transform: rotate(360deg);
    }
}

#config-widget {
    position: relative;
    min-height: 400px;
}

#weland-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 20px;
    border-radius: 5px;
    z-index: 9999;
}

/* Hide default WooCommerce elements on configurator category pages */
.woocommerce-products-header,
.woocommerce-archive-description,
.woocommerce-breadcrumb {
    display: none !important;
}

.woocommerce-products-header + .products,
.woocommerce-products-header ~ ul.products {
    display: none !important;
}

.weland-category-configurator-wrapper ~ .products {
    display: none !important;
}

/* Cart item details */
.woocommerce-cart .cart_item .weland-article-details {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
}

/* Tillbehor child category grid (#grid-category) */
#grid-category.weland-tillbehor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    list-style: none;
    margin: 20px 0;
    padding: 0;
}

.weland-grid-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: inherit;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.weland-grid-card:hover {
    border-color: #0073aa;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.weland-grid-card-image {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    background: #f5f5f5;
}

.weland-grid-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.weland-grid-card-name {
    display: block;
    padding: 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
}

/* Shop page: configurator category cards inside #normal-widget */
#normal-widget .weland-shop-configurator-categories,
#normal-widget ul.weland-shop-configurator-categories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    list-style: none;
    margin: 0 0 24px 0;
    padding: 0;
}

#normal-widget .weland-shop-configurator-card-wrap {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
}

#normal-widget .weland-shop-configurator-card {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex: 1;
    min-height: 100%;
    height: 100%;
    text-decoration: none;
    color: #333;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

#normal-widget .weland-shop-configurator-card:hover {
    border-color: #0073aa;
    box-shadow: 0 6px 16px rgba(0, 115, 170, 0.15);
    color: #0073aa;
}

#normal-widget .weland-shop-configurator-card-image {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    flex-shrink: 0;
    background: #f5f5f5;
    overflow: hidden;
}

#normal-widget .weland-shop-configurator-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#normal-widget .weland-shop-configurator-card-name {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 0;
    padding: 14px 12px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    line-height: 1.3;
}

/* ===== Configurator category list (#configurator-list) ===== */
#configurator-list {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#configurator-list .weland-configurator-list-wrapper,
.weland-configurator-list-wrapper {
    width: 100%;
    margin: 1.5em 0;
    padding: 1rem 0;
    box-sizing: border-box;
}

#configurator-list .weland-configurator-list,
.weland-configurator-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

#configurator-list .weland-configurator-list li,
.weland-configurator-list li {
    margin: 0;
    padding: 0;
    border-bottom: 1px solid #eee;
}

#configurator-list .weland-configurator-list li:last-child,
.weland-configurator-list li:last-child {
    border-bottom: none;
}

#configurator-list .weland-configurator-list-link,
.weland-configurator-list-link {
    display: block;
    padding: 12px 16px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #4e897c;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

#configurator-list .weland-configurator-list-link:hover,
.weland-configurator-list-link:hover {
    background: #f8f9fa;
    color: #3d6b62;
    text-decoration: none;
}

#configurator-list .weland-configurator-list-empty,
.weland-configurator-list-empty {
    margin: 0;
    padding: 1rem 0;
    color: #646970;
    font-size: 0.9375rem;
}

/* ===== Zero-price products table (#digital-products and shortcode) ===== */
#digital-products {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

#digital-products .weland-zero-price-wrapper,
.weland-zero-price-wrapper {
    width: 100%;
    max-width: 100%;
    margin: 1.5em 0;
    font-size: 1rem;
    box-sizing: border-box;
}

#digital-products .weland-zero-price-table-wrap,
.weland-zero-price-table-wrap {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    margin-bottom: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    box-sizing: border-box;
}

#digital-products .weland-zero-price-products-table,
.weland-zero-price-products-table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
    margin: 0;
    font-size: 0.9375rem;
    table-layout: auto;
}

#digital-products .weland-zero-price-products-table th,
#digital-products .weland-zero-price-products-table td,
.weland-zero-price-products-table th,
.weland-zero-price-products-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

#digital-products .weland-zero-price-products-table thead th,
.weland-zero-price-products-table thead th {
    background: #f8f9fa;
    font-weight: 600;
    color: #1a1a1a;
    border-bottom: 2px solid #e0e0e0;
    white-space: nowrap;
}

#digital-products .weland-zero-price-products-table th:first-child,
#digital-products .weland-zero-price-products-table td:first-child,
#digital-products .weland-zero-price-products-table .weland-zero-price-no,
.weland-zero-price-products-table th:first-child,
.weland-zero-price-products-table td:first-child,
.weland-zero-price-products-table .weland-zero-price-no {
    width: 3em;
    min-width: 3em;
    text-align: right;
}

#digital-products .weland-zero-price-products-table tbody tr:hover,
.weland-zero-price-products-table tbody tr:hover {
    background: #f8f9fa;
}

#digital-products .weland-zero-price-pdf-link,
.weland-zero-price-pdf-link {
    display: inline-block;
    padding: 4px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #4e897c;
    text-decoration: none;
    border: 1px solid #4e897c;
    border-radius: 4px;
    transition: background 0.2s, color 0.2s;
}

#digital-products .weland-zero-price-pdf-link:hover,
.weland-zero-price-pdf-link:hover {
    background: #4e897c;
    color: #fff;
    text-decoration: none;
}

#digital-products .weland-zero-price-empty,
.weland-zero-price-empty {
    margin: 0;
    padding: 1rem 0;
    color: #646970;
}

/* Shared primary PDF button: detail page + cart (same font, bg, hover) */
.weland-zero-price-pdf-btn-primary {
    display: inline-block;
    padding: 0.5em 1.1em;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #4e897c !important;
    background: #fff;
    border: 1px solid #4e897c;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.weland-zero-price-pdf-btn-primary:hover {
    background: #4e897c;
    color: #fff !important;
    text-decoration: none;
}

.weland-zero-price-pdf-btn-primary:focus {
    outline: 2px solid #4e897c;
    outline-offset: 2px;
}

.weland-zero-price-pdf-btn-primary:focus:not(:focus-visible) {
    outline: none;
}

.weland-zero-price-pdf-btn-primary:focus-visible {
    outline: 2px solid #4e897c;
    outline-offset: 2px;
}

/* Zero-price PDF on single product page */
.weland-zero-price-pdf-single {
    margin: 1rem 0 0 0;
    padding-top: 1rem;
    border-top: 1px solid #eee;
}

/* Cart page: zero-price PDF as text-only "Download" link */
.weland-zero-price-pdf-link-cart {
    display: inline;
    padding: 0;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #4e897c !important;
    background: none;
    border: none;
    border-radius: 0;
    text-decoration: none;
    transition: color 0.2s;
}

.weland-zero-price-pdf-link-cart:hover {
    background: none;
    color: #3d6b62 !important;
    text-decoration: underline;
}

/* Frontend pagination */
#digital-products .weland-zero-price-pagination,
.weland-zero-price-frontend .weland-zero-price-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    margin-top: 12px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

#digital-products .weland-zero-price-pagination-info,
.weland-zero-price-frontend .weland-zero-price-pagination-info {
    font-size: 0.875rem;
    color: #646970;
}

#digital-products .weland-zero-price-pagination-list,
.weland-zero-price-frontend .weland-zero-price-pagination-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

#digital-products .weland-zero-price-pagination-list li,
.weland-zero-price-frontend .weland-zero-price-pagination-list li {
    margin: 0;
    padding: 0;
}

/* Pagination buttons: same style as PDF button (#4e897c) */
#digital-products .weland-zero-price-page-btn,
.weland-zero-price-frontend .weland-zero-price-page-btn {
    display: inline-block;
    padding: 0.5em 1.1em;
    min-width: 36px;
    text-align: center;
    font-size: 0.9375rem;
    font-weight: 500;
    color: #4e897c;
    background: #fff;
    border: 1px solid #4e897c;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

#digital-products .weland-zero-price-page-btn:hover,
.weland-zero-price-frontend .weland-zero-price-page-btn:hover {
    background: #4e897c;
    color: #fff;
    border-color: #4e897c;
}

#digital-products .weland-zero-price-page-current,
.weland-zero-price-frontend .weland-zero-price-page-current {
    display: inline-block;
    padding: 0.5em 1.1em;
    min-width: 36px;
    text-align: center;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #fff;
    background: #4e897c;
    border: 1px solid #4e897c;
    border-radius: 4px;
}

/* Responsive: card layout on small screens */
@media screen and (max-width: 640px) {
    #digital-products .weland-zero-price-table-wrap,
    .weland-zero-price-table-wrap {
        border-radius: 6px;
        overflow: visible;
    }

    #digital-products .weland-zero-price-products-table thead,
    .weland-zero-price-products-table thead {
        display: none;
    }

    #digital-products .weland-zero-price-products-table tbody tr,
    .weland-zero-price-products-table tbody tr {
        display: block;
        padding: 12px 16px;
        margin-bottom: 10px;
        border: 1px solid #e8e8e8;
        border-radius: 6px;
        background: #fff;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    }

    #digital-products .weland-zero-price-products-table tbody tr:hover,
    .weland-zero-price-products-table tbody tr:hover {
        background: #f8f9fa;
    }

    #digital-products .weland-zero-price-products-table td,
    .weland-zero-price-products-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 8px 0;
        border-bottom: none;
    }

    #digital-products .weland-zero-price-products-table td:first-child,
    .weland-zero-price-products-table td:first-child {
        padding-top: 0;
        font-weight: 600;
        font-size: 1rem;
        color: #1a1a1a;
    }

    #digital-products .weland-zero-price-products-table td:last-child,
    .weland-zero-price-products-table td:last-child {
        padding-bottom: 0;
    }

    #digital-products .weland-zero-price-products-table td::before,
    .weland-zero-price-products-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #646970;
        flex-shrink: 0;
    }

    #digital-products .weland-zero-price-pagination,
    .weland-zero-price-frontend .weland-zero-price-pagination {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}