/* Product Gallery Filter - Frontend Styles */

.pgf-gallery {
    display: grid;
    gap: 30px;
    grid-auto-flow: dense;
}

.pgf-gallery-columns-1 { grid-template-columns: repeat(1, 1fr); }
.pgf-gallery-columns-2 { grid-template-columns: repeat(2, 1fr); }
.pgf-gallery-columns-3 { grid-template-columns: repeat(3, 1fr); }
.pgf-gallery-columns-4 { grid-template-columns: repeat(4, 1fr); }
.pgf-gallery-columns-5 { grid-template-columns: repeat(5, 1fr); }
.pgf-gallery-columns-6 { grid-template-columns: repeat(6, 1fr); }

.pgf-gallery-item {
    padding: 15px;
    box-sizing: border-box;
    background-color: #f4f4f4;
    border-radius: 15px;
    box-shadow: 9px 7px 21px -8px rgba(0, 0, 0, 0.5);
    border: 1px solid transparent;
    transition: opacity 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, background-color 0.3s ease, max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease, border-width 0.3s ease !important;
    overflow: hidden;
    max-height: 1000px;
}


.pgf-gallery-item.has-link:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border-color: #ddd;
    background-color: #e0e0e0;
}

.pgf-gallery-item.pgf-hiding {
    opacity: 0;
    transform: scale(0.95);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-width: 0;
    box-shadow: none;
    overflow: hidden;
    pointer-events: none;
}

.pgf-gallery-item.pgf-hidden {
    display: none;
}

.pgf-gallery-item-image {
    overflow: hidden;
    border-radius: 4px 4px 0 0;
    padding: 0%;
}

.pgf-gallery-item.has-thumbnail .pgf-gallery-item-image {
    position: relative;
    height: 0;
    padding-bottom: 100%; /* Portrait aspect ratio - maximum height */
}

.pgf-gallery-item-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease-in-out !important;
}

.pgf-gallery-item.has-thumbnail .pgf-gallery-item-image img {
    position: absolute;
    top: 0;
    left: 0;
    object-fit: cover;
}

.pgf-gallery-item.has-link:hover .pgf-gallery-item-image img {
    transform: scale(1.05) !important;
}

.pgf-gallery-item-content {
    padding: 0 15px 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.pgf-gallery-item-heading {
    margin: 0 0 10px 0;
    font-size: 1.25em;
    line-height: 1.3;
    min-height: 3.25em; /* Reserve space for 2 lines (1.625em per line) */
}

.pgf-gallery-item-heading a {
    text-decoration: none;
    color: #333;
    transition: color 0.3s ease;
}

.pgf-gallery-item-heading a:hover {
    color: #0073aa;
}

.pgf-gallery-item-description {
    margin-bottom: 68px;
    color: #666;
    line-height: 1.6;
    flex-grow: 1;
    max-height: 4.8em; /* 3 lines * 1.6 line-height */
    display: -webkit-box;
}

.pgf-gallery-item-description p {
    margin: 0 0 10px 0;
}

.pgf-gallery-item-description p:last-child {
    margin-bottom: 0;
}

.pgf-gallery-item-link {
    margin-top: auto;
}

.pgf-gallery-item-link-button {
    display: inline-block;
    padding: 8px 16px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 3px;
    font-weight: 500;
    transition: background 0.3s ease;
}

.pgf-gallery-item-link-button:hover {
    background: #005a87;
    color: #fff;
}

/* Link icon overlay for clickable images */
.pgf-gallery-item.has-link .pgf-gallery-item-image {
    position: relative;
    cursor: pointer;
}

.pgf-gallery-item.has-link .pgf-link-icon {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    pointer-events: none;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.pgf-gallery-item.has-link:hover .pgf-link-icon {
    opacity: 1;
}

.pgf-gallery-item.has-link .pgf-link-icon::before {
    content: "";
    display: block;
    width: 12px;
    height: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M10 6v2H5v11h11v-5h2v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm11-3v8h-2V6.413l-7.793 7.794-1.414-1.414L17.585 5H13V3h8z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* Widget link icon */
.pgf-widget-item.has-link .pgf-widget-item-image {
    position: relative;
    cursor: pointer;
}

.pgf-widget-item.has-link .pgf-link-icon {
    position: absolute;
    bottom: 5px;
    right: 5px;
    width: 18px;
    height: 18px;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    pointer-events: none;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.pgf-widget-item.has-link:hover .pgf-link-icon {
    opacity: 1;
}

.pgf-widget-item.has-link .pgf-link-icon::before {
    content: "";
    display: block;
    width: 9px;
    height: 9px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M10 6v2H5v11h11v-5h2v6a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h6zm11-3v8h-2V6.413l-7.793 7.794-1.414-1.414L17.585 5H13V3h8z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* Widget Styles */
.pgf-widget-gallery {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.pgf-widget-item {
    display: flex;
    gap: 15px;
    padding: 10px;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    background: #fff;
    transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease, border-width 0.3s ease, box-shadow 0.3s ease;
    overflow: hidden;
    max-height: 500px;
}

.pgf-widget-item.pgf-hiding {
    opacity: 0;
    transform: scale(0.95);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    margin-bottom: 0;
    border-width: 0;
    box-shadow: none;
    overflow: hidden;
    pointer-events: none;
}

.pgf-widget-item.pgf-hidden {
    display: none;
}

.pgf-widget-item-image {
    flex-shrink: 0;
    width: 80px;
}

.pgf-widget-item-image img {
    width: 100%;
    height: auto;
    border-radius: 3px;
}

.pgf-widget-item-content {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.pgf-widget-item-heading {
    margin: 0 0 5px 0;
    font-size: 1em;
    line-height: 1.3;
    min-height: 2.6em; /* Reserve space for 2 lines (1.3em per line) */
}

.pgf-widget-item-heading a {
    text-decoration: none;
    color: #333;
    transition: color 0.3s ease;
}

.pgf-widget-item-heading a:hover {
    color: #0073aa;
}

.pgf-widget-item-description {
    font-size: 0.9em;
    color: #666;
    line-height: 1.5;
    margin-bottom: 8px;
}

.pgf-widget-item-link-button {
    display: inline-block;
    padding: 4px 10px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 2px;
    font-size: 0.9em;
    margin-top: auto;
    align-self: flex-start;
    transition: background 0.3s ease;
}

.pgf-widget-item-link-button:hover {
    background: #005a87;
    color: #fff;
}

/* Tabbed Gallery */
.pgf-tabbed-gallery {
    margin-bottom: 30px;
    display: grid;
    grid-template-areas: "tabs" "gallery";
}

.pgf-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    justify-content: center;
    grid-area: tabs;
}

.pgf-gallery-container {
    grid-area: gallery;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    opacity: 1;
    visibility: visible;
}

.pgf-gallery-container:not(.active) {
    opacity: 0;
    visibility: hidden;
    height: 0;
    overflow: hidden;
    pointer-events: none;
}

.pgf-gallery-container.active {
    opacity: 1;
    visibility: visible;
    height: auto;
    overflow: visible;
    pointer-events: auto;
}

.pgf-gallery-container.pgf-loading {
    opacity: 0.6;
    pointer-events: none;
}

.pgf-tab {
    padding: 10px 20px;
    background: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    color: #000;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
}

.pgf-tab:hover {
    background: #f5f5f5;
}

.pgf-tab.active {
    background: #000;
    color: #fff;
}

.pgf-tab-count {
    font-size: 0.85em;
    opacity: 0.8;
}

.pgf-tab:not(.active) .pgf-tab-count {
    display: none;
}


/* Error/Empty States */
.pgf-error,
.pgf-no-items {
    padding: 15px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 15px 0;
}

/* Responsive */
@media (max-width: 1400px) {
    .pgf-gallery-columns-3,
    .pgf-gallery-columns-4,
    .pgf-gallery-columns-5,
    .pgf-gallery-columns-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 999px) {
    .pgf-gallery-columns-3,
    .pgf-gallery-columns-4,
    .pgf-gallery-columns-5,
    .pgf-gallery-columns-6 {
        grid-template-columns: repeat(2, 1fr);
    }

    .pgf-gallery {
        gap: 20px;
    }

    .pgf-gallery-item {
        padding: 10px;
    }

    .pgf-gallery-item-image {
        margin: -10px -10px 10px -10px;
    }

    .pgf-gallery-item-content {
        padding: 0 10px 10px;
    }
    .pgf-gallery-item-description {
        max-height: inherit;
    }
}

@media (max-width: 480px) {
    .pgf-gallery-columns-2,
    .pgf-gallery-columns-3,
    .pgf-gallery-columns-4,
    .pgf-gallery-columns-5,
    .pgf-gallery-columns-6 {
        grid-template-columns: 1fr;
    }

    .pgf-widget-item {
        flex-direction: column;
    }

    .pgf-widget-item-image {
        width: 100%;
    }

    .pgf-gallery-item-description {
        max-height: inherit;
    }
}
