/* کاملاً سازگار با سافاری و همه مرورگرها */
#dip-popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.75);
    z-index: 9999999;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

#dip-popup-overlay.active {
    display: flex !important;
}

#dip-popup {
    background: #fff;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    border-radius: 18px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
    overflow: hidden;
    direction: rtl;
    font-family: Tahoma, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

.dip-header {
    background: #2c3e50;
    color: #fff;
    padding: 18px 22px;
    font-size: 19px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.dip-close {
    cursor: pointer;
    font-size: 34px;
    font-weight: bold;
}

.dip-body {
    padding: 28px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* داغی — ظریف و شکیل */
.dip-daghi-box {
    background: #fffbe6;
    border: 2px solid #ffc107;
    border-radius: 14px;
    padding: 18px;
    margin: 22px 0;
    font-size: 15px;
}

.daghi-title {
    font-weight: bold;
    color: #e67e22;
    margin-bottom: 14px;
    font-size: 15.5px;
}

.daghi-radio {
    display: flex;
    align-items: center;
    margin: 12px 0;
    font-size: 15px;
    cursor: pointer;
}

.daghi-radio input {
    margin-left: 12px;
    transform: scale(1.4);
}

/* تعداد — جمع‌وجور */
.dip-qty {
    display: flex;
    align-items: center;
    border: 2px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
    width: fit-content !important;
}

.dip-qty button {
    width: 44px;
    height: 44px;
    background: #f8f9fa;
    border: none;
    font-size: 20px;
    cursor: pointer;
}

.dip-qty input {
    width: 66px !important;
    height: 44px;
    text-align: center;
    border: none;
    border-left: 2px solid #ddd;
    border-right: 2px solid #ddd;
    font-size: 16px;
}

/* درگاه */
#dip-gateway {
    width: 100%;
    padding: 14px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-size: 15px;
    margin: 20px 0;
}

/* هزینه‌ها — تمیز و کوچکتر */
.dip-fees-box {
    background: #f8f9fa;
    border-radius: 14px;
    padding: 20px;
    margin: 25px 0;
    border: 1px solid #eee;
}

.fee-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 14px 0;
    font-size: 14.5px !important;
}

.fee-row span {
    min-width: 150px;
    color: #555;
}

.fee-row strong, #base-price, #company-fee, #service-fee, #total-price strong {
    direction: ltr !important;
    unicode-bidi: embed !important;
    font-family: Tahoma !important;
    font-size: 15px !important;
    font-weight: bold !important;
    color: #2c3e50 !important;
    text-align: left !important;
    white-space: nowrap;
}

.fee-row.total {
    font-size: 18px !important;
    color: #27ae60 !important;
    border-top: 2px solid #ddd;
    padding-top: 18px;
    margin-top: 18px;
}

/* قوانین و دکمه */
.dip-rules {
    margin: 25px 0;
    font-size: 14px;
    line-height: 1.6;
}

#dip-rules-link {
    color: #2980b9;
    text-decoration: underline;
}

.dip-add-btn {
    width: 100%;
    padding: 18px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
}

.dip-add-btn:disabled {
    background: #95a5a6;
    cursor: not-allowed;
}

.dip-add-btn:not(:disabled):hover {
    background: #219653;
}

.dip-trigger-btn {
    display: inline-block !important;
    background: #0073aa !important;
    color: white !important;
    padding: 16px 36px !important;
    border-radius: 10px !important;
    font-size: 17px;
    font-weight: bold !important;
    text-decoration: none !important;
    margin: 30px 0 !important;
    box-shadow: 0 6px 20px rgba(0,115,170,0.4);
}

.dip-trigger-btn:hover {
    background: #005a87 !important;
}

.single_add_to_cart_button {
    display: none !important;
}

@media (max-width: 480px) {
    #dip-popup {
        max-width: 95%;
        max-height: 95vh;
    }
}

/* ===== اضافه شده برای آلرت قوانین در آیفون (اسکرول + دکمه سبز بستن) ===== */
.dip-rules-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 99999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

.dip-rules-content {
    background: #fff;
    color: #000;
    padding: 30px 25px;
    border-radius: 16px;
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 15px;
    line-height: 1.8;
    direction: rtl;
    text-align: right;
}

.dip-rules-content h3 {
    margin: 0 0 20px;
    font-size: 18px;
    color: #2c3e50;
}

.dip-rules-content button {
    width: 100%;
    padding: 14px;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 17px;
    cursor: pointer;
    margin-top: 20px;
}

/* پنجره قوانین — اسکرول دار + دکمه سبز بستن (در آیفون ۱۰۰٪ کار می‌کنه) */
.dip-rules-modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.9);
    z-index: 99999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.dip-rules-content {
    background: #fff;
    color: #000;
    padding: 30px 25px;
    border-radius: 16px;
    max-width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 15px;
    line-height: 1.8;
    direction: rtl;
    text-align: right;
}

.dip-rules-content h3 {
    margin: 0 0 20px;
    font-size: 18px;
    color: #2c3e50;
}

/* وقتی تیک نزنه قرمز می‌شه */
.dip-rules { transition: color 0.3s; }
.dip-rules.warning { color: #e74c3c !important; }