.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    -webkit-backdrop-filter: blur(0.5px);
    backdrop-filter: blur(0.5px);
    /* Add touch handling for mobile */
    touch-action: none;
    -webkit-touch-callout: none;
}

.modal-dialog {
    display: none;
    position: fixed;
    left: 50%;
    top: 50%;
    -webkit-transform: translate(-50%, -50%);
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 450px;
    background-color: #2C2C2E;
    border-radius: 14px;
    z-index: 10000;
    padding: 14px 16px 0 16px;
    box-sizing: border-box;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Improve iOS rendering */
    /* Fix iOS rubber-banding */
    overscroll-behavior: contain;
    /* Improve touch handling */
    touch-action: manipulation;
    /* Prevent text selection */
    -webkit-user-select: none;
    user-select: none;
    /* Smoother animations on iOS */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.modal-content {
    text-align: center;
}

.modal-title {
    color: #FFFFFF;
    font-size: 17px;
    line-height: 1.3;
    font-weight: 400;
    margin-bottom: 12px;
    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    letter-spacing: -0.01em;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 25px;
    align-items: center;
    padding: 0;
    margin: 0;
}

.modal-button {
    background: none;
    border: none;
    font-size: 17px;
    font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding: 0;
    cursor: pointer;
    letter-spacing: -0.01em;
    -webkit-tap-highlight-color: transparent;
}

.modal-button.cancel {
    color: #0A84FF;
    font-weight: 400;
}

.modal-button.open {
    color: #0A84FF;
    font-weight: 400;
}

/* تحسينات للأجهزة المحمولة */
@media screen and (max-width: 768px) {
    .modal-dialog {
        width: 90%;
        max-width: 450px;
        padding: 14px 16px 0 16px;
        /* إزالة المسافات الإضافية */
        padding-top: 14px;
        padding-bottom: 0;
    }
    
    .modal-buttons {
        gap: 20px;
        padding: 0;
        margin: 0;
        min-height: auto; /* إزالة الارتفاع الإضافي */
    }

    .modal-button {
        padding: 4px; /* تقليل المسافة حول الأزرار */
        min-width: auto;
        min-height: auto;
    }
}

/* تعديلات إضافية لـ iOS */
@supports (-webkit-touch-callout: none) {
    .modal-dialog {
        padding-bottom: 0;
    }
}

/* Safari and iOS specific improvements */
@supports (-webkit-touch-callout: none) {
    .modal-dialog {
        /* Improve iOS modal appearance */
        background-color: rgba(44, 44, 46, 0.95);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
    
    /* Fix for iPhone notch */
    @supports (padding-top: env(safe-area-inset-top)) {
        .modal-dialog {
            padding-left: max(16px, env(safe-area-inset-left));
            padding-right: max(16px, env(safe-area-inset-right));
        }
    }
}

/* Chrome and Android specific improvements */
@supports not (-webkit-touch-callout: none) {
    .modal-dialog {
        /* Better shadow rendering on Android */
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
    }
    
    .modal-button {
        /* Material Design-style ripple effect for Android */
        position: relative;
        overflow: hidden;
    }
}
