/* ==========================================================================
   PREMIUM DELIGHTS - ELEMENTOR CONTAINER-FRIENDLY WOOCOMMERCE WIDGET
   ========================================================================== */

/* 1. Main Widget Container - 100% Flexible & Container-Ready */
.pd-premium-delights {
    --pd-bg: transparent;
    --pd-card-bg: #ffffff;
    --pd-text: #2b1d16;
    --pd-muted: #6b625d;
    --pd-accent: #a8763e;
    --pd-green: #1a3c34;
    --pd-border: rgba(43, 29, 22, 0.10);
    --pd-content-max-width: 100%;

    width: 100%;
    max-width: var(--pd-content-max-width, 100%);
    margin: 0 auto;
    padding: 0;
    background: var(--pd-bg);
    font-family: 'Poppins', sans-serif;
    box-sizing: border-box;
    position: relative;
    min-width: 0; /* Prevents flex blowout inside Elementor Container */
}

/* Universal Box-Sizing and Flex Shrinking */
.pd-premium-delights,
.pd-premium-delights *,
.pd-premium-delights *::before,
.pd-premium-delights *::after {
    box-sizing: border-box;
}

/* Ensure Elementor Widget Container does not restrict flow */
.elementor-widget-premium_delights_woocommerce .elementor-widget-container {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* ==========================================================================
   SECTION HEADER
   ========================================================================== */
.pd-section-header {
    width: 100%;
    max-width: var(--pd-content-max-width, 100%);
    margin: 0 auto 40px;
    text-align: center;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.pd-subtitle {
    display: block;
    margin-bottom: 10px;
    color: var(--pd-accent);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.pd-section-header .pd-main-heading,
.pd-section-header h2 {
    margin: 0;
    color: var(--pd-text);
    font-family: 'Playfair Display', serif;
    font-size: clamp(28px, 3.5vw, 48px);
    font-weight: 600;
    line-height: 1.2;
    font-style: italic;
    word-break: break-word;
}

/* ==========================================================================
   FILTER & SORT BAR (RESPONSIVE & AUTO-WRAPPING)
   ========================================================================== */
.pd-filter-sort-wrapper {
    width: 100%;
    max-width: var(--pd-content-max-width, 100%);
    margin: 0 auto 45px;
    padding: 14px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--pd-border);
    border-radius: 14px;
    box-shadow: 0 5px 20px rgba(43, 29, 22, 0.04), 0 15px 35px rgba(43, 29, 22, 0.03);
    position: relative;
    min-width: 0;
}

/* Glass gradient highlight */
.pd-filter-sort-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    background: linear-gradient(
        135deg,
        rgba(168, 118, 62, 0.16),
        transparent 35%,
        transparent 70%,
        rgba(26, 60, 52, 0.06)
    );
    opacity: 0.8;
}

.pd-filter-group,
.pd-sort-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
    min-width: 0;
}

.pd-filter-label {
    color: var(--pd-accent);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    margin-right: 2px;
    white-space: nowrap;
}

/* Filter Button */
.pd-filter-btn {
    appearance: none;
    -webkit-appearance: none;
    padding: 8px 18px;
    background: transparent;
    border: 1px solid var(--pd-border);
    border-radius: 50px;
    color: var(--pd-text);
    font-family: 'Poppins', sans-serif;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
    user-select: none;
    white-space: nowrap;
}

.pd-filter-btn:hover {
    border-color: var(--pd-accent);
    color: var(--pd-accent);
    transform: translateY(-1px);
}

.pd-filter-btn.active {
    background: var(--pd-accent);
    color: #ffffff;
    border-color: var(--pd-accent);
    box-shadow: 0 5px 15px rgba(168, 118, 62, 0.22);
}

/* Sort Dropdown */
.pd-sort-select {
    min-width: 150px;
    padding: 8px 30px 8px 16px;
    border: 1px solid var(--pd-border);
    border-radius: 50px;
    background-color: #ffffff;
    color: var(--pd-text);
    font-family: 'Poppins', sans-serif;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    outline: none;
    cursor: pointer;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.pd-sort-select:focus {
    border-color: var(--pd-accent);
    box-shadow: 0 0 0 2px rgba(168, 118, 62, 0.15);
}

/* ==========================================================================
   PRODUCTS GRID - 100% CONTAINER FIT
   ========================================================================== */
.pd-delights-grid {
    width: 100%;
    max-width: var(--pd-content-max-width, 100%);
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 30px;
    position: relative;
    min-width: 0;
}

.pd-no-products {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px 20px;
    color: var(--pd-muted);
    font-size: 14px;
    font-style: italic;
}

/* ==========================================================================
   PRODUCT CARD (HORIZONTAL DEFAULT)
   ========================================================================== */
.pd-delight-card {
    position: relative;
    width: 100%;
    min-height: 260px;
    display: flex;
    overflow: hidden;
    background: var(--pd-card-bg);
    border: 1px solid var(--pd-border);
    border-radius: 15px;
    box-shadow: 0 6px 25px rgba(43, 29, 22, 0.05);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease, border-color 0.4s ease, opacity 0.3s ease;
    opacity: 1;
    min-width: 0;
}

.pd-delight-card:hover {
    transform: translateY(-5px);
    border-color: rgba(168, 118, 62, 0.35);
    box-shadow: 0 14px 40px rgba(43, 29, 22, 0.10);
}

/* Vertical Layout Option */
.pd-premium-delights.pd-layout-vertical .pd-delight-card {
    flex-direction: column;
}

.pd-premium-delights.pd-layout-vertical .pd-delight-img {
    width: 100% !important;
    height: 220px;
    min-height: 220px;
}

.pd-premium-delights.pd-layout-vertical .pd-delight-content {
    width: 100% !important;
    flex-grow: 1;
}

/* Image Right Option */
.pd-premium-delights.pd-layout-img_right .pd-delight-card,
.pd-premium-delights.pd-layout-img-right .pd-delight-card {
    flex-direction: row-reverse;
}

/* ==========================================================================
   PRODUCT IMAGE
   ========================================================================== */
.pd-delight-img {
    width: 46%;
    min-height: 260px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    background: #f5efe9;
    min-width: 0;
}

.pd-delight-img a {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}

.pd-delight-img img {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(0.2, 0.6, 0.2, 1), filter 0.4s ease;
    filter: grayscale(4%);
}

.pd-delight-card:hover .pd-delight-img img {
    transform: scale(1.06);
    filter: grayscale(0%);
}

/* ==========================================================================
   BADGES
   ========================================================================== */
.pd-trending-badge,
.pd-preorder-badge,
.pd-sale-badge {
    position: absolute;
    top: 12px;
    z-index: 5;
    padding: 6px 14px;
    border-radius: 50px;
    color: #ffffff;
    font-family: 'Poppins', sans-serif;
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    pointer-events: none;
    white-space: nowrap;
}

.pd-trending-badge {
    left: 12px;
    background: var(--pd-accent);
}

.pd-preorder-badge {
    right: 12px;
    background: var(--pd-green);
}

.pd-sale-badge {
    left: 12px;
    background: #b22222;
}

.pd-trending-badge + .pd-sale-badge {
    top: 38px;
}

/* ==========================================================================
   PRODUCT CONTENT
   ========================================================================== */
.pd-delight-content {
    width: 54%;
    position: relative;
    padding: 26px 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 0;
    overflow: hidden;
}

.pd-delight-number {
    position: absolute;
    top: 20px;
    right: 22px;
    color: rgba(168, 118, 62, 0.16);
    font-family: 'Playfair Display', serif;
    font-size: 24px;
    font-weight: 400;
    line-height: 1;
    pointer-events: none;
    user-select: none;
}

/* Title */
.pd-delight-title {
    margin: 0 0 4px;
    color: var(--pd-text);
    font-family: 'Playfair Display', serif;
    font-size: clamp(20px, 1.8vw, 28px);
    font-weight: 600;
    line-height: 1.2;
    width: 100%;
    word-break: break-word;
}

.pd-delight-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.pd-delight-title a:hover {
    color: var(--pd-accent);
}

/* Category Tags */
.pd-delight-tags {
    margin: 0 0 12px;
    color: var(--pd-accent);
    font-size: 9px;
    font-weight: 500;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    line-height: 1.4;
    width: 100%;
    word-break: break-word;
}

/* Description */
.pd-delight-desc {
    margin: 0 0 14px;
    color: var(--pd-muted);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.6;
    width: 100%;
    word-break: break-word;
}

/* Price */
.pd-delight-price {
    display: block;
    margin-bottom: 16px;
    color: var(--pd-accent);
    font-family: 'Playfair Display', serif;
    font-size: 19px;
    font-weight: 600;
    line-height: 1.2;
}

.pd-delight-price ins {
    text-decoration: none;
    color: inherit;
    font-weight: 600;
}

.pd-delight-price del {
    color: var(--pd-muted);
    font-size: 14px;
    font-weight: 400;
    margin-right: 6px;
    opacity: 0.65;
}

/* ==========================================================================
   BUTTON & AJAX ACTIONS
   ========================================================================== */
.pd-delight-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    color: var(--pd-accent);
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--pd-accent);
    font-family: 'Poppins', sans-serif;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    text-decoration: none;
    line-height: 1.3;
    cursor: pointer;
    transition: padding 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    white-space: nowrap;
}

.pd-delight-btn:hover {
    padding-right: 10px;
    color: #7f5224;
    border-color: #7f5224;
}

/* Loading state */
.pd-delight-btn.loading {
    opacity: 0.7;
    pointer-events: none;
}

.pd-delight-btn.loading::after {
    content: "";
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 2px solid var(--pd-accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: pd-spin 0.6s linear infinite;
    margin-left: 6px;
}

.pd-delight-btn.added {
    color: var(--pd-green);
    border-color: var(--pd-green);
}

@keyframes pd-spin {
    to { transform: rotate(360deg); }
}

.pd-delight-card.pd-hidden {
    display: none !important;
}

.pd-delight-card.pd-animating {
    animation: pdFadeIn 0.35s ease forwards;
}

@keyframes pdFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   RESPONSIVE (TABLET, MOBILE & NESTED CONTAINER BEHAVIOR)
   ========================================================================== */
@media (max-width: 1024px) {
    .pd-delights-grid {
        gap: 20px;
    }

    .pd-delight-card {
        min-height: 240px;
    }

    .pd-delight-img {
        min-height: 240px;
    }

    .pd-delight-content {
        padding: 20px 18px;
    }
}

/* Mobile Screens & Narrow Container Columns */
@media (max-width: 767px) {
    .pd-section-header {
        margin-bottom: 25px;
    }

    .pd-section-header .pd-main-heading,
    .pd-section-header h2 {
        font-size: 28px;
    }

    .pd-filter-sort-wrapper {
        flex-direction: column;
        align-items: stretch;
        padding: 16px;
        margin-bottom: 25px;
        gap: 15px;
    }

    .pd-filter-group,
    .pd-sort-group {
        justify-content: center;
        width: 100%;
    }

    .pd-sort-select {
        width: 100%;
    }

    .pd-delights-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .pd-delight-card {
        min-height: auto;
        flex-direction: column !important;
        border-radius: 12px;
    }

    .pd-delight-img {
        width: 100% !important;
        min-height: 140px;
        height: 140px;
    }

    .pd-delight-content {
        width: 100% !important;
        padding: 12px 10px 14px;
        align-items: center;
        text-align: center;
    }

    .pd-delight-number {
        display: none;
    }

    .pd-delight-title {
        font-size: 16px;
        margin-bottom: 3px;
    }

    .pd-delight-tags {
        font-size: 7px;
        letter-spacing: 1.1px;
        margin-bottom: 6px;
    }

    .pd-delight-desc {
        display: none;
    }

    .pd-delight-price {
        margin-bottom: 8px;
        font-size: 16px;
    }

    .pd-delight-btn {
        width: 100%;
        justify-content: center;
        font-size: 8px;
        letter-spacing: 0.9px;
    }

    .pd-trending-badge,
    .pd-preorder-badge,
    .pd-sale-badge {
        top: 8px;
        padding: 4px 8px;
        font-size: 7px;
    }

    .pd-trending-badge {
        left: 8px;
    }

    .pd-preorder-badge {
        right: 8px;
    }
}

@media (max-width: 420px) {
    .pd-delights-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .pd-filter-btn {
        padding: 7px 12px;
        font-size: 8px;
    }

    .pd-filter-label {
        font-size: 8px;
    }

    .pd-delight-img {
        height: 120px;
        min-height: 120px;
    }

    .pd-delight-title {
        font-size: 14px;
    }

    .pd-delight-price {
        font-size: 14px;
    }
}
