.pc-offer[hidden] {
    display: none !important;
}

.pc-offer,
.pc-offer * {
    box-sizing: border-box;
}

.pc-offer {
    --pc-red: #265b7c;
    --pc-bottom: 24px;

    position: fixed;
    bottom: calc(var(--pc-bottom) + env(safe-area-inset-bottom, 0px));
    z-index: 399;
    width: 420px;
    max-width: calc(100% - 24px);
    margin: 0;
    padding: 12px;
    direction: rtl;
    color: #242424;
    background: #fff;
    border: 1px solid #f0dddd;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgb(0 0 0 / 10%);
    font-family: inherit;
    text-align: right;
    animation: pc-offer-in .25s ease-out;
}

.pc-offer--left {
    left: max(12px, env(safe-area-inset-left, 0px));
    right: auto;
}

.pc-offer--right {
    right: max(12px, env(safe-area-inset-right, 0px));
    left: auto;
}

.pc-offer .pc-offer__product {
    display: grid;
    grid-template-columns: 80px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 0;
    color: inherit;
    background: none;
    text-decoration: none;
    border-radius: 12px;
}

.pc-offer .pc-offer__media {
    display: grid;
    place-items: center;
    width: 80px;
    height: 80px;
    padding: 4px;
    border-radius: 12px;
    overflow: hidden;
}

.pc-offer .pc-offer__image {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    object-fit: contain;
    transition: transform .2s ease;
}

.pc-offer .pc-offer__content {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.pc-offer .pc-offer__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    line-height: 1.7;
}

.pc-offer .pc-offer__badge {
    padding: 2px 8px;
    color: #bb2929;
    background: #edf4f8;
    border-radius: 6px;
    font-weight: 700;
}

.pc-offer .pc-offer__ad {
    color: #737373;
}

.pc-offer .pc-offer__title {
    display: -webkit-box;
    overflow: hidden;
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    color: #242424;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.8;
}

.pc-offer .pc-offer__side {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
    width:100%;
}

.pc-offer .pc-offer__price {
    flex: 1 1 160px;
    min-width: 0;
    color: #242424;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.7;
    overflow-wrap: anywhere;
}

/* جلوگیری از دخالت استایل عمومی قیمت‌های قالب */
.pc-offer .pc-offer__price :is(.amount, bdi, .pc-price-single) {
    float: none !important;
    color: inherit !important;
    font-size: inherit !important;
    font-weight: inherit;
}

.pc-offer .pc-offer__price :is(
    .pc-price-currency,
    .woocommerce-Price-currencySymbol
) {
    font-size: 11px !important;
    font-weight: 400;
}

.pc-offer .pc-offer__price del {
    display: block;
    color: #737373;
    font-size: 12px;
    font-weight: 400;
}

.pc-offer .pc-offer__price ins {
    background: none;
    text-decoration: none;
}

.pc-offer .pc-offer__cta {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 13px;
    color: var(--pc-red);
    border-radius: 11px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    transition: background .2s ease;
}

.pc-offer .pc-offer__arrow {
    font-size: 18px;
    line-height: 1;
    transition: transform .2s ease;
}

.pc-offer .pc-offer__close {
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    color: #777;
    background: transparent;
    border: 0;
    border-radius: 17px;
    box-shadow: none;
    font: 24px/1 Arial, sans-serif;
    cursor: pointer;
}

/* حذف آیکون اضافه‌ای که ممکن است قالب بسازد */
.pc-offer .pc-offer__close::before,
.pc-offer .pc-offer__close::after {
    content: none;
}

.pc-offer :is(a, button):focus-visible {
    outline: 2px solid var(--pc-red);
    outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
    .pc-offer__product:hover .pc-offer__image {
        transform: scale(1.04);
    }

    .pc-offer__product:hover .pc-offer__arrow {
        transform: translateX(-3px);
    }

    .pc-offer .pc-offer__close:hover {
        color: #bb2929;
        background: #edf4f8;
    }
}

@media (max-width: 767px) {
    .pc-offer {
        --pc-bottom: 90px;
        padding: 10px;
        border-radius: 16px;
    }

    .pc-offer .pc-offer__product {
        grid-template-columns: 64px minmax(0, 1fr);
        gap: 10px;
    }

    .pc-offer .pc-offer__media {
        width: 64px;
        height: 64px;
    }

    .pc-offer .pc-offer__title {
        font-size: 12px;
    }

    .pc-offer .pc-offer__price {
        flex-basis: 140px;
        font-size: 14px;
    }

    .pc-offer .pc-offer__cta {
        padding-inline: 10px;
        font-size: 11px;
    }
}

@keyframes pc-offer-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .pc-offer,
    .pc-offer * {
        animation: none !important;
        transition: none !important;
    }
}

/* Admin Panel */
#pco-admin {
    max-width: 1120px;
}

#pco-admin [hidden] {
    display: none !important;
}

.pco-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.pco-heading h2 {
    margin: 0 0 10px;
    font-size: 24px;
}

.pco-count {
    padding: 8px 16px;
    border-radius: 20px;
    background: #e0f2fe;
    color: #075985;
    white-space: nowrap;
}

.pco-panel,
.pco-rule {
    margin: 16px 0;
    padding: 20px;
    border: 1px solid #dbe2ea;
    border-radius: 12px;
    background: #fff;
}

.pco-master {
    font-size: 16px;
    font-weight: 700;
}

.pco-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.pco-field {
    display: flex;
    flex-direction: column;
    gap: 7px;
    min-width: 0;
}

.pco-field input,
.pco-field select,
.pco-field textarea {
    width: 100%;
    max-width: none;
    min-height: 40px;
    padding: 7px 10px;
    border: 1px solid #b7c3d1;
    border-radius: 7px;
    font-family: inherit;
}

.pco-field textarea {
    resize: vertical;
    font-family: monospace;
}

.pco-field small {
    color: #64748b;
    font-size: 12px;
    line-height: 1.8;
}

.pco-wide {
    grid-column: 1 / -1;
}

.pco-toolbar {
    position: sticky;
    top: 32px;
    z-index: 5;

    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;

    padding: 14px;

    border: 1px solid #dbe2ea;
    border-radius: 10px;
    background: #fff;
}

.pco-rule summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    font-size: 16px;
    cursor: pointer;
}

.pco-rule-status {
    padding: 3px 10px;
    border-radius: 14px;
    background: #f1f5f9;
    color: #334155;
    font-size: 12px;
}

.pco-rule-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
}

.pco-rule-toolbar label {
    margin-left: auto;
}

.pco-delete {
    color: #b91c1c !important;
}

.pco-frequency {
    padding: 14px;
    border-radius: 10px;
    background: #f8fafc;
}

.pco-test {
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #e2e8f0;
}

.pco-test label {
    display: block;
}

.pco-test-url {
    display: block;
    width: 100%;
    margin: 8px 0 12px;
}

.pco-preview-card .pc-offer {
    position: relative;
    right: auto;
    bottom: auto;
    left: auto;
    z-index: auto;

    max-width: 100%;
    max-height: none;
    margin: 16px 0;

    animation: none;
}

.pco-error {
    color: #b91c1c;
}

.pco-empty {
    padding: 40px;

    border: 1px dashed #cbd5e1;
    background: #fff;

    text-align: center;
}

.pco-save-state {
    font-weight: 600;
}

.pco-test-result ul {
    max-height: 200px;
    overflow: auto;
}

.pco-panel .description {
    line-height: 1.9;
}

@media (max-width: 700px) {
    .pco-grid {
        grid-template-columns: 1fr;
    }

    .pco-heading {
        display: block;
    }

    .pco-count {
        display: inline-block;
    }

    .pco-rule,
    .pco-panel {
        padding: 14px;
    }

    .pco-toolbar {
        top: 46px;
    }

    .pco-rule-toolbar {
        flex-wrap: wrap;
    }

    .pco-toolbar button {
        min-height: 40px;
    }
}